set-work-order.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="work-order__wrapper">
  3. <el-form ref="formRef" :model="list">
  4. <el-table size="mini" border :data="list">
  5. <el-table-column label="发货工单" align="center">
  6. <el-table-column prop="outChildCode" label="编号" width="160px" show-overflow-tooltip />
  7. <el-table-column label="计划发货数量" width="100px" prop="num" />
  8. <el-table-column prop="outChildCode" label="提退货时的发货单状态" width="145px" show-overflow-tooltip>
  9. <template slot-scope="scope">
  10. <el-tag size="mini">
  11. {{ (statusOptions.find(({value}) => value === String(scope.row.status)) || {}).label || '--' }}
  12. </el-tag>
  13. </template>
  14. </el-table-column>
  15. </el-table-column>
  16. <el-table-column label="发货仓库名称" prop="wsm_name" min-width="180px" show-overflow-tooltip>
  17. <template slot-scope="scope">
  18. <el-popover placement="top" width="380" trigger="hover">
  19. <h3>发货仓库</h3>
  20. <ul>
  21. <li>编码 : {{ scope.row.wsm_code }}</li>
  22. <li>负责人 : {{ scope.row.contactor_name }}</li>
  23. <li>所在供应商名称 : {{ scope.row.supplierName }}</li>
  24. <li>所在供应商编码 : {{ scope.row.supplierNo }}</li>
  25. </ul>
  26. <i slot="reference" class="el-icon-warning-outline" />
  27. </el-popover>
  28. <span>{{ scope.row.wsm_name }}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column width="110px" show-overflow-tooltip>
  32. <template slot="header">
  33. <span style="color:red;margin-right:2px">*</span>退货数量
  34. </template>
  35. <template slot-scope="scope">
  36. <el-form-item :prop="`${scope.$index}.return_num`" :rules="paramsRules.return_num">
  37. <digital-input
  38. :values="list[scope.$index].return_num"
  39. :placeholder="'退货数量'"
  40. :disabled="false"
  41. :max="list[scope.$index].num"
  42. :position="'right'"
  43. :precision="0"
  44. :size="'mini'"
  45. :controls="false"
  46. :append="''"
  47. @reschange="onNumberChange($event, scope.$index)"
  48. />
  49. </el-form-item>
  50. </template>
  51. </el-table-column>
  52. <el-table-column v-if="!isStock" min-width="160px" show-overflow-tooltip>
  53. <template slot="header">
  54. <span style="color:red;margin-right:2px">*</span>退货仓库编码
  55. </template>
  56. <template slot-scope="scope">
  57. <el-form-item :prop="`${scope.$index}.return_wsm_code`" :rules="paramsRules.return_wsm_code">
  58. <search-stock
  59. :disabled="isStock"
  60. :size="'mini'"
  61. :value="list[scope.$index].return_wsm_code"
  62. :placeholder="'仓库名称'"
  63. :is-relation="true"
  64. :wsmtype="'5'"
  65. :company-no="currentCompany"
  66. @searchChange="onStockChange($event, scope.$index)"
  67. />
  68. </el-form-item>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="退货仓库" align="center">
  72. <tempalte v-if="isStock">
  73. <el-table-column label="负责人" min-width="110px" prop="contactor_name" show-overflow-tooltip />
  74. <el-table-column label="仓库名称" prop="wsm_name" min-width="160px" show-overflow-tooltip />
  75. <el-table-column label="所在供应商名称" prop="supplierName" min-width="160px" show-overflow-tooltip />
  76. <el-table-column label="所在供应商编码" prop="supplierNo" min-width="160px" show-overflow-tooltip />
  77. </tempalte>
  78. <template v-else>
  79. <el-table-column label="所在供应商名称" prop="returnSupplierName" min-width="160px" show-overflow-tooltip />
  80. <el-table-column label="所在供应商编码" prop="returnSupplierNo" min-width="160px" show-overflow-tooltip />
  81. <el-table-column label="负责人" min-width="110px" prop="returnSupplierNameContactor" show-overflow-tooltip />
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </el-form>
  86. <el-button
  87. class="fr"
  88. style="margin:10px 0px"
  89. size="mini"
  90. type="primary"
  91. :loading="subLoading"
  92. @click="onSetOrderReturnChild"
  93. >
  94. 保存
  95. </el-button>
  96. </div>
  97. </template>
  98. <script>
  99. import asyncRequest from '@/apis/service/sellOut/sellAfterApply'
  100. import companyHelper from '@/mixins/companyHelper'
  101. import resToken from '@/mixins/resToken'
  102. export default {
  103. name: 'WorkOrder',
  104. mixins: [resToken, companyHelper],
  105. props: ['sitem'],
  106. data: () => ({
  107. names: [],
  108. list: [],
  109. loading: false,
  110. subLoading: false,
  111. companyNo: '',
  112. statusOptions: [
  113. { value: '1', label: '待发货' },
  114. { value: '2', label: '发货完成' },
  115. { value: '3', label: '已收货' },
  116. { value: '4', label: '已全部退货' }
  117. ]
  118. }),
  119. computed: {
  120. isStock() {
  121. const { order_type } = this.sitem || {}
  122. return order_type === '1'
  123. },
  124. paramsRules() {
  125. return ({
  126. return_wsm_code: [{
  127. required: true,
  128. message: '请选择退货仓库',
  129. trigger: 'change'
  130. }]
  131. })
  132. }
  133. },
  134. watch: {
  135. sitem: {
  136. async handler() {
  137. if (!this.sitem || !this.sitem.outCode) { return }
  138. const { outCode, order_type } = this.sitem
  139. const isStock = order_type === '1'
  140. const { data, code, message } = await asyncRequest.sendList({ outCode })
  141. switch (code) {
  142. case 0:
  143. this.list = data.map(item => {
  144. return {
  145. ...item,
  146. return_num: 0,
  147. names: isStock ? item.wsm_name : '',
  148. return_wsm_code: isStock ? [item.wsm_code] : ''
  149. }
  150. })
  151. break
  152. default:
  153. this.$message.warning(message)
  154. break
  155. }
  156. },
  157. immediate: true
  158. }
  159. },
  160. methods: {
  161. onStockChange({ code, supplierName, supplierNo, contactor_name } = {}, index) {
  162. this.$set(this.list, index, {
  163. ...this.list[index],
  164. returnSupplierNo: supplierNo,
  165. returnSupplierName: supplierName,
  166. return_wsm_code: code ? [code] : '',
  167. returnSupplierNameContactor: contactor_name
  168. })
  169. this.$nextTick(() => this.$refs.formRef.validate())
  170. },
  171. onNumberChange(return_num, index) {
  172. this.$set(this.list, index, {
  173. ...this.list[index],
  174. return_num
  175. })
  176. },
  177. async onSetOrderReturnChild() {
  178. this.$refs.formRef.validate(async isValid => {
  179. if (!isValid) return
  180. let sum = 0
  181. const list = this.list.map(({ outChildCode, return_num, return_wsm_code }) => {
  182. sum += Number(return_num)
  183. return {
  184. return_num,
  185. outChildCode,
  186. return_wsm_code: Array.isArray(return_wsm_code) ? return_wsm_code[0] : return_wsm_code
  187. }
  188. })
  189. if (Number(this.sitem.error_num) !== sum) {
  190. this.$message.warning('退货数量的和与异常数量不一致')
  191. return
  192. }
  193. const { code, message } = await asyncRequest.setOrderReturnChild({
  194. list,
  195. returnCode: this.sitem.returnCode
  196. })
  197. this.subLoading = false
  198. switch (code) {
  199. case 0:
  200. this.$emit('reload')
  201. break
  202. default:
  203. this.$message.warning(message)
  204. break
  205. }
  206. })
  207. }
  208. }
  209. }
  210. </script>