|
@@ -1,6 +1,8 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <el-page-header @back="$parent.pageType=0" :content="$parent.pageType=0?'新增':'编辑'" style=" padding: 20px 20px 0 20px;"></el-page-header>
|
|
|
+ <el-page-header @back="$parent.pageType=0" content="新增"
|
|
|
+ style=" padding: 20px 20px 0 20px;"
|
|
|
+ ></el-page-header>
|
|
|
<warehousing-header ref="header" />
|
|
|
<sales-table :dataList="dataList" :column="column" isOperation isSelection @handleSelection="handleSelection">
|
|
|
<template #bts>
|
|
@@ -12,7 +14,7 @@
|
|
|
<template #events>
|
|
|
<div>
|
|
|
<el-button type="primary" size="mini" @click="handelSubmit">提交</el-button>
|
|
|
- <el-button size="mini">重置</el-button>
|
|
|
+ <el-button size="mini" @click="onReset">重置</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
<template v-slot:custom="{item:{row,$index}}">
|
|
@@ -29,9 +31,9 @@
|
|
|
</el-popconfirm>
|
|
|
</template>
|
|
|
</sales-table>
|
|
|
-
|
|
|
-
|
|
|
- <sales-dialog :dialogVisible="dialogVisible" :customerNumber="customerNumber" :func="getDialogList" @confirm="confirm" />
|
|
|
+ <sales-dialog :dialogVisible="dialogVisible" :customerNumber="customerNumber" :func="getDialogList"
|
|
|
+ @confirm="confirm"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -39,7 +41,10 @@
|
|
|
import SalesDialog from '@/components/SalesDialog/SalesDialog'
|
|
|
import WarehousingHeader from '@/components/WarehousingHeader/WarehousingHeader'
|
|
|
import SalesTable from '@/components/SalesTable/SalesTable'
|
|
|
-import { getcustomerFrontList, addFrontOrder } from '@/api/stock'
|
|
|
+import { getcustomerFrontList,addCustomerStockOrder } from '@/api/stock'
|
|
|
+import {
|
|
|
+ addFrontOrder
|
|
|
+} from '@/api/sales'
|
|
|
|
|
|
export default {
|
|
|
name: 'WarehouseForm',
|
|
@@ -51,10 +56,10 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
dialogVisible: false,
|
|
|
- customerNumber:'',
|
|
|
+ customerNumber: '',
|
|
|
dataList: [],
|
|
|
selection: [],
|
|
|
- flag:1,
|
|
|
+ flag: 1,
|
|
|
column: [
|
|
|
{
|
|
|
prop: 'materialName',
|
|
@@ -100,6 +105,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ onReset() {
|
|
|
+ Object.assign(this.$data, this.$options.data())
|
|
|
+ Object.assign(this.$refs.header.$data, this.$refs.header.$options.data())
|
|
|
+
|
|
|
+ },
|
|
|
getDialogList(p) {
|
|
|
return getcustomerFrontList(...p)
|
|
|
},
|
|
@@ -115,34 +125,41 @@ export default {
|
|
|
handleDel(item, index) {
|
|
|
this.dataList.splice(index, 1)
|
|
|
},
|
|
|
+ //去掉相同数据
|
|
|
+ resArr(arr1, arr2) {
|
|
|
+ return arr1.filter(v => arr2.every(val => val.id != v.id))
|
|
|
+ },
|
|
|
delChange() {
|
|
|
- this.dataList.forEach((k, i) => {
|
|
|
- this.selection.forEach((l, e) => {
|
|
|
- if (k.id === l.id) {
|
|
|
- this.dataList.splice(i, 1)
|
|
|
- this.selection.splice(e, 1)
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
+ if (this.dataList.length){
|
|
|
+ this.dataList = this.resArr(this.dataList,this.selection)
|
|
|
+ if (!this.dataList.length){
|
|
|
+ this.customerNumber = ''
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
handleSelection(data) {
|
|
|
this.selection = data
|
|
|
},
|
|
|
handelSubmit() {
|
|
|
- this.dataList.forEach(k => {
|
|
|
- k.id = ''
|
|
|
- k.directFlag = k.flag
|
|
|
- })
|
|
|
+
|
|
|
+ for (let i = 0; i < this.dataList.length; i++) {
|
|
|
+ this.dataList[i].id = ''
|
|
|
+ this.dataList[i].directFlag = this.dataList[i].flag
|
|
|
+ if (Number(this.dataList[i].stockChangeQty) < 0 || !this.dataList[i].stockChangeQty) {
|
|
|
+ this.$errorMsg(`第${i + 1}产品数量有误`)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
const params = {
|
|
|
...this.$refs.header.screenForm,
|
|
|
orders: this.dataList
|
|
|
}
|
|
|
- addFrontOrder(params).then(res => {
|
|
|
+ addCustomerStockOrder(params).then(res => {
|
|
|
this.$successMsg('新增成功')
|
|
|
this.$parent.pageType = 0
|
|
|
this.$forceUpdate()
|
|
|
})
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|