From a23c1574393e29480488ad5722cfd397e790990d Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 06 一月 2026 16:07:44 +0800
Subject: [PATCH] 代码调整9

---
 src/views/environmentAccess/accessManagement/index.vue |  763 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 464 insertions(+), 299 deletions(-)

diff --git a/src/views/environmentAccess/accessManagement/index.vue b/src/views/environmentAccess/accessManagement/index.vue
index 587dc78..7429ce8 100644
--- a/src/views/environmentAccess/accessManagement/index.vue
+++ b/src/views/environmentAccess/accessManagement/index.vue
@@ -1,347 +1,512 @@
 <template>
   <div class="app-container">
-    <el-form :model="filters" :inline="true">
-      <el-form-item label="闂ㄧ鍚嶇О">
+    <div class="search_form">
+      <div>
+        <span class="search_title">闂ㄧ鍚嶇О锛�</span>
         <el-input
-          v-model="filters.name"
-          style="width: 240px"
-          placeholder="璇疯緭鍏ラ棬绂佸悕绉�"
-          clearable
-          :prefix-icon="Search"
-          @change="getTableData"
+            v-model="searchForm.customerName"
+            style="width: 240px"
+            placeholder="璇疯緭鍏�"
+            @change="handleQuery"
+            clearable
+            :prefix-icon="Search"
         />
-      </el-form-item>
-      <el-form-item label="闂ㄧ鐘舵��">
-        <el-select
-          v-model="filters.status"
-          style="width: 240px"
-          placeholder="璇烽�夋嫨闂ㄧ鐘舵��"
-          clearable
-          @change="getTableData"
+        <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
+        >鎼滅储</el-button
         >
-          <el-option label="姝e父" value="1"></el-option>
-          <el-option label="寮傚父" value="0"></el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item label="鍖哄煙">
-        <el-input
-          v-model="filters.area"
-          style="width: 240px"
-          placeholder="璇疯緭鍏ュ尯鍩�"
-          clearable
-          :prefix-icon="Search"
-          @change="getTableData"
-        />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" @click="getTableData">鎼滅储</el-button>
-        <el-button @click="resetFilters">閲嶇疆</el-button>
-      </el-form-item>
-    </el-form>
-    <div class="table_list">
-      <div class="actions">
-        <div></div>
-        <div>
-          <el-button type="primary" @click="add" icon="Plus"> 鏂板 </el-button>
-          <el-button type="danger" icon="Delete" :disabled="multipleList.length <= 0" @click="batchDelete">鎵归噺鍒犻櫎</el-button>
-        </div>
       </div>
-      <PIMTable
-        rowKey="id"
-        isSelection
-        :column="columns"
-        :tableData="dataList"
-        :page="{
-          current: pagination.currentPage,
-          size: pagination.pageSize,
-          total: pagination.total,
-        }"
-        @selection-change="handleSelectionChange"
-        @pagination="changePage"
-      >
-      </PIMTable>
+      <div>
+        <el-button type="primary" @click="openForm('add')">鏂板</el-button>
+        <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+      </div>
     </div>
-    <!-- 鏂板缂栬緫寮圭獥 -->
-    <el-dialog v-model="dialogVisible" :title="dialogTitle" width="600px">
-      <el-form :model="formData" label-width="100px">
-        <el-form-item label="闂ㄧ鍚嶇О" required>
-          <el-input v-model="formData.name" placeholder="璇疯緭鍏ラ棬绂佸悕绉�"></el-input>
-        </el-form-item>
-        <el-form-item label="鍖哄煙" required>
-          <el-input v-model="formData.area" placeholder="璇疯緭鍏ュ尯鍩�"></el-input>
-        </el-form-item>
-        <el-form-item label="浣嶇疆" required>
-          <el-input v-model="formData.location" placeholder="璇疯緭鍏ュ叿浣撲綅缃�"></el-input>
-        </el-form-item>
-        <el-form-item label="鐘舵��" required>
-          <el-select v-model="formData.status" placeholder="璇烽�夋嫨鐘舵��">
-            <el-option label="姝e父" value="1"></el-option>
-            <el-option label="寮傚父" value="0"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="鎻忚堪">
-          <el-input v-model="formData.description" type="textarea" rows="3" placeholder="璇疯緭鍏ユ弿杩颁俊鎭�"></el-input>
-        </el-form-item>
+    <div class="table_list">
+      <PIMTable
+          rowKey="id"
+          :column="tableColumn"
+          :tableData="tableData"
+          :page="page"
+          :isSelection="true"
+          @selection-change="handleSelectionChange"
+          :tableLoading="tableLoading"
+          @pagination="pagination"
+      ></PIMTable>
+    </div>
+    <el-dialog
+        v-model="dialogFormVisible"
+        :title="operationType === 'add' ? '鏂板闂ㄧ淇℃伅' : '缂栬緫闂ㄧ淇℃伅'"
+        width="70%"
+        @close="closeDia"
+    >
+      <el-form
+          :model="form"
+          label-width="140px"
+          label-position="top"
+          :rules="rules"
+          ref="formRef"
+      >
+        <el-row :gutter="30">
+          <el-col :span="12">
+            <el-form-item label="闂ㄧ鍚嶇О锛�" prop="customerName">
+              <el-input
+                  v-model="form.customerName"
+                  placeholder="璇疯緭鍏�"
+                  clearable
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item
+                label="鍖哄煙锛�"
+                prop="taxpayerIdentificationNumber"
+            >
+              <el-input
+                  v-model="form.taxpayerIdentificationNumber"
+                  placeholder="璇疯緭鍏�"
+                  clearable
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="12">
+            <el-form-item label="浣嶇疆锛�" prop="companyAddress">
+              <el-input
+                  v-model="form.companyAddress"
+                  placeholder="璇疯緭鍏�"
+                  clearable
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="12">
+            <el-form-item label="缁存姢浜猴細" prop="maintainer">
+              <el-select
+                  v-model="form.maintainer"
+                  placeholder="璇烽�夋嫨"
+                  clearable
+                  disabled
+              >
+                <el-option
+                    v-for="item in userList"
+                    :key="item.nickName"
+                    :label="item.nickName"
+                    :value="item.nickName"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="缁存姢鏃堕棿锛�" prop="maintenanceTime">
+              <el-date-picker
+                  style="width: 100%"
+                  v-model="form.maintenanceTime"
+                  value-format="YYYY-MM-DD"
+                  format="YYYY-MM-DD"
+                  type="date"
+                  placeholder="璇烽�夋嫨"
+                  clearable
+                  disabled
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
       </el-form>
       <template #footer>
-        <span class="dialog-footer">
-          <el-button @click="dialogVisible = false">鍙栨秷</el-button>
-          <el-button type="primary" @click="saveData">纭畾</el-button>
-        </span>
+        <div class="dialog-footer">
+          <el-button type="primary" @click="submitForm">纭</el-button>
+          <el-button @click="closeDia">鍙栨秷</el-button>
+        </div>
+      </template>
+    </el-dialog>
+    <!-- 鐢ㄦ埛瀵煎叆瀵硅瘽妗� -->
+    <el-dialog
+        :title="upload.title"
+        v-model="upload.open"
+        width="400px"
+        append-to-body
+    >
+      <el-upload
+          ref="uploadRef"
+          :limit="1"
+          accept=".xlsx, .xls"
+          :headers="upload.headers"
+          :action="upload.url + '?updateSupport=' + upload.updateSupport"
+          :disabled="upload.isUploading"
+          :before-upload="upload.beforeUpload"
+          :on-progress="upload.onProgress"
+          :on-success="upload.onSuccess"
+          :on-error="upload.onError"
+          :on-change="upload.onChange"
+          :auto-upload="false"
+          drag
+      >
+        <el-icon class="el-icon--upload"><upload-filled /></el-icon>
+        <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+        <template #tip>
+          <div class="el-upload__tip text-center">
+            <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
+            <!--            <el-link-->
+            <!--              type="primary"-->
+            <!--              :underline="false"-->
+            <!--              style="font-size: 12px; vertical-align: baseline"-->
+            <!--              @click="importTemplate"-->
+            <!--              >涓嬭浇妯℃澘</el-link-->
+            <!--            >-->
+          </div>
+        </template>
+      </el-upload>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+          <el-button @click="upload.open = false">鍙� 娑�</el-button>
+        </div>
       </template>
     </el-dialog>
   </div>
 </template>
 
 <script setup>
-import { ref, reactive, computed, onMounted } from 'vue';
-import { Search, Plus, Delete } from '@element-plus/icons-vue';
-import { ElMessage, ElMessageBox } from 'element-plus';
-import dayjs from 'dayjs';
+import {onMounted, ref} from "vue";
+import { Search } from "@element-plus/icons-vue";
+import {
+  addCustomer,
+  delCustomer,
+  getCustomer,
+  listCustomer,
+  updateCustomer,
+} from "@/api/basicData/customerFile.js";
+import { ElMessageBox } from "element-plus";
+import { userListNoPage } from "@/api/system/user.js";
+import useUserStore from "@/store/modules/user";
+import { getToken } from "@/utils/auth.js";
+const { proxy } = getCurrentInstance();
+const userStore = useUserStore();
 
-// 瀹氫箟鍋囨暟鎹�
-const mockData = [
-  { id: 1, name: '涓滈棬闂ㄧ', area: '鐢熶骇鍖�', location: '涓滈棬鍏ュ彛', status: '1', lastUpdate: '2025-12-30 08:30:00', description: '涓昏鐢ㄤ簬鍛樺伐涓婁笅鐝�氳' },
-  { id: 2, name: '瑗块棬闂ㄧ', area: '浠撳偍鍖�', location: '瑗块棬鍏ュ彛', status: '1', lastUpdate: '2025-12-30 09:15:00', description: '涓昏鐢ㄤ簬鐗╂祦杞﹁締閫氳' },
-  { id: 3, name: '鍗楅棬闂ㄧ', area: '鍔炲叕鍖�', location: '鍗楅棬鍏ュ彛', status: '0', lastUpdate: '2025-12-30 10:20:00', description: '涓昏鐢ㄤ簬璁垮閫氳锛屽綋鍓嶆晠闅�' },
-  { id: 4, name: '鍖楅棬闂ㄧ', area: '鐢熶骇鍖�', location: '鍖楅棬鍏ュ彛', status: '1', lastUpdate: '2025-12-30 11:45:00', description: '涓昏鐢ㄤ簬鍘熸潗鏂欒繍杈撹溅杈嗛�氳' },
-  { id: 5, name: '涓帶瀹ら棬绂�', area: '涓帶鍖�', location: '涓帶瀹ら棬鍙�', status: '1', lastUpdate: '2025-12-30 13:20:00', description: '浠呴檺鎺堟潈浜哄憳杩涘叆' },
-];
-
-// 鍝嶅簲寮忔暟鎹�
-const filters = reactive({
-  name: '',
-  status: '',
-  area: ''
-});
-
-const dataList = ref([]);
-const pagination = reactive({
-  currentPage: 1,
-  pageSize: 10,
-  total: 0
-});
-
-const multipleList = ref([]);
-const dialogVisible = ref(false);
-const dialogTitle = ref('鏂板闂ㄧ');
-const formData = reactive({
-  id: '',
-  name: '',
-  area: '',
-  location: '',
-  status: '1',
-  description: ''
-});
-
-// 琛ㄦ牸鍒楅厤缃�
-const columns = [
+const tableColumn = ref([
   {
-    label: '闂ㄧ鍚嶇О',
-    align: 'center',
-    prop: 'name',
+    label: "闂ㄧ鍚嶇О",
+    prop: "customerName",
+    width: 220,
   },
   {
-    label: '鍖哄煙',
-    align: 'center',
-    prop: 'area',
+    label: "鍖哄煙",
+    prop: "taxpayerIdentificationNumber",
+    width: 220,
   },
   {
-    label: '浣嶇疆',
-    align: 'center',
-    prop: 'location',
+    label: "浣嶇疆",
+    prop: "companyAddress",
+    width: 220,
   },
   {
-    label: '鐘舵��',
-    align: 'center',
-    prop: 'status',
-    formatter: (row) => {
-      return row.status === '1' ? '<el-tag type="success">姝e父</el-tag>' : '<el-tag type="danger">寮傚父</el-tag>';
-    }
+    label: "缁存姢浜�",
+    prop: "maintainer",
   },
   {
-    label: '鏈�鍚庢洿鏂�',
-    align: 'center',
-    prop: 'lastUpdate',
+    label: "缁存姢鏃堕棿",
+    prop: "maintenanceTime",
+    width: 100,
   },
   {
-    label: '鎻忚堪',
-    align: 'center',
-    prop: 'description',
-  },
-  {
-    dataType: 'action',
-    label: '鎿嶄綔',
-    align: 'center',
+    dataType: "action",
+    label: "鎿嶄綔",
+    align: "center",
     fixed: 'right',
-    width: 140,
     operation: [
       {
-        name: '缂栬緫',
-        type: 'text',
+        name: "缂栬緫",
+        type: "text",
         clickFun: (row) => {
-          edit(row);
+          openForm("edit", row);
         },
-      },
-      {
-        name: '鍒犻櫎',
-        type: 'text',
-        clickFun: (row) => {
-          deleteRow(row.id);
-        },
+        disabled: (row) => {
+          return row.maintainer !== userStore.nickName
+        }
       },
     ],
   },
-];
-
-// 杩囨护鍚庣殑鏁版嵁
-const filteredData = computed(() => {
-  return mockData.filter(item => {
-    const nameMatch = !filters.name || item.name.includes(filters.name);
-    const statusMatch = !filters.status || item.status === filters.status;
-    const areaMatch = !filters.area || item.area.includes(filters.area);
-    return nameMatch && statusMatch && areaMatch;
-  });
+]);
+const tableData = ref([]);
+const selectedRows = ref([]);
+const userList = ref([]);
+const tableLoading = ref(false);
+const page = reactive({
+  current: 1,
+  size: 100,
+  total: 0,
 });
+const total = ref(0);
 
-// 鑾峰彇琛ㄦ牸鏁版嵁
-const getTableData = () => {
-  pagination.total = filteredData.value.length;
-  const start = (pagination.currentPage - 1) * pagination.pageSize;
-  const end = start + pagination.pageSize;
-  dataList.value = filteredData.value.slice(start, end);
-};
-
-// 閲嶇疆杩囨护鍣�
-const resetFilters = () => {
-  filters.name = '';
-  filters.status = '';
-  filters.area = '';
-  pagination.currentPage = 1;
-  getTableData();
-};
-
-// 鍒嗛〉鍙樺寲
-const changePage = ({ page, limit }) => {
-  pagination.currentPage = page;
-  pagination.pageSize = limit;
-  getTableData();
-};
-
-// 澶氶�夊鐞�
-const handleSelectionChange = (selectionList) => {
-  multipleList.value = selectionList;
-};
-
-// 鏂板
-const add = () => {
-  dialogTitle.value = '鏂板闂ㄧ';
-  formData.id = '';
-  formData.name = '';
-  formData.area = '';
-  formData.location = '';
-  formData.status = '1';
-  formData.description = '';
-  dialogVisible.value = true;
-};
-
-// 缂栬緫
-const edit = (row) => {
-  dialogTitle.value = '缂栬緫闂ㄧ';
-  formData.id = row.id;
-  formData.name = row.name;
-  formData.area = row.area;
-  formData.location = row.location;
-  formData.status = row.status;
-  formData.description = row.description;
-  dialogVisible.value = true;
-};
-
-// 淇濆瓨鏁版嵁
-const saveData = () => {
-  if (!formData.name || !formData.area || !formData.location) {
-    ElMessage.warning('璇峰~鍐欏繀濉瓧娈�');
-    return;
-  }
-
-  const currentTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
-  if (formData.id) {
-    // 缂栬緫
-    const index = mockData.findIndex(item => item.id === formData.id);
-    if (index !== -1) {
-      mockData[index] = {
-        ...formData,
-        lastUpdate: currentTime
-      };
-      ElMessage.success('缂栬緫鎴愬姛');
+// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
+const operationType = ref("");
+const dialogFormVisible = ref(false);
+const formYYs = ref({    // 鍏朵粬瀛楁...
+  contactList: [
+    {
+      contactPerson: "",
+      contactPhone: ""
     }
-  } else {
-    // 鏂板
-    const newId = Math.max(...mockData.map(item => item.id), 0) + 1;
-    mockData.unshift({
-      ...formData,
-      id: newId,
-      lastUpdate: currentTime
+  ]
+});
+const data = reactive({
+  searchForm: {
+    customerName: "",
+  },
+  form: {
+    customerName: "",
+    taxpayerIdentificationNumber: "",
+    companyAddress: "",
+    companyPhone: "",
+    contactPerson: "",
+    contactPhone: "",
+    maintainer: "",
+    maintenanceTime: "",
+    basicBankAccount: "",
+    bankAccount: "",
+    bankCode: "",
+  },
+  rules: {
+    customerName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    taxpayerIdentificationNumber: [
+      { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+    ],
+    companyAddress: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    companyPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    // contactPerson: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    // contactPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    maintainer: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
+    maintenanceTime: [
+      { required: false, message: "璇烽�夋嫨", trigger: "change" },
+    ],
+    basicBankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    bankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    bankCode: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+  },
+});
+const upload = reactive({
+  // 鏄惁鏄剧ず寮瑰嚭灞傦紙瀹㈡埛瀵煎叆锛�
+  open: false,
+  // 寮瑰嚭灞傛爣棰橈紙瀹㈡埛瀵煎叆锛�
+  title: "",
+  // 鏄惁绂佺敤涓婁紶
+  isUploading: false,
+  // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+  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);
+    if(response.code === 200){
+      proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+    }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);
+    proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+  },
+  // 鏂囦欢涓婁紶杩涘害鍥炶皟
+  onProgress: (event, file, fileList) => {
+    console.log('涓婁紶涓�...', event.percent);
+  }
+});
+const { searchForm, form, rules } = toRefs(data);
+const addNewContact = () => {
+  formYYs.value.contactList.push({
+    contactPerson: "",
+    contactPhone: ""
+  });
+};
+
+const removeContact = (index) => {
+  if (formYYs.value.contactList.length > 1) {
+    formYYs.value.contactList.splice(index, 1);
+  }
+};
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+  page.current = 1;
+  getList();
+};
+const pagination = (obj) => {
+  page.current = obj.page;
+  page.size = obj.limit;
+  getList();
+};
+const getList = () => {
+  tableLoading.value = true;
+  listCustomer({ ...searchForm.value, ...page }).then((res) => {
+    tableLoading.value = false;
+    tableData.value = res.records;
+    page.total = res.total;
+  });
+};
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+  selectedRows.value = selection;
+};
+/** 鎻愪氦涓婁紶鏂囦欢 */
+function submitFileForm() {
+  proxy.$refs["uploadRef"].submit();
+}
+/** 瀵煎叆鎸夐挳鎿嶄綔 */
+function handleImport() {
+  upload.title = "瀹㈡埛瀵煎叆";
+  upload.open = true;
+}
+// 鎵撳紑寮规
+const openForm = (type, row) => {
+  operationType.value = type;
+  form.value = {};
+  form.value.maintainer = userStore.nickName;
+  formYYs.value.contactList = [
+    {
+      contactPerson: "",
+      contactPhone: ""
+    }
+  ];
+  form.value.maintenanceTime = getCurrentDate();
+  userListNoPage().then((res) => {
+    userList.value = res.data;
+  });
+  if (type === "edit") {
+    getCustomer(row.id).then((res) => {
+      form.value = { ...res.data };
+      formYYs.value.contactList = res.data.contactPerson.split(",").map((item, index) => {
+        return {
+          contactPerson: item,
+          contactPhone: res.data.contactPhone.split(",")[index]
+        }
+      });
+
     });
-    ElMessage.success('鏂板鎴愬姛');
   }
-  dialogVisible.value = false;
-  getTableData();
+  dialogFormVisible.value = true;
 };
-
-// 鍒犻櫎
-const deleteRow = (id) => {
-  ElMessageBox.confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ラ棬绂佽褰�, 鏄惁缁х画?', '鎻愮ず', {
-    confirmButtonText: '纭畾',
-    cancelButtonText: '鍙栨秷',
-    type: 'warning',
-  }).then(() => {
-    const index = mockData.findIndex(item => item.id === id);
-    if (index !== -1) {
-      mockData.splice(index, 1);
-      ElMessage.success('鍒犻櫎鎴愬姛');
-      getTableData();
-    }
-  }).catch(() => {});
-};
-
-// 鎵归噺鍒犻櫎
-const batchDelete = () => {
-  if (multipleList.value.length === 0) {
-    ElMessage.warning('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁');
-    return;
-  }
-
-  ElMessageBox.confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎鎵�閫夐棬绂佽褰�, 鏄惁缁х画?', '鎻愮ず', {
-    confirmButtonText: '纭畾',
-    cancelButtonText: '鍙栨秷',
-    type: 'warning',
-  }).then(() => {
-    const ids = multipleList.value.map(item => item.id);
-    mockData.forEach((item, index) => {
-      if (ids.includes(item.id)) {
-        mockData.splice(index, 1);
+// 鎻愪氦琛ㄥ崟
+const submitForm = () => {
+  proxy.$refs["formRef"].validate((valid) => {
+    if (valid) {
+      if (operationType.value === "edit") {
+        submitEdit();
+      } else {
+        submitAdd();
       }
-    });
-    ElMessage.success('鍒犻櫎鎴愬姛');
-    getTableData();
-    multipleList.value = [];
-  }).catch(() => {});
+    }
+  });
+};
+// 鎻愪氦鏂板
+const submitAdd = () => {
+  if(formYYs.value.contactList.length < 1){
+    return proxy.$modal.msgWarning("璇疯嚦灏戞坊鍔犱竴涓仈绯讳汉");
+  }
+  form.value.contactPerson = formYYs.value.contactList.map(item => item.contactPerson).join(",");
+  form.value.contactPhone = formYYs.value.contactList.map(item => item.contactPhone).join(",");
+  addCustomer(form.value).then((res) => {
+    proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+    closeDia();
+    getList();
+  });
+};
+// 鎻愪氦淇敼
+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();
+    getList();
+  });
+};
+// 鍏抽棴寮规
+const closeDia = () => {
+  proxy.resetForm("formRef");
+  dialogFormVisible.value = false;
+};
+// 瀵煎嚭
+const handleOut = () => {
+  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  })
+      .then(() => {
+        proxy.download("/basic/customer/export", {}, "瀹㈡埛妗f.xlsx");
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
+      });
+};
+// 鍒犻櫎
+const handleDelete = () => {
+  let ids = [];
+  if (selectedRows.value.length > 0) {
+    // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
+    const unauthorizedData = selectedRows.value.filter(item => item.maintainer !== userStore.nickName);
+    if (unauthorizedData.length > 0) {
+      proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
+      return;
+    }
+    ids = selectedRows.value.map((item) => item.id);
+  } else {
+    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+    return;
+  }
+  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  })
+      .then(() => {
+        tableLoading.value = true;
+        delCustomer(ids)
+            .then((res) => {
+              proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+              getList();
+            })
+            .finally(() => {
+              tableLoading.value = false;
+            });
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
+      });
 };
 
-// 鍒濆鍖栨暟鎹�
+// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
+function getCurrentDate() {
+  const today = new Date();
+  const year = today.getFullYear();
+  const month = String(today.getMonth() + 1).padStart(2, "0"); // 鏈堜唤浠�0寮�濮�
+  const day = String(today.getDate()).padStart(2, "0");
+  return `${year}-${month}-${day}`;
+}
+
 onMounted(() => {
-  getTableData();
+  getList();
 });
 </script>
 
-<style lang="scss" scoped>
-.table_list {
-  margin-top: unset;
-}
-.actions {
-  display: flex;
-  justify-content: space-between;
-  margin-bottom: 10px;
-}
-</style>
+<style scoped lang="scss"></style>

--
Gitblit v1.9.3