ZaiZai 9 місяців тому
батько
коміт
d9c55ce0fc

+ 15 - 3
src/views/project/detail/detail.vue

@@ -3,7 +3,8 @@
         <div class="hc-contract-info-drawer h-full">
             <hc-tab-card :scrollbar="tabsKey === '1'" :tabs="tabsData" :tab-key="tabsKey" is-action-btn @change="tabsChange">
                 <HcInfo v-if="tabsKey === '1'" :data="dataInfo" @close="drawerClose" @next="dataInfoNext" />
-                <HcWbs v-if="tabsKey === '2'" :data="dataInfo" @close="drawerClose" @next="dataWbsNext" />
+                <HcWbs v-if="tabsKey === '2'" :data="dataInfo" @close="drawerClose" @next="dataWbsNext" @back="dataWbsBack" />
+                <HcUser v-if="tabsKey === '3'" :data="dataInfo" @close="drawerClose" @back="dataUserBack" />
             </hc-tab-card>
         </div>
     </hc-drawer>
@@ -14,6 +15,7 @@ import { ref, watch } from 'vue'
 import { getObjValue, isNullES } from 'js-fast-way'
 import HcInfo from './info.vue'
 import HcWbs from './wbs.vue'
+import HcUser from './user.vue'
 
 const props = defineProps({
     data: {
@@ -74,9 +76,19 @@ const dataInfoNext = async (data) => {
     }
 }
 
+//上一步
+const dataWbsBack = () => {
+    tabsKey.value = '1'
+}
+
 //下一步
-const dataWbsNext = async (data) => {
-    console.log(data)
+const dataWbsNext = () => {
+    tabsKey.value = '3'
+}
+
+//上一步
+const dataUserBack = () => {
+    tabsKey.value = '2'
 }
 
 //关闭抽屉

+ 287 - 0
src/views/project/detail/user.vue

@@ -0,0 +1,287 @@
+<template>
+    <div class="hc-contract-info-user relative h-full">
+        <hc-card>
+            <template #header>
+                <div class="w-200px">
+                    <el-select v-model="rId" filterable clearable block placeholder="选择角色方" @change="setRolePostData">
+                        <el-option v-for="item in roleList" :key="item.id" :label="item.roleName" :value="item.id" />
+                    </el-select>
+                </div>
+                <div class="ml-14px w-200px">
+                    <el-select v-model="postId" filterable clearable block placeholder="选择岗位" @change="searchPostClick">
+                        <el-option v-for="item in postList" :key="item.id" :label="item.roleName" :value="item.id" />
+                    </el-select>
+                </div>
+            </template>
+            <template #extra>
+                <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="primary" @click="copyRowClick(row)">复制</el-link>
+                    <el-link type="warning" @click="resetRowClick(row)">重置密码</el-link>
+                    <el-link type="danger" @click="delRowClick(row)">删除</el-link>
+                </template>
+            </hc-table>
+            <template #action>
+                <hc-pages :pages="searchForm" @change="pageChange" />
+            </template>
+        </hc-card>
+        <div class="action">
+            <el-button hc-btn class="mr-4" @click="saveAndExit">保存并退出</el-button>
+            <el-button hc-btn type="primary" @click="saveAndBackStep">保存并返回上一步</el-button>
+        </div>
+    </div>
+</template>
+
+<script setup>
+import { onMounted, ref, watch } from 'vue'
+import { useRouter } from 'vue-router'
+import { NewDelMsg } from 'hc-vue3-ui'
+import { arrToId, deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
+import { getBizDictionary } from '~api/other'
+import projectApi from '~api/project/project'
+import contractApi from '~api/project/contract'
+
+const props = defineProps({
+    data: {
+        type: Object,
+        default: () => ({}),
+    },
+})
+
+//事件
+const emit = defineEmits(['close', 'back'])
+
+//路由
+const router = useRouter()
+
+//监听数据
+const dataInfo = ref(props.data)
+watch(() => props.data, (data) => {
+    dataInfo.value = data
+    getDataApi()
+}, { deep: true })
+
+//渲染完成
+onMounted(() => {
+    getDataApi()
+})
+
+//获取数据
+const getDataApi = () => {
+    getRoleList()
+    getUserData()
+}
+
+//搜索表单
+const searchForm = ref({ rId: '', current: 1, size: 30, total: 0 })
+
+//获取合同段数据
+const rId = ref('')
+const roleName = ref('')
+const roleList = ref([])
+const getRoleList = async () => {
+    const { data } = await contractApi.searchRole()
+    const res = getArrValue(data)
+    roleList.value = res
+    if (res.length > 0) {
+        rId.value = res[0].id
+        roleName.value = res[0].roleName
+    } else {
+        rId.value = ''
+    }
+    await setRolePostData()
+}
+
+//处理角色岗位
+const postId = ref('')
+const postList = ref([])
+const setRolePostData = async () => {
+    postId.value = ''
+    postList.value = []
+    if (isNullES(rId.value)) return
+    const arr = roleList.value
+    const res = arr.find((item) => item.id === rId.value)
+    const obj = deepClone(getObjValue(res))
+    postList.value = getArrValue(obj.children)
+    if (obj.roleName === '超级管理员') {
+        searchForm.value.rId = obj.id
+        searchClick()
+    }
+}
+
+//岗位搜索
+const searchPostClick = () => {
+    searchForm.value.rId = deepClone(postId.value)
+    searchClick()
+}
+
+//搜索
+const searchClick = () => {
+    searchForm.value.current = 1
+    getTableData()
+}
+
+//分页
+const pageChange = ({ current, size }) => {
+    searchForm.value.current = current
+    searchForm.value.size = size
+    getTableData()
+}
+
+//表格数据
+const tableColumn = ref([
+    { key: 'name', name: '姓名' },
+    { key: 'account', name: '登录账号' },
+    { key: 'password', name: '密码' },
+    { key: 'action', name: '操作', width: 160, align: 'center' },
+])
+const tableData = ref([])
+
+//获取表格数据
+const tableLoading = ref(false)
+const getTableData = async () => {
+    tableData.value = []
+    tableLoading.value = true
+    const { pid, cid } = getObjValue(dataInfo.value)
+    const { data } = await contractApi.findUserByCondition({
+        ...searchForm.value,
+        pId: pid,
+        cId: cid,
+    })
+    tableLoading.value = false
+    tableData.value = getArrValue(data?.records)
+    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 = () => {
+    router.push({
+        path: '/system/user',
+        query: { type: 'add' },
+    })
+}
+
+//复制
+const copyRowClick = (row) => {
+
+}
+
+//重置密码
+const resetRowClick = (row) => {
+
+}
+
+//全部删除
+const allDelClick = () => {
+    const data = tableData.value
+    if (data.length <= 0) {
+        window?.$message?.warning('暂无用户数据')
+        return
+    }
+    NewDelMsg({
+        text: '是否将所有用户移除出合同段?',
+    }, async (resolve) => {
+        const ids = arrToId(data)
+        const { code } = await contractApi.removeUsersByIds(ids)
+        resolve() //关闭弹窗的回调
+        if (code === 200) {
+            window?.$message?.success('删除成功')
+            getTableData().then()
+        }
+    })
+}
+
+//单独删除
+const delRowClick = (row) => {
+    NewDelMsg({
+        text: '是否将该用户移除出合同段?',
+    }, async (resolve) => {
+        const { code } = await contractApi.removeUsersByIds(row.id)
+        resolve() //关闭弹窗的回调
+        if (code === 200) {
+            window?.$message?.success('删除成功')
+            getTableData().then()
+        }
+    })
+}
+
+//保存并退出
+const saveAndExit = async () => {
+    emit('close', dataInfo.value)
+}
+
+//保存并返回上一步
+const saveAndBackStep = async () => {
+    emit('back', dataInfo.value)
+}
+</script>
+
+<style lang="scss">
+.hc-contract-info-user {
+    .hc-div-new-card-box.hc-full {
+        height: calc(100% - 55px);
+    }
+    .el-card.hc-card-box.hc-new-card-box {
+        box-shadow: none;
+    }
+    .action {
+        position: fixed;
+        bottom: 14px;
+        width: calc(100% - 240px);
+        text-align: center;
+        background: #fff;
+        padding: 14px 0;
+    }
+}
+</style>

+ 16 - 4
src/views/project/detail/wbs.vue

@@ -301,28 +301,40 @@ const getIds = async (ids, data) => {
 const saveAndExit = async () => {
     const isRes = await saveDataApi()
     if (!isRes) return
-    ///emit('close', dataInfo.value)
+    emit('close', dataInfo.value)
 }
 
 //保存并返回上一步
 const saveAndBackStep = async () => {
     const isRes = await saveDataApi()
     if (!isRes) return
-    //emit('back', dataInfo.value)
+    emit('back', dataInfo.value)
 }
 
 //保存并进入下一步
 const saveAndNextStep = async () => {
     const isRes = await saveDataApi()
     if (!isRes) return
-    //emit('next', dataInfo.value)
+    emit('next', dataInfo.value)
 }
 
 //保存
 const submitLoading = ref(false)
 const saveDataApi = async () => {
+    submitLoading.value = true
     const ids = await getTreeAllId('right')
-    console.log(ids)
+    const { pid, cid } = getObjValue(dataInfo.value)
+    const { code } = contractApi.submitWbsTreeInContract({
+        wbsId: wbsId.value,
+        projectId: pid,
+        contractId: cid,
+        wbsTreeIds: ids,
+    })
+    submitLoading.value = false
+    if (code === 200) {
+        window?.$message?.success('保存成功')
+    }
+    return code === 200
 }
 </script>