From 5e440a7dc434c43eb828fa62cf9c12b0078b8565 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期一, 20 一月 2025 11:36:18 +0800
Subject: [PATCH] !173 发布 5.3.0-BETA 公测版本 Merge pull request !173 from 疯狂的狮子Li/dev

---
 src/views/workflow/processDefinition/index.vue |  600 +++++++++++++++++++++++++++++------------------------------
 1 files changed, 293 insertions(+), 307 deletions(-)

diff --git a/src/views/workflow/processDefinition/index.vue b/src/views/workflow/processDefinition/index.vue
index 1dacb80..a45e484 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>
@@ -42,93 +42,86 @@
           <template #header>
             <el-row :gutter="10" class="mb8">
               <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>
-              <right-toolbar v-model:showSearch="showSearch" @query-table="getList"></right-toolbar>
+              <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="getList"></right-toolbar>
             </el-row>
           </template>
-
-          <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" type="index" label="搴忓彿" width="60"></el-table-column>
-            <el-table-column align="center" prop="name" label="娴佺▼瀹氫箟鍚嶇О" :show-overflow-tooltip="true"></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" width="100" :show-overflow-tooltip="true">
-              <template #default="scope">
-                <el-link type="primary" @click="clickPreview(scope.row.id, 'xml')">{{ scope.row.resourceName }}</el-link>
-              </template>
-            </el-table-column>
-            <el-table-column align="center" prop="diagramResourceName" label="娴佺▼鍥剧墖" width="100" :show-overflow-tooltip="true">
-              <template #default="scope">
-                <el-link type="primary" @click="clickPreview(scope.row.id, 'bpmn')">{{ scope.row.diagramResourceName }}</el-link>
-              </template>
-            </el-table-column>
-            <el-table-column align="center" prop="suspensionState" label="鐘舵��" width="80">
-              <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="閮ㄧ讲鏃堕棿" width="120" :show-overflow-tooltip="true"></el-table-column>
-            <el-table-column align="center" label="琛ㄥ悕/琛ㄥ崟KEY" width="120" :show-overflow-tooltip="true">
-              <template #default="scope">
-                <span v-if="scope.row.wfDefinitionConfigVo">
-                  {{ scope.row.wfDefinitionConfigVo.tableName }}
-                </span>
-              </template>
-            </el-table-column>
-            <el-table-column fixed="right" label="鎿嶄綔" align="center" width="220" 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="Document" @click="getProcessDefinitionHitoryList(scope.row.id, scope.row.key)">
-                      鍘嗗彶鐗堟湰
-                    </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-button link type="primary" size="small" icon="Tickets" @click="handleDefinitionConfigOpen(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-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="handleQuery"
+            />
+          </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,100 +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="娴佺▼瀹氫箟鍚嶇О" :show-overflow-tooltip="true" min-width="80"></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 type="text" size="small" icon="Tickets" @click="handleDefinitionConfigOpen(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="Delete" size="small" @click="handleDelete(scope.row)">鍒犻櫎</el-button>
-              </el-col>
-            </el-row>
-          </template>
-        </el-table-column>
-      </el-table>
-    </el-dialog>
-
-    <!-- 琛ㄥ崟閰嶇疆 -->
-    <el-dialog
-      v-model="definitionConfigDialog.visible"
-      :title="definitionConfigDialog.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-input v-model="definitionConfigForm.tableName" placeholder="绀轰緥:test_leave" />
-        </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="definitionConfigDialog.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>
@@ -251,53 +191,32 @@
 </template>
 
 <script lang="ts" setup name="processDefinition">
-import {
-  listProcessDefinition,
-  definitionImage,
-  definitionXml,
-  deleteProcessDefinition,
-  updateDefinitionState,
-  convertToModel,
-  deployProcessFile,
-  getListByKey
-} from '@/api/workflow/processDefinition';
-import { getByTableNameNotDefId, getByDefId, saveOrUpdate } from '@/api/workflow/definitionConfig';
-import ProcessPreview from './components/processPreview.vue';
-import { listCategory } from '@/api/workflow/category';
-import { CategoryVO } from '@/api/workflow/category/types';
-import { ProcessDefinitionQuery, ProcessDefinitionVO } from '@/api/workflow/processDefinition/types';
-import { DefinitionConfigForm } from '@/api/workflow/definitionConfig/types';
-import { UploadRequestOptions, ElMessage, ElMessageBox } from 'element-plus';
+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 { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
-const previewRef = ref<InstanceType<typeof ProcessPreview>>();
 const queryFormRef = ref<ElFormInstance>();
 const categoryTreeRef = ref<ElTreeInstance>();
-const definitionConfigForm = ref<DefinitionConfigForm>({});
-
-type CategoryOption = {
-  categoryCode: string;
-  categoryName: string;
-  children?: CategoryOption[];
-};
 
 const loading = ref(true);
 const ids = ref<Array<any>>([]);
-const deploymentIds = ref<Array<any>>([]);
-const keys = 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 categoryOptions = ref<CategoryOption[]>([]);
+const processDefinitionList = ref<FlowDefinitionVo[]>([]);
+const categoryOptions = ref<CategoryTreeVO[]>([]);
 const categoryName = ref('');
 /** 閮ㄧ讲鏂囦欢鍒嗙被閫夋嫨 */
 const selectCategory = ref();
-
+const defFormRef = ref<ElFormInstance>();
+const activeName = ref('0');
 const uploadDialog = reactive<DialogOption>({
   visible: false,
   title: '閮ㄧ讲娴佺▼鏂囦欢'
@@ -308,30 +227,49 @@
   title: '鍘嗗彶鐗堟湰'
 });
 
-const definitionConfigDialog = 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();
+  handleQuery();
   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();
 };
@@ -352,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();
@@ -375,73 +318,70 @@
 // 澶氶�夋閫変腑鏁版嵁
 const handleSelectionChange = (selection: any) => {
   ids.value = selection.map((item: any) => item.id);
-  deploymentIds.value = selection.map((item: any) => item.deploymentId);
-  keys.value = selection.map((item: any) => item.key);
+  flowCodeList.value = selection.map((item: any) => item.flowCode);
   single.value = selection.length !== 1;
   multiple.value = !selection.length;
 };
 //鍒嗛〉
 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;
 };
 
-type PreviewType = 'xml' | 'bpmn';
-//棰勮 鍏叡鏂规硶
-const clickPreview = async (id: string, type: PreviewType) => {
-  loading.value = true;
-  const resp = await definitionXml(id);
-  if (previewRef.value) {
-    const xmlStr = resp.data.xmlStr;
-    loading.value = false;
-    previewRef.value.openDialog(xmlStr, type);
-  }
-};
-
 /** 鍒犻櫎鎸夐挳鎿嶄綔 */
-const handleDelete = async (row?: ProcessDefinitionVO) => {
+const handleDelete = async (row?: FlowDefinitionVo) => {
   const id = row?.id || ids.value;
-  const deployIds = row?.deploymentId || deploymentIds.value;
-  const defKeys = row?.key || keys.value;
-  await proxy?.$modal.confirm('鏄惁纭鍒犻櫎娴佺▼瀹氫箟KEY涓恒��' + defKeys + '銆戠殑鏁版嵁椤癸紵');
+  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(deployIds, 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;
+  }
 };
 
 //涓婁紶鏂囦欢鍓嶇殑閽╁瓙
@@ -456,15 +396,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(() => {
@@ -472,46 +413,91 @@
     });
   return;
 };
-//鎵撳紑娴佺▼瀹氫箟閰嶇疆
-const handleDefinitionConfigOpen = async (row: ProcessDefinitionVO) => {
-  definitionConfigDialog.visible = true;
-  definitionConfigForm.value.processKey = row.key;
-  definitionConfigForm.value.definitionId = row.id;
-  definitionConfigForm.value.version = row.version;
-  const resp = await getByDefId(row.id);
-  if (resp.data) {
-    definitionConfigForm.value = resp.data;
-  } else {
-    definitionConfigForm.value.tableName = undefined;
-    definitionConfigForm.value.remark = undefined;
-  }
-};
-//淇濆瓨琛ㄥ崟
-const handlerSaveForm = async () => {
-  getByTableNameNotDefId(definitionConfigForm.value.tableName, definitionConfigForm.value.definitionId).then((res) => {
-    if (res.data && res.data.length > 0) {
-      ElMessageBox.confirm('琛ㄥ悕宸茶銆�' + res.data[0].processKey + '銆戠増鏈瑅' + res.data[0].version + '.0缁戝畾纭鍚庡皢浼氬垹闄ょ粦瀹氱殑娴佺▼KEY!', '鎻愮ず', {
-        confirmButtonText: '纭',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning'
-      }).then(() => {
-        saveOrUpdate(definitionConfigForm.value).then((resp) => {
-          if (resp.code === 200) {
-            proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛');
-            definitionConfigDialog.visible = false;
-            getList();
-          }
-        });
-      });
-    } else {
-      saveOrUpdate(definitionConfigForm.value).then((resp) => {
-        if (resp.code === 200) {
-          proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛');
-          definitionConfigDialog.visible = false;
-          getList();
-        }
-      });
+/**
+ * 璁捐娴佺▼
+ * @param row
+ */
+const design = async (row: FlowDefinitionVo) => {
+  proxy.$router.push({
+    path: `/workflow/design/index`,
+    query: {
+      definitionId: row.id,
+      disabled: false
     }
   });
 };
+
+/**
+ * 鏌ョ湅娴佺▼
+ * @param row
+ */
+const designView = async (row: FlowDefinitionVo) => {
+  proxy.$router.push({
+    path: `/workflow/design/index`,
+    query: {
+      definitionId: row.id,
+      disabled: true
+    }
+  });
+};
+/** 琛ㄥ崟閲嶇疆 */
+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