¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="p-2"> |
| | | <el-row :gutter="20"> |
| | | <!-- æµç¨åç±»æ --> |
| | | <el-col :lg="4" :xs="24" style=""> |
| | | <el-card shadow="hover"> |
| | | <el-input v-model="categoryName" placeholder="请è¾å
¥æµç¨åç±»å" prefix-icon="Search" clearable /> |
| | | <el-tree |
| | | ref="categoryTreeRef" |
| | | class="mt-2" |
| | | node-key="id" |
| | | :data="categoryOptions" |
| | | :props="{ label: 'categoryName', children: 'children' }" |
| | | :expand-on-click-node="false" |
| | | :filter-node-method="filterNode" |
| | | highlight-current |
| | | default-expand-all |
| | | @node-click="handleNodeClick" |
| | | ></el-tree> |
| | | </el-card> |
| | | </el-col> |
| | | <el-col :lg="20" :xs="24"> |
| | | <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> |
| | | <div v-show="showSearch" class="mb-[10px]"> |
| | | <el-card shadow="hover"> |
| | | <el-form v-show="showSearch" ref="queryFormRef" :model="queryParams" :inline="true"> |
| | | <el-form-item label="模ååç§°" prop="name"> |
| | | <el-input v-model="queryParams.name" placeholder="请è¾å
¥æ¨¡ååç§°" clearable @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="模åKEY" prop="key"> |
| | | <el-input v-model="queryParams.key" placeholder="请è¾å
¥æ¨¡åKEY" clearable @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">æç´¢</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">éç½®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-card> |
| | | </div> |
| | | </transition> |
| | | <el-card shadow="hover"> |
| | | <template #header> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd">æ°å¢</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()">ä¿®æ¹</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()">å é¤</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain :disabled="multiple" icon="Download" @click="clickExportZip()">导åº</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @query-table="getList"></right-toolbar> |
| | | </el-row> |
| | | </template> |
| | | |
| | | <el-table v-loading="loading" border :data="modelList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column fixed align="center" type="index" label="åºå·" width="80"></el-table-column> |
| | | <el-table-column align="center" :show-overflow-tooltip="true" prop="name" label="模ååç§°" width="200"></el-table-column> |
| | | <el-table-column align="center" prop="key" label="模åKEY"></el-table-column> |
| | | <el-table-column align="center" prop="version" label="çæ¬å·" width="90"> |
| | | <template #default="scope"> v{{ scope.row.version }}.0</template> |
| | | </el-table-column> |
| | | <el-table-column align="center" prop="metaInfo" label="夿³¨è¯´æ" min-width="130"></el-table-column> |
| | | <el-table-column align="center" :show-overflow-tooltip="true" prop="createTime" label="å建æ¶é´" width="160"></el-table-column> |
| | | <el-table-column align="center" :show-overflow-tooltip="true" prop="lastUpdateTime" label="æ´æ°æ¶é´" width="160"></el-table-column> |
| | | <el-table-column fixed="right" label="æä½" align="center" width="170" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button link type="primary" size="small" icon="Pointer" @click="clickDesign(scope.row.id)">设计æµç¨</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button link type="primary" size="small" icon="Delete" @click="handleDelete(scope.row)">å é¤</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button link type="primary" size="small" icon="ScaleToOriginal" @click="clickDeploy(scope.row.id, scope.row.key)"> |
| | | æµç¨é¨ç½² |
| | | </el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button link type="primary" size="small" icon="CopyDocument" @click="handleCopy(scope.row)"> å¤å¶æ¨¡å </el-button> |
| | | </el-col> |
| | | </el-row> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | :total="total" |
| | | @pagination="getList" |
| | | /> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- 设计æµç¨å¼å§ --> |
| | | <Design ref="designRef" @close-call-back="handleQuery"></Design> |
| | | <!-- 设计æµç¨ç»æ --> |
| | | <!-- æ·»å æ¨¡åå¯¹è¯æ¡ --> |
| | | <el-dialog v-model="dialog.visible" :title="dialog.title" width="650px" append-to-body :close-on-click-modal="false"> |
| | | <el-form ref="formRef" :model="form" :rules="rules" label-width="100px"> |
| | | <el-form-item label="模ååç§°ï¼" prop="name"> |
| | | <el-input v-model="form.name" :disabled="ids && ids.length > 0 && billType === 'update'" maxlength="20" show-word-limit /> |
| | | </el-form-item> |
| | | <el-form-item label="模åKEYï¼" prop="key"> |
| | | <el-input v-model="form.key" :disabled="ids && ids.length > 0 && billType === 'update'" maxlength="20" show-word-limit /> |
| | | </el-form-item> |
| | | <el-form-item label="æµç¨åç±»" prop="categoryCode"> |
| | | <el-tree-select |
| | | v-model="form.categoryCode" |
| | | :data="categoryOptions" |
| | | :props="{ value: 'categoryCode', label: 'categoryName', children: 'children' }" |
| | | value-key="categoryCode" |
| | | placeholder="è¯·éæ©æµç¨åç±»" |
| | | check-strictly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="夿³¨ï¼" prop="description"> |
| | | <el-input v-model="form.description" type="textarea" maxlength="200" show-word-limit></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">ç¡® å®</el-button> |
| | | <el-button @click="cancel">å æ¶</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts" setup name="Model"> |
| | | import Design from '../../../components/BpmnDesign/index.vue'; |
| | | import { listModel, addModel, delModel, modelDeploy, getInfo, update } from '@/api/workflow/model'; |
| | | import { ModelQuery, ModelForm, ModelVO } from '@/api/workflow/model/types'; |
| | | import { listCategory } from '@/api/workflow/category'; |
| | | import { copyModel } from '@/api/workflow/model'; |
| | | |
| | | const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
| | | |
| | | const formRef = ref<ElFormInstance>(); |
| | | const queryFormRef = ref<ElFormInstance>(); |
| | | const categoryTreeRef = ref<ElTreeInstance>(); |
| | | const designRef = ref<InstanceType<typeof Design>>(); |
| | | |
| | | type CategoryOption = { |
| | | categoryCode: string; |
| | | categoryName: string; |
| | | children?: CategoryOption[]; |
| | | }; |
| | | |
| | | const buttonLoading = ref(false); |
| | | const loading = ref(true); |
| | | const ids = ref<string[]>([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const showSearch = ref(true); |
| | | const total = ref(0); |
| | | const modelList = ref<ModelVO[]>([]); |
| | | const categoryOptions = ref<CategoryOption[]>([]); |
| | | const categoryName = ref(''); |
| | | const billType = ref<string>(''); |
| | | |
| | | const dialog = reactive<DialogOption>({ |
| | | visible: false, |
| | | title: '' |
| | | }); |
| | | |
| | | const initFormData: ModelForm = { |
| | | id: '', |
| | | name: '', |
| | | key: '', |
| | | categoryCode: '', |
| | | xml: '', |
| | | svg: '', |
| | | description: '' |
| | | }; |
| | | const data = reactive<PageData<ModelForm, ModelQuery>>({ |
| | | form: { ...initFormData }, |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | name: '', |
| | | key: '', |
| | | categoryCode: '' |
| | | }, |
| | | rules: { |
| | | name: [{ required: true, message: '模åä¸è½ä¸ºç©º', trigger: 'blur' }], |
| | | key: [{ required: true, message: '模åKEYä¸è½ä¸ºç©º', trigger: 'blur' }], |
| | | categoryCode: [{ required: true, message: 'æµç¨åç±»ä¸è½ä¸ºç©º', trigger: 'blur' }] |
| | | } |
| | | }); |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | getTreeselect(); |
| | | }); |
| | | |
| | | /** èç¹åå»äºä»¶ */ |
| | | const handleNodeClick = (data: ModelForm) => { |
| | | queryParams.value.categoryCode = data.categoryCode; |
| | | if (data.categoryCode === 'ALL') { |
| | | queryParams.value.categoryCode = ''; |
| | | } |
| | | handleQuery(); |
| | | }; |
| | | /** éè¿æ¡ä»¶è¿æ»¤èç¹ */ |
| | | const filterNode = (value: string, data: any) => { |
| | | if (!value) return true; |
| | | return data.categoryName.indexOf(value) !== -1; |
| | | }; |
| | | /** æ ¹æ®åç§°çéé¨é¨æ */ |
| | | watchEffect( |
| | | () => { |
| | | categoryTreeRef.value?.filter(categoryName.value); |
| | | }, |
| | | { |
| | | flush: 'post' // watchEffectä¼å¨DOMæè½½æè
æ´æ°ä¹åå°±ä¼è§¦åï¼æ¤å±æ§æ§å¶å¨DOMå
ç´ æ´æ°åè¿è¡ |
| | | } |
| | | ); |
| | | |
| | | /** æç´¢æé®æä½ */ |
| | | const handleQuery = () => { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | }; |
| | | /** éç½®æé®æä½ */ |
| | | const resetQuery = () => { |
| | | queryFormRef.value?.resetFields(); |
| | | queryParams.value.categoryCode = ''; |
| | | queryParams.value.pageNum = 1; |
| | | queryParams.value.pageSize = 10; |
| | | handleQuery(); |
| | | }; |
| | | // å¤éæ¡é䏿°æ® |
| | | const handleSelectionChange = (selection: ModelVO[]) => { |
| | | ids.value = selection.map((item: ModelVO) => item.id); |
| | | single.value = selection.length !== 1; |
| | | multiple.value = !selection.length; |
| | | }; |
| | | //å页 |
| | | const getList = async () => { |
| | | loading.value = true; |
| | | const resp = await listModel(queryParams.value); |
| | | modelList.value = resp.rows; |
| | | total.value = resp.total; |
| | | loading.value = false; |
| | | }; |
| | | /** å é¤æé®æä½ */ |
| | | const handleDelete = async (row?: ModelVO) => { |
| | | const id = row?.id || ids.value; |
| | | await proxy?.$modal.confirm('æ¯å¦ç¡®è®¤å 餿¨¡åid为ã' + id + 'ãçæ°æ®é¡¹ï¼'); |
| | | loading.value = true; |
| | | await delModel(id).finally(() => (loading.value = false)); |
| | | await getList(); |
| | | proxy?.$modal.msgSuccess('å 餿å'); |
| | | }; |
| | | // æµç¨é¨ç½² |
| | | const clickDeploy = async (id: string, key: string) => { |
| | | await proxy?.$modal.confirm('æ¯å¦é¨ç½²æ¨¡åkey为ã' + key + 'ãæµç¨ï¼'); |
| | | loading.value = true; |
| | | await modelDeploy(id).finally(() => (loading.value = false)); |
| | | await getList(); |
| | | proxy?.$modal.msgSuccess('é¨ç½²æå'); |
| | | }; |
| | | //æ°å¢æå¼ |
| | | const handleAdd = () => { |
| | | billType.value = 'add'; |
| | | ids.value = []; |
| | | getTreeselect(); |
| | | form.value = { ...initFormData }; |
| | | dialog.visible = true; |
| | | dialog.title = 'æ°å¢æ¨¡å'; |
| | | }; |
| | | //ä¿®æ¹æå¼ |
| | | const handleUpdate = () => { |
| | | billType.value = 'update'; |
| | | dialog.title = 'ä¿®æ¹æ¨¡å'; |
| | | nextTick(async () => { |
| | | await getTreeselect(); |
| | | const _id = ids.value[0]; |
| | | const res = await getInfo(_id); |
| | | Object.assign(form.value, res.data); |
| | | dialog.visible = true; |
| | | }); |
| | | }; |
| | | |
| | | //å¤å¶æå¼ |
| | | const handleCopy = (row?: ModelVO) => { |
| | | billType.value = 'copy'; |
| | | dialog.title = 'å¤å¶æ¨¡å'; |
| | | nextTick(async () => { |
| | | await getTreeselect(); |
| | | form.value = { ...initFormData }; |
| | | form.value.id = row.id; |
| | | dialog.visible = true; |
| | | }); |
| | | }; |
| | | |
| | | /** æäº¤æé® */ |
| | | const submitForm = () => { |
| | | formRef.value.validate(async (valid: boolean) => { |
| | | if (valid) { |
| | | buttonLoading.value = true; |
| | | if ('copy' === billType.value) { |
| | | await copyModel(form.value); |
| | | proxy?.$modal.msgSuccess('æä½æå'); |
| | | } else if (ids.value && ids.value.length > 0 && 'update' === billType.value) { |
| | | form.value.id = ids.value[0]; |
| | | await update(form.value); |
| | | proxy?.$modal.msgSuccess('æä½æå'); |
| | | } else { |
| | | initXml(form.value.key, form.value.name); |
| | | form.value.xml = xml.value; |
| | | await addModel(form.value); |
| | | proxy?.$modal.msgSuccess('æä½æå'); |
| | | } |
| | | dialog.visible = false; |
| | | await getList(); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | /** åæ¶æé® */ |
| | | const cancel = () => { |
| | | reset(); |
| | | dialog.visible = false; |
| | | }; |
| | | |
| | | /** 表åéç½® */ |
| | | const reset = () => { |
| | | form.value = { ...initFormData }; |
| | | formRef.value.resetFields(); |
| | | }; |
| | | |
| | | // æå¼è®¾è®¡æµç¨ |
| | | const clickDesign = async (id: string) => { |
| | | await designRef.value.open(id); |
| | | }; |
| | | // å¯¼åºæµç¨æ¨¡å |
| | | const clickExportZip = () => { |
| | | proxy?.$download.zip('/workflow/model/export/zip/' + ids.value, '模å'); |
| | | }; |
| | | /** æ¥è¯¢æµç¨åç±»ä¸ææ ç»æ */ |
| | | const getTreeselect = async () => { |
| | | const res = await listCategory(); |
| | | categoryOptions.value = []; |
| | | const data: CategoryOption = { categoryCode: 'ALL', categoryName: '顶级èç¹', children: [] }; |
| | | data.children = proxy?.handleTree<CategoryOption>(res.data, 'id', 'parentId'); |
| | | categoryOptions.value.push(data); |
| | | }; |
| | | |
| | | const xml = ref<string>(''); |
| | | |
| | | const initXml = async (key: string, name: string) => { |
| | | xml.value = `<?xml version="1.0" encoding="UTF-8"?> |
| | | <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" targetNamespace="http://www.flowable.org/processdef"> |
| | | <process id="${key}" name="${name}"> |
| | | <startEvent id="startNode1" name="å¼å§" /> |
| | | </process> |
| | | <bpmndi:BPMNDiagram id="BPMNDiagram_flow"> |
| | | <bpmndi:BPMNPlane id="BPMNPlane_flow" bpmnElement="T-2d89e7a3-ba79-4abd-9f64-ea59621c258c"> |
| | | <bpmndi:BPMNShape id="BPMNShape_startNode1" bpmnElement="startNode1" bioc:stroke=""> |
| | | <omgdc:Bounds x="240" y="200" width="30" height="30" /> |
| | | <bpmndi:BPMNLabel> |
| | | <omgdc:Bounds x="242" y="237" width="23" height="14" /> |
| | | </bpmndi:BPMNLabel> |
| | | </bpmndi:BPMNShape> |
| | | </bpmndi:BPMNPlane> |
| | | </bpmndi:BPMNDiagram> |
| | | </definitions>`; |
| | | return xml; |
| | | }; |
| | | </script> |