|
@@ -26,29 +26,26 @@
|
|
|
<el-button type="primary" @click="openProduct = true" v-if="modalType == 'add'" style="margin-bottom: 15px">
|
|
|
选择
|
|
|
</el-button>
|
|
|
+ <el-table :data="formData.data.supplierPriceList">
|
|
|
+ <el-table-column prop="customCode" label="物料编码" width="160" />
|
|
|
+ <el-table-column prop="name" label="物料名称" min-width="150" />
|
|
|
+ <!-- <el-table-column prop="spec" label="规格型号" /> -->
|
|
|
+ <el-table-column prop="unit" label="单位" :formatter="(row) => dictKeyValue(row.unit, materialUnit)" width="80" />
|
|
|
+ <el-table-column prop="price" label="供应单价" width="140">
|
|
|
+ <template #default="{ row, $index }">
|
|
|
+ <el-form-item label-width="0px" label="" :prop="'supplierPriceList.' + $index + '.price'" :rules="rules.price"
|
|
|
+ :inline-message="true" class="margin-b-0 wid100">
|
|
|
+ <el-input-number v-model="row.price" :precision="2" :controls="false" :min="0.01" onmousewheel="return false;" />
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
|
|
|
- <el-form ref="tableForm" :model="formData.data" :rules="rules" label-width="0px">
|
|
|
- <el-table :data="formData.data.supplierPriceList">
|
|
|
- <el-table-column prop="customCode" label="物料编码" width="160" />
|
|
|
- <el-table-column prop="name" label="物料名称" min-width="150" />
|
|
|
- <!-- <el-table-column prop="spec" label="规格型号" /> -->
|
|
|
- <el-table-column prop="unit" label="单位" :formatter="(row) => dictKeyValue(row.unit, materialUnit)" width="80" />
|
|
|
- <el-table-column prop="price" label="供应单价" width="140">
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <el-form-item :prop="'supplierPriceList.' + $index + '.price'" :rules="rules.price" :inline-message="true"
|
|
|
- class="margin-b-0 wid100">
|
|
|
- <el-input-number v-model="row.price" :precision="2" :controls="false" :min="1" onmousewheel="return false;" />
|
|
|
- </el-form-item>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
-
|
|
|
- <el-table-column prop="zip" label="操作" width="60" v-if="modalType == 'add'">
|
|
|
- <template #default="{ $index }">
|
|
|
- <el-button type="primary" link @click="handleRemove($index)" :disabled="modalType == 'edit'">删除</el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- </el-form>
|
|
|
+ <el-table-column prop="zip" label="操作" width="60" v-if="modalType == 'add'">
|
|
|
+ <template #default="{ $index }">
|
|
|
+ <el-button type="primary" link @click="handleRemove($index)" :disabled="modalType == 'edit'">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</div>
|
|
|
</template>
|
|
|
</byForm>
|
|
@@ -85,6 +82,7 @@ const materialUnit = computed(
|
|
|
const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传文件服务器地址
|
|
|
const headers = ref({ Authorization: "Bearer " + getToken() });
|
|
|
const uploadData = ref({});
|
|
|
+const supplierData = ref([]);
|
|
|
const loading = ref(false);
|
|
|
const submitLoading = ref(false);
|
|
|
const sourceList = ref({
|
|
@@ -145,7 +143,7 @@ const config = computed(() => {
|
|
|
attrs: {
|
|
|
label: "所属分类",
|
|
|
prop: "productClassifyName",
|
|
|
- width: 150,
|
|
|
+ width: 200,
|
|
|
},
|
|
|
},
|
|
|
{
|
|
@@ -261,7 +259,7 @@ const config = computed(() => {
|
|
|
];
|
|
|
});
|
|
|
|
|
|
-let formData = reactive({
|
|
|
+const formData = reactive({
|
|
|
data: {
|
|
|
supplierPriceList: [],
|
|
|
},
|
|
@@ -272,25 +270,14 @@ const formOption = reactive({
|
|
|
itemWidth: 100,
|
|
|
});
|
|
|
const byform = ref(null);
|
|
|
-const formConfig = reactive([
|
|
|
+const formConfig = computed(() => [
|
|
|
{
|
|
|
type: "select",
|
|
|
prop: "supplierInfoId",
|
|
|
label: "供应商",
|
|
|
- required: true,
|
|
|
- disabled: false,
|
|
|
+ disabled: modalType.value == "edit",
|
|
|
filterable: true,
|
|
|
- isLoad: {
|
|
|
- url: "/supplierInfo/page",
|
|
|
- req: {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 9999,
|
|
|
- },
|
|
|
- labelKey: "name",
|
|
|
- labelVal: "id",
|
|
|
- method: "post",
|
|
|
- resUrl: "rows",
|
|
|
- },
|
|
|
+ data: supplierData.value,
|
|
|
},
|
|
|
{
|
|
|
type: "slot",
|
|
@@ -298,6 +285,43 @@ const formConfig = reactive([
|
|
|
prop: "supplierPriceList",
|
|
|
label: "供应明细",
|
|
|
required: true,
|
|
|
+ isShow: modalType.value == "add",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ prop: "code",
|
|
|
+ label: "产品编码",
|
|
|
+ disabled: true,
|
|
|
+ isShow: modalType.value == "edit",
|
|
|
+ itemWidth: 50,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ prop: "name",
|
|
|
+ label: "产品名称",
|
|
|
+ disabled: true,
|
|
|
+ isShow: modalType.value == "edit",
|
|
|
+ itemWidth: 50,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "select",
|
|
|
+ prop: "unit",
|
|
|
+ label: "单位",
|
|
|
+ disabled: true,
|
|
|
+ filterable: true,
|
|
|
+ data: materialUnit.value,
|
|
|
+ isShow: modalType.value == "edit",
|
|
|
+ itemWidth: 50,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "number",
|
|
|
+ prop: "price",
|
|
|
+ label: "单价",
|
|
|
+ precision: 2,
|
|
|
+ min: 0.01,
|
|
|
+ controls: false,
|
|
|
+ itemWidth: 50,
|
|
|
+ isShow: modalType.value == "edit",
|
|
|
},
|
|
|
]);
|
|
|
const getList = (req) => {
|
|
@@ -314,7 +338,6 @@ const getList = (req) => {
|
|
|
const openModal = () => {
|
|
|
dialogVisible.value = true;
|
|
|
modalType.value = "add";
|
|
|
- formConfig[0].disabled = false;
|
|
|
formData.data = {
|
|
|
supplierPriceList: [],
|
|
|
renewWhileItExists: false,
|
|
@@ -324,90 +347,86 @@ const openModal = () => {
|
|
|
const submitForm = () => {
|
|
|
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(() => {
|
|
|
- submitData.renewWhileItExists = true;
|
|
|
- proxy
|
|
|
- .post("/supplierPrice/" + modalType.value, submitData)
|
|
|
- .then((res) => {
|
|
|
- if (res.addSuccess) {
|
|
|
- ElMessage({
|
|
|
- message: "修改成功",
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- getList();
|
|
|
- dialogVisible.value = false;
|
|
|
- submitLoading.value = false;
|
|
|
- }
|
|
|
+ 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(() => {
|
|
|
+ submitData.renewWhileItExists = true;
|
|
|
+ proxy
|
|
|
+ .post("/supplierPrice/" + modalType.value, submitData)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.addSuccess) {
|
|
|
+ ElMessage({
|
|
|
+ message: "修改成功",
|
|
|
+ type: "success",
|
|
|
});
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- submitLoading.value = false;
|
|
|
+ getList();
|
|
|
+ dialogVisible.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ }
|
|
|
});
|
|
|
- }
|
|
|
- },
|
|
|
- (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",
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ submitLoading.value = false;
|
|
|
});
|
|
|
- getList();
|
|
|
- dialogVisible.value = false;
|
|
|
- submitLoading.value = false;
|
|
|
- },
|
|
|
- (err) => {
|
|
|
- submitLoading.value = false;
|
|
|
- }
|
|
|
- );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (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;
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ submitLoading.value = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
} else {
|
|
|
return ElMessage({
|
|
|
message: "请添加供应明细!",
|
|
@@ -419,7 +438,6 @@ const submitForm = () => {
|
|
|
|
|
|
const getDtl = (row) => {
|
|
|
modalType.value = "edit";
|
|
|
- formConfig[0].disabled = true;
|
|
|
dialogVisible.value = true;
|
|
|
formData.data = {
|
|
|
id: row.id,
|
|
@@ -431,10 +449,14 @@ const getDtl = (row) => {
|
|
|
name: row.productName,
|
|
|
code: row.productCode,
|
|
|
unit: row.productUnit,
|
|
|
- spec: row.productSpec,
|
|
|
price: row.price,
|
|
|
},
|
|
|
],
|
|
|
+ productInfoId: row.productInfoId,
|
|
|
+ name: row.productName,
|
|
|
+ code: row.productCode,
|
|
|
+ unit: row.productUnit,
|
|
|
+ price: row.price,
|
|
|
};
|
|
|
};
|
|
|
|
|
@@ -512,6 +534,18 @@ const pushGoods = (goods) => {
|
|
|
};
|
|
|
|
|
|
getList();
|
|
|
+
|
|
|
+const getDict = () => {
|
|
|
+ proxy
|
|
|
+ .post("/supplierInfo/page", {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 9999,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ supplierData.value = res.rows;
|
|
|
+ });
|
|
|
+};
|
|
|
+getDict();
|
|
|
const acquireSelectList = () => {
|
|
|
let data = [];
|
|
|
if (
|