ZaiZai 1 year ago
parent
commit
9c1d31655a

+ 47 - 28
src/components/hc-report/hc-report.vue

@@ -1,11 +1,20 @@
 <template>
-    <hc-new-dialog widths="600px" bg-color="#fff" :show="isShow" title="流程上报" :loading="formReportLoading" is-row-footer @save="modalSave" @close="modalClose">
-        <el-form ref="formRef" class="p-4" :model="formModel" :rules="formRules" label-position="left" label-width="auto" size="large">
+    <hc-new-dialog
+        widths="600px" bg-color="#fff" :show="isShow" title="流程上报" :loading="formReportLoading"
+        is-row-footer @save="modalSave" @close="modalClose"
+    >
+        <el-form
+            ref="formRef" class="p-4" :model="formModel" :rules="formRules" label-position="left"
+            label-width="auto" size="large"
+        >
             <el-form-item label="任务名称:" prop="taskName">
                 <el-input v-model="formModel.taskName" disabled />
             </el-form-item>
             <el-form-item label="任务描述:">
-                <el-input v-model="formModel.taskDesc" :autosize="{ minRows: 3, maxRows: 5 }" placeholder="请输入任务描述" type="textarea" />
+                <el-input
+                    v-model="formModel.taskDesc" :autosize="{ minRows: 3, maxRows: 5 }"
+                    placeholder="请输入任务描述" type="textarea"
+                />
             </el-form-item>
             <el-form-item v-if="isBuildAudit" label="审计意见:" prop="isBuildAudit">
                 <el-radio-group v-model="formModel.isBuildAudit">
@@ -16,12 +25,14 @@
             <el-form-item label="任务流程:" prop="fixedFlowId">
                 <el-select v-model="formModel.fixedFlowId" block @change="handleProcessValue">
                     <el-option v-for="item in processData" :key="item.id" :disabled="item.disabled" :value="item.id" :label="item.fixedFlowName">
-                        <el-tooltip v-if="item.tips && item.disabled" class="box-item" effect="light" :content="item.tips " placement="right-end">{{ item.fixedFlowName }}</el-tooltip>
+                        <el-tooltip v-if="item.tips && item.disabled" class="box-item" effect="light" :content="item.tips " placement="right-end">
+                            {{ item.fixedFlowName }}
+                        </el-tooltip>
                     </el-option>
                 </el-select>
             </el-form-item>
             <el-form-item v-if="diyProcessUser" label="任务人:" prop="taskUserIds">
-                <hc-tasks-user ui="w-full" :project-id="projectId" :contract-id="contractId" :is-show-task-name="false" @change="diyProcessUserChange" />
+                <HcReportTasksUser ui="w-full" :data="tasksUserData" @change="diyProcessUserChange" />
             </el-form-item>
             <el-form-item v-else label="任务人:">
                 <div class="form-item-div" style="height: auto;">{{ linkUserJoinString }}</div>
@@ -44,7 +55,8 @@
 
 <script setup>
 import { ref, watch } from 'vue'
-import { arrIndex, arrToKey, formValidate, getArrValue, getObjValue } from 'js-fast-way'
+import { arrIndex, formValidate, getArrValue, getObjValue } from 'js-fast-way'
+import HcReportTasksUser from './modules/index.vue'
 import { useAppStore } from '~src/store'
 import mainApi from '~api/tasks/flow'
 
@@ -86,11 +98,22 @@ watch(() => props.info, (obj) => {
 //监听
 watch(isShow, (val) => {
     if (val) {
-        getProcessData()
-        getReportTaskName()
+        setInitData()
+
     }
 })
 
+//任务人
+const tasksUserData = ref({})
+const setInitData = () => {
+    tasksUserData.value = {
+        projectId: projectId.value,
+        contractId: contractId.value,
+    }
+    getProcessData()
+    getReportTaskName()
+}
+
 //获取任务名称
 const getReportTaskName = async () => {
     const { periodId, type } = reportInfo.value
@@ -127,31 +150,26 @@ const getProcessData = async () => {
     }
 }
 //获取流程详情
-const getFixedFlowDetail = async (id)=>{
+const getFixedFlowDetail = async (id) => {
     const { error, code, data } = await mainApi.queryFixedFlowDetail({ id: id })
     if (!error && code === 200) {
         let users = '', res = getObjValue(data)
         const list = getArrValue(res['fixedBranchVOList'])
-                console.log(list, 'list')
-            for (let index = 0; index < list.length; index++) {
-                const element = list[index]
-                const item = getArrValue(element['userList'])
-                for (let index1 = 0; index1 < item.length; index1++) {
-                    const element1 = item[index1]
-                         if (users) {
-                                users += `,${element1['userName']}`
-                        } else {
-                        users = `${element1['userName']}`
-                    }
-
+        console.log(list, 'list')
+        for (let index = 0; index < list.length; index++) {
+            const element = list[index]
+            const item = getArrValue(element['userList'])
+            for (let index1 = 0; index1 < item.length; index1++) {
+                const element1 = item[index1]
+                if (users) {
+                    users += `,${element1['userName']}`
+                } else {
+                    users = `${element1['userName']}`
                 }
             }
-
-            linkUserJoinString.value = users
         }
-
-
-
+        linkUserJoinString.value = users
+    }
 }
 
 //基础变量
@@ -192,8 +210,9 @@ const handleProcessValue = (val) => {
 }
 
 //自定义流程任务人选择完毕
-const diyProcessUserChange = (user) => {
-    formModel.value.taskUserIds = arrToKey(user, 'userId', ',')
+const diyProcessUserChange = (ids) => {
+    console.log(ids)
+    formModel.value.taskUserIds = ids
 }
 
 //保存

+ 212 - 0
src/components/hc-report/modules/index.scss

@@ -0,0 +1,212 @@
+.hc-report-tasks-user-box {
+    position: relative;
+    padding: 0 12px;
+    cursor: pointer;
+    min-height: 40px;
+    border: 1px solid #e0e0e6;
+    border-radius: 4px;
+    .tag-user-list {
+        position: relative;
+        display: flex;
+        align-items: center;
+        flex-flow: row wrap;
+        min-height: inherit;
+        .tasks-placeholder {
+            color: #a9abb2;
+            font-size: 14px;
+        }
+        .arrow-icon-tag {
+            position: relative;
+            color: #a9abb2;
+            font-size: 18px;
+            margin: 0 8px;
+        }
+    }
+}
+
+//选择任务人弹窗
+.el-overlay-dialog .el-dialog.hc-report-tasks-user-modal {
+    height: 650px;
+    .el-dialog__body {
+        padding: 0;
+        height: 100%;
+        display: flex;
+    }
+    .card-div-no, .card-empty-no {
+        position: relative;
+        border-left: 1px solid;
+        border-color: #EEEEEE;
+        background: #e8e8e8;
+    }
+    .card-div-no .hc-empty-box .hc-empty-body .hc-empty-title,
+    .card-empty-no .hc-empty-box .hc-empty-body .hc-empty-title {
+        color: #777777;
+    }
+    .card-empty-no {
+        height: 100%;
+        border-left: 0;
+    }
+    .card-empty-no .hc-empty-box .hc-empty-body .hc-empty-assets {
+        display: none;
+    }
+    .card-div-2 {
+        position: relative;
+        border-left: 1px solid;
+        border-color: #EEEEEE;
+    }
+    .card-div-3 {
+        position: relative;
+        border-left: 1px solid;
+        border-color: #EEEEEE;
+    }
+    .card-div-4 {
+        position: relative;
+        border-left: 1px solid;
+        border-color: #EEEEEE;
+    }
+    .card-div-5 {
+        position: relative;
+        border-left: 1px solid;
+        border-right: 1px solid;
+        border-color: #EEEEEE;
+    }
+    //卡片
+    .el-card.hc-card-box.hc-new-card-box {
+        box-shadow: none;
+        --el-card-border-radius: 0;
+        --el-card-bg-color: transparent;
+        .el-scrollbar__bar.is-vertical {
+            right: -8px;
+        }
+    }
+    //角色类型
+    .hc-tasks-user-role-item {
+        position: relative;
+        color: #1F222A;
+        background: white;
+        cursor: pointer;
+        padding: 6px 10px;
+        border-radius: 3px;
+        transition: all .2s;
+        display: flex;
+        align-items: center;
+        i {
+            font-size: 18px;
+            display: inline-block;
+        }
+        &:hover {
+            color: #3A85E9;
+            background: #f2f3f5;
+        }
+        &.cur {
+            color: #3A85E9;
+            background: #EDF3FF;
+        }
+    }
+    //人员列表
+    .hc-tasks-user-sign-pfx-box {
+        position: relative;
+        padding-right: 8px;
+        height: 100%;
+        .el-scrollbar__bar.is-vertical {
+            right: 2px;
+        }
+    }
+    .hc-sign-pfx-file-item {
+        position: relative;
+        background: #f7f7f7;
+        .hc-tasks-user-letter {
+            position: relative;
+            font-weight: bold;
+            padding: 6px 6px;
+            border-bottom: 1px solid #eee;
+        }
+        .hc-tasks-user-item {
+            position: relative;
+            color: #1F222A;
+            background: white;
+            cursor: pointer;
+            padding: 6px 6px;
+            border-radius: 3px;
+            transition: all .2s;
+            display: flex;
+            align-items: center;
+            i {
+                font-size: 16px;
+                display: inline-block;
+            }
+            &:hover {
+                color: #3A85E9;
+                background: #f2f3f5;
+            }
+            &.cur {
+                color: #3A85E9;
+                background: #EDF3FF;
+            }
+        }
+    }
+    //字母索引
+    .hc-tasks-user-letter-index {
+        position: absolute;
+        right: -8px;
+        top: 0;
+        bottom: 0;
+        width: 13px;
+        display: flex;
+        align-items: center;
+        flex-wrap: wrap;
+        color: #5f5e5e;
+        .item {
+            position: relative;
+            flex: 13px;
+            width: 13px;
+            height: 13px;
+            font-size: 12px;
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            cursor: pointer;
+            transition: all .2s;
+            &:hover {
+                color: #0a84ff;
+            }
+        }
+    }
+    //已选择列表
+    .hc-tasks-user-cur-box {
+        position: relative;
+        .hc-tasks-user-item {
+            position: relative;
+            margin-top: 18px;
+        }
+        .hc-tasks-user-item:first-child {
+            margin-top: 0;
+        }
+        &.type-1 {
+            .hc-tasks-user-item + .hc-tasks-user-item {
+                &::before{
+                    content: "";
+                    position: absolute;
+                    background: #BBBBBB;
+                    top: -18px;
+                    height: 18px;
+                    width: 1px;
+                    left: 18px;
+                }
+            }
+        }
+        .el-tag {
+            --el-tag-bg-color: #D7E6FB;
+            --el-tag-border-color: #AECCEE;
+            --el-tag-hover-color: var(--el-color-primary);
+            .el-tag__content {
+                display: flex;
+                align-items: center;
+                i {
+                    font-size: 14px;
+                    display: inline-block;
+                }
+            }
+        }
+    }
+}

+ 59 - 0
src/components/hc-report/modules/index.vue

@@ -0,0 +1,59 @@
+<template>
+    <div :class="ui" class="hc-report-tasks-user-box">
+        <div class="tag-user-list" @click="userShowModal">
+            <template v-for="(item, index) in userData" :key="index">
+                <el-tag>{{ item.userName }}</el-tag>
+                <hc-icon v-if="(userData.length - 1) > index" name="arrow-right" ui="arrow-icon-tag" />
+            </template>
+            <div v-if="userData.length <= 0" class="tasks-placeholder">点击这里选择任务人</div>
+        </div>
+        <!-- 选择任务人 -->
+        <HcUserModal v-model="isUserModalShow" :data="userData" :datas="dataInfo" @finish="fixedUserFinish" />
+    </div>
+</template>
+
+<script setup>
+import { ref, watch } from 'vue'
+import { arrToKey, deepClone, getObjValue } from 'js-fast-way'
+import HcUserModal from './user-modal.vue'
+
+//参数
+const props = defineProps({
+    ui: {
+        type: String,
+        default: '',
+    },
+    data: {
+        type: Object,
+        default: () => ({}),
+    },
+})
+
+//事件
+const emit = defineEmits(['change'])
+
+//监听基础数据
+const dataInfo = ref(props.data)
+watch(() => props.data, (data) => {
+    dataInfo.value = getObjValue(data)
+}, { deep: true, immediate: true })
+
+//展开弹窗
+const isUserModalShow = ref(false)
+const userShowModal = () => {
+    isUserModalShow.value = true
+}
+
+//选择完成
+const userData = ref([])
+const fixedUserFinish = (data) => {
+    const res = deepClone(data)
+    userData.value = res
+    const userIds = arrToKey(res, 'userId', ',')
+    emit('change', userIds)
+}
+</script>
+
+<style lang="scss">
+@import './index.scss';
+</style>

+ 80 - 0
src/components/hc-report/modules/sort-modal.vue

@@ -0,0 +1,80 @@
+<template>
+    <hc-dialog v-model="isShow" ui="hc-tasks-user-sort-modal" widths="600px" title="调整任务人顺序" @close="modalClose">
+        <hc-table
+            ref="tableRef" :column="tableColumn" :datas="tableData" ui="hc-tasks-user-sort-drop-table"
+            is-row-drop quick-sort is-sort @row-drop="rowDropTap" @row-sort="rowSortTap"
+        />
+        <template #footer>
+            <el-button @click="modalClose">取消</el-button>
+            <el-button type="primary" @click="confirmClick">确定</el-button>
+        </template>
+    </hc-dialog>
+</template>
+
+<script setup>
+import { nextTick, ref, watch } from 'vue'
+import { deepClone, getArrValue } from 'js-fast-way'
+
+const props = defineProps({
+    data: {
+        type: Array,
+        default: () => ([]),
+    },
+})
+
+const emit = defineEmits(['finish', 'close'])
+
+//双向绑定
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听数据
+const userData = ref([])
+watch(() => props.data, (data) => {
+    const res = getArrValue(data)
+    userData.value = deepClone(res)
+}, { deep: true, immediate: true })
+
+watch(isShow, (val) => {
+    if (val) setInitData()
+})
+
+//表格
+const tableRef = ref(null)
+const tableColumn = [{ key: 'userName', name: '名称' }]
+const tableData = ref([])
+
+//初始化
+const setInitData = async () => {
+    await nextTick()
+    tableData.value = getArrValue(userData.value)
+}
+
+// 行拖拽
+const rowDropTap = async (rows) => {
+    tableData.value = []
+    await nextTick()
+    tableData.value = rows
+}
+
+// 点击排序
+const rowSortTap = async (rows) => {
+    tableData.value = []
+    await nextTick()
+    tableData.value = rows
+}
+
+//确定选择
+const confirmClick = async () => {
+    const list = deepClone(tableData.value)
+    emit('finish', list)
+    modalClose()
+}
+
+//关闭窗口
+const modalClose = () => {
+    isShow.value = false
+    emit('close')
+}
+</script>

+ 273 - 0
src/components/hc-report/modules/user-modal.vue

@@ -0,0 +1,273 @@
+<template>
+    <hc-dialog v-model="isShow" ui="hc-report-tasks-user-modal" widths="960px" title="选择任务人" @close="modalClose">
+        <div class="card-div-2 h-full w-235px">
+            <hc-card scrollbar title="角色类型" :loading="signUserLoading">
+                <template v-for="item in signUserList" :key="item.roleId">
+                    <div class="hc-tasks-user-role-item" :class="{ cur: roleItem.roleId === item.roleId }" @click="roleItemClick(item)">
+                        {{ item.roleName }}
+                    </div>
+                </template>
+            </hc-card>
+        </div>
+        <div class="card-div-3 h-full w-265px">
+            <hc-card v-if="positionList.length > 0" scrollbar>
+                <template #header>
+                    <hc-search-input v-model="positionKey" placeholder="岗位搜索" icon="" @search="positionSearch" />
+                </template>
+                <template v-for="item in positionList" :key="item.roleId">
+                    <div class="hc-tasks-user-role-item" :class="{ cur: positionItem.roleId === item.roleId }" @click="positionItemClick(item)">
+                        <i class="i-ph-user-list-light mr-5px" />
+                        <span>{{ item.roleName }}</span>
+                    </div>
+                </template>
+            </hc-card>
+            <div v-else class="card-empty-no">
+                <hc-empty :src="HcLoadSvg" title="请先选择角色" />
+            </div>
+        </div>
+        <div class="card-div-4 h-full w-235px">
+            <hc-card v-if="signPfxFileList.length > 0">
+                <template #header>
+                    <hc-search-input v-model="signUserKey" placeholder="人员搜索" icon="" @search="signUserSearch" />
+                </template>
+                <div class="hc-tasks-user-sign-pfx-box">
+                    <el-scrollbar ref="scrollRef">
+                        <template v-for="item in signPfxFileList" :key="item.name">
+                            <div v-if="item.data.length > 0" :id="`hc-sign-pfx-file-item-${item.name}`" class="hc-sign-pfx-file-item">
+                                <div class="hc-tasks-user-letter">{{ item.name }}</div>
+                                <template v-for="(items, index) in item.data" :key="index">
+                                    <div class="hc-tasks-user-item" @click="signUserItemClick(items)">
+                                        <i class="i-iconoir-user mr-5px" />
+                                        <span>{{ items.certificateUserName }}</span>
+                                    </div>
+                                </template>
+                            </div>
+                        </template>
+                    </el-scrollbar>
+                </div>
+                <div class="hc-tasks-user-letter-index">
+                    <div v-for="item in alphabet" :key="item" class="item" @click="alphabetClick(item)">{{ item }}</div>
+                </div>
+            </hc-card>
+            <div v-else class="card-empty-no">
+                <hc-empty :src="HcLoadSvg" title="请先选择岗位" />
+            </div>
+        </div>
+        <div class="card-div-5 h-full w-205px">
+            <hc-card v-if="userData.length > 0" scrollbar>
+                <template #header>
+                    <span>已选择{{ userData.length || 0 }}人</span>
+                </template>
+                <template #extra>
+                    <el-button type="warning" size="small" @click="fixedUserSortClick">调整排序</el-button>
+                </template>
+                <div class="hc-tasks-user-cur-box type-1">
+                    <template v-for="(item, index) in userData" :key="index">
+                        <div class="hc-tasks-user-item">
+                            <el-tag closable @close="fixedItemUserListDel(index)">
+                                <i class="i-ri-user-3-fill mr-5px" />
+                                <span>{{ item.userName }}</span>
+                            </el-tag>
+                        </div>
+                    </template>
+                </div>
+            </hc-card>
+            <div v-else class="card-empty-no">
+                <hc-empty :src="HcLoadSvg" title="请先选择人员" />
+            </div>
+        </div>
+        <template #footer>
+            <el-button @click="modalClose">取消</el-button>
+            <el-button type="primary" :loading="confirmLoading" @click="confirmClick">确定</el-button>
+        </template>
+    </hc-dialog>
+    <!-- 任务人排序 -->
+    <HcSortModal v-model="isUserSort" :data="userSortData" @finish="userSortFinish" />
+</template>
+
+<script setup>
+import { nextTick, ref, watch } from 'vue'
+import { pinyin } from 'pinyin-pro'
+import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
+import HcLoadSvg from '~src/assets/view/load.svg'
+import HcSortModal from './sort-modal.vue'
+import mainApi from '~api/tasks/flow'
+
+const props = defineProps({
+    data: {
+        type: Array,
+        default: () => ([]),
+    },
+    datas: {
+        type: Object,
+        default: () => ({}),
+    },
+})
+
+const emit = defineEmits(['finish', 'close'])
+
+//双向绑定
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听参数
+const dataInfo = ref(props.datas)
+watch(() => props.datas, (data) => {
+    dataInfo.value = getObjValue(data)
+}, { deep: true, immediate: true })
+
+//监听数据
+const userData = ref([])
+watch(() => props.data, (data) => {
+    const res = getArrValue(data)
+    userData.value = deepClone(res)
+}, { deep: true, immediate: true })
+
+watch(isShow, (val) => {
+    if (val) setInitData()
+})
+
+//初始化
+const setInitData = async () => {
+    await nextTick()
+    await getAllRoleList()
+    console.log(userData.value)
+}
+
+//角色列表
+const signUserLoading = ref(false)
+const signUserList = ref([])
+const getAllRoleList = async () => {
+    signUserLoading.value = true
+    const { contractId } = getObjValue(dataInfo.value)
+    const { data } = await mainApi.queryAllRoleList({ contractId })
+    signUserList.value = getArrValue(data)
+    signUserLoading.value = false
+}
+
+//角色被点击
+const roleItem = ref({})
+const roleItemClick = (item) => {
+    roleItem.value = item
+    const arr = getArrValue(item.childRoleList)
+    positionList.value = deepClone(arr)
+}
+
+//岗位搜索
+const positionKey = ref('')
+const positionList = ref([])
+const positionSearch = () => {
+    const key = positionKey.value
+    const list = getArrValue(roleItem.value?.childRoleList)
+    const arr = deepClone(list)
+    if (isNullES(key)) {
+        positionList.value = arr
+        return
+    }
+    positionList.value = arr.filter(({ roleName }) => roleName.toLowerCase().includes(key.toLowerCase()))
+}
+
+//岗位被点击
+const positionItem = ref({})
+const positionItemClick = (item) => {
+    positionItem.value = item
+    setSignPfxUser(item.signPfxFileList)
+}
+
+//设置任务人数据
+const alphabet = Array.from({ length: 26 }, (_, i) => String.fromCharCode(65 + i))
+const setSignPfxUser = (data) => {
+    const list = deepClone(data)
+    const arr = getArrValue(list)
+    arr.forEach(item => {
+        item.letter = getFirstLetter(item.certificateUserName)
+    })
+    signPfxFileData.value = deepClone(arr)
+    signPfxFileList.value = alphabet.map(letter => ({
+        name: letter,
+        data: arr.filter(item => item.letter === letter),
+    }))
+}
+
+//中文转姓氏拼音
+const getFirstLetter = (name) => {
+    return pinyin(name.charAt(0), { pattern: 'first', toneType: 'none', surname: 'head' }).charAt(0).toUpperCase()
+}
+
+//搜索任务人
+const signPfxFileData = ref([])
+const signUserKey = ref('')
+const signPfxFileList = ref([])
+const signUserSearch = () => {
+    const key = signUserKey.value
+    const arr = deepClone(signPfxFileData.value)
+    if (isNullES(key)) {
+        setSignPfxUser(arr)
+        return
+    }
+    const letterName = getFirstLetter(key)
+    const filteredData = arr.filter(({ certificateUserName, letter }) => {
+        return certificateUserName.toLowerCase().includes(key.toLowerCase()) || letter.toLowerCase().includes(letterName.toLowerCase())
+    })
+    signPfxFileList.value = alphabet.map(letter => ({
+        name: letter,
+        data: filteredData.filter(item => item.letter === letter),
+    }))
+}
+
+//滚动到相关位置
+const scrollRef = ref(null)
+const alphabetClick = (key) => {
+    const ids = `hc-sign-pfx-file-item-${key}`
+    const dom = document.getElementById(ids)
+    if (isNullES(dom)) return
+    scrollRef.value?.setScrollTop(dom.offsetTop - 20)
+}
+
+//任务人被点击
+const signUserItemClick = ({ certificateUserId, certificateUserName }) => {
+    userData.value.push({ userId: certificateUserId, userName: certificateUserName })
+}
+
+//删除选择的任务人
+const fixedItemUserListDel = (index) => {
+    userData.value.splice(index, 1)
+}
+
+//任务人排序
+const isUserSort = ref(false)
+const userSortData = ref([])
+const fixedUserSortClick = () => {
+    const arr = deepClone(userData.value)
+    if (arr.length <= 0) {
+        window.$message.warning('请先添加任务人')
+        return
+    }
+    userSortData.value = arr
+    isUserSort.value = true
+}
+
+//任务人排序完成
+const userSortFinish = (data) => {
+    userData.value = getArrValue(data)
+}
+
+//确定选择
+const confirmLoading = ref(false)
+const confirmClick = async () => {
+    const list = deepClone(userData.value)
+    if (list.length <= 0) {
+        window.$message.warning('请先添加任务人')
+        return
+    }
+    emit('finish', list)
+    modalClose()
+}
+
+//关闭窗口
+const modalClose = () => {
+    isShow.value = false
+    emit('close')
+}
+</script>