process-modal.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <hc-dialog v-model="isShow" ui="hc-tasks-user-process-modal" widths="800px" title="流程设置" @close="modalClose">
  3. <hc-table
  4. ref="tableRef" :column="tableColumn" :datas="tableData" ui="hc-tasks-process-drop-table"
  5. is-row-drop quick-sort is-sort @row-drop="rowDropTap" @row-sort="rowSortTap"
  6. >
  7. <template #name="{ row }">
  8. <hc-table-input v-model="row.name" size="small" />
  9. </template>
  10. <template #flowTaskType="{ row }">
  11. <el-select v-model="row.flowTaskType" size="small" filterable block>
  12. <template v-if="flowTaskTypeData.length > 0">
  13. <el-option v-for="item in flowTaskTypeData" :key="item.value" :label="item.label" :value="item.value" />
  14. </template>
  15. <el-option v-else label="普通流程" :value="1" />
  16. </el-select>
  17. </template>
  18. <template #type="{ row }">
  19. <el-select v-model="row.type" size="small" filterable block>
  20. <el-option label="流程审批" :value="1" />
  21. <el-option label="平行审批" :value="2" />
  22. </el-select>
  23. </template>
  24. <template #action="{ row, index }">
  25. <el-link type="danger" @click="delRowClick(row, index)">删除</el-link>
  26. </template>
  27. </hc-table>
  28. <template #footer>
  29. <el-button @click="modalClose">取消</el-button>
  30. <el-button type="primary" @click="confirmClick">确定</el-button>
  31. </template>
  32. </hc-dialog>
  33. </template>
  34. <script setup>
  35. import { nextTick, ref, watch } from 'vue'
  36. import { HcDelMsg } from 'hc-vue3-ui'
  37. import { deepClone, getArrValue } from 'js-fast-way'
  38. import { getDictionaryData } from '~uti/tools'
  39. const props = defineProps({
  40. data: {
  41. type: Array,
  42. default: () => ([]),
  43. },
  44. })
  45. const emit = defineEmits(['finish', 'close'])
  46. //双向绑定
  47. const isShow = defineModel('modelValue', {
  48. default: false,
  49. })
  50. //监听数据
  51. const fixedData = ref([])
  52. watch(() => props.data, (data) => {
  53. const res = getArrValue(data)
  54. fixedData.value = deepClone(res)
  55. }, { deep: true, immediate: true })
  56. watch(isShow, (val) => {
  57. if (val) setInitData()
  58. })
  59. //表格
  60. const tableRef = ref(null)
  61. const tableColumn = [
  62. { key: 'name', name: '名称' },
  63. { key: 'flowTaskType', name: '流程类型', width: 120 },
  64. { key: 'type', name: '审批类型', width: 120 },
  65. { key: 'action', name: '操作', width: 70, align: 'center' },
  66. ]
  67. const tableData = ref([])
  68. //初始化
  69. const setInitData = async () => {
  70. await nextTick()
  71. tableData.value = getArrValue(fixedData.value)
  72. getFlowTaskTypeData().then()
  73. }
  74. //获取流程类型
  75. const flowTaskTypeData = ref([])
  76. const getFlowTaskTypeData = async () => {
  77. flowTaskTypeData.value = await getDictionaryData('flow_task_type', true)
  78. }
  79. //删除数据
  80. const delRowClick = (item, index) => {
  81. HcDelMsg({
  82. title: '确认删除任务流程?',
  83. text: `确认是否需要删除【${item.name}】?`,
  84. }, (resolve) => {
  85. tableData.value?.splice(index, 1)
  86. resolve()
  87. })
  88. }
  89. // 行拖拽
  90. const rowDropTap = async (rows) => {
  91. // 先清空,否则排序会异常
  92. tableData.value = []
  93. await nextTick()
  94. tableRef.value?.setData(rows)
  95. }
  96. // 点击排序
  97. const rowSortTap = async (rows) => {
  98. // 先清空,否则排序会异常
  99. tableData.value = []
  100. await nextTick()
  101. tableData.value = rows
  102. }
  103. //确定选择
  104. const confirmClick = async () => {
  105. const list = deepClone(tableData.value)
  106. emit('finish', list)
  107. modalClose()
  108. }
  109. //关闭窗口
  110. const modalClose = () => {
  111. isShow.value = false
  112. emit('close')
  113. }
  114. </script>