edit.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="bg-white">
  3. <view style="padding: 20rpx;height: 100%;background-color: white;">
  4. <view style="padding: 30rpx;background-color: white;border-radius:50rpx"
  5. class="padding-xl shadow-warp radius bg-blue">
  6. <u--form labelPosition="left" :model="planInfo" ref="uForm" style="background-color:white"
  7. labelWidth="calc(3em + 15px)">
  8. <u-form-item label="订单号:" prop="orderNo" borderBottom ref="uItem" :required="true">
  9. <u--input v-model="planInfo.orderNo" border="none" disabledColor="#ffffff" disabled></u--input>
  10. <u-icon slot="right" name="search" size="25px" color="blue" @click="showOrder = true"></u-icon>
  11. </u-form-item>
  12. <u-form-item label="数量:" prop="qty" borderBottom ref="uItem">
  13. <u--input v-model="planInfo.qty" border="none" disabled></u--input>
  14. </u-form-item>
  15. <u-form-item label="班制:" prop="workShift" borderBottom ref="uItem"
  16. @click="showWorkShift = true" :required="true">
  17. <u--input v-model="planInfo.workShift" border="none"></u--input>
  18. <u-icon slot="right" name="arrow-right" size="25px"></u-icon>
  19. </u-form-item>
  20. <u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
  21. <u-button type="error" text="重置" customStyle="margin-top: 10px" @click="reset" disabled></u-button>
  22. </u--form>
  23. <u-action-sheet :show="showWorkShift" :actions="actions" title="请选择班制" @close="showWorkShift = false"
  24. @select="workShiftSelect" />
  25. </view>
  26. <u-popup :show="showOrder" mode="bottom" :overlay="true" :safeAreaInsetBottom="true"
  27. :safeAreaInsetTop="true" @close="showOrder = false">
  28. <u-toolbar @cancel="cancel" @confirm="confirm"></u-toolbar>
  29. <u-line></u-line>
  30. <scroll-view :scroll-y="true" class="u-popup-slot" style="height:750rpx">
  31. <radio-group @change="radioChange" style="width: 100%;">
  32. <view class="cu-list menu">
  33. <view class="cu-item" v-for="(item,index) in orderList" @click="itemClick(item)">
  34. <view class="content">
  35. <view class="cu-form-group">
  36. <view style="min-width: 10%">
  37. <radio :value="item.orderNo" :checked="index === current" />
  38. </view>
  39. <view class="title" style="min-width: 80%;text-align: center;">{{item.orderNo}}({{item.workshop.zyProductWorkshop}}-{{item.team.zyTeam}})
  40. </view>
  41. <view class="text-grey" style="flex: 1;">{{item.qty}}</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </radio-group>
  47. </scroll-view>
  48. </u-picker>
  49. </u-popup>
  50. <u-toast ref="uToast"></u-toast>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. // getPlanOrderData
  57. list
  58. } from '@/api/biz/filing.js'
  59. import {
  60. add,
  61. edit
  62. } from '@/api/biz/plan.js'
  63. export default {
  64. data() {
  65. return {
  66. orderList: [],
  67. planInfo: {
  68. id:'',
  69. orderNo: '',
  70. qty: '',
  71. workShift: ''
  72. },
  73. current: -1,
  74. showOrder: false,
  75. showWorkShift: false,
  76. actions: [{
  77. name: '早',
  78. },
  79. {
  80. name: '中',
  81. },
  82. {
  83. name: '晚',
  84. },{
  85. name: '管理线',
  86. },
  87. ],
  88. rules: {
  89. 'orderNo': {
  90. type: 'string',
  91. required: true,
  92. message: '请填写订单号',
  93. trigger: ['blur', 'change']
  94. },
  95. 'workShift':{
  96. type: 'string',
  97. required: true,
  98. message: '请填写班制',
  99. trigger: ['blur', 'change']
  100. }
  101. },
  102. }
  103. },
  104. methods: {
  105. workShiftSelect(e) {
  106. this.planInfo.workShift = e.name
  107. },
  108. itemClick(item) {
  109. },
  110. cancel() {
  111. this.showOrder = false
  112. },
  113. confirm() {
  114. console.log(this.current)
  115. const focusObj = this.orderList[this.current]
  116. console.log(focusObj)
  117. this.planInfo.orderNo = focusObj.orderNo
  118. this.planInfo.qty = focusObj.qty
  119. this.showOrder = false
  120. },
  121. radioChange(evt) {
  122. for (let i = 0; i < this.orderList.length; i++) {
  123. if (this.orderList[i].orderNo === evt.detail.value) {
  124. this.current = i;
  125. break;
  126. }
  127. }
  128. },
  129. loadOrderInfo() {
  130. list(0).then(res => {
  131. if (res.success) {
  132. this.orderList = res.data
  133. }
  134. })
  135. },
  136. submit() {
  137. this.$refs.uForm.validate().then(val => {
  138. edit(this.planInfo).then(res => {
  139. if (res.success) {
  140. this.$refs.uToast.show({
  141. type: 'success',
  142. message: "修改成功",
  143. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  144. })
  145. uni.$emit('loadData');
  146. uni.navigateBack(1);
  147. } else {
  148. this.$refs.uToast.show({
  149. type: 'error',
  150. message: res.message,
  151. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  152. })
  153. }
  154. })
  155. })
  156. },
  157. reset() {
  158. this.$refs.uForm.resetFields()
  159. // this.planInfo.orderNo = ''
  160. // this.planInfo.qty = ''
  161. // this.planInfo.workShift = ''
  162. }
  163. },
  164. onReady() {
  165. this.loadOrderInfo()
  166. this.$refs.uForm.setRules(this.rules)
  167. },
  168. onLoad(option) {
  169. const planInfo = JSON.parse(decodeURIComponent(option.planInfo))
  170. this.planInfo = planInfo
  171. }
  172. }
  173. </script>
  174. <style>
  175. </style>