customer_sales_form.vue 4.0 KB

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