From 5dcfee4c071d22aba34b31923dc63c47cfb8d7cc Mon Sep 17 00:00:00 2001 From: LiuHao <liuhaoai545@gmail.com> Date: 星期一, 18 三月 2024 11:52:44 +0800 Subject: [PATCH] update 流程部署支持多选 --- src/views/workflow/processDefinition/index.vue | 81 +++++++++++++++++++++++++++------------- 1 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/views/workflow/processDefinition/index.vue b/src/views/workflow/processDefinition/index.vue index 3843573..df630dc 100644 --- a/src/views/workflow/processDefinition/index.vue +++ b/src/views/workflow/processDefinition/index.vue @@ -125,12 +125,32 @@ <!-- 閮ㄧ讲鏂囦欢 --> <el-dialog v-if="uploadDialog.visible" v-model="uploadDialog.visible" :title="uploadDialog.title" width="30%"> <div v-loading="uploadDialogLoading"> - <el-upload class="upload-demo" drag accept="application/zip,application/xml,.bpmn" :http-request="handerDeployProcessFile"> + <div class="mb5"> + <el-text class="mx-1" size="large"><span class="text-danger">*</span>璇烽�夋嫨閮ㄧ讲娴佺▼鍒嗙被锛�</el-text> + <el-tree-select + v-model="selectCategory" + :data="categoryOptions" + :props="{ value: 'categoryCode', label: 'categoryName', children: 'children' }" + filterable + value-key="categoryCode" + :render-after-expand="false" + check-strictly + style="width: 240px" + /> + </div> + <el-upload + class="upload-demo" + drag + multiple + accept="application/zip,application/xml,.bpmn" + :before-upload="handlerBeforeUpload" + :http-request="handerDeployProcessFile" + > <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">PS:濡傝嫢閮ㄧ讲璇烽儴缃蹭粠鏈」鐩ā鍨嬬鐞嗗鍑虹殑鏁版嵁</div> - </el-upload> + </el-upload> </div> </el-dialog> @@ -194,13 +214,13 @@ <script lang="ts" setup name="processDefinition"> import { listProcessDefinition, - processDefinitionImage, - processDefinitionXml, + definitionImage, + definitionXml, deleteProcessDefinition, - updateProcessDefState, + updateDefinitionState, convertToModel, deployProcessFile, - getProcessDefinitionListByKey + getListByKey } from '@/api/workflow/processDefinition'; import ProcessPreview from './components/processPreview.vue'; import { listCategory } from '@/api/workflow/category'; @@ -232,6 +252,8 @@ const url = ref<string[]>([]); const categoryOptions = ref<CategoryOption[]>([]); const categoryName = ref(''); +/** 閮ㄧ讲鏂囦欢鍒嗙被閫夋嫨 */ +const selectCategory = ref(); const uploadDialog = reactive<DialogOption>({ visible: false, @@ -320,7 +342,7 @@ const getProcessDefinitionHitoryList = async (id: string, key: string) => { processDefinitionDialog.visible = true; loading.value = true; - const resp = await getProcessDefinitionListByKey(key); + const resp = await getListByKey(key); if (resp.data && resp.data.length > 0) { processDefinitionHistoryList.value = resp.data.filter((item: any) => item.id !== id); } @@ -330,7 +352,7 @@ //棰勮鍥剧墖 const clickPreviewImg = async (id: string) => { loading.value = true; - const resp = await processDefinitionImage(id); + const resp = await definitionImage(id); if (previewRef.value) { url.value = []; url.value.push('data:image/png;base64,' + resp.data); @@ -341,7 +363,7 @@ //棰勮xml const clickPreviewXML = async (id: string) => { loading.value = true; - const resp = await processDefinitionXml(id); + const resp = await definitionXml(id); if (previewRef.value) { url.value = []; url.value = resp.data.xml; @@ -367,7 +389,7 @@ } await proxy?.$modal.confirm(msg); loading.value = true; - await updateProcessDefState(row.id).finally(() => (loading.value = false)); + await updateDefinitionState(row.id).finally(() => (loading.value = false)); await getList(); proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛'); }; @@ -379,25 +401,32 @@ proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛'); }; +//涓婁紶鏂囦欢鍓嶇殑閽╁瓙 +const handlerBeforeUpload = () => { + if (selectCategory.value === 'ALL') { + proxy?.$modal.msgError('椤剁骇鑺傜偣涓嶅彲浣滀负鍒嗙被锛�'); + return false; + } + if (!selectCategory.value) { + proxy?.$modal.msgError('璇烽�夋嫨宸︿晶瑕佷笂浼犵殑鍒嗙被锛�'); + return false; + } +}; //閮ㄧ讲鏂囦欢 const handerDeployProcessFile = (data: UploadRequestOptions): XMLHttpRequest => { let formData = new FormData(); - if (queryParams.value.categoryCode === 'ALL') { - proxy?.$modal.msgError('椤剁骇鑺傜偣涓嶅彲浣滀负鍒嗙被锛�'); - return; - } - if (!queryParams.value.categoryCode) { - proxy?.$modal.msgError('璇烽�夋嫨宸︿晶瑕佷笂浼犵殑鍒嗙被锛�'); - return; - } - uploadDialogLoading.value = true + uploadDialogLoading.value = true; formData.append('file', data.file); - formData.append('categoryCode', queryParams.value.categoryCode); - deployProcessFile(formData).then(() => { - uploadDialog.visible = false; - proxy?.$modal.msgSuccess('閮ㄧ讲鎴愬姛'); - uploadDialogLoading.value = false - handleQuery(); - }); + formData.append('categoryCode', selectCategory.value); + deployProcessFile(formData) + .then(() => { + uploadDialog.visible = false; + proxy?.$modal.msgSuccess('閮ㄧ讲鎴愬姛'); + handleQuery(); + }) + .finally(() => { + uploadDialogLoading.value = false; + }); + return; }; </script> -- Gitblit v1.9.3