|
@@ -45,7 +45,7 @@
|
|
|
ref="byform"
|
|
|
>
|
|
|
<template #details>
|
|
|
- <div>
|
|
|
+ <div style="width: 100%">
|
|
|
<el-button type="primary" @click="openProduct = true">
|
|
|
添加货品
|
|
|
</el-button>
|
|
@@ -57,21 +57,21 @@
|
|
|
label-width="0px"
|
|
|
style="margin-top: 15px"
|
|
|
>
|
|
|
- <el-table :data="formData.data.goodsList">
|
|
|
- <el-table-column prop="productCode" label="货品编码" />
|
|
|
- <el-table-column prop="productName" label="货品名称" />
|
|
|
- <el-table-column prop="productName" label="规格型号" />
|
|
|
- <el-table-column prop="productUnit" label="单位" />
|
|
|
- <el-table-column prop="quantity" label="供应单价" width="150">
|
|
|
+ <el-table :data="formData.data.supplierPriceList">
|
|
|
+ <el-table-column prop="code" label="货品编码" />
|
|
|
+ <el-table-column prop="name" label="货品名称" min-width="150" />
|
|
|
+ <el-table-column prop="spec" label="规格型号" />
|
|
|
+ <el-table-column prop="unit" label="单位" />
|
|
|
+ <el-table-column prop="price" label="供应单价" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item
|
|
|
- :prop="'goodsList.' + $index + '.quantity'"
|
|
|
- :rules="rules.quantity"
|
|
|
+ :prop="'supplierPriceList.' + $index + '.price'"
|
|
|
+ :rules="rules.price"
|
|
|
:inline-message="true"
|
|
|
>
|
|
|
<el-input-number
|
|
|
- v-model="row.quantity"
|
|
|
- :precision="2"
|
|
|
+ v-model="row.price"
|
|
|
+ :precision="4"
|
|
|
:controls="false"
|
|
|
:min="1"
|
|
|
/>
|
|
@@ -147,7 +147,10 @@ let openProduct = ref(false);
|
|
|
let modalType = ref("add");
|
|
|
let fileList = ref([]);
|
|
|
let rules = ref({
|
|
|
- name: [{ required: true, message: "请输入供应价格名称", trigger: "blur" }],
|
|
|
+ supplierInfoId: [
|
|
|
+ { required: true, message: "请选择供应商", trigger: "change" },
|
|
|
+ ],
|
|
|
+ price: [{ required: true, message: "请输入供应单价", trigger: "blur" }],
|
|
|
});
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
const selectConfig = reactive([
|
|
@@ -170,38 +173,62 @@ const config = computed(() => {
|
|
|
return [
|
|
|
{
|
|
|
attrs: {
|
|
|
- label: "供应价格类型",
|
|
|
- prop: "name",
|
|
|
+ label: "货品类型",
|
|
|
+ prop: "definition",
|
|
|
+ },
|
|
|
+ render(definition) {
|
|
|
+ return definition === 1 ? "产品" : definition === 2 ? "物料" : "";
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "所属分类",
|
|
|
+ prop: "productClassifyName",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "货品编码",
|
|
|
+ prop: "productCode",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "货品名称",
|
|
|
+ prop: "productName",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
- label: "供应价格编码",
|
|
|
- prop: "remarks",
|
|
|
+ label: "规格型号",
|
|
|
+ prop: "productSpec",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
- label: "供应价格名称",
|
|
|
- prop: "remarks",
|
|
|
+ label: "单位",
|
|
|
+ prop: "productUnit",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
- label: "所在城市",
|
|
|
- prop: "remarks",
|
|
|
+ label: "供应商类型",
|
|
|
+ prop: "supplierType",
|
|
|
+ },
|
|
|
+ render(supplierType) {
|
|
|
+ return supplierType === 1 ? "贸易商" : supplierType === 2 ? "工厂" : "";
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
- label: "联系人",
|
|
|
- prop: "remarks",
|
|
|
+ label: "供应商名称",
|
|
|
+ prop: "supplierName",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
- label: "联系人电话",
|
|
|
- prop: "remarks",
|
|
|
+ label: "供应单价",
|
|
|
+ prop: "price",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
@@ -244,7 +271,7 @@ const config = computed(() => {
|
|
|
).then(() => {
|
|
|
// 删除
|
|
|
proxy
|
|
|
- .post("/productionProcesses/delete", {
|
|
|
+ .post("/supplierPrice/delete", {
|
|
|
id: row.id,
|
|
|
})
|
|
|
.then((res) => {
|
|
@@ -265,7 +292,7 @@ const config = computed(() => {
|
|
|
|
|
|
let formData = reactive({
|
|
|
data: {
|
|
|
- goodsList: [],
|
|
|
+ supplierPriceList: [],
|
|
|
},
|
|
|
});
|
|
|
const formOption = reactive({
|
|
@@ -275,38 +302,38 @@ const formOption = reactive({
|
|
|
rules: [],
|
|
|
});
|
|
|
const byform = ref(null);
|
|
|
-const formConfig = computed(() => {
|
|
|
- return [
|
|
|
- // {
|
|
|
- // type: "radio",
|
|
|
- // prop: "name",
|
|
|
- // label: "供应价格类型",
|
|
|
- // required: true,
|
|
|
- // border: true,
|
|
|
- // data: [
|
|
|
- // { label: "贸易商", value: "1" },
|
|
|
- // { label: "工厂", value: "2" },
|
|
|
- // ],
|
|
|
- // },
|
|
|
- {
|
|
|
- type: "select",
|
|
|
- prop: "name",
|
|
|
- label: "供应商",
|
|
|
- required: true,
|
|
|
- },
|
|
|
- {
|
|
|
- type: "slot",
|
|
|
- slotName: "details",
|
|
|
- label: "供应明细",
|
|
|
- required: true,
|
|
|
+const formConfig = reactive([
|
|
|
+ {
|
|
|
+ type: "select",
|
|
|
+ prop: "supplierInfoId",
|
|
|
+ label: "供应商",
|
|
|
+ required: true,
|
|
|
+ disabled: false,
|
|
|
+ isLoad: {
|
|
|
+ url: "/supplierInfo/page",
|
|
|
+ req: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 9999,
|
|
|
+ },
|
|
|
+ labelKey: "name",
|
|
|
+ labelVal: "id",
|
|
|
+ method: "post",
|
|
|
+ resUrl: "rows",
|
|
|
},
|
|
|
- ];
|
|
|
-});
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "slot",
|
|
|
+ slotName: "details",
|
|
|
+ prop: "supplierPriceList",
|
|
|
+ label: "供应明细",
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+]);
|
|
|
const getList = async (req) => {
|
|
|
sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
|
|
|
loading.value = true;
|
|
|
proxy
|
|
|
- .post("/productionProcesses/page", sourceList.value.pagination)
|
|
|
+ .post("/supplierPrice/page", sourceList.value.pagination)
|
|
|
.then((message) => {
|
|
|
console.log(message);
|
|
|
sourceList.value.data = message.rows;
|
|
@@ -319,53 +346,149 @@ const getList = async (req) => {
|
|
|
const openModal = () => {
|
|
|
dialogVisible.value = true;
|
|
|
modalType.value = "add";
|
|
|
+ formConfig[0].disabled = false;
|
|
|
formData.data = {
|
|
|
- goodsList: [],
|
|
|
+ supplierPriceList: [],
|
|
|
+ renewWhileItExists: false,
|
|
|
};
|
|
|
};
|
|
|
|
|
|
const submitForm = () => {
|
|
|
- if (formData.data.goodsList.length > 0) {
|
|
|
- byform.value.handleSubmit((valid) => {
|
|
|
- submitLoading.value = true;
|
|
|
- proxy.post("/productionProcesses/" + modalType.value, formData.data).then(
|
|
|
- (res) => {
|
|
|
- ElMessage({
|
|
|
- message: modalType.value == "add" ? "添加成功" : "编辑成功",
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- fileList.value = [];
|
|
|
- dialogVisible.value = false;
|
|
|
- submitLoading.value = false;
|
|
|
- getList();
|
|
|
- },
|
|
|
- (err) => {
|
|
|
- console.log(err, "aswwwww");
|
|
|
- submitLoading.value = false;
|
|
|
+ byform.value.handleSubmit((valid) => {
|
|
|
+ if (formData.data.supplierPriceList.length > 0) {
|
|
|
+ proxy.$refs.tableForm.validate((vaild) => {
|
|
|
+ if (vaild) {
|
|
|
+ if (!formData.data.id) {
|
|
|
+ const submitData = {
|
|
|
+ ...formData.data,
|
|
|
+ supplierPriceList: formData.data.supplierPriceList.map((x) => ({
|
|
|
+ productInfoId: x.productInfoId,
|
|
|
+ price: x.price,
|
|
|
+ })),
|
|
|
+ };
|
|
|
+ submitLoading.value = true;
|
|
|
+ proxy.post("/supplierPrice/" + modalType.value, submitData).then(
|
|
|
+ (res) => {
|
|
|
+ if (res.addSuccess) {
|
|
|
+ ElMessage({
|
|
|
+ message: modalType.value == "add" ? "添加成功" : "编辑成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ getList();
|
|
|
+ dialogVisible.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ } else {
|
|
|
+ ElMessage({
|
|
|
+ message: `已存在供应价格,价格为${res.existSupplierPriceList[0].price}`,
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ "继续提交将修改已存在的单价数据, 是否继续?",
|
|
|
+ "提示",
|
|
|
+ {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ const arr = [];
|
|
|
+ for (
|
|
|
+ let i = 0;
|
|
|
+ i < formData.data.supplierPriceList.length;
|
|
|
+ i++
|
|
|
+ ) {
|
|
|
+ const iele = formData.data.supplierPriceList[i];
|
|
|
+ for (
|
|
|
+ let j = 0;
|
|
|
+ j < res.existSupplierPriceList.length;
|
|
|
+ j++
|
|
|
+ ) {
|
|
|
+ const jele = res.existSupplierPriceList[j];
|
|
|
+ if (iele.productInfoId === jele.productInfoId) {
|
|
|
+ jele.price = iele.price;
|
|
|
+ arr.push(jele);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ formData.data.supplierPriceList = arr.map((x) => ({
|
|
|
+ productInfoId: x.productInfoId,
|
|
|
+ price: x.price,
|
|
|
+ }));
|
|
|
+ formData.data.renewWhileItExists = true;
|
|
|
+ proxy
|
|
|
+ .post(
|
|
|
+ "/supplierPrice/" + modalType.value,
|
|
|
+ formData.data
|
|
|
+ )
|
|
|
+ .then((res) => {
|
|
|
+ if (res.addSuccess) {
|
|
|
+ ElMessage({
|
|
|
+ message: "修改成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ getList();
|
|
|
+ dialogVisible.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ submitLoading.value = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ formData.data.supplierInfoId = formData.data.supplierInfoIdCopy;
|
|
|
+ formData.data.productInfoId =
|
|
|
+ formData.data.supplierPriceList[0].productInfoId;
|
|
|
+ formData.data.price = formData.data.supplierPriceList[0].price;
|
|
|
+ delete formData.data.supplierPriceList;
|
|
|
+ delete formData.data.supplierInfoIdCopy;
|
|
|
+ proxy
|
|
|
+ .post("/supplierPrice/" + modalType.value, formData.data)
|
|
|
+ .then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: "修改成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ getList();
|
|
|
+ dialogVisible.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- );
|
|
|
- });
|
|
|
- } else {
|
|
|
- return ElMessage({
|
|
|
- message: "请添加供应明细!",
|
|
|
- type: "info",
|
|
|
- });
|
|
|
- }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return ElMessage({
|
|
|
+ message: "请添加供应明细!",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
const getDtl = (row) => {
|
|
|
modalType.value = "edit";
|
|
|
- proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
|
|
|
- fileList.value = [
|
|
|
+ formConfig[0].disabled = true;
|
|
|
+ dialogVisible.value = true;
|
|
|
+ formData.data = {
|
|
|
+ id: row.id,
|
|
|
+ supplierInfoIdCopy: row.supplierInfoId,
|
|
|
+ supplierInfoId: row.supplierName,
|
|
|
+ supplierPriceList: [
|
|
|
{
|
|
|
- id: "",
|
|
|
- fileName: res.fileName,
|
|
|
- path: "",
|
|
|
+ productInfoId: row.productInfoId,
|
|
|
+ name: row.productName,
|
|
|
+ code: row.productCode,
|
|
|
+ unit: row.productUnit,
|
|
|
+ spec: row.productSpec,
|
|
|
+ price: row.price,
|
|
|
},
|
|
|
- ];
|
|
|
- formData.data = res;
|
|
|
- dialogVisible.value = true;
|
|
|
- });
|
|
|
+ ],
|
|
|
+ };
|
|
|
};
|
|
|
|
|
|
// const handleClickFile = (row) => {
|
|
@@ -381,7 +504,7 @@ const getDtl = (row) => {
|
|
|
// };
|
|
|
|
|
|
const handleRemove = (index) => {
|
|
|
- formData.data.goodsList.splice(index, 1);
|
|
|
+ formData.data.supplierPriceList.splice(index, 1);
|
|
|
return ElMessage({
|
|
|
message: "删除成功!",
|
|
|
type: "success",
|
|
@@ -389,12 +512,14 @@ const handleRemove = (index) => {
|
|
|
};
|
|
|
|
|
|
const pushGoods = (goods) => {
|
|
|
- formData.data.goodsList = formData.data.goodsList.concat(goods);
|
|
|
+ const arr = goods.map((x) => ({ ...x, productInfoId: x.id, price: "" }));
|
|
|
+ formData.data.supplierPriceList = formData.data.supplierPriceList.concat(arr);
|
|
|
return ElMessage({
|
|
|
message: "添加成功!",
|
|
|
type: "success",
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
getList();
|
|
|
</script>
|
|
|
|