From 9601915072973553406f549f06aa1cfa93172b92 Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期一, 29 十二月 2025 13:30:52 +0800
Subject: [PATCH] 添加客户分类功能,零售客户和进销商客户

---
 src/views/basicData/customerFile/index.vue |  129 +++++++++++++++++++++++++++++++++---------
 1 files changed, 101 insertions(+), 28 deletions(-)

diff --git a/src/views/basicData/customerFile/index.vue b/src/views/basicData/customerFile/index.vue
index 284300d..0f39e25 100644
--- a/src/views/basicData/customerFile/index.vue
+++ b/src/views/basicData/customerFile/index.vue
@@ -5,12 +5,23 @@
         <span class="search_title">瀹㈡埛鍚嶇О锛�</span>
         <el-input
           v-model="searchForm.customerName"
-          style="width: 240px"
+          style="width: 240px;margin-right: 10px"
           placeholder="璇疯緭鍏�"
           @change="handleQuery"
           clearable
           :prefix-icon="Search"
         />
+         <span class="search_title">瀹㈡埛鍒嗙被锛�</span>
+         <el-select
+          v-model="searchForm.customerType"
+          placeholder="璇烽�夋嫨"
+          style="width: 240px"
+          clearable
+           @change="handleQuery"
+        >
+           <el-option  label="闆跺敭瀹㈡埛" value="闆跺敭瀹㈡埛" />
+           <el-option  label="杩涢攢鍟嗗鎴�" value="杩涢攢鍟嗗鎴�" />
+        </el-select>
         <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
           >鎼滅储</el-button
         >
@@ -92,25 +103,6 @@
             </el-form-item>
           </el-col>
         </el-row>
-        <el-row :gutter="30" v-for="(contact, index) in formYYs.contactList" :key="index">
-          <el-col :span="12">
-            <el-form-item label="鑱旂郴浜猴細" prop="contactPerson">
-              <el-input v-model="contact.contactPerson" placeholder="璇疯緭鍏�" clearable  />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="鑱旂郴鐢佃瘽锛�" prop="contactPhone">
-              <div style="display: flex; align-items: center;width: 100%;">
-                <el-input v-model="contact.contactPhone" placeholder="璇疯緭鍏�" clearable />
-                <el-button   @click="removeContact(index)" type="danger" circle style="margin-left: 5px;">
-                  <el-icon><Close /></el-icon>
-                </el-button>
-              </div>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-button @click="addNewContact" style="margin-bottom: 10px;">+ 鏂板鑱旂郴浜�</el-button>
-
         <el-row :gutter="30">
           <el-col :span="12">
             <el-form-item label="閾惰鍩烘湰鎴凤細" prop="basicBankAccount">
@@ -141,7 +133,33 @@
               />
             </el-form-item>
           </el-col>
+          <el-col :span="12">
+            <el-form-item label="瀹㈡埛鍒嗙被锛�" prop="customerType">
+               <el-select  v-model="form.customerType" placeholder="璇烽�夋嫨" clearable>
+                 <el-option  label="闆跺敭瀹㈡埛" value="闆跺敭瀹㈡埛" />
+                 <el-option  label="杩涢攢鍟嗗鎴�" value="杩涢攢鍟嗗鎴�" />
+              </el-select>
+            </el-form-item>
+          </el-col>
         </el-row>
+				<el-row :gutter="30" v-for="(contact, index) in formYYs.contactList" :key="index">
+					<el-col :span="12">
+						<el-form-item label="鑱旂郴浜猴細" prop="contactPerson">
+							<el-input v-model="contact.contactPerson" placeholder="璇疯緭鍏�" clearable  />
+						</el-form-item>
+					</el-col>
+					<el-col :span="12">
+						<el-form-item label="鑱旂郴鐢佃瘽锛�" prop="contactPhone">
+							<div style="display: flex; align-items: center;width: 100%;">
+								<el-input v-model="contact.contactPhone" placeholder="璇疯緭鍏�" clearable />
+								<el-button   @click="removeContact(index)" type="danger" circle style="margin-left: 5px;">
+									<el-icon><Close /></el-icon>
+								</el-button>
+							</div>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-button @click="addNewContact" style="margin-bottom: 10px;">+ 鏂板鑱旂郴浜�</el-button>
         <el-row :gutter="30">
           <el-col :span="12">
             <el-form-item label="缁存姢浜猴細" prop="maintainer">
@@ -170,7 +188,6 @@
                 type="date"
                 placeholder="璇烽�夋嫨"
                 clearable
-                disabled
               />
             </el-form-item>
           </el-col>
@@ -197,8 +214,11 @@
         :headers="upload.headers"
         :action="upload.url + '?updateSupport=' + upload.updateSupport"
         :disabled="upload.isUploading"
-        :on-progress="handleFileUploadProgress"
-        :on-success="handleFileSuccess"
+        :before-upload="upload.beforeUpload"
+        :on-progress="upload.onProgress"
+        :on-success="upload.onSuccess"
+        :on-error="upload.onError"
+        :on-change="upload.onChange"
         :auto-upload="false"
         drag
       >
@@ -228,7 +248,7 @@
 </template>
 
 <script setup>
-import { ref } from "vue";
+import {onMounted, ref} from "vue";
 import { Search } from "@element-plus/icons-vue";
 import {
   addCustomer,
@@ -245,6 +265,11 @@
 const userStore = useUserStore();
 
 const tableColumn = ref([
+  {
+    label: "瀹㈡埛鍒嗙被",
+    prop: "customerType",
+    width: 120,
+  },
   {
     label: "瀹㈡埛鍚嶇О",
     prop: "customerName",
@@ -305,9 +330,6 @@
         clickFun: (row) => {
           openForm("edit", row);
         },
-				disabled: (row) => {
-					return row.maintainer !== userStore.nickName
-				}
       },
     ],
   },
@@ -337,6 +359,7 @@
 const data = reactive({
   searchForm: {
     customerName: "",
+    customerType: "",
   },
   form: {
     customerName: "",
@@ -350,6 +373,7 @@
     basicBankAccount: "",
     bankAccount: "",
     bankCode: "",
+    customerType: "",
   },
   rules: {
     customerName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
@@ -367,6 +391,7 @@
     basicBankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
     bankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
     bankCode: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    customerType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
   },
 });
 const upload = reactive({
@@ -380,6 +405,45 @@
   headers: { Authorization: "Bearer " + getToken() },
   // 涓婁紶鐨勫湴鍧�
   url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData",
+  // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
+  beforeUpload: (file) => {
+    console.log('鏂囦欢鍗冲皢涓婁紶', file);
+    // 鍙互鍦ㄦ澶勫仛鏂囦欢绫诲瀷鎴栧ぇ灏忔牎楠�
+    const isValid = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.name.endsWith('.xlsx') || file.name.endsWith('.xls');
+    if (!isValid) {
+      proxy.$modal.msgError("鍙兘涓婁紶 Excel 鏂囦欢");
+    }
+    return isValid;
+  },
+  // 鏂囦欢鐘舵�佹敼鍙樻椂鐨勫洖璋�
+  onChange: (file, fileList) => {
+    console.log('鏂囦欢鐘舵�佹敼鍙�', file, fileList);
+  },
+  // 鏂囦欢涓婁紶鎴愬姛鏃剁殑鍥炶皟
+  onSuccess: (response, file, fileList) => {
+    console.log('涓婁紶鎴愬姛', response, file, fileList);
+    upload.isUploading = false;
+    if(response.code === 200){
+      proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+      upload.open = false;
+      proxy.$refs["uploadRef"].clearFiles();
+      getList();
+    }else if(response.code === 500){
+      proxy.$modal.msgError(response.msg);
+    }else{
+      proxy.$modal.msgWarning(response.msg);
+    }
+  },
+  // 鏂囦欢涓婁紶澶辫触鏃剁殑鍥炶皟
+  onError: (error, file, fileList) => {
+    console.error('涓婁紶澶辫触', error, file, fileList);
+    upload.isUploading = false;
+    proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+  },
+  // 鏂囦欢涓婁紶杩涘害鍥炶皟
+  onProgress: (event, file, fileList) => {
+    console.log('涓婁紶涓�...', event.percent);
+  }
 });
 const { searchForm, form, rules } = toRefs(data);
 const addNewContact = () => {
@@ -419,12 +483,17 @@
 };
 /** 鎻愪氦涓婁紶鏂囦欢 */
 function submitFileForm() {
+  upload.isUploading = true;
   proxy.$refs["uploadRef"].submit();
 }
 /** 瀵煎叆鎸夐挳鎿嶄綔 */
 function handleImport() {
   upload.title = "瀹㈡埛瀵煎叆";
   upload.open = true;
+}
+/** 涓嬭浇妯℃澘 */
+function importTemplate() {
+  proxy.download("/basic/customer/downloadTemplate", {}, "瀹㈡埛瀵煎叆妯℃澘.xlsx");
 }
 // 鎵撳紑寮规
 const openForm = (type, row) => {
@@ -482,6 +551,8 @@
 };
 // 鎻愪氦淇敼
 const submitEdit = () => {
+	form.value.contactPerson = formYYs.value.contactList.map(item => item.contactPerson).join(",");
+	form.value.contactPhone = formYYs.value.contactList.map(item => item.contactPhone).join(",");
   updateCustomer(form.value).then((res) => {
     proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
     closeDia();
@@ -552,7 +623,9 @@
   return `${year}-${month}-${day}`;
 }
 
-getList();
+onMounted(() => {
+	getList();
+});
 </script>
 
 <style scoped lang="scss"></style>

--
Gitblit v1.9.3