edit.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view style="padding: 20rpx;">
  3. <view style="padding: 30rpx;background-color: white;border-radius:50rpx">
  4. <u--form labelPosition="left" :model="formData" ref="uForm" labelWidth='120'>
  5. <u-form-item label="制衣生产车间:" prop="workshopInfo.zyProductWorkshop" borderBottom ref="uItem"
  6. :required="true">
  7. <u--input v-model="formData.workshopInfo.zyProductWorkshop" border="none"></u--input>
  8. </u-form-item>
  9. <u-calendar :show="deliveryDateShowFlag" mode="single" @confirm="confirm"></u-calendar>
  10. <u-form-item label="启用:" prop="workshopInfo.status" borderBottom ref="uItem">
  11. <u-switch v-model="formData.workshopInfo.status"></u-switch>
  12. </u-form-item>
  13. <u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
  14. <u-button type="error" text="重置" customStyle="margin-top: 10px" @click="reset"></u-button>
  15. </u--form>
  16. </view>
  17. <u-toast ref="uToast"></u-toast>
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. edit
  23. } from '@/api/biz/workshop.js'
  24. export default {
  25. data() {
  26. return {
  27. formData: {
  28. workshopInfo: {
  29. zyProductWorkshop: '',
  30. // zyTeam: '',
  31. // orderNo: '',
  32. // deliveryDate: "",
  33. status: false
  34. }
  35. },
  36. // deliveryDateShowFlag: false,
  37. rules: {
  38. 'workshopInfo.zyProductWorkshop': {
  39. type: 'string',
  40. required: true,
  41. message: '请填写制衣生产车间',
  42. trigger: ['blur', 'change']
  43. }
  44. // 'workshopInfo.zyTeam': {
  45. // type: 'string',
  46. // required: true,
  47. // message: '请填写制衣班组',
  48. // trigger: ['blur', 'change']
  49. // },
  50. // 'workshopInfo.orderNo': {
  51. // type: 'string',
  52. // required: true,
  53. // message: '请填写订单号',
  54. // trigger: ['blur', 'change']
  55. // },
  56. // 'workshopInfo.deliveryDate': {
  57. // type: 'string',
  58. // required: true,
  59. // message: '请填写交期',
  60. // trigger: ['blur', 'change']
  61. // }
  62. }
  63. }
  64. },
  65. onLoad(option) {
  66. const workshopInfo = JSON.parse(decodeURIComponent(option.workshopInfo))
  67. this.formData.workshopInfo = workshopInfo
  68. console.log(this.formData.workshopInfo)
  69. },
  70. onReady() {
  71. this.$refs.uForm.setRules(this.rules)
  72. },
  73. methods: {
  74. confirm(e) {
  75. console.log(e);
  76. this.deliveryDateShowFlag = false
  77. this.formData.workshopInfo.deliveryDate = e[0]
  78. },
  79. submit() {
  80. this.$refs.uForm.validate().then(val => {
  81. edit(this.formData.workshopInfo).then(res => {
  82. console.log(res)
  83. if (res.success) {
  84. this.$refs.uToast.show({
  85. type: 'success',
  86. message: "新增成功",
  87. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  88. })
  89. uni.$emit('loadData');
  90. uni.navigateBack(1);
  91. } else {
  92. this.$refs.uToast.show({
  93. type: 'error',
  94. message: res.message,
  95. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  96. })
  97. }
  98. })
  99. })
  100. },
  101. reset() {
  102. this.formData = {
  103. workshopInfo: {
  104. zyProductWorkshop: '',
  105. // zyTeam: '',
  106. // orderNo: '',
  107. // deliveryDate: "",
  108. status: true
  109. }
  110. }
  111. }
  112. }
  113. }
  114. </script>
  115. <style>
  116. </style>