|
@@ -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>
|
|
|
|