customer_sales_form.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div>
  3. <el-page-header @back="$parent.pageType=0" :content="detailsId?'编辑':'新增'" 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 v-if="!detailsId">
  14. <el-button type="primary" size="mini" @click="handelSubmit(1)">提交</el-button>
  15. <el-button size="mini">重置</el-button>
  16. <el-button size="mini" :disabled="dis" @click="handleInform(2)">通知发货</el-button>
  17. </div>
  18. <div v-else>
  19. <el-button type="primary" size="mini" @click="handelSubmit(2)">保存</el-button>
  20. <el-button size="mini">重置</el-button>
  21. </div>
  22. </template>
  23. <template v-slot:custom="{item:{row,$index}}">
  24. <el-radio label="1" v-model="row.flag">增加</el-radio>
  25. <el-radio label="-1" v-model="row.flag">减少</el-radio>
  26. </template>
  27. <template v-slot:operation="{item:{row,$index}}">
  28. <el-popconfirm
  29. style="margin-left: 10px"
  30. title="删除?"
  31. @onConfirm="handleDel(row,$index)"
  32. >
  33. <el-button slot="reference" type="text" size="mini">删除</el-button>
  34. </el-popconfirm>
  35. </template>
  36. </sales-table>
  37. <sales-dialog :dialogVisible="dialogVisible" :customerNumber="customerNumber" :func="getDialogList"
  38. @confirm="confirm"
  39. />
  40. </div>
  41. </template>
  42. <script>
  43. import SalesDialog from '@/components/SalesDialog/SalesDialog'
  44. import SalesHeader from '@/components/SalesHeader/SalesHeader'
  45. import SalesTable from '@/components/SalesTable/SalesTable'
  46. import { addFrontOrder, getFrontOrderDetail, sbumitFrontOrder, updateFrontOrder } from '@/api/sales'
  47. import { getcustomerFrontList } from '@/api/stock'
  48. export default {
  49. name: 'WarehouseForm',
  50. components: {
  51. SalesHeader,
  52. SalesTable,
  53. SalesDialog
  54. },
  55. props:['detailsId'],
  56. data() {
  57. return {
  58. dialogVisible: false,
  59. customerNumber: '',
  60. dataList: [],
  61. selection: [],
  62. flag: 1,
  63. dis:true,
  64. column: [
  65. {
  66. prop: 'materialName',
  67. label: '产品名称',
  68. width: '180'
  69. },
  70. {
  71. prop: 'materialOldNumber',
  72. label: '物料编码',
  73. width: '180'
  74. },
  75. {
  76. prop: 'specification',
  77. label: '规格型号',
  78. width: '300'
  79. },
  80. {
  81. prop: 'stockLockQty',
  82. label: '库存数量',
  83. width: '180'
  84. },
  85. {
  86. prop: 'qty',
  87. label: '数量',
  88. width: '180',
  89. isInput: true
  90. },
  91. {
  92. prop: 'volume',
  93. label: '体积',
  94. width: '180'
  95. },
  96. {
  97. prop: 'totalVolume',
  98. label: '总体积',
  99. width: '180'
  100. },
  101. {
  102. prop: 'notes',
  103. label: '备注',
  104. width: '180',
  105. isInput: true
  106. }
  107. ]
  108. }
  109. },
  110. created() {
  111. if (this.$parent.pageType == 2 || this.detailsId) {
  112. getFrontOrderDetail({id:this.detailsId}).then(res=>{
  113. this.dataList = res.data.orders
  114. this.$refs.header.screenForm = res.data
  115. this.$refs.header.screenForm.provinceId = res.data.province
  116. this.$refs.header.screenForm.cityId = res.data.city
  117. this.$refs.header.screenForm.areaId = res.data.area
  118. this.$refs.header.screenForm.streetId = res.data.street
  119. this.$refs.header.screenForm.stockType = res.data.stockType == 1 ? '前置仓' : '商家仓'
  120. })
  121. }
  122. },
  123. methods: {
  124. getDialogList(p) {
  125. return getcustomerFrontList(...p)
  126. },
  127. confirm(selected) {
  128. // console.log(selected)
  129. this.dataList = selected
  130. this.$refs.header.screenForm.customerName = this.dataList[0].customerName
  131. this.$refs.header.screenForm.customerNumber = this.dataList[0].customerNumber
  132. this.$refs.header.screenForm.stockType = this.dataList[0].stockType
  133. this.customerNumber = this.dataList[0].customerNumber
  134. this.dialogVisible = false
  135. },
  136. handleDel(item, index) {
  137. this.dataList.splice(index, 1)
  138. },
  139. delChange() {
  140. this.dataList.forEach((k, i) => {
  141. this.selection.forEach((l, e) => {
  142. if (k.id === l.id) {
  143. this.dataList.splice(i, 1)
  144. this.selection.splice(e, 1)
  145. }
  146. })
  147. })
  148. },
  149. handleSelection(data) {
  150. this.selection = data
  151. },
  152. handleInform(status=2){
  153. console.log(33)
  154. sbumitFrontOrder({id:this.$refs.header.screenForm.id,status}).then(res=>{
  155. console.log(res)
  156. })
  157. },
  158. handelSubmit(type,status=1) {
  159. this.dataList.forEach(k => {
  160. k.id = ''
  161. k.directFlag = k.flag
  162. })
  163. const params = {
  164. ...this.$refs.header.screenForm,
  165. orders: this.dataList,
  166. status:status
  167. }
  168. if (type==1){
  169. params.id = ''
  170. addFrontOrder(params).then(res => {
  171. this.$successMsg('新增成功')
  172. this.dis = false
  173. this.$parent.pageType = 0
  174. this.$forceUpdate()
  175. })
  176. }else {
  177. updateFrontOrder(params).then(res=>{
  178. this.$successMsg('编辑成功')
  179. this.$parent.pageType = 0
  180. this.$forceUpdate()
  181. })
  182. }
  183. }
  184. }
  185. }
  186. </script>
  187. <style scoped>
  188. </style>