index.vue 6.2 KB

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