瀏覽代碼

更新条件

lex-xin 4 年之前
父節點
當前提交
1f9ff45fa0

+ 9 - 0
.eslintrc.js

@@ -21,6 +21,15 @@ module.exports = {
         "allowFirstLine": false
       }
     }],
+    "vue/html-self-closing": ["error", {
+      "html": {
+          "void": "never",
+          "normal": "any",
+          "component": "any"
+      },
+      "svg": "always",
+      "math": "always"
+    }],
     "vue/singleline-html-element-content-newline": "off",
     "vue/multiline-html-element-content-newline":"off",
     "vue/name-property-casing": ["error", "PascalCase"],

+ 95 - 13
src/components/wfd/components/DetailPanel/FlowDetail.vue

@@ -19,28 +19,42 @@
       </div>
       <div class="panelRow">
         <div>{{ i18n['sequenceFlow.expression'] }}:</div>
-        <el-input
+        <!-- <el-input
           style="width:90%; font-size:12px"
           type="textarea"
           :rows="4"
           :disabled="readOnly"
           :value="model.conditionExpression"
           @input="(value) => {onChange('conditionExpression', value)}"
-        />
-        <!-- <div v-for="(item, index) in conditionList" :key="index">
+        /> -->
+        <div v-for="(item, index) in conditionList" :key="index">
           <el-select
             v-model="item.key"
             style="width:90%; font-size:12px"
             placeholder="请选择关联字段"
+            clearable
+            @change="onChangeCondition"
           >
-            <el-option label="同意" value="1" />
-            <el-option label="拒绝" value="0" />
-            <el-option label="其他" value="2" />
+            <el-option-group
+              v-for="group in fieldList"
+              :key="group.label"
+              :label="group.label"
+            >
+              <el-option
+                v-for="i in group.options"
+                :key="i.value"
+                :label="i.label"
+                :value="i.value"
+              >
+              </el-option>
+            </el-option-group>
           </el-select>
           <el-select
             v-model="item.sign"
-            style="width:90%; font-size:12px"
+            style="width:40%; font-size:12px"
             placeholder="请选择标识"
+            clearable
+            @change="onChangeCondition"
           >
             <el-option label="大于" value=">" />
             <el-option label="大于等于" value=">=" />
@@ -53,17 +67,20 @@
             v-model="item.value"
             style="width:90%; font-size:12px"
             type="number"
+            clearable
+            @change="onChangeCondition"
           />
+          <el-button v-if="conditionList.length > 1" type="text" icon="el-icon-remove-outline" @click="delDisplayCondition(index)">删  除</el-button>
           <hr v-if="conditionList.length > 1" style="background-color: #dcdfe6; border:none; height:1px;">
         </div>
-        <el-button type="text" icon="el-icon-circle-plus-outline" @click="addDisplayCondition">新  增</el-button> -->
+        <el-button type="text" icon="el-icon-circle-plus-outline" @click="addDisplayCondition">新  增</el-button>
       </div>
     </div>
   </div>
 </template>
 <script>
 import DefaultDetail from './DefaultDetail'
-// import { templateDetails } from '@/api/process/admin/template'
+import { templateDetails } from '@/api/process/admin/template'
 export default {
   inject: ['i18n'],
   components: {
@@ -97,14 +114,70 @@ export default {
         key: null,
         sign: null,
         value: null
-      }]
+      }],
+      fieldList: []
+    }
+  },
+  watch: {
+    templates(newValue) {
+      this.__init()
     }
   },
-  mounted() {
-    console.log(this.templates, this.templatesBase)
-    // api-oa/api/v1/tpl/details?template_id=28
+  async mounted() {
+    this.__init()
+    console.log(this.model.conditionExpression)
   },
   methods: {
+    onChangeCondition() {
+      this.onChange('conditionExpression', JSON.stringify(this.conditionList))
+    },
+    async __init() {
+      const templateList = []
+      this.templates.forEach((item) => {
+        templateList.push(this.getFieldList(item))
+      })
+
+      Promise.all(templateList).then(values => {
+        this.formatTemplateData(values)
+        // 反显数据
+        let conditionExpression = this.model.conditionExpression
+        conditionExpression = JSON.parse(conditionExpression)
+        if (conditionExpression) {
+          this.conditionList = conditionExpression
+        }
+      })
+    },
+    async getFieldList(id) {
+      return new Promise(async(resolve, reject) => {
+        await templateDetails({ template_id: id }).then(res => {
+          resolve(res.data)
+        }).catch(() => {
+          reject()
+        })
+      })
+    },
+    formatTemplateData(template) {
+      const templates = template || []
+      const optionList = []
+      templates.forEach(template => {
+        const options = {}
+        options.label = template.name
+        options.options = []
+        const formStructure = template.form_structure.list || []
+        if (formStructure.length > 0) {
+          formStructure.forEach(item => {
+            if (item.type != 'subform') {
+              options.options.push({
+                label: item.name,
+                value: item.model
+              })
+            }
+          })
+        }
+        optionList.push(options)
+      })
+      this.fieldList = optionList
+    },
     addDisplayCondition() {
       // 添加验证
       this.conditionList.push({
@@ -112,6 +185,15 @@ export default {
         sign: null,
         value: null
       })
+    },
+    delDisplayCondition(index) {
+      this.$confirm('是否删除条件表达式?', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.conditionList.splice(index, 1)
+      })
     }
   }
 }

File diff suppressed because it is too large
+ 0 - 0
web/index.html


File diff suppressed because it is too large
+ 0 - 0
web/static/web/js/chunk-7d19a5ec.5d7b670a.js


File diff suppressed because it is too large
+ 0 - 0
web/static/web/js/chunk-7d19a5ec.7bfb14f9.js


Some files were not shown because too many files changed in this diff