edit.vue 3.6 KB

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