WarehouseForm.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div>
  3. <el-page-header @back="$parent.pageType=0" content="新增"
  4. style=" padding: 20px 20px 0 20px;"
  5. ></el-page-header>
  6. <warehousing-header ref="header" />
  7. <sales-table :dataList="dataList" :column="column" isOperation isSelection @handleSelection="handleSelection">
  8. <template #bts>
  9. <div>
  10. <el-button type="primary" size="mini" @click="dialogVisible=true">添加</el-button>
  11. <el-button type="danger" size="mini" @click="delChange">删除</el-button>
  12. </div>
  13. </template>
  14. <template #events>
  15. <div>
  16. <el-button type="primary" size="mini" @click="handelSubmit">提交</el-button>
  17. <el-button size="mini" @click="onReset">重置</el-button>
  18. </div>
  19. </template>
  20. <template v-slot:custom="{item:{row,$index}}">
  21. <el-radio label="1" v-model="row.flag">增加</el-radio>
  22. <el-radio label="-1" v-model="row.flag">减少</el-radio>
  23. </template>
  24. <template v-slot:operation="{item:{row,$index}}">
  25. <el-popconfirm
  26. style="margin-left: 10px"
  27. title="删除?"
  28. @onConfirm="handleDel(row,$index)"
  29. >
  30. <el-button slot="reference" type="text" size="mini">删除</el-button>
  31. </el-popconfirm>
  32. </template>
  33. </sales-table>
  34. <sales-dialog :dialogVisible="dialogVisible" :customerNumber="customerNumber" :func="getDialogList"
  35. @confirm="confirm"
  36. />
  37. </div>
  38. </template>
  39. <script>
  40. import SalesDialog from '@/components/SalesDialog/SalesDialog'
  41. import WarehousingHeader from '@/components/WarehousingHeader/WarehousingHeader'
  42. import SalesTable from '@/components/SalesTable/SalesTable'
  43. import { getcustomerFrontList,addCustomerStockOrder } from '@/api/stock'
  44. import {
  45. addFrontOrder
  46. } from '@/api/sales'
  47. export default {
  48. name: 'WarehouseForm',
  49. components: {
  50. WarehousingHeader,
  51. SalesTable,
  52. SalesDialog
  53. },
  54. data() {
  55. return {
  56. dialogVisible: false,
  57. customerNumber: '',
  58. dataList: [],
  59. selection: [],
  60. flag: 1,
  61. column: [
  62. {
  63. prop: 'materialName',
  64. label: '产品名称',
  65. width: '180'
  66. },
  67. {
  68. prop: 'materialOldNumber',
  69. label: '物料编码',
  70. width: '180'
  71. },
  72. {
  73. prop: 'specification',
  74. label: '规格型号',
  75. width: '300'
  76. },
  77. {
  78. prop: 'stockLockQty',
  79. label: '库存',
  80. width: '180'
  81. },
  82. {
  83. prop: 'directFlag',
  84. label: '发生方向',
  85. width: '180',
  86. isCustom: true
  87. },
  88. {
  89. prop: 'stockChangeQty',
  90. label: '数量',
  91. width: '180',
  92. isInput: true
  93. },
  94. {
  95. prop: 'remark',
  96. label: '备注',
  97. width: '180',
  98. isInput: true
  99. }
  100. ]
  101. }
  102. },
  103. methods: {
  104. onReset() {
  105. Object.assign(this.$data, this.$options.data())
  106. Object.assign(this.$refs.header.$data, this.$refs.header.$options.data())
  107. },
  108. getDialogList(p) {
  109. return getcustomerFrontList(...p)
  110. },
  111. confirm(selected) {
  112. // console.log(selected)
  113. this.dataList = selected
  114. this.$refs.header.screenForm.customerName = this.dataList[0].customerName
  115. this.$refs.header.screenForm.customerNumber = this.dataList[0].customerNumber
  116. this.customerNumber = this.dataList[0].customerNumber
  117. this.dialogVisible = false
  118. },
  119. handleDel(item, index) {
  120. this.dataList.splice(index, 1)
  121. },
  122. //去掉相同数据
  123. resArr(arr1, arr2) {
  124. return arr1.filter(v => arr2.every(val => val.id != v.id))
  125. },
  126. delChange() {
  127. if (this.dataList.length){
  128. this.dataList = this.resArr(this.dataList,this.selection)
  129. if (!this.dataList.length){
  130. this.customerNumber = ''
  131. }
  132. }
  133. },
  134. handleSelection(data) {
  135. this.selection = data
  136. },
  137. handelSubmit() {
  138. for (let i = 0; i < this.dataList.length; i++) {
  139. this.dataList[i].id = ''
  140. this.dataList[i].directFlag = this.dataList[i].flag
  141. if (Number(this.dataList[i].stockChangeQty) < 0 || !this.dataList[i].stockChangeQty) {
  142. this.$errorMsg(`第${i + 1}产品数量有误`)
  143. return
  144. }
  145. }
  146. const params = {
  147. ...this.$refs.header.screenForm,
  148. orders: this.dataList
  149. }
  150. addCustomerStockOrder(params).then(res => {
  151. this.$successMsg('新增成功')
  152. this.$parent.pageType = 0
  153. this.$forceUpdate()
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style scoped>
  160. </style>