whj 11 月之前
父節點
當前提交
e9e455cfc2

+ 1 - 0
src/utils/dict.js

@@ -355,6 +355,7 @@ DictCache.TYPE = {
   CUSTOM_FORM_TYPE: 'CUSTOM_FORM_TYPE',
   CATEGORY_TYPE: 'CATEGORY_TYPE',
   CLASS_NAME_CODE: 'CLASS_NAME_CODE',
+  TREATMENT_CONDITION:'TREATMENT_CONDITION'
 
 }
 DictCache.CODE = {

+ 12 - 7
src/views/test/Test1.vue

@@ -80,14 +80,16 @@ export default {
       // 初始化节点
       this.instance = newInstance({
         container: this.$refs.container,
+        connectionsDetachable: false,
         dragOptions: {
           containmentPadding: 10,
           grid: { w: 20, h: 20 },
         },
       })
       this.instance.importDefaults({
-        anchor: 'Continuous',
+        anchors: ['Bottom', 'Top'],
         connectionsDetachable: false,
+        reattachConnections: true,
         // 连接器类型,这里设置为Flowchart
         connector: {
           type: 'Flowchart',
@@ -135,7 +137,6 @@ export default {
               target: this.$refs[children][0].$el,
               // 连接方式,这里设置为连续
               // paintStyle: { stroke: children.label == '同意' ? '#345' : 'red', strokeWidth: 3 },
-              anchor: 'AutoDefault',
               // 连接器类型,这里设置为Flowchart
               connector: 'Flowchart',
               // 添加两个标签和箭头
@@ -176,20 +177,24 @@ export default {
       // })
       //拖拽
       this.instance.bind(EVENT_DRAG_STOP, (val) => {
-        console.log(val.el.__vue__)
-        console.log(3)
         val.el.__vue__.setPosition(val.elements[0].pos)
       })
       // 建立链接
       this.instance.bind(EVENT_CONNECTION, (val) => {
-        console.log(val)
-        console.log(2)
+        if (val.source.__vue__.detail.children.includes(val.target.__vue__.detail.id)) {
+          return
+        }
+        val.source.__vue__.detail.children.push(val.target.__vue__.detail.id)
       })
       // 删除连接
       this.instance.bind(EVENT_CONNECTION_DBL_CLICK, (conn) => {
         this.$confirm({
           title: '确定删除所点击的链接吗?',
           onOk() {
+            conn.source.__vue__.detail.children.splice(
+              conn.source.__vue__.detail.children.indexOf(conn.target.__vue__.detail.id),
+              1
+            )
             that.instance.deleteConnection(conn)
           },
         })
@@ -209,6 +214,7 @@ export default {
       this.instance.setZoom(this.scale / 100)
     },
     add(record, type) {
+      console.log(record)
       const newVal = {
         name: type === 2 ? '条件分支' : '审核人',
         id: +new Date(),
@@ -249,7 +255,6 @@ export default {
           target: this.$refs[newVal.id][0].$el,
           // 连接方式,这里设置为连续
           // paintStyle: { stroke: children.label == '同意' ? '#345' : 'red', strokeWidth: 3 },
-          anchor: 'AutoDefault',
           // 连接器类型,这里设置为Flowchart
           connector: 'Flowchart',
           // 添加两个标签和箭头

+ 30 - 23
src/views/workflow/workflow/modules/BaseForm.vue

@@ -51,26 +51,11 @@ export default {
           name: '发起人',
           id: '1',
           type: 1,
+          sortNum: 1,
           y: 100,
           x: 500,
           children: [],
         },
-        // {
-        //   y: 350,
-        //   x: 500,
-        //   id: '2',
-        //   type: 2,
-        //   name: 'node2',
-        //   children: ['3'],
-        // },
-        // {
-        //   y: 600,
-        //   x: 500,
-        //   id: '3',
-        //   type: 3,
-        //   name: 'node3',
-        //   children: [],
-        // },
       ],
     }
   },
@@ -102,8 +87,9 @@ export default {
         },
       })
       this.instance.importDefaults({
-        anchor: 'Continuous',
+        anchors: ['Bottom', 'Top'],
         connectionsDetachable: false,
+        reattachConnections: true,
         // 连接器类型,这里设置为Flowchart
         connector: {
           type: 'Flowchart',
@@ -142,6 +128,7 @@ export default {
       })
       this.instance.addSourceSelector('.bottom')
       this.instance.addTargetSelector('.top')
+      console.log(this.details)
       this.details.forEach((item) => {
         if (item.children.length) {
           item.children.forEach((children) => {
@@ -151,7 +138,6 @@ export default {
               target: this.$refs[children][0].$el,
               // 连接方式,这里设置为连续
               // paintStyle: { stroke: children.label == '同意' ? '#345' : 'red', strokeWidth: 3 },
-              anchor: 'AutoDefault',
               // 连接器类型,这里设置为Flowchart
               connector: 'Flowchart',
               // 添加两个标签和箭头
@@ -192,20 +178,24 @@ export default {
       // })
       //拖拽
       this.instance.bind(EVENT_DRAG_STOP, (val) => {
-        console.log(val.el.__vue__)
-        console.log(3)
         val.el.__vue__.setPosition(val.elements[0].pos)
       })
       // 建立链接
       this.instance.bind(EVENT_CONNECTION, (val) => {
-        console.log(val)
-        console.log(2)
+        if (val.source.__vue__.detail.children.includes(val.target.__vue__.detail.id)) {
+          return
+        }
+        val.source.__vue__.detail.children.push(val.target.__vue__.detail.id)
       })
       // 删除连接
       this.instance.bind(EVENT_CONNECTION_DBL_CLICK, (conn) => {
         this.$confirm({
           title: '确定删除所点击的链接吗?',
           onOk() {
+            conn.source.__vue__.detail.children.splice(
+              conn.source.__vue__.detail.children.indexOf(conn.target.__vue__.detail.id),
+              1
+            )
             that.instance.deleteConnection(conn)
           },
         })
@@ -229,10 +219,12 @@ export default {
         name: type === 2 ? '条件分支' : '审核人',
         id: +new Date(),
         verifier: '',
+        userName: '',
         reflect: '',
         titleCode: '',
         titleColumnCode: '',
         handleNameId: '',
+        sortNum: record.sortNum++,
       }
       if (record.children.length > 0) {
         const children = this.details
@@ -270,7 +262,6 @@ export default {
           target: this.$refs[newVal.id][0].$el,
           // 连接方式,这里设置为连续
           // paintStyle: { stroke: children.label == '同意' ? '#345' : 'red', strokeWidth: 3 },
-          anchor: 'AutoDefault',
           // 连接器类型,这里设置为Flowchart
           connector: 'Flowchart',
           // 添加两个标签和箭头
@@ -312,6 +303,19 @@ export default {
     },
     handleBack() {
       this.visible = false
+      this.record = {}
+      this.name = ''
+      this.details = [
+        {
+          name: '发起人',
+          id: '1',
+          type: 1,
+          sortNum: 1,
+          y: 100,
+          x: 500,
+          children: [],
+        },
+      ]
       this.$emit('ok')
     },
   },
@@ -365,6 +369,9 @@ export default {
   display: flex;
   flex-direction: column;
   min-height: calc(100vh - 100px);
+  max-height: calc(100vh - 100px);
+  overflow-y: auto;
+
   width: 100%;
 }
 .scale {

+ 45 - 2
src/views/workflow/workflow/modules/modules/BaseForm.vue

@@ -10,11 +10,15 @@
           </a-tree-select>
         </a-form-item>
         <a-form-item label="审核人">
-          <a-select v-decorator="['verifier', {rules: [{required: true, message: '审核人不能为空'}]}]" placeholder="请选择">
+          <a-select v-decorator="['verifier', {rules: [{required: true, message: '审核人不能为空'}]}]" placeholder="请选择" @change="handleVerifier">
             <a-select-option v-for="{realName, userId} in verifierList" :key="userId" :label="realName" :value="userId">{{ realName }}
             </a-select-option>
           </a-select>
         </a-form-item>
+        <a-form-item label="审核人姓名 " v-show="false">
+          <a-input type="hidden" v-decorator="['userName']">
+          </a-input>
+        </a-form-item>
       </template>
       <template v-if="record.type===2">
         <a-form-item label="配置类型" v-show="false">
@@ -39,6 +43,18 @@
             </a-select-option>
           </a-select>
         </a-form-item>
+        <a-form-item label="处理条件">
+          <a-row>
+            <a-col :span="6">
+              <a-select v-decorator="['handleCondition', {rules: [{required: true, message: '处理条件不能为空'}]}]">
+                <a-select-option v-for="(label,value) in handleConditionMap" :key="value" :value="value">{{label}}</a-select-option>
+              </a-select>
+            </a-col>
+            <a-col :span="18">
+              <a-input v-decorator="['handleConditionValue', {rules: [{required: true, message: '处理条件值不能为空'}]}]" />
+            </a-col>
+          </a-row>
+        </a-form-item>
       </template>
 
       <!-- <a-form-item label="描述">
@@ -73,9 +89,12 @@ export default {
       customCodeList: [],
       customClassNameList: [],
       handleNameList: [],
+      handleConditionMap: {},
     }
   },
   created() {
+    this.handleConditionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.TREATMENT_CONDITION)
+    console.log(this.handleConditionMap)
     getDeptTree().then((res) => {
       this.treeData = this.setTree(res.data)
     })
@@ -94,7 +113,17 @@ export default {
       this.$nextTick(() => {
         setFieldsValue(
           Object.assign(
-            pick(record, ['name', 'verifier', 'reflect', 'titleCode', 'titleColumnCode', 'handleNameId', 'id'])
+            pick(record, [
+              'name',
+              'verifier',
+              'reflect',
+              'titleCode',
+              'titleColumnCode',
+              'handleNameId',
+              'id',
+              'handleCondition',
+              'handleConditionValue',
+            ])
           )
         )
       })
@@ -147,7 +176,18 @@ export default {
         })
       })
     },
+    handleVerifier(_, val) {
+      console.log(val)
+      const {
+        form: { setFieldsValue },
+      } = this
 
+      this.$nextTick(() => {
+        setFieldsValue({
+          userName: val.componentOptions.propsData.label,
+        })
+      })
+    },
     save() {
       const {
         form: { validateFieldsAndScroll },
@@ -165,6 +205,9 @@ export default {
         this.record.titleColumnCode = values.titleColumnCode
         this.record.handleNameId = values.handleNameId
         this.record.deptId = values.deptId
+        this.record.userName = values.userName
+        this.record.handleConditionValue = values.handleConditionValue
+        this.record.handleCondition = values.handleCondition
         this.confirmLoading = false
         this.onClose()
       })

+ 0 - 1
src/views/workflow/workflow/modules/modules/Node.vue

@@ -98,7 +98,6 @@ export default {
   },
   methods: {
     setPosition(position) {
-      console.log(position)
       this.detail.x = position.x
       this.detail.y = position.y
     },