From b2a415728547d5aa0fa77f5653ddb7b8e6a5a8a2 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期五, 24 一月 2025 13:08:48 +0800 Subject: [PATCH] !175 发布 5.3.0 新春版 祝大家新年快乐 Merge pull request !175 from 疯狂的狮子Li/dev --- src/views/workflow/processDefinition/index.vue | 626 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 317 insertions(+), 309 deletions(-) diff --git a/src/views/workflow/processDefinition/index.vue b/src/views/workflow/processDefinition/index.vue index 2712929..9888892 100644 --- a/src/views/workflow/processDefinition/index.vue +++ b/src/views/workflow/processDefinition/index.vue @@ -10,7 +10,7 @@ class="mt-2" node-key="id" :data="categoryOptions" - :props="{ label: 'categoryName', children: 'children' }" + :props="{ label: 'label', children: 'children' }" :expand-on-click-node="false" :filter-node-method="filterNode" highlight-current @@ -24,11 +24,11 @@ <div v-show="showSearch" class="mb-[10px]"> <el-card shadow="hover"> <el-form v-show="showSearch" ref="queryFormRef" :model="queryParams" :inline="true" label-width="120px"> - <el-form-item label="娴佺▼瀹氫箟鍚嶇О" prop="name"> - <el-input v-model="queryParams.name" placeholder="璇疯緭鍏ユ祦绋嬪畾涔夊悕绉�" clearable @keyup.enter="handleQuery" /> + <el-form-item label="娴佺▼瀹氫箟鍚嶇О" prop="flowName"> + <el-input v-model="queryParams.flowName" placeholder="璇疯緭鍏ユ祦绋嬪畾涔夊悕绉�" clearable @keyup.enter="handleQuery" /> </el-form-item> - <el-form-item label="娴佺▼瀹氫箟KEY" prop="key"> - <el-input v-model="queryParams.key" placeholder="璇疯緭鍏ユ祦绋嬪畾涔塊EY" clearable @keyup.enter="handleQuery" /> + <el-form-item label="娴佺▼瀹氫箟KEY" prop="flowCode"> + <el-input v-model="queryParams.flowCode" placeholder="璇疯緭鍏ユ祦绋嬪畾涔塊EY" clearable @keyup.enter="handleQuery" /> </el-form-item> <el-form-item> <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button> @@ -38,97 +38,90 @@ </el-card> </div> </transition> - <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-button type="primary" icon="UploadFilled" @click="uploadDialog.visible = true">閮ㄧ讲娴佺▼鏂囦欢</el-button> - </el-card> - </div> - </transition> <el-card shadow="hover"> <template #header> <el-row :gutter="10" class="mb8"> - <el-col :span="1.5"> </el-col> - <right-toolbar v-model:showSearch="showSearch" @query-table="getList"></right-toolbar> + <el-col :span="1.5"> + <el-button type="primary" icon="Plus" @click="handleAdd()">娣诲姞</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="success" icon="Edit" :disabled="single" @click="handleUpdate()">淇敼</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="danger" icon="Delete" :disabled="multiple" @click="handleDelete()">鍒犻櫎</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="primary" icon="UploadFilled" @click="uploadDialog.visible = true">閮ㄧ讲娴佺▼鏂囦欢</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="warning" icon="Download" :disabled="single" @click="handleExportDef">瀵煎嚭</el-button> + </el-col> + <right-toolbar v-model:show-search="showSearch" @query-table="handleQuery"></right-toolbar> </el-row> </template> - - <el-table border v-loading="loading" :data="processDefinitionList" @selection-change="handleSelectionChange"> - <el-table-column type="selection" width="55" align="center" /> - <el-table-column align="center" type="index" label="搴忓彿" width="60"></el-table-column> - <el-table-column align="center" prop="name" label="娴佺▼瀹氫箟鍚嶇О"></el-table-column> - <el-table-column align="center" prop="key" label="鏍囪瘑KEY" width="80"></el-table-column> - <el-table-column align="center" prop="version" label="鐗堟湰鍙�" width="80"> - <template #default="scope"> v{{ scope.row.version }}.0</template> - </el-table-column> - <el-table-column align="center" prop="resourceName" label="娴佺▼XML" min-width="80" :show-overflow-tooltip="true"> - <template #default="scope"> - <el-link type="primary" @click="clickPreviewXML(scope.row.id)">{{ scope.row.resourceName }}</el-link> - </template> - </el-table-column> - <el-table-column align="center" prop="diagramResourceName" label="娴佺▼鍥剧墖" min-width="80" :show-overflow-tooltip="true"> - <template #default="scope"> - <el-link type="primary" @click="clickPreviewImg(scope.row.id)">{{ scope.row.diagramResourceName }}</el-link> - </template> - </el-table-column> - <el-table-column align="center" prop="suspensionState" label="鐘舵��" min-width="50"> - <template #default="scope"> - <el-tag v-if="scope.row.suspensionState == 1" type="success">婵�娲�</el-tag> - <el-tag v-else type="danger">鎸傝捣</el-tag> - </template> - </el-table-column> - <el-table-column align="center" prop="deploymentTime" label="閮ㄧ讲鏃堕棿" :show-overflow-tooltip="true"></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="scope.row.suspensionState === 1 ? 'Lock' : 'Unlock'" - @click="handleProcessDefState(scope.row)" - > - {{ scope.row.suspensionState === 1 ? '鎸傝捣娴佺▼' : '婵�娲绘祦绋�' }} - </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="Sort" @click="handleConvertToModel(scope.row)"> 杞崲妯″瀷 </el-button> - </el-col> - <el-col :span="1.5"> - <el-dropdown> - <el-button type="text" size="small"> - 鏇村<el-icon class="el-icon--right"><arrow-down /></el-icon> - </el-button> - <template #dropdown> - <el-dropdown-menu> - <el-dropdown-item @click="getProcessDefinitionHitoryList(scope.row.id, scope.row.key)">鍘嗗彶鐗堟湰</el-dropdown-item> - <el-dropdown-item @click="handleFormOpen(scope.row)">琛ㄥ崟閰嶇疆</el-dropdown-item> - </el-dropdown-menu> - </template> - </el-dropdown> - </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-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"> + <el-tab-pane label="宸插彂甯�" name="0"></el-tab-pane> + <el-tab-pane label="鏈彂甯�" name="1"></el-tab-pane> + <el-table v-loading="loading" border :data="processDefinitionList" @selection-change="handleSelectionChange"> + <el-table-column type="selection" width="55" align="center" /> + <el-table-column align="center" prop="id" label="涓婚敭" v-if="false"></el-table-column> + <el-table-column align="center" prop="flowName" label="娴佺▼瀹氫箟鍚嶇О" :show-overflow-tooltip="true"></el-table-column> + <el-table-column align="center" prop="flowCode" label="鏍囪瘑KEY" :show-overflow-tooltip="true"></el-table-column> + <el-table-column align="center" prop="version" label="鐗堟湰鍙�" width="80"> + <template #default="scope"> v{{ scope.row.version }}.0</template> + </el-table-column> + <el-table-column align="center" prop="activityStatus" label="婵�娲荤姸鎬�" width="130"> + <template #default="scope"> + <el-switch + v-model="scope.row.activityStatus" + :active-value="1" + :inactive-value="0" + @change="(status) => handleProcessDefState(scope.row, status)" + /> + </template> + </el-table-column> + <el-table-column align="center" prop="isPublish" label="鍙戝竷鐘舵��" width="100"> + <template #default="scope"> + <el-tag v-if="scope.row.isPublish == 0" type="danger">鏈彂甯�</el-tag> + <el-tag v-else-if="scope.row.isPublish == 1" type="success">宸插彂甯�</el-tag> + <el-tag v-else type="danger">澶辨晥</el-tag> + </template> + </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="Delete" @click="handleDelete(scope.row)">鍒犻櫎娴佺▼</el-button> + </el-col> + <el-col :span="1.5"> + <el-button link type="primary" size="small" icon="CopyDocument" @click="handleCopyDef(scope.row)">澶嶅埗娴佺▼</el-button> + </el-col> + </el-row> + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button link type="primary" v-if="scope.row.isPublish === 0" icon="Pointer" size="small" @click="design(scope.row)" + >娴佺▼璁捐</el-button + > + <el-button link type="primary" v-else icon="View" size="small" @click="designView(scope.row)">鏌ョ湅娴佺▼</el-button> + </el-col> + <el-col v-if="scope.row.isPublish !== 1" :span="1.5"> + <el-button link type="primary" size="small" icon="CircleCheck" @click="handlePublish(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="getPageList" + /> + </el-tabs> </el-card> </el-col> </el-row> - <!-- 棰勮鍥剧墖鎴杧ml --> - <process-preview ref="previewRef" /> <!-- 閮ㄧ讲鏂囦欢 --> <el-dialog v-if="uploadDialog.visible" v-model="uploadDialog.visible" :title="uploadDialog.title" width="30%"> @@ -138,9 +131,9 @@ <el-tree-select v-model="selectCategory" :data="categoryOptions" - :props="{ value: 'categoryCode', label: 'categoryName', children: 'children' }" + :props="{ value: 'id', label: 'label', children: 'children' }" filterable - value-key="categoryCode" + value-key="id" :render-after-expand="false" check-strictly style="width: 240px" @@ -150,97 +143,47 @@ class="upload-demo" drag multiple - accept="application/zip,application/xml,.bpmn" + accept="application/json,application/text" :before-upload="handlerBeforeUpload" - :http-request="handerDeployProcessFile" + :http-request="handlerImportDefinition" > <el-icon class="UploadFilled"><upload-filled /></el-icon> - <div class="el-upload__text"><em>鐐瑰嚮涓婁紶锛岄�夋嫨BPMN娴佺▼鏂囦欢</em></div> - <div class="el-upload__text">浠呮敮鎸� .zip銆�.bpmn20.xml銆乥pmn 鏍煎紡鏂囦欢</div> + <div class="el-upload__text"><em>鐐瑰嚮涓婁紶锛岄�夋嫨JSON娴佺▼鏂囦欢</em></div> + <div class="el-upload__text">浠呮敮鎸乯son鏍煎紡鏂囦欢</div> <div class="el-upload__text">PS:濡傝嫢閮ㄧ讲璇烽儴缃蹭粠鏈」鐩ā鍨嬬鐞嗗鍑虹殑鏁版嵁</div> </el-upload> </div> </el-dialog> - <!-- 鍘嗗彶鐗堟湰 --> - <el-dialog v-if="processDefinitionDialog.visible" v-model="processDefinitionDialog.visible" :title="processDefinitionDialog.title" width="70%"> - <el-table v-loading="loading" :data="processDefinitionHistoryList" @selection-change="handleSelectionChange"> - <el-table-column type="selection" width="55" align="center" /> - <el-table-column align="center" type="index" label="搴忓彿" width="60"></el-table-column> - <el-table-column align="center" prop="name" label="娴佺▼瀹氫箟鍚嶇О"></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="resourceName" label="娴佺▼XML" min-width="80" :show-overflow-tooltip="true"> - <template #default="scope"> - <el-link type="primary" @click="clickPreviewXML(scope.row.id)">{{ scope.row.resourceName }}</el-link> - </template> - </el-table-column> - <el-table-column align="center" prop="diagramResourceName" label="娴佺▼鍥剧墖" min-width="80" :show-overflow-tooltip="true"> - <template #default="scope"> - <el-link type="primary" @click="clickPreviewImg(scope.row.id)">{{ scope.row.diagramResourceName }}</el-link> - </template> - </el-table-column> - <el-table-column align="center" prop="suspensionState" label="鐘舵��" min-width="70"> - <template #default="scope"> - <el-tag v-if="scope.row.suspensionState == 1" type="success">婵�娲�</el-tag> - <el-tag v-else type="danger">鎸傝捣</el-tag> - </template> - </el-table-column> - <el-table-column align="center" prop="deploymentTime" label="閮ㄧ讲鏃堕棿" :show-overflow-tooltip="true"></el-table-column> - <el-table-column fixed="right" label="鎿嶄綔" align="center" width="200" 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="scope.row.suspensionState === 1 ? 'Lock' : 'Unlock'" - @click="handleProcessDefState(scope.row)" - > - {{ scope.row.suspensionState === 1 ? '鎸傝捣娴佺▼' : '婵�娲绘祦绋�' }} - </el-button> - </el-col> - <el-col :span="1.5"> - <el-button link type="primary" icon="Delete" size="small" @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" icon="Sort" size="small" @click="handleConvertToModel(scope.row)"> 杞崲妯″瀷 </el-button> - </el-col> - <el-col :span="1.5"> - <el-button link type="primary" icon="Setting" size="small" @click="handleFormOpen(scope.row)"> 琛ㄥ崟閰嶇疆 </el-button> - </el-col> - </el-row> - </template> - </el-table-column> - </el-table> - </el-dialog> - <!-- 琛ㄥ崟閰嶇疆 --> - <el-dialog v-model="formDialog.visible" :title="formDialog.title" width="650px" append-to-body :close-on-click-modal="false"> - <el-form :model="definitionConfigForm" label-width="auto"> - <el-form-item label="娴佺▼KEY"> - <el-input v-model="definitionConfigForm.processKey" disabled/> - </el-form-item> - <el-form-item label="琛ㄥ崟" prop="formId"> - <el-select v-model="definitionConfigForm.formId" clearable filterable placeholder="璇烽�夋嫨琛ㄥ崟" style="width: 260px" > - <el-option v-for="item in formManageList" :key="item.id" :label="item.formTypeName+':'+item.formName" :value="item.id" /> - </el-select> - </el-form-item> - <el-form-item label="澶囨敞"> - <el-input v-model="definitionConfigForm.remark" type="textarea" resize="none"/> - </el-form-item> - </el-form> - + <!-- 鏂板/缂栬緫娴佺▼瀹氫箟 --> + <el-dialog v-model="modelDialog.visible" :title="modelDialog.title" width="650px" append-to-body :close-on-click-modal="false"> <template #footer> + <el-form ref="defFormRef" :model="form" :rules="rules" label-width="110px"> + <el-form-item label="娴佺▼绫诲埆" prop="category"> + <el-tree-select + v-model="form.category" + :data="categoryOptions" + :props="{ value: 'id', label: 'label', children: 'children' }" + filterable + value-key="id" + :render-after-expand="false" + check-strictly + style="width: 100%" + /> + </el-form-item> + <el-form-item label="娴佺▼缂栫爜" prop="flowCode"> + <el-input v-model="form.flowCode" placeholder="璇疯緭鍏ユ祦绋嬬紪鐮�" maxlength="40" show-word-limit /> + </el-form-item> + <el-form-item label="娴佺▼鍚嶇О" prop="flowName"> + <el-input v-model="form.flowName" placeholder="璇疯緭鍏ユ祦绋嬪悕绉�" maxlength="100" show-word-limit /> + </el-form-item> + <el-form-item label="琛ㄥ崟璺緞" prop="flowName"> + <el-input v-model="form.formPath" placeholder="璇疯緭鍏ヨ〃鍗曡矾寰�" maxlength="100" show-word-limit /> + </el-form-item> + </el-form> <div class="dialog-footer"> - <el-button @click="formDialog.visible = false">鍙栨秷</el-button> - <el-button type="primary" @click="handlerSaveForm"> - 淇濆瓨 - </el-button> + <el-button @click="modelDialog.visible = false">鍙栨秷</el-button> + <el-button type="primary" @click="handleSubmit">淇濆瓨</el-button> </div> </template> </el-dialog> @@ -248,55 +191,32 @@ </template> <script lang="ts" setup name="processDefinition"> -import { - listProcessDefinition, - definitionImage, - definitionXml, - deleteProcessDefinition, - updateDefinitionState, - convertToModel, - deployProcessFile, - getListByKey -} from '@/api/workflow/processDefinition'; -import ProcessPreview from './components/processPreview.vue'; -import { listCategory } from '@/api/workflow/category'; -import { getByDefId,saveOrUpdate } from '@/api/workflow/definitionConfig'; -import { CategoryVO } from '@/api/workflow/category/types'; -import { ProcessDefinitionQuery, ProcessDefinitionVO } from '@/api/workflow/processDefinition/types'; -import { definitionConfigForm } from '@/api/workflow/definitionConfig/types'; -import { UploadRequestOptions } from 'element-plus'; -import { FormManageVO } from '@/api/workflow/formManage/types'; -import { selectListFormManage } from '@/api/workflow/formManage'; +import { listDefinition, deleteDefinition, active, importDef, unPublishList, publish, add, edit, getInfo, copy } from '@/api/workflow/definition'; +import { categoryTree } from '@/api/workflow/category'; +import { CategoryTreeVO } from '@/api/workflow/category/types'; +import { FlowDefinitionQuery, FlowDefinitionVo, FlowDefinitionForm } from '@/api/workflow/definition/types'; +import { UploadRequestOptions, TabsPaneContext } from 'element-plus'; -const formManageList = ref<FormManageVO[]>([]); const { proxy } = getCurrentInstance() as ComponentInternalInstance; -const previewRef = ref<InstanceType<typeof ProcessPreview>>(); const queryFormRef = ref<ElFormInstance>(); const categoryTreeRef = ref<ElTreeInstance>(); -type CategoryOption = { - categoryCode: string; - categoryName: string; - children?: CategoryOption[]; -}; - const loading = ref(true); -const ids = ref<Array<string | number>>([]); +const ids = ref<Array<any>>([]); +const flowCodeList = ref<Array<any>>([]); const single = ref(true); const multiple = ref(true); const showSearch = ref(true); const total = ref(0); const uploadDialogLoading = ref(false); -const processDefinitionList = ref<ProcessDefinitionVO[]>([]); -const processDefinitionHistoryList = ref<ProcessDefinitionVO[]>([]); -const url = ref<string[]>([]); -const categoryOptions = ref<CategoryOption[]>([]); +const processDefinitionList = ref<FlowDefinitionVo[]>([]); +const categoryOptions = ref<CategoryTreeVO[]>([]); const categoryName = ref(''); /** 閮ㄧ讲鏂囦欢鍒嗙被閫夋嫨 */ const selectCategory = ref(); -const definitionConfigForm = ref<definitionConfigForm>({}); - +const defFormRef = ref<ElFormInstance>(); +const activeName = ref('0'); const uploadDialog = reactive<DialogOption>({ visible: false, title: '閮ㄧ讲娴佺▼鏂囦欢' @@ -307,30 +227,49 @@ title: '鍘嗗彶鐗堟湰' }); -const formDialog = reactive<DialogOption>({ +const modelDialog = reactive<DialogOption>({ visible: false, - title: '琛ㄥ崟閰嶇疆' + title: '' }); // 鏌ヨ鍙傛暟 -const queryParams = ref<ProcessDefinitionQuery>({ +const queryParams = ref<FlowDefinitionQuery>({ pageNum: 1, pageSize: 10, - name: undefined, - key: undefined, - categoryCode: undefined + flowName: undefined, + flowCode: undefined, + category: undefined }); - +const rules = { + category: [{ required: true, message: '鍒嗙被鍚嶇О涓嶈兘涓虹┖', trigger: 'blur' }], + flowName: [{ required: true, message: '娴佺▼瀹氫箟鍚嶇О涓嶈兘涓虹┖', trigger: 'blur' }], + flowCode: [{ required: true, message: '娴佺▼瀹氫箟缂栫爜涓嶈兘涓虹┖', trigger: 'blur' }] +}; +const initFormData: FlowDefinitionForm = { + id: '', + flowName: '', + flowCode: '', + category: '', + formPath: '' +}; +//娴佺▼瀹氫箟鍙傛暟 +const form = ref<FlowDefinitionForm>({ + id: '', + flowName: '', + flowCode: '', + category: '', + formPath: '' +}); onMounted(() => { - getList(); + getPageList(); getTreeselect(); }); /** 鑺傜偣鍗曞嚮浜嬩欢 */ -const handleNodeClick = (data: CategoryVO) => { - queryParams.value.categoryCode = data.categoryCode; - if (data.categoryCode === 'ALL') { - queryParams.value.categoryCode = ''; +const handleNodeClick = (data: CategoryTreeVO) => { + queryParams.value.category = data.id; + if (data.id === '0') { + queryParams.value.category = ''; } handleQuery(); }; @@ -351,22 +290,27 @@ /** 鏌ヨ娴佺▼鍒嗙被涓嬫媺鏍戠粨鏋� */ 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 res = await categoryTree(); + categoryOptions.value = res.data; }; - +const handleClick = (tab: TabsPaneContext, event: Event) => { + // v-model澶勭悊鏈夊欢杩� 闇�瑕佹墜鍔ㄥ鐞� + activeName.value = tab.index; + handleQuery(); +}; /** 鎼滅储鎸夐挳鎿嶄綔 */ const handleQuery = () => { queryParams.value.pageNum = 1; - getList(); + if (activeName.value === '0') { + getList(); + } else { + getUnPublishList(); + } }; /** 閲嶇疆鎸夐挳鎿嶄綔 */ const resetQuery = () => { queryFormRef.value?.resetFields(); - queryParams.value.categoryCode = ''; + queryParams.value.category = ''; queryParams.value.pageNum = 1; queryParams.value.pageSize = 10; handleQuery(); @@ -374,78 +318,82 @@ // 澶氶�夋閫変腑鏁版嵁 const handleSelectionChange = (selection: any) => { ids.value = selection.map((item: any) => item.id); + flowCodeList.value = selection.map((item: any) => item.flowCode); single.value = selection.length !== 1; multiple.value = !selection.length; }; //鍒嗛〉 +const getPageList = async () => { + console.log(proxy.$route.query.activeName) + if (proxy.$route.query.activeName) { + activeName.value = proxy.$route.query.activeName; + } + if (activeName.value === '0') { + getList(); + } else { + getUnPublishList(); + } +}; +//鍒嗛〉 const getList = async () => { loading.value = true; - const resp = await listProcessDefinition(queryParams.value); + const resp = await listDefinition(queryParams.value); processDefinitionList.value = resp.rows; total.value = resp.total; loading.value = false; }; -//鑾峰彇鍘嗗彶娴佺▼瀹氫箟 -const getProcessDefinitionHitoryList = async (id: string, key: string) => { - processDefinitionDialog.visible = true; +//鏌ヨ鏈彂甯冪殑娴佺▼瀹氫箟鍒楄〃 +const getUnPublishList = async () => { loading.value = true; - const resp = await getListByKey(key); - if (resp.data && resp.data.length > 0) { - processDefinitionHistoryList.value = resp.data.filter((item: any) => item.id !== id); - } + const resp = await unPublishList(queryParams.value); + processDefinitionList.value = resp.rows; + total.value = resp.total; loading.value = false; }; -//棰勮鍥剧墖 -const clickPreviewImg = async (id: string) => { - loading.value = true; - const resp = await definitionImage(id); - if (previewRef.value) { - url.value = []; - url.value.push('data:image/png;base64,' + resp.data); - loading.value = false; - previewRef.value.openDialog(url.value, 'png'); - } -}; -//棰勮xml -const clickPreviewXML = async (id: string) => { - loading.value = true; - const resp = await definitionXml(id); - if (previewRef.value) { - url.value = []; - url.value = resp.data.xml; - loading.value = false; - previewRef.value.openDialog(url.value, 'xml'); - } -}; /** 鍒犻櫎鎸夐挳鎿嶄綔 */ -const handleDelete = async (row: ProcessDefinitionVO) => { - await proxy?.$modal.confirm('鏄惁纭鍒犻櫎娴佺▼瀹氫箟key涓恒��' + row.key + '銆戠殑鏁版嵁椤癸紵'); +const handleDelete = async (row?: FlowDefinitionVo) => { + const id = row?.id || ids.value; + const defList = processDefinitionList.value.filter((x) => id.indexOf(x.id) != -1).map((x) => x.flowCode); + await proxy?.$modal.confirm('鏄惁纭鍒犻櫎娴佺▼瀹氫箟KEY涓恒��' + defList + '銆戠殑鏁版嵁椤癸紵'); loading.value = true; - await deleteProcessDefinition(row.deploymentId, row.id).finally(() => (loading.value = false)); - await getList(); + await deleteDefinition(id).finally(() => (loading.value = false)); + await handleQuery(); proxy?.$modal.msgSuccess('鍒犻櫎鎴愬姛'); }; -/** 鎸傝捣/婵�娲� */ -const handleProcessDefState = async (row: ProcessDefinitionVO) => { - let msg: string; - if (row.suspensionState === 1) { - msg = `鏆傚仠鍚庯紝姝ゆ祦绋嬩笅鐨勬墍鏈変换鍔¢兘涓嶅厑璁稿線鍚庢祦杞紝鎮ㄧ‘瀹氭寕璧枫��${row.name || row.key}銆戝悧锛焋; - } else { - msg = `鍚姩鍚庯紝姝ゆ祦绋嬩笅鐨勬墍鏈変换鍔¢兘鍏佽寰�鍚庢祦杞紝鎮ㄧ‘瀹氭縺娲汇��${row.name || row.key}銆戝悧锛焋; - } - await proxy?.$modal.confirm(msg); + +/** 鍙戝竷娴佺▼瀹氫箟 */ +const handlePublish = async (row?: FlowDefinitionVo) => { + await proxy?.$modal.confirm( + '鏄惁纭鍙戝竷娴佺▼瀹氫箟KEY涓恒��' + row.flowCode + '銆戠増鏈负銆�' + row.version + '銆戠殑鏁版嵁椤癸紵锛屽彂甯冨悗浼氬皢宸插彂甯冩祦绋嬪畾涔夋敼涓哄け鏁堬紒' + ); loading.value = true; - await updateDefinitionState(row.id).finally(() => (loading.value = false)); - await getList(); - proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛'); + await publish(row.id).finally(() => (loading.value = false)); + processDefinitionDialog.visible = false; + activeName.value = "0" + await handleQuery(); + proxy?.$modal.msgSuccess('鍙戝竷鎴愬姛'); }; -/** 娴佺▼瀹氫箟杞崲涓烘ā鍨� */ -const handleConvertToModel = async (row: ProcessDefinitionVO) => { - await proxy?.$modal.confirm('鏄惁纭杞崲娴佺▼瀹氫箟key涓恒��' + row.key + '銆戠殑鏁版嵁椤癸紵'); - await convertToModel(row.id).finally(() => (loading.value = false)); - getList(); - proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛'); +/** 鎸傝捣/婵�娲� */ +const handleProcessDefState = async (row: FlowDefinitionVo, status: number | string | boolean) => { + let msg: string; + if (status === 0) { + msg = `鏆傚仠鍚庯紝姝ゆ祦绋嬩笅鐨勬墍鏈変换鍔¢兘涓嶅厑璁稿線鍚庢祦杞紝鎮ㄧ‘瀹氭寕璧枫��${row.flowName || row.flowCode}銆戝悧锛焋; + } else { + msg = `鍚姩鍚庯紝姝ゆ祦绋嬩笅鐨勬墍鏈変换鍔¢兘鍏佽寰�鍚庢祦杞紝鎮ㄧ‘瀹氭縺娲汇��${row.flowName || row.flowCode}銆戝悧锛焋; + } + try { + loading.value = true; + await proxy?.$modal.confirm(msg); + await active(row.id, !!status); + await handleQuery(); + proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛'); + } catch (error) { + row.activityStatus = status === 0 ? 1 : 0; + console.error(error); + } finally { + loading.value = false; + } }; //涓婁紶鏂囦欢鍓嶇殑閽╁瓙 @@ -460,15 +408,16 @@ } }; //閮ㄧ讲鏂囦欢 -const handerDeployProcessFile = (data: UploadRequestOptions): XMLHttpRequest => { +const handlerImportDefinition = (data: UploadRequestOptions): XMLHttpRequest => { let formData = new FormData(); uploadDialogLoading.value = true; formData.append('file', data.file); - formData.append('categoryCode', selectCategory.value); - deployProcessFile(formData) + formData.append('category', selectCategory.value); + importDef(formData) .then(() => { uploadDialog.visible = false; proxy?.$modal.msgSuccess('閮ㄧ讲鎴愬姛'); + activeName.value = "1" handleQuery(); }) .finally(() => { @@ -476,34 +425,93 @@ }); return; }; -//鎵撳紑琛ㄥ崟閰嶇疆 -const handleFormOpen = async (row: ProcessDefinitionVO) => { - listFormManage() - formDialog.visible = true - definitionConfigForm.value.processKey = row.key - definitionConfigForm.value.definitionId = row.id - const resp = await getByDefId(row.id) - if(resp.data){ - definitionConfigForm.value = resp.data - }else{ - definitionConfigForm.value.formId = undefined - definitionConfigForm.value.remark = undefined - } -} -//淇濆瓨琛ㄥ崟 -const handlerSaveForm = async () => { - await proxy?.$modal.confirm('鏄惁纭淇濆瓨锛�'); - saveOrUpdate(definitionConfigForm.value).then(resp=>{ - if(resp.code === 200){ - proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛'); - formDialog.visible = false - getList(); +/** + * 璁捐娴佺▼ + * @param row + */ +const design = async (row: FlowDefinitionVo) => { + proxy.$router.push({ + path: `/workflow/design/index`, + query: { + definitionId: row.id, + disabled: false, + activeName: activeName.value } - }) -} -//琛ㄥ崟鍒楄〃 -const listFormManage = async () => { - const res = await selectListFormManage(); - formManageList.value = res.data; -} + }); +}; + +/** + * 鏌ョ湅娴佺▼ + * @param row + */ +const designView = async (row: FlowDefinitionVo) => { + proxy.$router.push({ + path: `/workflow/design/index`, + query: { + definitionId: row.id, + disabled: true, + activeName: activeName.value + } + }); +}; +/** 琛ㄥ崟閲嶇疆 */ +const reset = () => { + form.value = { ...initFormData }; + defFormRef.value?.resetFields(); +}; +/** + * 鏂板 + */ +const handleAdd = async () => { + reset(); + modelDialog.visible = true; + modelDialog.title = '鏂板娴佺▼'; +}; +/** 淇敼鎸夐挳鎿嶄綔 */ +const handleUpdate = async (row?: FlowDefinitionVo) => { + reset(); + const id = row?.id || ids.value[0]; + const res = await getInfo(id); + Object.assign(form.value, res.data); + modelDialog.visible = true; + modelDialog.title = '淇敼娴佺▼'; +}; + +const handleSubmit = async () => { + defFormRef.value.validate(async (valid: boolean) => { + if (valid) { + loading.value = true; + if (form.value.id) { + await edit(form.value).finally(() => loading.value = false); + } else { + await add(form.value).finally(() => loading.value = false); + } + proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛'); + modelDialog.visible = false; + handleQuery(); + } + }); +}; +//澶嶅埗 +const handleCopyDef = async (row: FlowDefinitionVo) => { + ElMessageBox.confirm(`鏄惁纭澶嶅埗銆�${row.flowCode}銆戠増鏈负銆�${row.version}銆戠殑娴佺▼瀹氫箟锛乣, '鎻愮ず', { + confirmButtonText: '纭', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(() => { + loading.value = true; + copy(row.id).then((resp) => { + if (resp.code === 200) { + proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛'); + activeName.value = "1" + handleQuery(); + } + }).finally(() => loading.value = false); + }); +}; + +/** 瀵煎嚭鎸夐挳鎿嶄綔 */ +const handleExportDef = () => { + proxy?.download(`/workflow/definition/exportDef/${ids.value[0]}`, {}, `${flowCodeList.value[0]}.json`); +}; </script> -- Gitblit v1.9.3