From 9289a4fbacafcc7a80385fc3a3167f383d5cf991 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 15 一月 2026 18:00:51 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New' into dev_New

---
 src/views/salesManagement/salespersonManagement/index.vue |  153 ++++++++++++++++++++++-----------------------------
 1 files changed, 66 insertions(+), 87 deletions(-)

diff --git a/src/views/salesManagement/salespersonManagement/index.vue b/src/views/salesManagement/salespersonManagement/index.vue
index 3169b79..e0094ec 100644
--- a/src/views/salesManagement/salespersonManagement/index.vue
+++ b/src/views/salesManagement/salespersonManagement/index.vue
@@ -61,7 +61,7 @@
         </el-table-column>
         <el-table-column prop="permissions" label="鏉冮檺">
           <template #default="scope">
-            <el-tag v-for="perm in scope.row.permissions" :key="perm" size="small" style="margin-right: 5px;">
+            <el-tag v-for="perm in scope.row.permissionsList" :key="perm" size="small" style="margin-right: 5px;">
               {{ perm }}
             </el-tag>
           </template>
@@ -77,16 +77,16 @@
 
       <!-- 鍒嗛〉 -->
       <pagination
-        :total="pagination.total"
+        :total="total"
         layout="total, sizes, prev, pager, next, jumper"
-        :page="pagination.currentPage"
-        :limit="pagination.pageSize"
+        :page="pagination.current"
+        :limit="pagination.size"
         @pagination="handleCurrentChange"
       />
     </el-card>
 
     <!-- 鏂板/缂栬緫瀵硅瘽妗� -->
-    <el-dialog v-model="dialogVisible" :title="dialogTitle" width="600px">
+    <FormDialog v-model="dialogVisible" :title="dialogTitle" :width="'600px'" @close="dialogVisible = false" @confirm="handleSubmit" @cancel="dialogVisible = false">
       <el-form :model="form" :rules="rules" ref="formRef" label-width="100px">
         <el-row :gutter="20">
           <el-col :span="12">
@@ -147,16 +147,10 @@
           </el-col>
         </el-row>
       </el-form>
-      <template #footer>
-        <div class="dialog-footer">
-          <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
-          <el-button type="primary" @click="handleSubmit">纭� 瀹�</el-button>
-        </div>
-      </template>
-    </el-dialog>
+    </FormDialog>
 
     <!-- 鏉冮檺璁剧疆瀵硅瘽妗� -->
-    <el-dialog v-model="permissionDialogVisible" title="鏉冮檺璁剧疆" width="500px">
+    <FormDialog v-model="permissionDialogVisible" title="鏉冮檺璁剧疆" :width="'500px'" @close="permissionDialogVisible = false" @confirm="savePermissions" @cancel="permissionDialogVisible = false">
       <el-form label-width="100px">
         <el-form-item label="涓氬姟鍛樺鍚�">
           <span>{{ currentSalesperson.name }}</span>
@@ -172,21 +166,32 @@
           </el-checkbox-group>
         </el-form-item>
       </el-form>
-      <template #footer>
-        <div class="dialog-footer">
-          <el-button @click="permissionDialogVisible = false">鍙� 娑�</el-button>
-          <el-button type="primary" @click="savePermissions">纭� 瀹�</el-button>
-        </div>
-      </template>
-    </el-dialog>
+    </FormDialog>
   </div>
 </template>
 
 <script setup>
-import { ref, reactive, computed, nextTick } from 'vue'
+import { ref, reactive, computed,onMounted } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
+import {listPage,add,update,deleteSalespersonManagement} from '@/api/salesManagement/salespersonManagement.js'
 import { Plus, Search } from '@element-plus/icons-vue'
 import Pagination from '@/components/PIMTable/Pagination.vue'
+import FormDialog from '@/components/Dialog/FormDialog.vue'
+
+const salespersonList = ref([])
+const total = ref(0)
+
+onMounted(() => {
+   getList()
+})
+const getList = () => {
+  loading.value = true
+  listPage({...pagination,...searchForm}).then(res => {
+    salespersonList.value = res.data.records
+    total.value = res.data.total
+    loading.value = false
+  })
+}
 
 // 鍝嶅簲寮忔暟鎹�
 const loading = ref(false)
@@ -196,46 +201,11 @@
   status: ''
 })
 
-const salespersonList = ref([
-  {
-    id: 1,
-    name: '闄堝織寮�',
-    phone: '13800138001',
-    email: 'chenzhiqiang@company.com',
-    department: '閿�鍞儴',
-    position: '閿�鍞粡鐞�',
-    hireDate: '2023-01-15',
-    status: '鍦ㄨ亴',
-    permissions: ['璁㈠崟绠$悊', '瀹㈡埛绠$悊', '璐㈠姟绠$悊']
-  },
-  {
-    id: 2,
-    name: '鍒橀泤濠�',
-    phone: '13800138002',
-    email: 'liuyating@company.com',
-    department: '甯傚満閮�',
-    position: '甯傚満涓撳憳',
-    hireDate: '2023-03-20',
-    status: '鍦ㄨ亴',
-    permissions: ['瀹㈡埛绠$悊', '鎶ヨ〃鏌ョ湅']
-  },
-  {
-    id: 3,
-    name: '鐜嬪缓鍥�',
-    phone: '13800138003',
-    email: 'wangjianguo@company.com',
-    department: '瀹㈡湇閮�',
-    position: '瀹㈡湇涓荤',
-    hireDate: '2022-11-10',
-    status: '鍦ㄨ亴',
-    permissions: ['瀹㈡埛绠$悊', '鍙戣揣绠$悊']
-  }
-])
 
-const pagination = ref({
-  total: 3,
-  currentPage: 1,
-  pageSize: 10
+
+const pagination = reactive({
+  current: 1,
+  size: 10
 })
 
 const dialogVisible = ref(false)
@@ -293,6 +263,7 @@
 }
 
 const handleSearch = () => {
+  getList()
   // 鎼滅储閫昏緫宸插湪computed涓鐞�
 }
 
@@ -329,28 +300,35 @@
     cancelButtonText: '鍙栨秷',
     type: 'warning'
   }).then(() => {
-    const index = salespersonList.value.findIndex(item => item.id === row.id)
-    if (index > -1) {
-      salespersonList.value.splice(index, 1)
-      pagination.value.total--
-      ElMessage.success('鍒犻櫎鎴愬姛')
-    }
+    let ids = [row.id]
+    deleteSalespersonManagement(ids).then(res => {
+      if(res.code === 200){
+        ElMessage.success('鍒犻櫎鎴愬姛')
+        getList()
+      }
+    })
   })
 }
 
 const handlePermissions = (row) => {
   currentSalesperson.value = row
-  currentPermissions.value = [...row.permissions]
+  currentPermissions.value = row.permissions.split(",")
   permissionDialogVisible.value = true
 }
 
 const savePermissions = () => {
-  const index = salespersonList.value.findIndex(item => item.id === currentSalesperson.value.id)
-  if (index > -1) {
-    salespersonList.value[index].permissions = [...currentPermissions.value]
-    ElMessage.success('鏉冮檺璁剧疆鎴愬姛')
-    permissionDialogVisible.value = false
+  let splice = currentPermissions.value;
+  if(splice[0] === ''){
+    splice.splice(0,1)
   }
+  currentSalesperson.value.permissions =  splice.join(",")
+  update(currentSalesperson.value).then(res => {
+    if(res.code === 200){
+      ElMessage.success('鏉冮檺璁剧疆鎴愬姛')
+      permissionDialogVisible.value = false
+      getList()
+    }
+  })
 }
 
 const handleSubmit = () => {
@@ -358,23 +336,24 @@
     if (valid) {
       if (isEdit.value) {
         // 缂栬緫
-        const index = salespersonList.value.findIndex(item => item.id === editId.value)
-        if (index > -1) {
-          salespersonList.value[index] = { ...form, id: editId.value }
-          ElMessage.success('缂栬緫鎴愬姛')
-        }
-      } else {
-        // 鏂板
-        const newId = Math.max(...salespersonList.value.map(item => item.id)) + 1
-        salespersonList.value.push({
-          ...form,
-          id: newId,
-          permissions: []
+        update(form).then(res => {
+          if(res.code === 200){
+            ElMessage.success('缂栬緫鎴愬姛')
+            dialogVisible.value = false
+            getList()
+          }
         })
-        pagination.value.total++
-        ElMessage.success('鏂板鎴愬姛')
+      } else {
+        add(form).then(res => {
+          if(res.code === 200){
+            ElMessage.success('鏂板鎴愬姛')
+            dialogVisible.value = false
+            getList()
+          }
+        })
+
       }
-      dialogVisible.value = false
+
     }
   })
 }

--
Gitblit v1.9.3