edit.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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="orderInfo.zyProductWorkshop" borderBottom ref="uItem"
  6. :required="true">
  7. <u--input v-model="formData.orderInfo.zyProductWorkshop" border="none" :disabled="formData.orderInfo.orderStatus>=1"></u--input>
  8. </u-form-item>
  9. <u-form-item label="制衣班组:" prop="orderInfo.zyTeam" borderBottom ref="uItem" :required="true">
  10. <u--input v-model="formData.orderInfo.zyTeam" border="none" :disabled="formData.orderInfo.orderStatus>=1"></u--input>
  11. </u-form-item> -->
  12. <u-form-item label="制衣生产车间:" prop="orderInfo.zyProductWorkshop" borderBottom @click="showWorkshop = true" :required="true" ref="uItem">
  13. <u--input v-model="formData.orderInfo.zyProductWorkshop" disabled disabledColor="#ffffff" placeholder="请选择生产车间" border="none"></u--input>
  14. <u-icon slot="right" name="arrow-right"></u-icon>
  15. </u-form-item>
  16. <u-action-sheet :show="showWorkshop" :actions="options" title="请选择车间" @close="showWorkshop = false" @select="workshopSelect" />
  17. <u-form-item label="制衣班组:" prop="orderInfo.zyTeam" borderBottom @click="showTeam = true" ref="uItem" :required="true">
  18. <u--input v-model="formData.orderInfo.zyTeam" disabled disabledColor="#ffffff" border="none" placeholder="请输入班组"></u--input>
  19. <u-icon slot="right" name="arrow-right"></u-icon>
  20. </u-form-item>
  21. <u-action-sheet :show="showTeam" :actions="teamoptions" title="请选择班组" @close="showTeam = false" @select="teamSelect" />
  22. <u-form-item label="订单号:" prop="orderInfo.orderNo" borderBottom ref="uItem" :required="true">
  23. <u--input v-model="formData.orderInfo.orderNo" border="none" placeholder="请输入订单号"></u--input>
  24. </u-form-item>
  25. <u-form-item label="交期:" prop="orderInfo.deliveryDate" borderBottom ref="uItem"
  26. @click="deliveryDateShowFlag=true" :required="false">
  27. <u-input v-model="formData.orderInfo.deliveryDate" border="none" placeholder="请选择交期"></u-input>
  28. </u-form-item>
  29. <u-calendar :show="deliveryDateShowFlag" mode="single" @confirm="confirm" @close="deliveryDateShowFlag=false"></u-calendar>
  30. <u-form-item label="封存状态:" prop="orderInfo.status" borderBottom ref="uItem">
  31. <u-switch v-model="formData.orderInfo.status"></u-switch>
  32. </u-form-item>
  33. <u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
  34. <u-button type="error" text="重置" customStyle="margin-top: 10px" @click="reset"></u-button>
  35. </u--form>
  36. </view>
  37. <u-toast ref="uToast"></u-toast>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. edit
  43. } from '@/api/biz/filing.js'
  44. import { workshopData,teamData } from '@/api/biz/team.js';
  45. export default {
  46. data() {
  47. return {
  48. formData: {
  49. orderInfo: {
  50. zyProductWorkshop: '',
  51. zyTeam: '',
  52. orderNo: '',
  53. deliveryDate: "",
  54. status: true,
  55. }
  56. },
  57. options: [],
  58. teamoptions: [],
  59. deliveryDateShowFlag: false,
  60. rules: {
  61. 'orderInfo.zyProductWorkshop': {
  62. type: 'string',
  63. required: true,
  64. message: '请填写制衣生产车间',
  65. trigger: ['blur', 'change']
  66. },
  67. 'orderInfo.zyTeam': {
  68. type: 'string',
  69. required: true,
  70. message: '请填写制衣班组',
  71. trigger: ['blur', 'change']
  72. },
  73. 'orderInfo.orderNo': {
  74. type: 'string',
  75. required: true,
  76. message: '请填写订单号',
  77. trigger: ['blur', 'change']
  78. },
  79. // 'orderInfo.deliveryDate': {
  80. // type: 'string',
  81. // required: true,
  82. // message: '请填写交期',
  83. // trigger: ['blur', 'change']
  84. // }
  85. },
  86. showWorkshop: false,
  87. showTeam: false,
  88. }
  89. },
  90. onLoad(option) {
  91. const orderInfo = JSON.parse(decodeURIComponent(option.orderInfo))
  92. console.log(orderInfo);
  93. this.formData.orderInfo = orderInfo
  94. this.formData.orderInfo.workshopId = this.formData.orderInfo.workshop.id;
  95. this.formData.orderInfo.teamId = this.formData.orderInfo.team.id;
  96. // console.log(this.formData.orderInfo)
  97. this.getWorkshop();
  98. },
  99. onReady() {
  100. this.$refs.uForm.setRules(this.rules)
  101. },
  102. methods: {
  103. getWorkshop() {
  104. workshopData().then(res => {
  105. if (res.success) {
  106. for (let i in res.data) {
  107. // console.log(res.data[i]['id'])
  108. // console.log(res.data[i]['zyProductWorkshop'])
  109. let o = {
  110. value: res.data[i]['id'],
  111. name: res.data[i]['zyProductWorkshop']
  112. };
  113. this.options.push(o);
  114. }
  115. } else {
  116. }
  117. });
  118. },
  119. getTeamByWorkshopId(workshopId) {
  120. console.log("======workshopId"+workshopId)
  121. teamData(workshopId).then(res => {
  122. if (res.success) {
  123. console.log(res.data)
  124. for (let i in res.data) {
  125. // console.log(res.data[i]['id'])
  126. // console.log(res.data[i]['zyProductWorkshop'])
  127. let o = {
  128. value: res.data[i]['id'],
  129. name: res.data[i]['zyTeam']
  130. };
  131. this.teamoptions.push(o);
  132. }
  133. } else {
  134. }
  135. });
  136. },
  137. workshopSelect(e) {
  138. console.log(e);
  139. this.formData.orderInfo.zyProductWorkshop = e.name;
  140. this.formData.orderInfo.workshopId = e.value;
  141. this.getTeamByWorkshopId(this.formData.orderInfo.workshopId);
  142. this.teamoptions=[];
  143. this.formData.orderInfo.zyTeam = '';
  144. this.formData.orderInfo.teamId = '';
  145. },
  146. teamSelect(e) {
  147. console.log(e);
  148. this.formData.orderInfo.zyTeam = e.name;
  149. this.formData.orderInfo.teamId = e.value;
  150. // this.getTeamByWorkshopId(this.formData.orderInfo.workshopId);
  151. },
  152. confirm(e) {
  153. console.log(e);
  154. this.deliveryDateShowFlag = false
  155. this.formData.orderInfo.deliveryDate = e[0]
  156. },
  157. submit() {
  158. this.$refs.uForm.validate().then(val => {
  159. edit(this.formData.orderInfo).then(res => {
  160. console.log(res)
  161. if (res.success) {
  162. this.$refs.uToast.show({
  163. type: 'success',
  164. message: "新增成功",
  165. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  166. })
  167. uni.$emit('loadData',this.formData.orderInfo.status?1:0);
  168. uni.navigateBack(1);
  169. } else {
  170. this.$refs.uToast.show({
  171. type: 'error',
  172. message: res.message,
  173. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  174. })
  175. }
  176. })
  177. })
  178. },
  179. reset() {
  180. this.formData = {
  181. orderInfo: {
  182. zyProductWorkshop: '',
  183. zyTeam: '',
  184. orderNo: '',
  185. deliveryDate: "",
  186. status: true
  187. }
  188. }
  189. }
  190. }
  191. }
  192. </script>
  193. <style>
  194. </style>