Explorar el Código

:bulb: 工作流程增加租户绑定

smallchill hace 6 años
padre
commit
89607e12b2

+ 2 - 1
src/api/flow/flow.js

@@ -63,9 +63,10 @@ export const changeState = (params) => {
   })
 }
 
-export const deployUpload = (category, files) => {
+export const deployUpload = (category, tenantIds, files) => {
   const formData = new FormData();
   formData.append('category', category);
+  formData.append('tenantIds', tenantIds);
   files.forEach(file => {
     formData.append('files', file);
   });

+ 2 - 1
src/views/desk/notice.vue

@@ -101,9 +101,10 @@
             {
               label: "通知时间",
               prop: "releaseTimeRange",
-              type: "datetimerange",
+              type: "datetime",
               format: "yyyy-MM-dd hh:mm:ss",
               valueFormat: "yyyy-MM-dd hh:mm:ss",
+              searchRange:true,
               hide: true,
               addDisplay: false,
               editDisplay: false,

+ 72 - 6
src/views/flow/deploy.vue

@@ -1,6 +1,6 @@
 <template>
   <basic-container>
-    <avue-form :option="option" v-model="form" :upload-before="uploadBefore" :upload-after="uploadAfter"></avue-form>
+    <avue-form ref="form" :option="option" v-model="form" :upload-before="uploadBefore" :upload-after="uploadAfter"/>
   </basic-container>
 </template>
 
@@ -13,7 +13,8 @@
       return {
         form: {
           flowCategory: '',
-          imgUrl: [],
+          tenantId: '',
+          flowFile: [],
           file: {},
         },
         option: {
@@ -29,6 +30,8 @@
                 label: "dictValue",
                 value: "dictKey"
               },
+              row: true,
+              span: 12,
               dataType: "number",
               rules: [
                 {
@@ -38,9 +41,55 @@
                 }
               ]
             },
+            {
+              label: "流程模式",
+              prop: "flowType",
+              type: "radio",
+              dicData: [
+                {
+                  label: "通用流程",
+                  value: 1
+                },
+                {
+                  label: "定制流程",
+                  value: 2
+                }
+              ],
+              value: 1,
+              row: true,
+              span: 12,
+              rules: [
+                {
+                  required: true,
+                  message: '请选择流程模式',
+                  trigger: 'blur'
+                }
+              ],
+            },
+            {
+              label: "所属租户",
+              prop: "tenantId",
+              type: "tree",
+              multiple: true,
+              dicUrl: "/api/blade-system/tenant/select",
+              props: {
+                label: "tenantName",
+                value: "tenantId"
+              },
+              display: false,
+              row: true,
+              span: 12,
+              rules: [
+                {
+                  required: true,
+                  message: '请选择所属租户',
+                  trigger: 'blur'
+                }
+              ],
+            },
             {
               label: '附件上传',
-              prop: 'imgUrl',
+              prop: 'flowFile',
               type: 'upload',
               loadText: '附件上传中,请稍等',
               span: 24,
@@ -54,9 +103,18 @@
         }
       }
     },
+    watch: {
+      'form.flowType'() {
+        this.$refs.form.option.column.filter(item => {
+          if (item.prop === "tenantId") {
+            item.display = this.form.flowType === 2;
+          }
+        });
+      }
+    },
     methods: {
       uploadBefore(file, done) {
-        this.$message.success('部署开始')
+        this.$message.success('部署开始');
         this.file = file;
         done()
       },
@@ -66,11 +124,19 @@
           loading()
           return false;
         }
+        if (this.form.flowType === 1 && !this.form.tenantId) {
+          this.$message.warning('清先选择对应租户');
+          loading();
+          return false;
+        }
         if (res.success) {
-          deployUpload(flowCategory(this.form.flowCategory), [this.file]).then(res => {
+          deployUpload(
+            flowCategory(this.form.flowCategory),
+            (this.form.tenantId) ? this.form.tenantId.join(",") : "",
+            [this.file]
+          ).then(res => {
             const data = res.data;
             if (data.success) {
-              this.$message.success('部署结束')
               done()
             } else {
               this.$message.error(data.msg);

+ 112 - 47
src/views/flow/model.vue

@@ -83,33 +83,18 @@
       <span slot="footer"
             class="dialog-footer">
         <el-button @click="flowBox = false">取 消</el-button>
-        <el-button type="primary"
-                   @click="handleRefresh">确 定</el-button>
+        <el-button type="primary" @click="handleRefresh">确 定</el-button>
       </span>
     </el-dialog>
     <el-dialog title="流程部署"
                append-to-body
                :visible.sync="deployBox"
                width="20%">
-      <el-form :model="form"
-               ref="form"
-               label-width="80px">
-        <el-form-item label="流程类型">
-          <el-select v-model="categoryValue" placeholder="请选择" value="">
-            <el-option
-              v-for="item in category"
-              :key="item.dictKey"
-              :label="item.dictValue"
-              :value="item.dictKey">
-            </el-option>
-          </el-select>
-        </el-form-item>
-      </el-form>
+      <avue-form ref="form" :option="optionDeploy" v-model="form" @submit="handleSubmit"/>
       <span slot="footer"
             class="dialog-footer">
         <el-button @click="deployBox = false">取 消</el-button>
-        <el-button type="primary"
-                   @click="handleDoDeploy">确 定</el-button>
+        <el-button type="primary" @click="handleDoDeploy" :loading="deployLoading">确 定</el-button>
       </span>
     </el-dialog>
   </basic-container>
@@ -121,15 +106,85 @@
   import {getDictionary} from "@/api/system/dict";
   import {modelList, removeModel, deployModel} from "@/api/flow/flow";
   import {flowCategory} from "@/util/flow";
+  import {leaveProcess} from "@/api/work/process";
 
   export default {
     data() {
       return {
         form: {},
+        optionDeploy: {
+          menuBtn: false,
+          column: [
+            {
+              label: "流程类型",
+              type: "select",
+              dicUrl: "/api/blade-system/dict/dictionary?code=flow",
+              props: {
+                label: "dictValue",
+                value: "dictKey"
+              },
+              dataType: "number",
+              slot: true,
+              prop: "categoryValue",
+              search: true,
+              span: 24,
+              rules: [{
+                required: true,
+                message: "请选择流程类型",
+                trigger: "blur"
+              }]
+            },
+            {
+              label: "流程模式",
+              prop: "flowType",
+              type: "radio",
+              dicData: [
+                {
+                  label: "通用流程",
+                  value: 1
+                },
+                {
+                  label: "定制流程",
+                  value: 2
+                }
+              ],
+              value: 1,
+              span: 24,
+              rules: [
+                {
+                  required: true,
+                  message: '请选择流程模式',
+                  trigger: 'blur'
+                }
+              ],
+            },
+            {
+              label: "所属租户",
+              prop: "tenantId",
+              type: "tree",
+              multiple: true,
+              dicUrl: "/api/blade-system/tenant/select",
+              props: {
+                label: "tenantName",
+                value: "tenantId"
+              },
+              display: false,
+              span: 24,
+              rules: [
+                {
+                  required: true,
+                  message: '请选择所属租户',
+                  trigger: 'blur'
+                }
+              ],
+            },
+          ],
+        },
         selectionId: '',
         selectionList: [],
         query: {},
         loading: true,
+        deployLoading: false,
         page: {
           pageSize: 10,
           currentPage: 1,
@@ -138,8 +193,6 @@
         deployBox: false,
         flowBox: false,
         flowUrl: '',
-        category: [],
-        categoryValue: '',
         option: {
           height: 'auto',
           calcHeight: 30,
@@ -193,6 +246,15 @@
         data: []
       };
     },
+    watch: {
+      'form.flowType'() {
+        this.$refs.form.option.column.filter(item => {
+          if (item.prop === "tenantId") {
+            item.display = this.form.flowType === 2;
+          }
+        });
+      }
+    },
     computed: {
       ...mapGetters(["permission"]),
       ids() {
@@ -204,6 +266,33 @@
       }
     },
     methods: {
+      handleSubmit(form, done) {
+        this.deployLoading = true;
+        deployModel({
+          modelId: this.selectionId,
+          category: flowCategory(form.categoryValue),
+          tenantIds: form.tenantId.join(",")
+        }).then(res => {
+          const data = res.data;
+          if (data.success) {
+            this.$message({
+              type: "success",
+              message: data.msg
+            });
+            done();
+            this.$refs.form.resetForm();
+            this.deployBox = false;
+            this.deployLoading = false;
+          } else {
+            done();
+            this.deployLoading = false;
+            this.$message({
+              type: "warn",
+              message: data.msg
+            });
+          }
+        })
+      },
       searchReset() {
         this.query = {};
         this.onLoad(this.page);
@@ -256,28 +345,7 @@
         this.selectionId = row.id;
       },
       handleDoDeploy() {
-        if (!this.categoryValue) {
-          this.$message({
-            type: "warn",
-            message: "请先选择流程类型!"
-          });
-          return;
-        }
-        deployModel({modelId: this.selectionId, category: flowCategory(this.categoryValue)}).then(res => {
-          const data = res.data;
-          if (data.success) {
-            this.$message({
-              type: "success",
-              message: data.msg
-            });
-            this.deployBox = false;
-          } else {
-            this.$message({
-              type: "warn",
-              message: data.msg
-            });
-          }
-        })
+        this.$refs.form.submit();
       },
       handleDownload(row) {
         window.open(`${website.flowDesignUrl}/app/rest/models/${row.id}/bpmn20`);
@@ -304,10 +372,10 @@
         this.flowBox = false;
         this.onLoad(this.page);
       },
-      currentChange(currentPage){
+      currentChange(currentPage) {
         this.page.currentPage = currentPage;
       },
-      sizeChange(pageSize){
+      sizeChange(pageSize) {
         this.page.pageSize = pageSize;
       },
       refreshChange() {
@@ -322,9 +390,6 @@
           this.loading = false;
           this.selectionClear();
         });
-        getDictionary({code: 'flow'}).then(res => {
-          this.category = res.data.data;
-        })
       }
     }
   };

+ 0 - 1
src/views/work/claim.vue

@@ -5,7 +5,6 @@
                :data="data"
                ref="crud"
                v-model="form"
-               :page="page"
                @search-change="searchChange"
                @search-reset="searchReset"
                @selection-change="selectionChange"

+ 1 - 1
src/views/work/process/leave/form.vue

@@ -1,6 +1,6 @@
 <template>
   <basic-container>
-    <avue-form :option="option" v-model="form" @submit="handleSubmit"></avue-form>
+    <avue-form :option="option" v-model="form" @submit="handleSubmit"/>
   </basic-container>
 </template>
 

+ 28 - 4
src/views/work/start.vue

@@ -13,6 +13,12 @@
                @size-change="sizeChange"
                @refresh-change="refreshChange"
                @on-load="onLoad">
+      <template slot="menuLeft">
+        <el-radio-group v-model="mode" size="small">
+          <el-radio-button label="1">通用流程</el-radio-button>
+          <el-radio-button label="2">定制流程</el-radio-button>
+        </el-radio-group>
+      </template>
       <template slot-scope="scope" slot="menu">
         <el-button type="text"
                    size="small"
@@ -29,6 +35,10 @@
                    @click.stop="handleImage(scope.row,scope.index)">流程图
         </el-button>
       </template>
+      <template slot-scope="{row}"
+                slot="tenantId">
+        <el-tag>{{row.tenantId===''?'通用':row.tenantId}}</el-tag>
+      </template>
       <template slot-scope="{row}"
                 slot="version">
         <el-tag>v{{row.version}}</el-tag>
@@ -69,12 +79,14 @@
 <script>
   import {mapGetters} from "vuex";
   import {startList} from "@/api/work/work";
-  import {flowCategory,flowRoute} from "@/util/flow";
+  import {flowCategory, flowRoute} from "@/util/flow";
+  import func from "@/util/func";
 
   export default {
     data() {
       return {
         form: {},
+        mode: '1',
         selectionId: '',
         selectionList: [],
         query: {},
@@ -103,6 +115,12 @@
           menuWidth: 150,
           dialogWidth: 900,
           column: [
+            {
+              label: '租户编号',
+              prop: 'tenantId',
+              slot: true,
+              width: 150,
+            },
             {
               label: "流程分类",
               type: "select",
@@ -149,6 +167,11 @@
         data: []
       };
     },
+    watch: {
+      'mode'() {
+        this.onLoad(this.page);
+      }
+    },
     computed: {
       ...mapGetters(["permission", "flowRoutes"]),
       ids() {
@@ -184,10 +207,10 @@
         this.flowUrl = `/api/blade-flow/process/resource-view?processDefinitionId=${row.id}`;
         this.flowBox = true;
       },
-      currentChange(currentPage){
+      currentChange(currentPage) {
         this.page.currentPage = currentPage;
       },
-      sizeChange(pageSize){
+      sizeChange(pageSize) {
         this.page.pageSize = pageSize;
       },
       refreshChange() {
@@ -196,7 +219,8 @@
       onLoad(page, params = {}) {
         const query = {
           ...this.query,
-          category: (params.category) ? flowCategory(params.category) : null
+          category: (params.category) ? flowCategory(params.category) : null,
+          mode: this.mode
         };
         this.loading = true;
         startList(page.currentPage, page.pageSize, Object.assign(params, query)).then(res => {

+ 0 - 1
src/views/work/todo.vue

@@ -5,7 +5,6 @@
                :data="data"
                ref="crud"
                v-model="form"
-               :page="page"
                @search-change="searchChange"
                @search-reset="searchReset"
                @selection-change="selectionChange"