|
|
@@ -39,8 +39,8 @@
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:action="{ row, $index }">
|
|
|
- <template >
|
|
|
- <el-link type="primary" :underline="false" @click="categorySelect">
|
|
|
+ <template>
|
|
|
+ <el-link type="primary" :underline="false" @click="categorySelect(row)">
|
|
|
添加物料
|
|
|
</el-link>
|
|
|
<el-popconfirm class="ele-action" title="确定要删除此销售订单吗?" @confirm="remove(row, $index)">
|
|
|
@@ -56,30 +56,42 @@
|
|
|
|
|
|
<!-- 展开内容 -->
|
|
|
<template v-slot:expand="{ row }">
|
|
|
- <div style="width:100%; min-height: 60px" v-if="row.materialList">
|
|
|
+ <div style="width:100%; min-height: 60px" v-if="row.materialList.length > 0">
|
|
|
<ele-pro-table :toolbar="false" toolsTheme="none" ref="table2" :need-page="false"
|
|
|
:datasource="row.materialList" :columns="columns2" row-key="id">
|
|
|
|
|
|
- <template v-slot:categoryName="{ row, $index }">
|
|
|
- <el-input :value="row.categoryName" placeholder="请选择"
|
|
|
- @click.native="categorySelect(row, $index)"></el-input>
|
|
|
- </template>
|
|
|
|
|
|
|
|
|
- <template v-slot:unit="{ row }">
|
|
|
- <DictSelection dictName="计量单位" v-model="row.unit"></DictSelection>
|
|
|
+
|
|
|
+ <template v-slot:demandQuantity="{ row }">
|
|
|
+ <el-input v-model="row.demandQuantity" placeholder="请输入" @input="(value) =>
|
|
|
+ (row.demandQuantity = value.replace(
|
|
|
+ /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
|
|
|
+ '$1$2.$3'
|
|
|
+ ))
|
|
|
+ "></el-input>
|
|
|
</template>
|
|
|
|
|
|
|
|
|
- <template v-slot:count="{ row }">
|
|
|
- <el-input v-model="row.count" placeholder="请输入" @input="(value) =>
|
|
|
- (row.count = value.replace(
|
|
|
+ <template v-slot:purchaseQuantity="{ row }">
|
|
|
+ <el-input v-model="row.purchaseQuantity" placeholder="请输入" @input="(value) =>
|
|
|
+ (row.purchaseQuantity = value.replace(
|
|
|
/^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
|
|
|
'$1$2.$3'
|
|
|
))
|
|
|
"></el-input>
|
|
|
</template>
|
|
|
|
|
|
+ <template v-slot:action="{ row }">
|
|
|
+ <el-popconfirm class="ele-action" title="确定要删除当前物料吗?" @confirm="remove2(row)">
|
|
|
+ <template v-slot:reference>
|
|
|
+ <el-link type="danger" :underline="false" icon="el-icon-delete">
|
|
|
+ 删除
|
|
|
+ </el-link>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+
|
|
|
</ele-pro-table>
|
|
|
</div>
|
|
|
|
|
|
@@ -100,7 +112,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- <ProductModal ref="productRefs" />
|
|
|
+ <ProductModal ref="productRefs" @chooseModal="chooseModal" />
|
|
|
|
|
|
</ele-modal>
|
|
|
</template>
|
|
|
@@ -108,10 +120,8 @@
|
|
|
<script>
|
|
|
|
|
|
import saleOrderPop from './saleOrderPop.vue'
|
|
|
-
|
|
|
-
|
|
|
import ProductModal from './ProductModal.vue'
|
|
|
-
|
|
|
+import { listBomBySalesOrderIds, save } from '@/api/materialPlan/index';
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
@@ -145,7 +155,7 @@ export default {
|
|
|
slot: 'code',
|
|
|
showOverflowTooltip: true,
|
|
|
align: 'center',
|
|
|
- minWidth: 120
|
|
|
+ minWidth: 150
|
|
|
},
|
|
|
{
|
|
|
prop: 'customerName',
|
|
|
@@ -159,6 +169,13 @@ export default {
|
|
|
align: 'center',
|
|
|
showOverflowTooltip: true
|
|
|
},
|
|
|
+ {
|
|
|
+ prop: 'productCode',
|
|
|
+ label: '产品编码',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 140
|
|
|
+ },
|
|
|
|
|
|
{
|
|
|
prop: 'productName',
|
|
|
@@ -186,7 +203,16 @@ export default {
|
|
|
align: 'center',
|
|
|
showOverflowTooltip: true
|
|
|
},
|
|
|
-
|
|
|
+ {
|
|
|
+ prop: 'contractNum',
|
|
|
+ label: '合同数量',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'lackNum',
|
|
|
+ label: '欠交数量',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'remark',
|
|
|
label: '备注',
|
|
|
@@ -212,14 +238,12 @@ export default {
|
|
|
|
|
|
{
|
|
|
label: '物料名称',
|
|
|
- prop: 'categoryName',
|
|
|
- slot: 'categoryName',
|
|
|
- action: 'categoryName'
|
|
|
+ prop: 'name',
|
|
|
},
|
|
|
|
|
|
{
|
|
|
label: '物料编码',
|
|
|
- prop: 'categoryCode'
|
|
|
+ prop: 'code'
|
|
|
},
|
|
|
{
|
|
|
label: '牌号',
|
|
|
@@ -229,17 +253,50 @@ export default {
|
|
|
label: '型号',
|
|
|
prop: 'modelType'
|
|
|
},
|
|
|
+
|
|
|
{
|
|
|
- label: '数量',
|
|
|
- slot: 'count',
|
|
|
- action: 'count'
|
|
|
+ prop: 'availableCountBase',
|
|
|
+ label: '包装库存',
|
|
|
+ sortable: 'custom',
|
|
|
},
|
|
|
{
|
|
|
label: '单位',
|
|
|
- slot: 'unit',
|
|
|
- action: 'unit'
|
|
|
+ prop: 'weightUnit'
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ prop: 'packingCountBase',
|
|
|
+ label: '计量库存',
|
|
|
+ sortable: 'custom',
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ label: '计量单位',
|
|
|
+ prop: 'unit'
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ label: '需求数量',
|
|
|
+ slot: 'demandQuantity',
|
|
|
+ action: 'demandQuantity'
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ label: '采购数量',
|
|
|
+ slot: 'purchaseQuantity',
|
|
|
+ action: 'purchaseQuantity'
|
|
|
},
|
|
|
|
|
|
+ {
|
|
|
+ columnKey: 'action',
|
|
|
+ label: '操作',
|
|
|
+
|
|
|
+ align: 'center',
|
|
|
+ resizable: false,
|
|
|
+ slot: 'action',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ }
|
|
|
+
|
|
|
],
|
|
|
rules: {
|
|
|
materialName: [
|
|
|
@@ -254,7 +311,7 @@ export default {
|
|
|
},
|
|
|
formData: {
|
|
|
materialName: '',
|
|
|
- salesOrderPOList: []
|
|
|
+
|
|
|
},
|
|
|
|
|
|
|
|
|
@@ -263,7 +320,6 @@ export default {
|
|
|
methods: {
|
|
|
async open(type, row = {}) {
|
|
|
this.type = type;
|
|
|
- // this.formData = Object.assign({}, this.formData, row);
|
|
|
this.visible = true;
|
|
|
},
|
|
|
|
|
|
@@ -271,10 +327,16 @@ export default {
|
|
|
confirm() {
|
|
|
this.$refs.formRef.validate(async (value) => {
|
|
|
if (value) {
|
|
|
- const request = this.type == 'add' ? save : update;
|
|
|
|
|
|
+ let _arr = this.$refs.table.getData() ?? []
|
|
|
|
|
|
- // await request(this.formData);
|
|
|
+ if (_arr.length == 0) {
|
|
|
+ this.$message.info('请添加销售订单');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.formData['salesOrderPOList'] = _arr
|
|
|
+ const request = this.type == 'add' ? save : update;
|
|
|
+ await request(this.formData);
|
|
|
this.$message.success('保存成功!');
|
|
|
this.$emit('success');
|
|
|
this.cancel();
|
|
|
@@ -301,7 +363,22 @@ export default {
|
|
|
},
|
|
|
|
|
|
chooseOrder(list) {
|
|
|
+ let salesOrderIds = []
|
|
|
+ list.map((m => {
|
|
|
+ m.materialList = []
|
|
|
+ salesOrderIds.push(m.id)
|
|
|
+ return {
|
|
|
+ ...m,
|
|
|
+ }
|
|
|
+ }))
|
|
|
this.$refs.table.setData([...this.tableData, ...list]);
|
|
|
+
|
|
|
+
|
|
|
+ if (salesOrderIds.length > 0) {
|
|
|
+ listBomBySalesOrderIds({ salesOrderIds: salesOrderIds }).then((res) => {
|
|
|
+ this.$refs.table.setData([...this.tableData, ...res]);
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
remove(row, index) {
|
|
|
@@ -311,8 +388,49 @@ export default {
|
|
|
},
|
|
|
|
|
|
categorySelect(row) {
|
|
|
- this.current = row;
|
|
|
- this.$refs.productRefs.open(row.materialList, this.current, 1)
|
|
|
+ this.$refs.productRefs.open(row.materialList, row)
|
|
|
+ },
|
|
|
+
|
|
|
+ chooseModal(data, current) {
|
|
|
+ data.map((m => {
|
|
|
+ m.parentId = current.id
|
|
|
+ return {
|
|
|
+ ...m,
|
|
|
+ }
|
|
|
+ }))
|
|
|
+
|
|
|
+ let tableList = []
|
|
|
+ tableList = this.$refs.table.getData()
|
|
|
+
|
|
|
+ tableList.forEach(e => {
|
|
|
+ if (e.id == current.id) {
|
|
|
+
|
|
|
+ if (e.materialList.length == 0) {
|
|
|
+ e.materialList = data
|
|
|
+
|
|
|
+ } else {
|
|
|
+ e.materialList = [...e.materialList, ...data]
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ this.$refs.table.setData([...tableList]);
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ remove2(row) {
|
|
|
+ const data = this.$refs.table.getData() ?? [];
|
|
|
+ data.forEach((e) => {
|
|
|
+ if (row.parentId == e.id) {
|
|
|
+ e.materialList = e.materialList.filter((d) => d.id !== row.id);
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ this.$refs.table.setData([...data])
|
|
|
+ this.$forceUpdate()
|
|
|
},
|
|
|
|
|
|
|