Răsfoiți Sursa

修改客户模块

hurx 5 zile în urmă
părinte
comite
d560ac2dde

+ 24 - 5
src/views/customer/customerFile/customerInfo/add.vue

@@ -300,7 +300,12 @@
         <el-table-column label="手机号" align="center" prop="phone" min-width="150" />
         <el-table-column label="固定电话" align="center" prop="officePhone" min-width="150" />
         <el-table-column label="邮箱地址" align="center" prop="email" min-width="180" />
-        <el-table-column label="备注信息" align="center" prop="remark" min-width="180" />
+        <el-table-column label="主联系人" align="center" prop="isPrimary">
+          <template #default="scope">
+            <span>{{ scope.row.isPrimary == '0' ? '是' : '否' }}</span>
+          </template>
+        </el-table-column>
+        <!-- <el-table-column label="备注信息" align="center" prop="remark" min-width="180" /> -->
         <el-table-column label="操作" align="center" width="150" fixed="right">
           <template #default="{ row, $index }">
             <el-button link type="primary" @click="handleEditContact(row, $index)">编辑</el-button>
@@ -562,6 +567,17 @@ const handleLogoSelected = (files: any[]) => {
   }
 };
 
+/** 状态修改  */
+const handlePrimaryChange = async (row: any) => {
+  if (row.isPrimary === '0') {
+    contactList.value.forEach((item) => {
+      if (item.id !== row.id) {
+        item.isPrimary = '1';
+      }
+    });
+  }
+};
+
 const handCompanyChange = async (val) => {
   try {
     try {
@@ -791,7 +807,8 @@ const loadComDeptList = async () => {
 
 // 打开添加联系人对话框
 const handleAddContact = () => {
-  currentContact.value = undefined;
+  // 第一个联系人默认为主联系人,后面的默认为非主联系人
+  currentContact.value = contactList.value.length === 0 ? ({ isPrimary: '0' } as CustomerContactForm) : ({ isPrimary: '1' } as CustomerContactForm);
   currentContactIndex.value = -1;
   contactDialogVisible.value = true;
 };
@@ -882,10 +899,12 @@ const handleEditContact = (row: CustomerContactForm, index: number) => {
 
 // 确认添加/编辑联系人
 const handleContactConfirm = (data: CustomerContactForm) => {
-  // 如果新增/编辑的是主联系人(isPrimary === '0'),将其他所有联系人置为非主联系人
+  // 如果新增/编辑的是主联系人,将其他联系人置为非主联系人
   if (data.isPrimary === '0') {
-    contactList.value.forEach((item) => {
-      item.isPrimary = '1';
+    contactList.value.forEach((item, index) => {
+      if (index !== currentContactIndex.value) {
+        item.isPrimary = '1';
+      }
     });
   }
 

+ 3 - 3
src/views/customer/customerFile/customerInfo/components/addContactDialog.vue

@@ -21,8 +21,8 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item label="办公电话1" prop="officePhoneTwo">
-            <el-input v-model="form.officePhoneTwo" placeholder="请输入办公电话" />
+          <el-form-item label="邮箱" prop="email">
+            <el-input v-model="form.email" placeholder="请输入邮箱" />
           </el-form-item>
         </el-col>
       </el-row>
@@ -60,7 +60,7 @@
             <el-cascader v-model="codeArr" :options="regionData" placeholder="请选择" @change="handleChange" style="width: 100%"></el-cascader>
           </el-form-item>
           <el-form-item prop="addressDetail">
-            <el-input v-model="form.addressDetail" type="textarea" :rows="3" placeholder="请输入详细地址" />
+            <el-input v-model="form.addressDetail" placeholder="请输入详细地址" />
           </el-form-item>
         </el-col>
       </el-row>

+ 1 - 1
src/views/customer/customerFile/customerInfo/index.vue

@@ -607,7 +607,7 @@ const submitCheck = () => {
         checkDialog.visible = false;
         await getList();
       } catch (error) {
-        proxy?.$modal.msgError('审核失败,请重试');
+        // proxy?.$modal.msgError('审核失败,请重试');
       }
     }
   });

+ 6 - 11
src/views/customer/customerFile/customerInfo/overview/contactInfo.vue

@@ -156,14 +156,7 @@
               ></el-cascader>
             </el-form-item>
             <el-form-item prop="addressDetail">
-              <el-input
-                v-model="form.addressDetail"
-                type="textarea"
-                :rows="3"
-                placeholder="请输入详细地址"
-                style="width: 100%"
-                :disabled="isViewMode"
-              />
+              <el-input v-model="form.addressDetail" placeholder="请输入详细地址" style="width: 100%" :disabled="isViewMode" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -347,14 +340,14 @@ const loadCustomerDeptList = async () => {
 
 /** 状态修改  */
 const handlePrimaryChange = async (row: any) => {
-  //   const text = row.status === '0' ? '是' : '否';
   try {
-    // await proxy?.$modal.confirm('确认要"' + text + '"吗?');
+    // 如果设置为主联系人,将其他联系人置为非主联系人
+
     await changeIsPrimary(row.id, row.isPrimary);
     proxy?.$modal.msgSuccess('操作成功');
     getList();
   } catch (err) {
-    row.status = row.status === '0' ? '1' : '0';
+    row.isPrimary = row.isPrimary === '0' ? '1' : '0';
   }
 };
 
@@ -433,6 +426,8 @@ const handleAdd = async () => {
   if (props.customerId) {
     form.value.customerId = props.customerId;
   }
+  // 第一个联系人默认为主联系人,后面的默认为非主联系人
+  form.value.isPrimary = customerContactList.value.length === 0 ? '0' : '1';
   dialog.visible = true;
   dialog.title = '添加客户联系人信息';
 };

+ 10 - 0
src/views/customer/customerFile/customerInfo/overview/erpSaleInfo.vue

@@ -269,6 +269,9 @@ const loadTaxrateList = async () => {
       pageSize: 1000
     });
     taxrateList.value = res.rows || [];
+    if (res.rows && res.rows.length > 0) {
+      salesForm.rateId = res.rows[0].id;
+    }
   } catch (error) {}
 };
 
@@ -344,6 +347,13 @@ const loadCustomerData = async (id: any) => {
     if (data.customerSalesInfoVo) {
       Object.assign(salesForm, data.customerSalesInfoVo);
 
+      // 编辑时如果为空,使用默认值
+      if (!salesForm.customerSource) salesForm.customerSource = '1';
+      if (!salesForm.sellChannel) salesForm.sellChannel = '1';
+      if (!salesForm.unitPrice) salesForm.unitPrice = 'True';
+      if (!salesForm.creditLimit) salesForm.creditLimit = '1';
+      if (!salesForm.creditTimeLimit) salesForm.creditTimeLimit = '1';
+
       // 如果有部门ID,且部门不在列表中,从API获取
       if (salesForm.belongingDepartmentId) {
         const deptExists = comDeptList.value.find((d) => String(d.deptId) === String(salesForm.belongingDepartmentId));

+ 13 - 4
src/views/customer/customerFile/customerInfo/overview/shippingAddress.vue

@@ -68,7 +68,7 @@
           ></el-cascader>
         </el-form-item>
         <el-form-item prop="address">
-          <el-input v-model="form.address" type="textarea" placeholder="请输入内容" :disabled="isViewMode" />
+          <el-input v-model="form.address" placeholder="请输入内容" :disabled="isViewMode" />
         </el-form-item>
       </el-form>
       <template #footer>
@@ -170,6 +170,7 @@ const data = reactive<PageData<ShippingAddressForm, ShippingAddressQuery>>({
   },
   rules: {
     consignee: [{ required: true, message: '收货人姓名不能为空', trigger: 'blur' }],
+    postal: [{ required: true, message: '邮政编码不能为空', trigger: 'blur' }],
     phone: [
       { required: true, message: '收货人手机号不能为空', trigger: 'blur' },
       { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
@@ -229,14 +230,20 @@ const getList = async () => {
 
 /** 状态修改  */
 const handleDefaultAddressChange = async (row: ShippingAddressVO) => {
-  //   const text = row.status === '0' ? '是' : '否';
   try {
-    // await proxy?.$modal.confirm('确认要"' + text + '"吗?');
+    // 如果设置为默认地址,将其他地址置为非默认地址
+    if (row.defaultAddress === '0') {
+      shippingAddressList.value.forEach((item) => {
+        if (item.id !== row.id) {
+          item.defaultAddress = '1';
+        }
+      });
+    }
     await changeDefaultAddress(row.id, row.defaultAddress);
     proxy?.$modal.msgSuccess('操作成功');
     getList();
   } catch (err) {
-    row.status = row.status === '0' ? '1' : '0';
+    row.defaultAddress = row.defaultAddress === '0' ? '1' : '0';
   }
 };
 
@@ -280,6 +287,8 @@ const handleAdd = () => {
   if (props.customerId) {
     form.value.customerId = props.customerId;
   }
+  // 第一个地址默认为默认地址,后面的默认为非默认地址
+  form.value.defaultAddress = shippingAddressList.value.length === 0 ? '0' : '1';
   dialog.visible = true;
   dialog.title = '添加客户收货地址';
 };