ZaiZai преди 1 година
родител
ревизия
6f1dc97e4e

+ 126 - 0
src/components/hc-tasks-user/modules/process-modal.vue

@@ -0,0 +1,126 @@
+<template>
+    <hc-dialog v-model="isShow" ui="hc-tasks-user-process-modal" widths="800px" title="流程设置" @close="modalClose">
+        <hc-table
+            ref="tableRef" :column="tableColumn" :datas="tableData" ui="hc-tasks-process-drop-table"
+            is-row-drop quick-sort is-sort @row-drop="rowDropTap" @row-sort="rowSortTap"
+        >
+            <template #name="{ row }">
+                <hc-table-input v-model="row.name" size="small" />
+            </template>
+            <template #flowTaskType="{ row }">
+                <el-select v-model="row.flowTaskType" size="small" filterable block>
+                    <el-option v-for="item in flowTaskTypeData" :key="item.value" :label="item.label" :value="item.value" />
+                </el-select>
+            </template>
+            <template #type="{ row }">
+                <el-select v-model="row.type" size="small" filterable block>
+                    <el-option label="流程审批" :value="1" />
+                    <el-option label="平行审批" :value="2" />
+                </el-select>
+            </template>
+            <template #action="{ row, index }">
+                <el-link type="danger" @click="delRowClick(row, index)">删除</el-link>
+            </template>
+        </hc-table>
+        <template #footer>
+            <el-button @click="modalClose">取消</el-button>
+            <el-button type="primary" :loading="confirmLoading" @click="confirmClick">确定</el-button>
+        </template>
+    </hc-dialog>
+</template>
+
+<script setup>
+import { nextTick, ref, watch } from 'vue'
+import { HcDelMsg } from 'hc-vue3-ui'
+import { deepClone, getArrValue } from 'js-fast-way'
+import { getDictionaryData } from '~uti/tools'
+
+const props = defineProps({
+    data: {
+        type: Array,
+        default: () => ([]),
+    },
+})
+
+const emit = defineEmits(['finish', 'close'])
+
+//双向绑定
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听数据
+const fixedData = ref([])
+watch(() => props.data, (data) => {
+    const res = getArrValue(data)
+    fixedData.value = deepClone(res)
+}, { deep: true, immediate: true })
+
+watch(isShow, (val) => {
+    if (val) setInitData()
+})
+
+//表格
+const tableRef = ref(null)
+const tableColumn = [
+    { key: 'name', name: '名称' },
+    { key: 'flowTaskType', name: '流程类型', width: 120 },
+    { key: 'type', name: '审批类型', width: 120 },
+    { key: 'action', name: '操作', width: 70, align: 'center' },
+]
+const tableData = ref([])
+
+//初始化
+const setInitData = async () => {
+    await nextTick()
+    tableData.value = getArrValue(fixedData.value)
+    getFlowTaskTypeData().then()
+}
+
+//获取流程类型
+const flowTaskTypeData = ref([])
+const getFlowTaskTypeData = async () => {
+    flowTaskTypeData.value = await getDictionaryData('flow_task_type', true)
+}
+
+//删除数据
+const delRowClick = (item, index) => {
+    HcDelMsg({
+        title: '确认删除任务流程?',
+        text: `确认是否需要删除【${item.name}】?`,
+    }, (resolve) => {
+        tableData.value?.splice(index, 1)
+        resolve()
+    })
+}
+
+// 行拖拽
+const rowDropTap = async (rows) => {
+    // 先清空,否则排序会异常
+    tableData.value = []
+    await nextTick()
+    tableRef.value?.setData(rows)
+}
+
+// 点击排序
+const rowSortTap = async (rows) => {
+    // 先清空,否则排序会异常
+    tableData.value = []
+    await nextTick()
+    tableData.value = rows
+}
+
+//确定选择
+const confirmLoading = ref(false)
+const confirmClick = async () => {
+    const list = deepClone(tableData.value)
+    emit('finish', list)
+    modalClose()
+}
+
+//关闭窗口
+const modalClose = () => {
+    isShow.value = false
+    emit('close')
+}
+</script>

+ 58 - 0
src/components/hc-tasks-user/modules/sort-modal.vue

@@ -0,0 +1,58 @@
+<template>
+    <hc-dialog v-model="isShow" ui="hc-tasks-user-sort-modal" widths="600px" title="调整任务人顺序" @close="modalClose">
+        111111
+        <template #footer>
+            <el-button @click="modalClose">取消</el-button>
+            <el-button type="primary" :loading="confirmLoading" @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 setInitData = async () => {
+    await nextTick()
+    console.log(userData.value)
+}
+
+//确定选择
+const confirmLoading = ref(false)
+const confirmClick = async () => {
+    emit('finish')
+    modalClose()
+}
+
+//关闭窗口
+const modalClose = () => {
+    isShow.value = false
+    emit('close')
+}
+</script>

+ 50 - 3
src/components/hc-tasks-user/modules/user-modal.vue

@@ -3,7 +3,7 @@
         <div class="card-div-1 h-full w-235px">
             <hc-body scrollbar padding="0">
                 <div class="hc-process-item">
-                    <div class="process setup">
+                    <div class="process setup" @click="processSetupClick">
                         <div class="icon hc-flex-center">
                             <i class="i-hugeicons-flowchart-01" />
                         </div>
@@ -101,7 +101,7 @@
                         <span>已选择{{ fixedItem?.userList?.length || 0 }}人</span>
                     </template>
                     <template #extra>
-                        <el-button type="warning" size="small">调整排序</el-button>
+                        <el-button type="warning" size="small" @click="fixedUserSortClick">调整排序</el-button>
                     </template>
                     <div class="hc-tasks-user-cur-box flex gap-2">
                         <template v-for="(item, index) in fixedItem?.userList" :key="index">
@@ -125,15 +125,21 @@
             <el-button type="primary" :loading="confirmLoading" @click="confirmClick">确定</el-button>
         </template>
     </hc-dialog>
+    <!-- 流程设置 -->
+    <HcProcessModal v-model="isProcessSetup" :data="fixedData" @finish="processSetupFinish" />
+    <!-- 任务人排序 -->
+    <HcSortModal v-model="isUserSort" :data="userSortData" @finish="userSortFinish" />
 </template>
 
 <script setup>
 import { nextTick, ref, watch } from 'vue'
 import { HcDelMsg } from 'hc-vue3-ui'
 import { pinyin } from 'pinyin-pro'
+import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
 import HcLoadSvg from '~src/assets/view/load.svg'
+import HcProcessModal from './process-modal.vue'
+import HcSortModal from './sort-modal.vue'
 import mainApi from '~api/tasks/flow'
-import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
 
 const props = defineProps({
     data: {
@@ -175,6 +181,7 @@ const setInitData = async () => {
     await nextTick()
     fixedData.value.forEach(item => {
         item.isDataSave = true
+        item.flowTaskType = isNullES(item.flowTaskType) ? 1 : item.flowTaskType
     })
 }
 
@@ -202,6 +209,7 @@ const fixedTypeClick = (item) => {
 const fixedAddClick = () => {
     fixedData.value.push({
         type: 1,
+        flowTaskType: 1,
         name: '流程审批名称',
         isDataAdd: true,
         isDataSave: false,
@@ -338,6 +346,45 @@ const singleSaveClick = () => {
     window.$message.success('保存成功,全部完成后,请点击确定')
 }
 
+//流程设置
+const isProcessSetup = ref(false)
+const processSetupClick = () => {
+    const arr = getArrValue(fixedData.value)
+    if (arr.length <= 0) {
+        window.$message.warning('请先创建任务流程')
+        return
+    }
+    isProcessSetup.value = true
+}
+
+//流程设置完成
+const processSetupFinish = (data) => {
+    isProcessSetup.value = false
+    fixedData.value = getArrValue(data)
+    fixedIndex.value = -1
+    fixedItem.value = {}
+}
+
+//任务人排序
+const isUserSort = ref(false)
+const userSortData = ref([])
+const fixedUserSortClick = () => {
+    const arr = fixedData.value, index = fixedIndex.value
+    const list = getArrValue(arr[index]?.userList)
+    if (list.length <= 0) {
+        window.$message.warning('请先添加任务人')
+        return
+    }
+    userSortData.value = list
+    isUserSort.value = true
+}
+
+//任务人排序完成
+const userSortFinish = (data) => {
+    console.log(data)
+}
+
+
 //确定选择
 const confirmLoading = ref(false)
 const confirmClick = async () => {

+ 2 - 2
src/config/index.json

@@ -1,8 +1,8 @@
 {
     "version": "20230607160059",
     "target1": "http://127.0.0.1:8090",
-    "target2": "http://192.168.0.125:8090",
-    "target": "http://39.108.216.210:8090",
+    "target": "http://192.168.0.125:8090",
+    "target3": "http://39.108.216.210:8090",
     "target4": "http://192.168.0.109:8090",
     "target5": "http://192.168.0.102:8090",
     "smsPhone": "",

+ 14 - 7
src/utils/tools.js

@@ -1,5 +1,5 @@
 import { getArrValue } from 'js-fast-way'
-import { getDictionary } from '~api/other'
+import { getDictionary, getDictionaryBiz } from '~api/other'
 
 /**
  * 效验是否为数字或小数的数字
@@ -13,15 +13,22 @@ export const isNumberReg = (text, lose = true) => {
 }
 
 //获取字典数据
-export const getDictionaryData = async (code) => {
-    const { data } = await getDictionary({ code: code })
+export const getDictionaryData = async (code, biz = false) => {
+    let res = []
+    if (biz) {
+        const { data } = await getDictionaryBiz({ code: code })
+        res = getArrValue(data)
+    } else {
+        const { data } = await getDictionary({ code: code })
+        res = getArrValue(data)
+    }
     //处理数据
     let newArr = []
-    const newData = getArrValue(data)
-    for (let i = 0; i < newData.length; i++) {
+    for (let i = 0; i < res.length; i++) {
+        const val = isNumberReg(res[i]['dictKey']) ? Number(res[i]['dictKey']) : res[i]['dictKey']
         newArr.push({
-            label: newData[i]['dictValue'],
-            value: Number(newData[i]['dictKey']),
+            label: res[i]['dictValue'],
+            value: val,
         })
     }
     return newArr