BUG 优化

dev
xiepeng 2024-04-16 09:47:06 +08:00
parent f4518ef360
commit 7b37c0fcf1
2 changed files with 8 additions and 15 deletions

View File

@ -18,3 +18,6 @@ export const getTrafficCustomerSelectView = (params) =>
export const editSafetyCustomerInfo = (params) =>
upload("/securitycustomer/edit", params); // 添加
export const deleteContactInfo = (params) =>
upload("/securitycustomer/deleteContactInfo", params); // 删除

View File

@ -52,7 +52,6 @@
:label="'联系人' + (index + 1)"
:prop="`contacts.${index}.CONTACT`"
:rules="{ required: true, message: '请输入联系人' }"
@change="fnChangeContacts(contact.CUSTOMERCONTACT_ID)"
>
<el-input
v-model="contact.CONTACT"
@ -84,7 +83,6 @@
v-model="contact.CONTACTPHONE"
placeholder="请输入联系电话"
clearable
@change="fnChangeContacts(contact.CUSTOMERCONTACT_ID)"
/>
</el-form-item>
</el-col>
@ -98,7 +96,6 @@
v-model="contact.CUSTOMERADDRESS"
placeholder="请输入客户地址"
clearable
@change="fnChangeContacts(contact.CUSTOMERCONTACT_ID)"
/>
</el-form-item>
</el-col>
@ -106,7 +103,7 @@
<el-button
v-if="index !== 0"
type="danger"
@click="removeContact(index)"
@click="removeContact(index,contact.CUSTOMERCONTACT_ID)"
>
删除
<!-- 添加的删除文字 -->
@ -129,6 +126,7 @@ import { ElMessage } from "element-plus";
import {
getTrafficCustomerSelectView,
editSafetyCustomerInfo,
deleteContactInfo,
} from "@/request/customer_management.js";
import { useRoute, useRouter } from "vue-router";
const route = useRoute();
@ -153,6 +151,7 @@ const data = reactive({
CUSTOMERNAME: "",
contacts: [
{
CUSTOMERCONTACT_ID: "",
CONTACT: "",
CONTACTPHONE: "",
CUSTOMERADDRESS: "",
@ -180,31 +179,22 @@ const addContact = () => {
});
};
//
const removeContact = (index) => {
const removeContact = async (index, CUSTOMERCONTACT_ID) => {
if (index > 0) {
//
data.form.contacts.splice(index, 1);
await deleteContactInfo({CUSTOMERCONTACT_ID});
}
};
const fnChangeContacts = async (CUSTOMERCONTACTID) => {
data.form.CUSTOMERCONTACT_IDS =
data.form.CUSTOMERCONTACT_IDS + CUSTOMERCONTACTID + ",";
data.form.CUSTOMERCONTACT_ID = data.form.CUSTOMERCONTACT_IDS;
};
const fnSubmit = async () => {
await useFormValidate(formRef);
const formData = new FormData();
data.form.CUSTOMERCONTACT_ID = data.form.CUSTOMERCONTACT_ID.substring(
0,
data.form.CUSTOMERCONTACT_ID.lastIndexOf(",")
);
formData.append("TRANSPORTATIONCOMPANY", data.form.TRANSPORTATIONCOMPANY);
formData.append("CUSTOMERTYPE", data.form.CUSTOMERTYPE);
formData.append("CUSTOMERNAME", data.form.CUSTOMERNAME);
formData.append("CUSTOMERCONTACT_ID", data.form.CUSTOMERCONTACT_ID);
// contactsJSON
const contactsJson = JSON.stringify(data.form.contacts);
// 使JSONcontacts