index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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='120'>
  8. <u-form-item label="订单号:" prop="orderNo" borderBottom ref="uItem" :required="true"@click="showOrder = true">
  9. <u--input v-model="planInfo.orderNo" disabled disabledColor="#ffffff" border="none"></u--input>
  10. <u-icon slot="right" name="search" size="25px" ></u-icon>
  11. </u-form-item>
  12. <u-form-item label="车间:" borderBottom ref="uItem">
  13. <u--input v-model="planInfo.workshop" disabled disabledColor="#ffffff" border="none"></u--input>
  14. </u-form-item>
  15. <u-form-item label="班组:" borderBottom ref="uItem">
  16. <u--input v-model="planInfo.team" disabled disabledColor="#ffffff" border="none"></u--input>
  17. </u-form-item>
  18. <u-form-item label="数量:" prop="qty" borderBottom ref="uItem">
  19. <u--input v-model="planInfo.qty" border="none"></u--input>
  20. </u-form-item>
  21. <u-form-item label="班制:" prop="workShift" borderBottom ref="uItem"
  22. @click="showWorkShift = true" :required="true">
  23. <u--input v-model="planInfo.workShift" disabled disabledColor="#ffffff" border="none"></u--input>
  24. <u-icon slot="right" name="arrow-right" size="25px"></u-icon>
  25. </u-form-item>
  26. <u-form-item label="排产总数:" prop="qty_sum" borderBottom ref="uItem">
  27. <u--input v-model="planInfo.qty_sum" disabled disabledColor="#ffffff" border="none"></u--input>
  28. </u-form-item>
  29. <u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
  30. <u-button type="error" text="重置" customStyle="margin-top: 10px" @click="reset"></u-button>
  31. </u--form>
  32. <u-action-sheet :show="showWorkShift" :actions="actions" title="请选择班制" @close="showWorkShift = false"
  33. @select="workShiftSelect" />
  34. </view>
  35. <u-popup :show="showOrder" mode="bottom" :overlay="true" :safeAreaInsetBottom="true"
  36. :safeAreaInsetTop="true" @close="showOrder = false">
  37. <u-toolbar @cancel="cancel" @confirm="confirm"></u-toolbar>
  38. <u-line></u-line>
  39. <scroll-view :scroll-y="true" class="u-popup-slot" style="height:750rpx">
  40. <radio-group @change="radioChange" style="width: 100%;">
  41. <view class="cu-list menu">
  42. <view class="cu-item" v-for="(item,index) in orderList" @click="itemClick(item)">
  43. <view class="content">
  44. <view class="cu-form-group">
  45. <view style="min-width: 10%">
  46. <radio :value="index" :checked="index == current" />
  47. </view>
  48. <view class="title" style="min-width: 80%;text-align: center;">{{item.orderNo}}({{item.workshop.zyProductWorkshop}}-{{item.team.zyTeam}})
  49. </view>
  50. <view class="text-grey" style="flex: 1;">{{item.stockQty}}</view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </radio-group>
  56. </scroll-view>
  57. </u-picker>
  58. </u-popup>
  59. <u-toast ref="uToast"></u-toast>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. list
  66. // getPlanOrderData
  67. } from '@/api/biz/filing.js'
  68. import {
  69. add,
  70. edit,
  71. planCount
  72. } from '@/api/biz/plan.js'
  73. export default {
  74. data() {
  75. return {
  76. orderList: [],
  77. planInfo: {
  78. orderNo: '',
  79. qty: '',
  80. workShift: '',
  81. orderId:'',
  82. qty_sum:0
  83. },
  84. current: -1,
  85. showOrder: false,
  86. showWorkShift: false,
  87. actions: [{
  88. name: '早',
  89. },
  90. {
  91. name: '中',
  92. },
  93. {
  94. name: '晚',
  95. },{
  96. name: '管理线',
  97. },
  98. ],
  99. rules: {
  100. 'orderNo': {
  101. type: 'string',
  102. required: true,
  103. message: '请填写订单号',
  104. trigger: ['blur', 'change']
  105. },
  106. 'workShift':{
  107. type: 'string',
  108. required: true,
  109. message: '请填写班制',
  110. trigger: ['blur', 'change']
  111. }
  112. },
  113. }
  114. },
  115. methods: {
  116. workShiftSelect(e) {
  117. this.planInfo.workShift = e.name
  118. //传递参数:订单号,班制
  119. let params = {
  120. orderId: this.planInfo.orderId,
  121. workShift: this.planInfo.workShift
  122. };
  123. this.planInfo.qty_sum = 0;
  124. this.getPlanCount(params);
  125. },
  126. getPlanCount(params) {
  127. planCount(params).then(res => {
  128. if (res.success) {
  129. // console.log(res.data)
  130. // console.log(res.data!=false)
  131. if(res.data!=false){
  132. if(this.planInfo.qty == undefined){
  133. this.planInfo.qty_sum = Number(res.data[0].qtySum)
  134. }else{
  135. this.planInfo.qty_sum = Number(res.data[0].qtySum) + Number(this.planInfo.qty)
  136. }
  137. }else{
  138. if(this.planInfo.qty == undefined || this.planInfo.qty == ''){
  139. this.planInfo.qty_sum = 0}else{
  140. this.planInfo.qty_sum = this.planInfo.qty
  141. }
  142. }
  143. } else {
  144. }
  145. });
  146. },
  147. itemClick(item) {
  148. },
  149. cancel() {
  150. this.showOrder = false
  151. },
  152. confirm() {
  153. console.log(this.current)
  154. const focusObj = this.orderList[this.current]
  155. console.log(focusObj)
  156. this.planInfo.orderNo = focusObj.orderNo
  157. this.planInfo.qty = focusObj.qty
  158. this.planInfo.orderId = focusObj.id
  159. this.planInfo.workshop = focusObj.workshop.zyProductWorkshop
  160. this.planInfo.team = focusObj.team.zyTeam
  161. this.showOrder = false
  162. },
  163. radioChange(evt) {
  164. console.log(evt);
  165. // for (let i = 0; i < this.orderList.length; i++) {
  166. // if (this.orderList[i].orderNo === evt.detail.value) {
  167. // this.current = i;
  168. this.current = evt.detail.value;
  169. // break;
  170. // }
  171. // }
  172. },
  173. loadOrderInfo() {
  174. list(0).then(res => {
  175. if (res.success) {
  176. console.log(res.data)
  177. this.orderList = res.data
  178. }
  179. })
  180. },
  181. submit() {
  182. this.$refs.uForm.validate().then(val => {
  183. console.log(this.planInfo.orderId);
  184. add(this.planInfo).then(res => {
  185. if (res.success) {
  186. this.$refs.uToast.show({
  187. type: 'success',
  188. message: "新增成功",
  189. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  190. })
  191. this.reset()
  192. } else {
  193. this.$refs.uToast.show({
  194. type: 'error',
  195. message: res.message,
  196. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  197. })
  198. }
  199. })
  200. })
  201. },
  202. reset() {
  203. this.planInfo = {
  204. orderNo: '',
  205. qty: '',
  206. workShift: '',
  207. orderId:'',
  208. qty_sum:0
  209. }
  210. this.$refs.uForm.clearValidate()
  211. }
  212. },
  213. onReady() {
  214. this.loadOrderInfo()
  215. this.$refs.uForm.setRules(this.rules)
  216. },
  217. onUnload() {
  218. uni.$emit('loadData');
  219. }
  220. }
  221. </script>
  222. <style>
  223. </style>