第二模块完成

This commit is contained in:
huanghui 2023-08-16 17:43:06 +08:00
parent 69035b3ff7
commit bce709dd64
2 changed files with 238 additions and 42 deletions

View File

@ -30,7 +30,8 @@
</a-button> </a-button>
</template> </template>
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="采购详情" v-if="item.supplierSelection == null"> <a-descriptions-item label="采购详情(未整理)"
v-if="item.supplierSelection == null || item.supplierSelection == ''">
<div v-for="(item2, index2) in item.procurementContent" :key="index2.toString()"> <div v-for="(item2, index2) in item.procurementContent" :key="index2.toString()">
<a-row> <a-row>
<a-col :span="2">{{ item2.name }}</a-col> <a-col :span="2">{{ item2.name }}</a-col>
@ -40,7 +41,30 @@
<a-button style="float: right;" type="primary" @click="arrangeOpen(item)">物品和供应商整理</a-button> <a-button style="float: right;" type="primary" @click="arrangeOpen(item)">物品和供应商整理</a-button>
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="采购详情" v-else> <a-descriptions-item label="采购详情" v-else>
123
<a-card style="margin-top: 20px;margin-right: 20px;"
v-for="(item2, index2) in item.supplierSelection" :key="index2.toString()">
<template #title>
{{ item2.supplier }}
</template>
<div v-for="(item3, index3) in item2.goods" :key="index3.toString()">
<a-row :gutter="16" style="margin-top: 5px;">
<a-col :span="8">
<a-input v-model="item3.name" placeholder="物品名称" disabled />
</a-col>
<a-col :span="6">
<a-input v-model="item3.number" placeholder="数量" disabled />
</a-col>
<a-col :span="6">
<a-input v-model="item3.unit" placeholder="单位" disabled />
</a-col>
</a-row>
</div>
</a-card>
<a-button style="margin-top: 10px;float: right;" type="primary"
@click="arrangeOpen(item)">物品和供应商整理</a-button>
</a-descriptions-item> </a-descriptions-item>
</a-descriptions> </a-descriptions>
</div> </div>
@ -55,27 +79,63 @@
</a-empty> </a-empty>
<a-modal title="采购整理" :visible="arrange" @ok="arrangeOk" @cancel="arrangeCancel"> <a-modal title="采购整理" :visible="arrange" @ok="arrangeOk" @cancel="arrangeCancel">
<!-- {{ arrangeData }}
{{ supplierList }} -->
<div v-if="classifyData.length == 0"> <div v-if="classifyData.length == 0">
未数据分类 暂无数据
</div> </div>
<div v-else> <div v-else>
<div class="card-container"> <div>
<a-card style="margin-top: 20px;margin-right: 20px;" v-for="(item, index) in classifyData" :key="index.toString()"> <a-card style="margin-top: 20px;margin-right: 20px;" v-for="(item, index) in classifyData"
:key="index.toString()">
<template #title> <template #title>
{{ item.supplier }} {{ item.supplier }}
<a-button style="float: right;" type="primary" @click="delSupplier(item)">删除公司</a-button>
</template> </template>
<div v-for="(item2, index2) in item.goods" :key="index2.toString()"> <div style="margin-bottom: 20px;">
{{ item2.name }} <a-select v-model:value="selectedFoods" mode="multiple" style="width: 60%"
placeholder="Please select">
<a-select-option v-for="food in classFood" :key="food.name" :value="food.name">
{{ food.name }}
</a-select-option>
</a-select>
<a-button style="float: right;" @click="importFoods(index)">导入</a-button>
<br>
</div> </div>
<div v-for="(item2, index2) in item.goods" :key="index2.toString()">
<a-row :gutter="16" style="margin-top: 5px;">
<a-col :span="8">
<a-input v-model="item2.name" placeholder="物品名称" />
</a-col>
<a-col :span="6">
<a-input v-model="item2.number" placeholder="数量" />
</a-col>
<a-col :span="6">
<a-input v-model="item2.unit" placeholder="单位" />
</a-col>
<a-col :span="2">
<!-- 通过点击按钮触发新增行 -->
<a-icon type="plus-circle" @click="addRow(item2, index)" />
</a-col>
<a-col :span="2">
<!-- 通过点击按钮触发删除行 -->
<a-icon type="minus-circle" @click="removeRow(index, index2)" />
</a-col>
</a-row>
</div>
</a-card> </a-card>
</div> </div>
</div> </div>
<a-button type="primary" style="margin-top: 20px;" @click="addSupplier">添加供应商</a-button> <div>
<a-select mode="default" v-model="selectedSuppliers" style="width: 160px;">
<a-select-option v-for="supplier in classSupplier" :key="supplier.id" :value="supplier.id">
{{ supplier.name }}
</a-select-option>
</a-select>
<a-button type="primary" style="margin-top: 20px;margin-left: 20px;" @click="addSupplier()">添加供应商</a-button>
</div>
</a-modal> </a-modal>
</a-card> </a-card>
</template> </template>
@ -92,6 +152,7 @@ export default {
getPurchaseSupplier: "Try/purchaseSupplier/list", getPurchaseSupplier: "Try/purchaseSupplier/list",
getdata: "/Try/purchaseOrderConfirmation/joinList", getdata: "/Try/purchaseOrderConfirmation/joinList",
receiveNOurl: "/Try/purchaseOrderConfirmation/cancelReceiving", receiveNOurl: "/Try/purchaseOrderConfirmation/cancelReceiving",
editUrl: '/Try/purchaseOrderConfirmation/edit'
}, },
activeKey: [], activeKey: [],
username: Vue.ls.get(USER_INFO).username, username: Vue.ls.get(USER_INFO).username,
@ -100,8 +161,13 @@ export default {
tableData: [], tableData: [],
dataShow: false, dataShow: false,
arrange: false, arrange: false,
arrangeData: [],
classifyData: [], classifyData: [],
classSupplier: [],
selectedSuppliers: '',
classFood: [],
selectedFoods: [],
poenNmber: '',
} }
}, },
computed: { computed: {
@ -114,6 +180,9 @@ export default {
receiveNOurl: function () { receiveNOurl: function () {
return `${window._CONFIG['domianURL']}/${this.url.receiveNOurl}`; return `${window._CONFIG['domianURL']}/${this.url.receiveNOurl}`;
}, },
editUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.editUrl}`;
},
}, },
created() { created() {
this.getSupplierData(); this.getSupplierData();
@ -135,15 +204,22 @@ export default {
getAction(this.getdata).then(res => { getAction(this.getdata).then(res => {
//200 //200
if (res.code == 200) { if (res.code == 200) {
this.tableData = res.result; this.tableData = res.result.records;
// //
if (this.tableData.length == 0) { if (this.tableData.length == 0) {
this.dataShow = false; this.dataShow = false;
} else { } else {
this.activeKey = [0]; this.activeKey = [''];
//
this.tableData.forEach(item => { this.tableData.forEach(item => {
item.procurementContent = JSON.parse(item.procurementContent); item.procurementContent = JSON.parse(item.procurementContent);
}); });
//supplierSelection
this.tableData.forEach(item => {
if (item.supplierSelection != null && item.supplierSelection != '') {
item.supplierSelection = JSON.parse(item.supplierSelection);
}
});
this.dataShow = true; this.dataShow = true;
} }
} else { } else {
@ -155,6 +231,7 @@ export default {
//item //item
let newItem = Object.assign({}, item); let newItem = Object.assign({}, item);
newItem.procurementContent = JSON.stringify(newItem.procurementContent); newItem.procurementContent = JSON.stringify(newItem.procurementContent);
newItem.supplierSelection = JSON.stringify(newItem.supplierSelection);
postAction(this.receiveNOurl, newItem).then(res => { postAction(this.receiveNOurl, newItem).then(res => {
//200 //200
if (res.code == 200) { if (res.code == 200) {
@ -197,47 +274,166 @@ export default {
generateOrder(item) { generateOrder(item) {
this.$message.success('生成订单成功'); this.$message.success('生成订单成功');
}, },
arrangeOpen(item) { //
this.classifyData = [];
this.arrangeData = Object.assign({}, item);
this.arrange = true;
},
arrangeOk() { arrangeOk() {
this.classifyData.forEach((item, index) => {
//itemgoods
item.goods.forEach((item2, index2) => {
//
let flag1 = item2.name == null || item2.name == '' || item2.name == undefined;
let flag2 = item2.number == null || item2.number == '' || item2.number == undefined;
let flag3 = item2.unit == null || item2.unit == '' || item2.unit == undefined;
if (flag1 && flag2 && flag3) {
item.goods.splice(index2, 1);
}
});
});
let data = {
associationNumber: this.poenNmber,
supplierSelection: JSON.stringify(this.classifyData),
}
if (data.supplierSelection == '[]') {
data.supplierSelection = '';
}
postAction(this.editUrl, data).then(res => {
if (res.code == 200) {
this.$message.success('整理成功'); this.$message.success('整理成功');
this.arrange = false; this.arrange = false;
this.getTableData();
//
this.classifyData = [];
this.classSupplier = [];
this.classFood = [];
this.selectedSuppliers = '';
this.selectedFoods = [];
this.poenNmber = '';
} else {
this.$message.error(res.message);
}
})
}, },
//
arrangeCancel() { arrangeCancel() {
this.$message.success('整理取消');
this.arrange = false; this.arrange = false;
//
this.classifyData = [];
this.classSupplier = [];
this.classFood = [];
this.selectedSuppliers = '';
this.selectedFoods = [];
this.poenNmber = '';
},
//,
arrangeOpen(item) {
//
this.classifyData = [];
this.classSupplier = [];
this.supplierList.forEach(item => {
this.classSupplier.push({
id: item.id,
name: item.name,
});
});
this.classSupplier = Object.assign([], this.classSupplier);
//
this.classFood = Object.assign([], item.procurementContent);
this.poenNmber = item.requirementNumber;
//supplierSelectionnull
if (item.supplierSelection == null || item.supplierSelection == '') {
this.arrange = true;
}
else {
//
let newData = JSON.parse(JSON.stringify(item.supplierSelection))
//classSupplier
newData.forEach(item => {
this.classSupplier.forEach((item2, index2) => {
if (item2.id == item.supplierID) {
this.classSupplier.splice(index2, 1);
}
});
});
//classifyData
this.classifyData = JSON.parse(JSON.stringify(newData))
this.arrange = true;
}
},
//
delSupplier(item) {
//IDclassifyData
this.classifyData.forEach((item2, index2) => {
if (item2.supplierID == item.supplierID) {
this.classifyData.splice(index2, 1);
}
});
//classSupplier
this.classSupplier.push({
id: item.supplierID,
name: item.supplier,
});
}, },
addSupplier() { addSupplier() {
//classifyData //
if (this.selectedSuppliers == '') {
this.$message.warning('请选择供应商');
return;
}
let selectedID = this.selectedSuppliers;
let selectedSupplier = {};
this.classSupplier.forEach((item, index) => {
if (item.id == selectedID) {
selectedSupplier = Object.assign({}, item);
this.classSupplier.splice(index, 1);
}
});
this.classifyData.push({ this.classifyData.push({
supplier: "哈哈公司", supplierID: selectedSupplier.id,
supplier: selectedSupplier.name,
goods: [{ goods: [{
name: "哈哈", name: '',
number: "1", number: '',
unit: "个", unit: '',
}, {
name: "哈哈",
number: "1",
unit: "个",
} }
], ],
}); });
//
this.selectedSuppliers = '';
},
addRow(item, index) {
this.classifyData[index].goods.push({
name: '',
number: '',
unit: '',
});
},
removeRow(index1, index2) {
this.classifyData[index1].goods.splice(index2, 1);
},
importFoods(index) {
let selectedFoods = this.selectedFoods;
let selectedGoods = [];
this.classFood.forEach(item => {
selectedFoods.forEach(item2 => {
if (item.name == item2) {
selectedGoods.push(item);
} }
});
});
//push
selectedGoods.forEach(item => {
this.classifyData[index].goods.push({
name: item.name,
number: item.number,
unit: item.unit,
});
});
this.selectedFoods = [];
},
}, },
} }
</script> </script>
<style> <style></style>
.card-container {
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
}
/* 其他样式 */
</style>

View File

@ -118,7 +118,7 @@ export default {
if (this.dataList.length == 0) { if (this.dataList.length == 0) {
this.dataShow = false; this.dataShow = false;
} else { } else {
this.activeKey = [0]; this.activeKey = [''];
//procurementContentjson //procurementContentjson
this.dataList.forEach(item => { this.dataList.forEach(item => {
item.procurementContent = JSON.parse(item.procurementContent); item.procurementContent = JSON.parse(item.procurementContent);