Răsfoiți Sursa

更新依赖

ZaiZai 11 luni în urmă
părinte
comite
811d339808
4 a modificat fișierele cu 131 adăugiri și 27 ștergeri
  1. 2 2
      package.json
  2. 7 0
      src/api/modules/project/contract.js
  3. 114 17
      src/views/project/info/user.vue
  4. 8 8
      yarn.lock

+ 2 - 2
package.json

@@ -22,7 +22,7 @@
         "dayjs": "^1.11.13",
         "echarts": "^5.5.1",
         "element-plus": "2.8.5",
-        "hc-vue3-ui": "^4.3.7",
+        "hc-vue3-ui": "^4.3.8",
         "js-base64": "^3.7.7",
         "js-fast-way": "^0.5.6",
         "js-md5": "^0.8.3",
@@ -47,6 +47,6 @@
         "typescript": "^5.6.3",
         "unocss": "^0.58.9",
         "unocss-preset-extra": "^0.5.3",
-        "vite": "^5.4.8"
+        "vite": "^5.4.9"
     }
 }

+ 7 - 0
src/api/modules/project/contract.js

@@ -62,6 +62,13 @@ export default {
             params: form,
         })
     },
+    async getUserListByCondition(form) {
+        return HcApi({
+            url: '/api/blade-manager/contractInfo/get-user-list-by-condition',
+            method: 'get',
+            params: form,
+        })
+    },
     async findUserList() {
         return HcApi({
             url: '/api/blade-manager/contractInfo/get-user-list',

+ 114 - 17
src/views/project/info/user.vue

@@ -3,24 +3,33 @@
         <hc-card>
             <template #header>
                 <div class="w-200px">
-                    <el-select v-model="contractId" filterable clearable block placeholder="选择合同段" @change="contractClick">
+                    <el-select v-model="searchForm.cId" filterable clearable block placeholder="选择合同段" @change="searchClick">
                         <el-option v-for="item in contractList" :key="item.id" :label="item.contractName" :value="item.id" />
                     </el-select>
                 </div>
                 <div class="ml-14px w-200px">
-                    选择维护人员角色
+                    <el-tree-select
+                        v-model="searchForm.rId" placeholder="选择维护人员角色" clearable filterable check-strictly block
+                        :data="roleList" :props="roleProps" :render-after-expand="false" @change="searchClick"
+                    />
                 </div>
             </template>
             <template #extra>
-                <el-button hc-btn type="primary">创建新用户</el-button>
-                <el-button hc-btn type="danger">全部删除</el-button>
+                <el-button hc-btn type="primary" @click="addUserClick">创建新用户</el-button>
+                <el-button hc-btn type="danger" @click="allDelClick">全部删除</el-button>
             </template>
             <template #search>
-                自定义搜索区域
+                <div class="mr-14px w-160px">
+                    <el-select-v2
+                        v-model="userId" :options="userList" :props="userProps"
+                        placeholder="选择系统内部人员" filterable clearable block
+                    />
+                </div>
+                <el-button type="primary" :disabled="isNullES(userId)" @click="addUserTap">添加</el-button>
             </template>
             <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :is-index="false">
                 <template #action="{ row }">
-                    <el-link type="danger">删除</el-link>
+                    <el-link type="danger" @click="delRowClick(row)">删除</el-link>
                 </template>
             </hc-table>
             <template #action>
@@ -32,6 +41,10 @@
 
 <script setup>
 import { onMounted, ref, watch } from 'vue'
+import { getArrValue, isNullES } from 'js-fast-way'
+import { getBizDictionary } from '~api/other'
+import contractApi from '~api/project/contract'
+import { NewDelMsg } from 'hc-vue3-ui'
 
 //双向绑定
 const modelData = defineModel('modelValue', {
@@ -46,18 +59,37 @@ watch(() => modelData.value, (data) => {
 
 //渲染完成
 onMounted(() => {
+    getContractList()
+    getRoleList()
+    searchClick()
+    getUserData()
+})
 
+//搜索表单
+const searchForm = ref({
+    cId: '', pId: '', postId: '', rId: '',
+    current: 1, size: 30, total: 0,
 })
 
-//合同段列表
-const contractId = ref('')
+//获取合同段数据
 const contractList = ref([])
-const contractClick = () => {
-
+const getContractList = async () => {
+    const { id } = formModel.value
+    if (isNullES(id)) {
+        contractList.value = []
+        return
+    }
+    const { data } = await contractApi.getList(id)
+    contractList.value = getArrValue(data)
 }
 
-//搜索表单
-const searchForm = ref({ current: 1, size: 30, total: 0 })
+//角色列表
+const roleList = ref([])
+const roleProps = { value: 'id', label: 'dictValue' }
+const getRoleList = async () => {
+    const { data } = await getBizDictionary({ code: 'maintainer_role' })
+    roleList.value = getArrValue(data)
+}
 
 //搜索
 const searchClick = () => {
@@ -77,7 +109,7 @@ const tableColumn = ref([
     { key: 'name', name: '姓名', width: 120, align: 'center' },
     { key: 'phone', name: '电话', width: 120, align: 'center' },
     { key: 'postName', name: '岗位', width: 120, align: 'center' },
-    { key: 'contractName', name: '合同段名称', align: 'center' },
+    { key: 'contractName', name: '合同段名称' },
     { key: 'action', name: '操作', width: 80, align: 'center' },
 ])
 const tableData = ref([])
@@ -85,15 +117,80 @@ const tableData = ref([])
 //获取表格数据
 const tableLoading = ref(false)
 const getTableData = async () => {
-    /*tableData.value = []
+    tableData.value = []
+    const { id } = formModel.value
+    if (isNullES(id)) return
     tableLoading.value = true
-    const { data } = await mainApi.page({
+    const { data } = await contractApi.getUserListByCondition({
         ...searchForm.value,
-        total: null,
+        pId: id,
     })
     tableLoading.value = false
     tableData.value = getArrValue(data?.records)
-    searchForm.value.total = data?.total || 0*/
+    searchForm.value.total = data?.total || 0
+}
+
+//用户列表
+const userId = ref('')
+const userProps = { value: 'id', label: 'name' }
+
+//获取用户列表
+const userList = ref([])
+const getUserData = async () => {
+    const { data } = await contractApi.findUserList()
+    userList.value = getArrValue(data)
+}
+
+//将系统用户添加进来
+const addUserLoading = ref(false)
+const addUserTap = async () => {
+    const { id } = formModel.value
+    if (isNullES(id)) {
+        window?.$message?.warning('项目数据异常')
+        return
+    }
+    const { cId, rId } = searchForm.value
+    if (isNullES(rId)) {
+        window?.$message?.warning('请先选择维护人员角色再进行添加')
+        return
+    }
+    addUserLoading.value = true
+    const list = [{
+        projectId: id,
+        contractId: isNullES(cId) ? undefined : cId,
+        userId: userId.value,
+        roleId: rId,
+    }]
+    const { code } = await contractApi.saveUserInfoByProject(list)
+    addUserLoading.value = false
+    if (code === 200) {
+        window?.$message?.success('添加成功')
+        getTableData().then()
+    }
+}
+
+//创建新用户
+const addUserClick = () => {
+
+}
+
+//全部删除
+const allDelClick = () => {
+
+}
+
+//单独删除
+const delRowClick = (row) => {
+    NewDelMsg({
+        text: '是否将该用户移除出合同段?',
+    }, async (resolve) => {
+        const { code } = await contractApi.removeUsersByIds(row.id)
+        if (code === 200) {
+            window?.$message?.success('删除成功')
+            getTableData().then()
+        }
+        resolve() //关闭弹窗的回调
+    })
 }
 </script>
 

+ 8 - 8
yarn.lock

@@ -2063,10 +2063,10 @@ has-flag@^4.0.0:
   resolved "http://39.108.216.210:9000/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
   integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
 
-hc-vue3-ui@^4.3.7:
-  version "4.3.7"
-  resolved "http://39.108.216.210:9000/hc-vue3-ui/-/hc-vue3-ui-4.3.7.tgz#d0091ec79fe70df7429017ca383d9597dffaaead"
-  integrity sha512-mvHHg1MJIx9qvEstSxwOxkblYXhr9y2yZVwUrrZ4WQwOVfqv+Za/C9q99jJYCNaSuQFPKW4qpR5v1b1H/NHbAA==
+hc-vue3-ui@^4.3.8:
+  version "4.3.8"
+  resolved "http://39.108.216.210:9000/hc-vue3-ui/-/hc-vue3-ui-4.3.8.tgz#931190300daccf62e833eea0c521466c3cda8500"
+  integrity sha512-hLOVW9t9AYVetEAzK+CDgFlsStgVdz37ll6Fjwgw3uOSshwMJZUdKLpHOYAk0/fscKVTrTUwV/IUc8DaEuLwiA==
   dependencies:
     axios "^1.7.7"
     dayjs "^1.11.13"
@@ -3121,10 +3121,10 @@ util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1:
   resolved "http://39.108.216.210:9000/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
   integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==
 
-vite@^5.4.8:
-  version "5.4.8"
-  resolved "http://39.108.216.210:9000/vite/-/vite-5.4.8.tgz#af548ce1c211b2785478d3ba3e8da51e39a287e8"
-  integrity sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ==
+vite@^5.4.9:
+  version "5.4.9"
+  resolved "http://39.108.216.210:9000/vite/-/vite-5.4.9.tgz#215c80cbebfd09ccbb9ceb8c0621391c9abdc19c"
+  integrity sha512-20OVpJHh0PAM0oSOELa5GaZNWeDjcAvQjGXy2Uyr+Tp+/D2/Hdz6NLgpJLsarPTA2QJ6v8mX2P1ZfbsSKvdMkg==
   dependencies:
     esbuild "^0.21.3"
     postcss "^8.4.43"