mirror of
https://github.com/yudaocode/yudao-ui-admin-vue3.git
synced 2026-05-03 18:04:36 +00:00
feat: 代码评审修改
This commit is contained in:
@@ -3,7 +3,9 @@ import * as ProcessInstanceApi from '@/api/bpm/processInstance'
|
|||||||
import { useUserStore } from '@/store/modules/user'
|
import { useUserStore } from '@/store/modules/user'
|
||||||
import { formatDate } from '@/utils/formatTime'
|
import { formatDate } from '@/utils/formatTime'
|
||||||
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
||||||
import { decodeFields } from '@/utils/formCreate'
|
import { decodeFields, setConfAndFields2 } from '@/utils/formCreate'
|
||||||
|
import type { ApiAttrs } from '@form-create/element-ui/types/config'
|
||||||
|
import formCreate from "@form-create/element-ui";
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
@@ -16,6 +18,21 @@ const printTime = ref(formatDate(new Date(), 'YYYY-MM-DD HH:mm'))
|
|||||||
const formFields = ref()
|
const formFields = ref()
|
||||||
const printDataMap = ref({})
|
const printDataMap = ref({})
|
||||||
|
|
||||||
|
const fApi = ref<ApiAttrs>()
|
||||||
|
const detailForm = ref({
|
||||||
|
rule: [],
|
||||||
|
option: {},
|
||||||
|
value: {}
|
||||||
|
})
|
||||||
|
|
||||||
|
const fApiH = ref<ApiAttrs>()
|
||||||
|
const detailFormH = ref({
|
||||||
|
rule: [],
|
||||||
|
option: {},
|
||||||
|
value: {}
|
||||||
|
})
|
||||||
|
const fcRef = ref()
|
||||||
|
|
||||||
const open = async (id: string) => {
|
const open = async (id: string) => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
@@ -30,9 +47,38 @@ const open = async (id: string) => {
|
|||||||
defineExpose({ open })
|
defineExpose({ open })
|
||||||
|
|
||||||
const parseFormFields = () => {
|
const parseFormFields = () => {
|
||||||
|
const processInstance = printData.value.processInstance
|
||||||
|
const processDefinition = processInstance.processDefinition
|
||||||
|
setConfAndFields2(
|
||||||
|
detailForm,
|
||||||
|
processDefinition.formConf,
|
||||||
|
processDefinition.formFields,
|
||||||
|
processInstance.formVariables
|
||||||
|
)
|
||||||
|
detailForm.value.option = {
|
||||||
|
submitBtn: false,
|
||||||
|
resetBtn: false,
|
||||||
|
form: {
|
||||||
|
disabled: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setConfAndFields2(
|
||||||
|
detailFormH,
|
||||||
|
processDefinition.formConf,
|
||||||
|
processDefinition.formFields,
|
||||||
|
processInstance.formVariables
|
||||||
|
)
|
||||||
|
detailFormH.value.option = {
|
||||||
|
submitBtn: false,
|
||||||
|
resetBtn: false,
|
||||||
|
form: {
|
||||||
|
disabled: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
// TODO @lesan:form field 有可能基于 form-create 什么 api 生成么?好像也挺难的 = =
|
// TODO @lesan:form field 有可能基于 form-create 什么 api 生成么?好像也挺难的 = =
|
||||||
const formFieldsObj = decodeFields(printData.value.formFields)
|
const formFieldsObj = decodeFields(printData.value.formFields)
|
||||||
const processVariables = printData.value.processVariables
|
const processVariables = printData.value.processInstance.formVariables
|
||||||
let res: any = []
|
let res: any = []
|
||||||
for (const item of formFieldsObj) {
|
for (const item of formFieldsObj) {
|
||||||
const id = item['field']
|
const id = item['field']
|
||||||
@@ -40,6 +86,7 @@ const parseFormFields = () => {
|
|||||||
let html = '暂不支持此类型的表单展示'
|
let html = '暂不支持此类型的表单展示'
|
||||||
// TODO 完善各类型表单的展示
|
// TODO 完善各类型表单的展示
|
||||||
// TODO @lesan:要不 UploadImg、UploadFile 特殊处理下,其它就 else processVariables[item['field']]?
|
// TODO @lesan:要不 UploadImg、UploadFile 特殊处理下,其它就 else processVariables[item['field']]?
|
||||||
|
// TODO @芋艿:感觉很多都要处理一下,select那些都要转为可读的label,还有子表单那些,都需要处理一下...
|
||||||
if (item['type'] === 'input') {
|
if (item['type'] === 'input') {
|
||||||
html = processVariables[item['field']]
|
html = processVariables[item['field']]
|
||||||
} else if (item['type'] === 'UploadImg') {
|
} else if (item['type'] === 'UploadImg') {
|
||||||
@@ -52,15 +99,15 @@ const parseFormFields = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const initPrintDataMap = () => {
|
const initPrintDataMap = () => {
|
||||||
printDataMap.value['startUser'] = printData.value.startUser.nickname
|
printDataMap.value['startUser'] = printData.value.processInstance.startUser.nickname
|
||||||
printDataMap.value['startUserDept'] = printData.value.startUser.deptName
|
printDataMap.value['startUserDept'] = printData.value.processInstance.startUser.deptName
|
||||||
printDataMap.value['processName'] = printData.value.processName
|
printDataMap.value['processName'] = printData.value.processInstance.name
|
||||||
printDataMap.value['processNum'] = printData.value.processInstanceId
|
printDataMap.value['processNum'] = printData.value.processInstance.id
|
||||||
printDataMap.value['startTime'] = printData.value.startTime
|
printDataMap.value['startTime'] = formatDate(printData.value.processInstance.startTime)
|
||||||
printDataMap.value['endTime'] = printData.value.endTime
|
printDataMap.value['endTime'] = formatDate(printData.value.processInstance.endTime)
|
||||||
printDataMap.value['processStatus'] = getDictLabel(
|
printDataMap.value['processStatus'] = getDictLabel(
|
||||||
DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS,
|
DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS,
|
||||||
printData.value.processStatus
|
printData.value.processInstance.status
|
||||||
)
|
)
|
||||||
printDataMap.value['printUsername'] = userName.value
|
printDataMap.value['printUsername'] = userName.value
|
||||||
printDataMap.value['printTime'] = printTime.value
|
printDataMap.value['printTime'] = printTime.value
|
||||||
@@ -96,12 +143,12 @@ const getPrintTemplateHTML = () => {
|
|||||||
headTd.innerHTML = '流程节点'
|
headTd.innerHTML = '流程节点'
|
||||||
headTr.appendChild(headTd)
|
headTr.appendChild(headTd)
|
||||||
processRecordTable.appendChild(headTr)
|
processRecordTable.appendChild(headTr)
|
||||||
printData.value.approveNodes.forEach((item) => {
|
printData.value.tasks.forEach((item) => {
|
||||||
const tr = document.createElement('tr')
|
const tr = document.createElement('tr')
|
||||||
const td1 = document.createElement('td')
|
const td1 = document.createElement('td')
|
||||||
td1.innerHTML = item.nodeName
|
td1.innerHTML = item.name
|
||||||
const td2 = document.createElement('td')
|
const td2 = document.createElement('td')
|
||||||
td2.innerHTML = item.nodeDesc
|
td2.innerHTML = item.description
|
||||||
tr.appendChild(td1)
|
tr.appendChild(td1)
|
||||||
tr.appendChild(td2)
|
tr.appendChild(td2)
|
||||||
processRecordTable.appendChild(tr)
|
processRecordTable.appendChild(tr)
|
||||||
@@ -114,6 +161,25 @@ const getPrintTemplateHTML = () => {
|
|||||||
return doc.body.innerHTML
|
return doc.body.innerHTML
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const html = ref('')
|
||||||
|
const handleDialogOpened = async () => {
|
||||||
|
const processInstance = printData.value.processInstance
|
||||||
|
const processDefinition = processInstance.processDefinition
|
||||||
|
let fcData = {
|
||||||
|
rule: [],
|
||||||
|
option: {},
|
||||||
|
value: {}
|
||||||
|
}
|
||||||
|
setConfAndFields2(
|
||||||
|
fcData,
|
||||||
|
processDefinition.formConf,
|
||||||
|
processDefinition.formFields,
|
||||||
|
processInstance.formVariables
|
||||||
|
)
|
||||||
|
const api = formCreate.create(fcData.rule,fcData.option)
|
||||||
|
console.log(api)
|
||||||
|
}
|
||||||
|
|
||||||
const printObj = ref({
|
const printObj = ref({
|
||||||
id: 'printDivTag',
|
id: 'printDivTag',
|
||||||
popTitle: ' ',
|
popTitle: ' ',
|
||||||
@@ -128,26 +194,31 @@ const printObj = ref({
|
|||||||
<div id="printDivTag">
|
<div id="printDivTag">
|
||||||
<div v-if="printData.printTemplateEnable" v-html="getPrintTemplateHTML()"></div>
|
<div v-if="printData.printTemplateEnable" v-html="getPrintTemplateHTML()"></div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<h2 class="text-center">{{ printData.processName }}</h2>
|
<h2 class="text-center">{{ printData.processInstance.name }}</h2>
|
||||||
<div class="text-right text-15px">{{ '打印人员: ' + userName }}</div>
|
<div class="text-right text-15px">{{ '打印人员: ' + userName }}</div>
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<div class="text-15px">{{ '流程编号: ' + printData.processInstanceId }}</div>
|
<div class="text-15px">{{ '流程编号: ' + printData.processInstance.id }}</div>
|
||||||
<div class="text-15px">{{ '打印时间: ' + printTime }}</div>
|
<div class="text-15px">{{ '打印时间: ' + printTime }}</div>
|
||||||
</div>
|
</div>
|
||||||
<table class="mt-20px w-100%" border="1" style="border-collapse: collapse">
|
<table class="mt-20px w-100%" border="1" style="border-collapse: collapse">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="p-5px w-25%">发起人</td>
|
<td class="p-5px w-25%">发起人</td>
|
||||||
<td class="p-5px w-25%">{{ printData.startUser.nickname }}</td>
|
<td class="p-5px w-25%">{{ printData.processInstance.startUser.nickname }}</td>
|
||||||
<td class="p-5px w-25%">发起时间</td>
|
<td class="p-5px w-25%">发起时间</td>
|
||||||
<td class="p-5px w-25%">{{ printData.startTime }}</td>
|
<td class="p-5px w-25%">{{ formatDate(printData.processInstance.startTime) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="p-5px w-25%">所属部门</td>
|
<td class="p-5px w-25%">所属部门</td>
|
||||||
<td class="p-5px w-25%">{{ printData.startUser.deptName }}</td>
|
<td class="p-5px w-25%">{{ printData.processInstance.startUser.deptName }}</td>
|
||||||
<td class="p-5px w-25%">流程状态</td>
|
<td class="p-5px w-25%">流程状态</td>
|
||||||
<td class="p-5px w-25%">
|
<td class="p-5px w-25%">
|
||||||
{{ getDictLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS, printData.processStatus) }}
|
{{
|
||||||
|
getDictLabel(
|
||||||
|
DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS,
|
||||||
|
printData.processInstance.status
|
||||||
|
)
|
||||||
|
}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -155,12 +226,14 @@ const printObj = ref({
|
|||||||
<h4>表单内容</h4>
|
<h4>表单内容</h4>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="item in formFields" :key="item.id">
|
<tr>
|
||||||
<td class="p-5px w-20%">
|
<td class="p-5px w-100% text-center" colspan="4">
|
||||||
{{ item.name }}
|
<form-create
|
||||||
</td>
|
v-model="detailForm.value"
|
||||||
<td class="p-5px w-80%" colspan="3">
|
v-model:api="fApi"
|
||||||
<div v-html="item.html"></div>
|
:option="detailForm.option"
|
||||||
|
:rule="detailForm.rule"
|
||||||
|
/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -168,12 +241,12 @@ const printObj = ref({
|
|||||||
<h4>流程节点</h4>
|
<h4>流程节点</h4>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="item in printData.approveNodes" :key="item.nodeId">
|
<tr v-for="item in printData.tasks" :key="item.id">
|
||||||
<td class="p-5px w-20%">
|
<td class="p-5px w-20%">
|
||||||
{{ item.nodeName }}
|
{{ item.name }}
|
||||||
</td>
|
</td>
|
||||||
<td class="p-5px w-80%" colspan="3">
|
<td class="p-5px w-80%" colspan="3">
|
||||||
{{ item.nodeDesc }}
|
{{ item.description }}
|
||||||
<div v-if="item.signUrl !== ''">
|
<div v-if="item.signUrl !== ''">
|
||||||
<img class="w-90px h-40px" :src="item.signUrl" alt="" />
|
<img class="w-90px h-40px" :src="item.signUrl" alt="" />
|
||||||
</div>
|
</div>
|
||||||
@@ -185,7 +258,7 @@ const printObj = ref({
|
|||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button @click="visible = false">取 消</el-button>
|
<el-button @click="handleDialogOpened">取 消</el-button>
|
||||||
<el-button type="primary" v-print="printObj"> 打 印</el-button>
|
<el-button type="primary" v-print="printObj"> 打 印</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user