|
@@ -36,10 +36,26 @@
|
|
|
:rules="rules"
|
|
|
ref="byform"
|
|
|
>
|
|
|
+ <template #enterpriseSlot>
|
|
|
+ <div style="width: 100%">
|
|
|
+ <el-select
|
|
|
+ filterable
|
|
|
+ allow-create
|
|
|
+ v-model="formData.data.enterpriseId"
|
|
|
+ :disabled="modalType !== 'add'"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in enterpriseData"
|
|
|
+ :label="item.enterpriseName"
|
|
|
+ :value="item.enterpriseId"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
<template #fileSlot>
|
|
|
<div style="width: 100%">
|
|
|
<el-button type="primary" @click="addRow"> 添加 </el-button>
|
|
|
-
|
|
|
<el-form
|
|
|
ref="tableForm"
|
|
|
:model="formData.data"
|
|
@@ -48,28 +64,42 @@
|
|
|
style="margin-top: 15px"
|
|
|
>
|
|
|
<el-table
|
|
|
- :data="formData.data.supplierPriceList"
|
|
|
+ :data="formData.data.contactsList"
|
|
|
v-if="modalType == 'add'"
|
|
|
>
|
|
|
- <el-table-column prop="pricea" label="联系人" min-width="150">
|
|
|
+ <el-table-column
|
|
|
+ prop="contactName"
|
|
|
+ label="联系人"
|
|
|
+ min-width="150"
|
|
|
+ >
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item
|
|
|
- :prop="'supplierPriceList.' + $index + '.pricea'"
|
|
|
- :rules="rules.pricea"
|
|
|
+ :prop="'contactsList.' + $index + '.contactName'"
|
|
|
+ :rules="rules.contactName"
|
|
|
:inline-message="true"
|
|
|
>
|
|
|
- <el-input v-model="row.pricea" placeholder="请输入" />
|
|
|
+ <el-input
|
|
|
+ v-model="row.contactName"
|
|
|
+ placeholder="请输入"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="price" label="手机号" min-width="150">
|
|
|
+ <el-table-column
|
|
|
+ prop="phoneNumber"
|
|
|
+ label="手机号"
|
|
|
+ min-width="150"
|
|
|
+ >
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item
|
|
|
- :prop="'supplierPriceList.' + $index + '.price'"
|
|
|
- :rules="rules.price"
|
|
|
+ :prop="'contactsList.' + $index + '.phoneNumber'"
|
|
|
+ :rules="rules.phoneNumber"
|
|
|
:inline-message="true"
|
|
|
>
|
|
|
- <el-input v-model="row.price" placeholder="请输入" />
|
|
|
+ <el-input
|
|
|
+ v-model="row.phoneNumber"
|
|
|
+ placeholder="请输入"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -84,28 +114,44 @@
|
|
|
</el-table>
|
|
|
|
|
|
<el-table
|
|
|
- :data="formData.data.supplierPriceList"
|
|
|
+ :data="formData.data.externalAddressBookList"
|
|
|
v-if="modalType == 'edit'"
|
|
|
>
|
|
|
- <el-table-column prop="pricea" label="类型" min-width="150">
|
|
|
+ <el-table-column prop="type" label="类型" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item
|
|
|
- :prop="'supplierPriceList.' + $index + '.pricea'"
|
|
|
- :rules="rules.pricea"
|
|
|
+ :prop="'internalAddressBookList.' + $index + '.type'"
|
|
|
:inline-message="true"
|
|
|
>
|
|
|
- <el-input v-model="row.pricea" placeholder="请输入" />
|
|
|
+ <!-- :rules="rules.type" -->
|
|
|
+ <el-select v-model="row.type" placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="item in contactInformationType"
|
|
|
+ :label="item.dictValue"
|
|
|
+ :value="item.dictKey"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="price" label="联系号码" min-width="150">
|
|
|
+ <el-table-column
|
|
|
+ prop="contactNumber"
|
|
|
+ label="联系号码"
|
|
|
+ min-width="150"
|
|
|
+ >
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item
|
|
|
- :prop="'supplierPriceList.' + $index + '.price'"
|
|
|
- :rules="rules.price"
|
|
|
+ :prop="
|
|
|
+ 'internalAddressBookList.' + $index + '.contactNumber'
|
|
|
+ "
|
|
|
:inline-message="true"
|
|
|
>
|
|
|
- <el-input v-model="row.price" placeholder="请输入" />
|
|
|
+ <!-- :rules="rules.contactNumber" -->
|
|
|
+ <el-input
|
|
|
+ v-model="row.contactNumber"
|
|
|
+ placeholder="请输入"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -145,6 +191,7 @@ import byForm from "@/components/byForm/index";
|
|
|
import FileUpload from "@/components/FileUpload/index";
|
|
|
import { computed, defineComponent, ref } from "vue";
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
+import useUserStore from "@/store/modules/user";
|
|
|
|
|
|
const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传文件服务器地址
|
|
|
const headers = ref({ Authorization: "Bearer " + getToken() });
|
|
@@ -157,7 +204,6 @@ const sourceList = ref({
|
|
|
total: 3,
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
- type: "",
|
|
|
keyword: "",
|
|
|
},
|
|
|
});
|
|
@@ -165,8 +211,15 @@ let dialogVisible = ref(false);
|
|
|
let modalType = ref("add");
|
|
|
let fileList = ref([]);
|
|
|
let rules = ref({
|
|
|
- pricea: [{ required: true, message: "请输入联系人", trigger: "blur" }],
|
|
|
- price: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
|
|
|
+ enterpriseId: [
|
|
|
+ { required: true, message: "请选择/输入企业", trigger: ["change", "blur"] },
|
|
|
+ ],
|
|
|
+ contactName: [{ required: true, message: "请输入联系人", trigger: "blur" }],
|
|
|
+ phoneNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
|
|
|
+ type: [{ required: true, message: "请选择联系类型", trigger: "change" }],
|
|
|
+ contactNumber: [
|
|
|
+ { required: true, message: "请输入联系号码", trigger: "blur" },
|
|
|
+ ],
|
|
|
});
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
const selectConfig = reactive([
|
|
@@ -194,14 +247,14 @@ const config = computed(() => {
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "来源",
|
|
|
- prop: "type",
|
|
|
+ prop: "enterpriseType",
|
|
|
},
|
|
|
- render(type) {
|
|
|
- return type === 1
|
|
|
+ render(enterpriseType) {
|
|
|
+ return enterpriseType === 1
|
|
|
? "客户"
|
|
|
- : type === 2
|
|
|
+ : enterpriseType === 2
|
|
|
? "供应商"
|
|
|
- : type === 3
|
|
|
+ : enterpriseType === 3
|
|
|
? "自定义"
|
|
|
: "";
|
|
|
},
|
|
@@ -209,37 +262,37 @@ const config = computed(() => {
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "关联企业",
|
|
|
- prop: "code",
|
|
|
+ prop: "enterpriseName",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "联系人",
|
|
|
- prop: "name",
|
|
|
+ prop: "contactName",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "手机号",
|
|
|
- prop: "remarks",
|
|
|
+ prop: "phoneNumber",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "电子邮箱",
|
|
|
- prop: "contactPerson",
|
|
|
+ prop: "createTime",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "座机",
|
|
|
- prop: "contactNumber",
|
|
|
+ prop: "createTime",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "WhatsApp",
|
|
|
- prop: "remark",
|
|
|
+ prop: "createTime",
|
|
|
},
|
|
|
},
|
|
|
|
|
@@ -283,7 +336,7 @@ const config = computed(() => {
|
|
|
).then(() => {
|
|
|
// 删除
|
|
|
proxy
|
|
|
- .post("/supplierInfo/delete", {
|
|
|
+ .post("/contacts/delete", {
|
|
|
id: row.id,
|
|
|
})
|
|
|
.then((res) => {
|
|
@@ -319,64 +372,113 @@ const formConfig = ref([]);
|
|
|
const getList = async (req) => {
|
|
|
sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
|
|
|
loading.value = true;
|
|
|
- proxy
|
|
|
- .post("/supplierInfo/page", sourceList.value.pagination)
|
|
|
- .then((message) => {
|
|
|
- console.log(message);
|
|
|
- sourceList.value.data = message.rows;
|
|
|
- sourceList.value.pagination.total = message.total;
|
|
|
- setTimeout(() => {
|
|
|
- loading.value = false;
|
|
|
- }, 200);
|
|
|
- });
|
|
|
+ proxy.post("/contacts/page", sourceList.value.pagination).then((message) => {
|
|
|
+ console.log(message);
|
|
|
+ sourceList.value.data = message.rows;
|
|
|
+ sourceList.value.pagination.total = message.total;
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.value = false;
|
|
|
+ }, 200);
|
|
|
+ });
|
|
|
};
|
|
|
const openModal = () => {
|
|
|
dialogVisible.value = true;
|
|
|
formConfig.value = configData[0];
|
|
|
modalType.value = "add";
|
|
|
formData.data = {
|
|
|
- supplierPriceList: [],
|
|
|
+ contactsList: [],
|
|
|
};
|
|
|
};
|
|
|
|
|
|
const submitForm = () => {
|
|
|
byform.value.handleSubmit((valid) => {
|
|
|
- // if (fileList.value.length > 0) {
|
|
|
- // formData.data.fileList = fileList.value;
|
|
|
-
|
|
|
- // } else {
|
|
|
- // return ElMessage({
|
|
|
- // message: "请上传附件!",
|
|
|
- // type: "info",
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
- submitLoading.value = true;
|
|
|
- proxy.post("/supplierInfo/" + modalType.value, formData.data).then(
|
|
|
- (res) => {
|
|
|
- ElMessage({
|
|
|
- message: modalType.value == "add" ? "添加成功" : "编辑成功",
|
|
|
- type: "success",
|
|
|
+ if (modalType.value === "add") {
|
|
|
+ if (formData.data.contactsList.length > 0) {
|
|
|
+ proxy.$refs.tableForm.validate((vaild) => {
|
|
|
+ if (vaild) {
|
|
|
+ const current = enterpriseData.value.find(
|
|
|
+ (x) => x.enterpriseId === formData.data.enterpriseId
|
|
|
+ );
|
|
|
+ if (current && current !== undefined) {
|
|
|
+ formData.data.enterpriseType = current.enterpriseType;
|
|
|
+ } else {
|
|
|
+ formData.data.enterpriseType = 3;
|
|
|
+ formData.data.enterpriseName = formData.data.enterpriseId;
|
|
|
+ formData.data.enterpriseId = "";
|
|
|
+ }
|
|
|
+ submitLoading.value = true;
|
|
|
+ proxy.post("/contacts/" + modalType.value, formData.data).then(
|
|
|
+ (res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: modalType.value == "add" ? "添加成功" : "编辑成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ dialogVisible.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ getList();
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ submitLoading.value = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return ElMessage({
|
|
|
+ message: "请添加联系人!",
|
|
|
+ type: "info",
|
|
|
});
|
|
|
- fileList.value = [];
|
|
|
- dialogVisible.value = false;
|
|
|
- submitLoading.value = false;
|
|
|
- getList();
|
|
|
- },
|
|
|
- (err) => {
|
|
|
- console.log(err, "aswwwww");
|
|
|
- submitLoading.value = false;
|
|
|
}
|
|
|
- );
|
|
|
+ } else {
|
|
|
+ if (formData.data.externalAddressBookList.length > 0) {
|
|
|
+ console.log(formData.data, "aww");
|
|
|
+ proxy.$refs.tableForm.validate((vaild) => {
|
|
|
+ if (vaild) {
|
|
|
+ submitLoading.value = true;
|
|
|
+ proxy.post("/contacts/" + modalType.value, formData.data).then(
|
|
|
+ (res) => {
|
|
|
+ const submitData = {
|
|
|
+ externalAddressBookList:
|
|
|
+ formData.data.externalAddressBookList.map((x) => ({
|
|
|
+ ...x,
|
|
|
+ id: formData.data.id,
|
|
|
+ })),
|
|
|
+ };
|
|
|
+ proxy
|
|
|
+ .post("/contacts/" + modalType.value, submitData)
|
|
|
+ .then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: "编辑成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ dialogVisible.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ submitLoading.value = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return ElMessage({
|
|
|
+ message: "请添加联系方式!",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
const configData = [
|
|
|
[
|
|
|
{
|
|
|
- type: "input",
|
|
|
- prop: "type",
|
|
|
+ type: "slot",
|
|
|
+ slotName: "enterpriseSlot",
|
|
|
+ prop: "enterpriseId",
|
|
|
label: "关联企业",
|
|
|
- required: true,
|
|
|
},
|
|
|
{
|
|
|
type: "slot",
|
|
@@ -386,14 +488,13 @@ const configData = [
|
|
|
],
|
|
|
[
|
|
|
{
|
|
|
- type: "input",
|
|
|
- prop: "type",
|
|
|
+ type: "slot",
|
|
|
+ slotName: "enterpriseSlot",
|
|
|
+ prop: "enterpriseId",
|
|
|
label: "关联企业",
|
|
|
- required: true,
|
|
|
- disabled: true,
|
|
|
},
|
|
|
{
|
|
|
- prop: "name",
|
|
|
+ prop: "contactName",
|
|
|
type: "input",
|
|
|
label: "联系人",
|
|
|
},
|
|
@@ -404,36 +505,65 @@ const configData = [
|
|
|
},
|
|
|
],
|
|
|
];
|
|
|
+
|
|
|
+const enterpriseData = ref([]);
|
|
|
+
|
|
|
+const contactInformationType = ref([]);
|
|
|
+const getDict = () => {
|
|
|
+ const tenantId = useUserStore().user.tenantId;
|
|
|
+ proxy
|
|
|
+ .post("/dictTenantData/page", {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 999,
|
|
|
+ tenantId: "@福建宏星!#¥%……&*()",
|
|
|
+ dictCode: "contact_information",
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ contactInformationType.value = res.rows;
|
|
|
+ });
|
|
|
+
|
|
|
+ proxy.post("/contacts/list", { pageNum: 1, pageSize: 9999 }).then((res) => {
|
|
|
+ enterpriseData.value = res;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
const getDtl = (row) => {
|
|
|
modalType.value = "edit";
|
|
|
formConfig.value = configData[1];
|
|
|
dialogVisible.value = true;
|
|
|
-
|
|
|
- // proxy.post("/supplierInfo/detail", { id: row.id }).then((res) => {
|
|
|
- // getCityData(res.countryId, "20");
|
|
|
- // getCityData(res.provinceId, "30");
|
|
|
- // // fileList.value = [
|
|
|
- // // {
|
|
|
- // // id: "",
|
|
|
- // // fileName: res.fileName,
|
|
|
- // // path: "",
|
|
|
- // // },
|
|
|
- // // ];
|
|
|
- // res.type = res.type + "";
|
|
|
- // formData.data = res;
|
|
|
- // dialogVisible.value = true;
|
|
|
- // });
|
|
|
+ proxy.post("/contacts/detail", { id: row.id }).then((res) => {
|
|
|
+ res.externalAddressBookList = [];
|
|
|
+ formData.data = res;
|
|
|
+ proxy.post("/externalAddressBook/detail", { id: row.id }).then((res) => {
|
|
|
+ console.log(res, "ass");
|
|
|
+ });
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
-const handleRemove = (file) => {};
|
|
|
+const handleRemove = (index) => {
|
|
|
+ if (modalType.value === "add") {
|
|
|
+ formData.data.contactsList.splice(index, 1);
|
|
|
+ } else {
|
|
|
+ formData.data.externalAddressBookList.splice(index, 1);
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
getList();
|
|
|
+getDict();
|
|
|
|
|
|
const addRow = () => {
|
|
|
- formData.data.supplierPriceList.push({
|
|
|
- price: "",
|
|
|
- pricea: "",
|
|
|
- });
|
|
|
+ if (modalType.value === "add") {
|
|
|
+ formData.data.contactsList.push({
|
|
|
+ contactName: "",
|
|
|
+ phoneNumber: "",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ formData.data.externalAddressBookList.push({
|
|
|
+ id: "",
|
|
|
+ type: "",
|
|
|
+ contactNumber: "",
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|
|
|
|