朱鑫波 il y a 4 ans
Parent
commit
681df9f42b

+ 1 - 1
src/components/formComponents/selectGroup.vue

@@ -244,7 +244,7 @@ export default {
           })
           if (!this.multiple && !this.require) {
             data.unshift({ label: '不限', value: 'unlimited' })
-            if (this.value == '' || this.value.length == 0 || this.value == null) {
+            if (this.value == ''|| this.value == null || this.value.length == 0 ) {
               this.selectedVal = ['unlimited']
             }
           } else {

+ 384 - 141
src/views/modules/earlyWarningRules/ruleModule.vue

@@ -1,10 +1,20 @@
+
+<style>
+.display-none-selset {
+  display: none !important;
+}
+</style>
 <template>
   <div class="ruleModule">
     <div class="toolbox-automate-rules-create-body">
-      <div class="toolbox-automate-rules-create-content_title"><h3>预警值填写</h3></div>
+      <a-steps :current="current" size="default" style="width: 50%; margin: 0 auto" v-if="editShow">
+        <a-step title="预警值填写" />
+        <a-step title="开关设置" />
+      </a-steps>
+
       <!-- {{ ceshi }}{{ time }}
       <br />
-      <selectGroup v-model="ceshi2" style="width: 300px" code="37f678d06fc45b494a924894355d6f76" :multiple="true" />
+      <selectGroup v-model="ceshi2" style="width: 300px;margin-right:5px" code="37f678d06fc45b494a924894355d6f76" :multiple="true" />
 
       <timeRange v-model="time" :allowClear="true" :disabledDate="disabledDate" /> -->
       <!-- {{ ceshi }}
@@ -16,146 +26,342 @@
         :radioStyle="true"
       />
       {{ form }} -->
-      <div class="toolbox-automate-rules-create-content">
-        <a-form-model ref="ruleForm" :model="form">
-          <div class="moduler">
-            <template v-for="(item, index) of form.ruleList">
-              <div class="row-item" v-if="item.ruleType == 'base'">
-                <div class="hint-item">
-                  <a-tooltip>
-                    <template slot="title">
-                      {{ item.remark }}
-                    </template>
-                    <a-icon type="question-circle" />
-                  </a-tooltip>
-                </div>
-                <div class="label-item">
-                  <div class="text-item">{{ item.groupName }}</div>
-                  <div class="required-item"></div>
-                </div>
-                <div class="input-item">
-                  <a-form-model-item
-                    v-for="(value, valueIndex) of item.ruleDetail"
-                    :key="valueIndex"
-                    :ref="value.indicatorCode + valueIndex"
-                    :prop="'ruleList.' + index + '.ruleDetail.' + valueIndex + '.threshold'"
-                    :rules="{
-                      required: true,
-                      message: `${item.groupName}必填`,
-                      trigger: value.dataType == 'array' ? 'change' : 'blur',
-                    }"
-                  >
-                    <a-input-number
-                      v-model="value.threshold"
-                      :min="0"
-                      style="width: 300px"
-                      v-if="value.dataType == 'number'"
-                    />
-
-                    <a-input
+      <div v-if="current == 0">
+        <div class="toolbox-automate-rules-create-content_title"><h3>预警值填写</h3></div>
+        <a-spin :spinning="spinLoading">
+          <div class="toolbox-automate-rules-create-content">
+            <a-form-model ref="ruleForm" :model="form" layout="horizontal" v-bind="allCol">
+              <div class="moduler">
+                <template v-for="(item, index) of form.ruleList">
+                  <div class="row-item" v-if="item.ruleType == 'base' && item.isCopy == 0">
+                    <div class="hint-item">
+                      <a-tooltip>
+                        <template slot="title">
+                          {{ item.remark }}
+                        </template>
+                        <a-icon type="question-circle" />
+                      </a-tooltip>
+                    </div>
+                    <div class="label-item">
+                      <div class="text-item">{{ item.groupName }}</div>
+                      <div class="required-item"></div>
+                    </div>
+                    <div class="input-item">
+                      <a-form-model-item
+                        v-for="(value, valueIndex) of item.ruleDetail"
+                        :key="valueIndex"
+                        :ref="value.indicatorCode + valueIndex"
+                        :prop="'ruleList.' + index + '.ruleDetail.' + valueIndex + '.threshold'"
+                        :rules="{
+                          required: true,
+                          message: `${item.groupName}必填`,
+                          trigger: value.dataType == 'array' ? 'change' : 'blur',
+                        }"
+                      >
+                        <a-input-number
+                          v-model="value.threshold"
+                          :min="0"
+                          style="width: 300px;margin-right:5px"
+                          v-if="value.modelType == 'numberText'"
+                        />
+                        <a-input v-model="value.threshold" style="width: 300px;margin-right:5px" v-else-if="value.modelType == 'text'" />
+                        <selectGroup
+                          v-model="value.threshold"
+                          style="width: 300px;margin-right:5px"
+                          :code="value.dictId"
+                          :multiple="value.dataType == 'string' ? false : true"
+                          v-else-if="value.modelType == 'select'"
+                        />
+                        <!-- <selectGroup
                       v-model="value.threshold"
-                      :min="0"
-                      style="width: 300px"
-                      v-else-if="value.dataType == 'string'"
-                    />
-                    <selectGroup
-                      v-model="value.threshold == '' ? [] : value.threshold"
-                      style="width: 300px"
+                      style="width: 300px;margin-right:5px"
                       :code="value.dictId"
                       :multiple="value.dataType == 'string' ? false : true"
-                      v-else-if="(value.dataType == 'array' || value.dataType == 'string') && value.dictId != ''"
-                    />{{ value.dataUnit }}
-                  </a-form-model-item>
-                </div>
-              </div>
+                    /> -->
+                        <checkBoxGroup
+                          v-model="value.threshold"
+                          style="width: 300px;margin-right:5px"
+                          :code="value.dictId"
+                          :allValue="value.dataType == 'string' ? true : false"
+                          :radioStyle="value.dataType == 'string' ? true : false"
+                          v-else-if="value.modelType == 'checkBox'"
+                        />
+                        <a-select
+                          mode="tags"
+                          style="width: 100%"
+                          placeholder="按回车生成标签"
+                          v-model="value.threshold"
+                          dropdownClassName="display-none-selset"
+                          :token-separators="[',', ' ', ',']"
+                          v-else-if="value.modelType == 'tagBox'"
+                        >
+                        </a-select>
+                        {{ value.dataUnit }}
+                      </a-form-model-item>
+                    </div>
+                  </div>
 
-              <div class="row-item" v-else>
-                <div class="hint-item">
-                  <a-tooltip>
-                    <template slot="title">
-                      {{ item.remark }}
-                    </template>
-                    <a-icon type="question-circle" />
-                  </a-tooltip>
-                </div>
-                <div class="label-item">
-                  <div class="text-item">{{ item.groupName }}</div>
-                  <div class="required-item"></div>
-                </div>
-                <div class="input-item">
-                  <div class="toolbox-automate-rules-create-content_rules-and-condition_rules">
-                    <div class="content">
-                      <div class="rules-list" v-for="(value, valueIndex) of item.ruleDetail" :key="valueIndex">
-                        <div class="rules-list-item">
-                          <template>
-                            <div class="row-item">
-                              <div class="hint-item"></div>
+                  <div class="row-item" v-else-if="item.ruleType == 'group' && item.isCopy == 0">
+                    <div class="hint-item">
+                      <a-tooltip>
+                        <template slot="title">
+                          {{ item.remark }}
+                        </template>
+                        <a-icon type="question-circle" />
+                      </a-tooltip>
+                    </div>
+                    <div class="label-item">
+                      <div class="text-item">{{ item.groupName }}</div>
+                      <div class="required-item"></div>
+                    </div>
+                    <div class="input-item">
+                      <div class="toolbox-automate-rules-create-content_rules-and-condition_rules">
+                        <div class="content">
+                          <div class="rules-list">
+                            <div class="rules-list-item">
+                              <template v-for="(value, valueIndex) of item.ruleDetail">
+                                <div class="row-item row-group" v-if="value.variableType == 1">
+                                  <!-- <div class="hint-item"></div>
                               <div class="label-item">
-                                <div class="text-item">{{ value.name }}</div>
+                                <div class="text-item"></div>
                                 <div class="required-item"></div>
-                              </div>
-                              <div class="input-item">
-                                <a-form-model-item
-                                  :ref="value.indicatorCode + valueIndex"
-                                  :prop="'ruleList.' + index + '.ruleDetail.' + valueIndex + '.threshold'"
-                                  :rules="{
-                                    required: true,
-                                    message: `${item.groupName}必填`,
-                                    trigger: 'blur',
-                                  }"
-                                  v-if="value.dataType == 'number'"
-                                >
-                                  <a-input-number v-model="value.threshold" :min="0" style="width: 300px" />{{
-                                    value.dataUnit
-                                  }}
-                                </a-form-model-item>
-                                <a-form-model-item
-                                  :ref="value.indicatorCode + valueIndex"
-                                  :prop="'ruleList.' + index + '.ruleDetail.' + valueIndex + '.threshold'"
-                                  :rules="{
-                                    required: true,
-                                    message: `${value.name}必选`,
-                                    trigger: 'change',
-                                  }"
-                                  v-if="(value.dataType == 'array' || value.dataType == 'string') && value.dictId != ''"
+                              </div> -->
+                                  <div class="input-item">
+                                    <a-form-model-item
+                                      :label="value.name"
+                                      :ref="value.indicatorCode + valueIndex"
+                                      :prop="'ruleList.' + index + '.ruleDetail.' + valueIndex + '.threshold'"
+                                      :rules="{
+                                        required: true,
+                                        message: `${value.name}必填`,
+                                        trigger: 'blur',
+                                      }"
+                                      v-if="value.modelType == 'numberText'"
+                                    >
+                                      <a-input-number style="width: 95%;" v-model="value.threshold" :min="0" />{{
+                                        value.dataUnit
+                                      }}
+                                    </a-form-model-item>
+                                    <a-form-model-item
+                                      :label="value.name"
+                                      :ref="value.indicatorCode + valueIndex"
+                                      :prop="'ruleList.' + index + '.ruleDetail.' + valueIndex + '.threshold'"
+                                      :rules="{
+                                        required: true,
+                                        message: `${value.name}必填`,
+                                        trigger: 'blur',
+                                      }"
+                                      v-else-if="value.modelType == 'text'"
+                                    >
+                                      <a-input v-model="value.threshold" style="width: 95%;" />
+                                    </a-form-model-item>
+                                    <a-form-model-item
+                                      :label="value.name"
+                                      :ref="value.indicatorCode + valueIndex"
+                                      :prop="'ruleList.' + index + '.ruleDetail.' + valueIndex + '.threshold'"
+                                      :rules="{
+                                        required: true,
+                                        message: `${value.name}必选`,
+                                        trigger: 'change',
+                                      }"
+                                      v-else-if="value.modelType == 'select' || value.modelType == 'checkBox'"
+                                    >
+                                      <selectGroup
+                                        v-model="value.threshold"
+                                        :code="value.dictId"
+                                        :multiple="value.dataType == 'string' ? false : true"
+                                        style="width: 95%"
+                                        @clearValidate="clearAll"
+                                      />
+                                    </a-form-model-item>
+                                    <a-form-model-item
+                                      :label="value.name"
+                                      :ref="value.indicatorCode + valueIndex"
+                                      :prop="'ruleList.' + index + '.ruleDetail.' + valueIndex + '.threshold'"
+                                      :rules="{
+                                        required: true,
+                                        message: `${value.name}必选`,
+                                        trigger: 'change',
+                                      }"
+                                      v-else-if="value.modelType == 'tagBox'"
+                                    >
+                                      <a-select
+                                        mode="tags"
+                                        style="width: 100%"
+                                        placeholder="按回车生成标签"
+                                        v-model="value.threshold"
+                                        dropdownClassName="display-none-selset"
+                                        :token-separators="[',', ' ', ',']"
+                                      >
+                                      </a-select>
+                                    </a-form-model-item>
+                                  </div>
+                                </div>
+                              </template>
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                    </div>
+                  </div>
+                  <div class="row-item" v-else-if="item.ruleType == 'group' && item.isCopy == 1">
+                    <div class="hint-item">
+                      <a-tooltip>
+                        <template slot="title">
+                          {{ item.remark }}
+                        </template>
+                        <a-icon type="question-circle" />
+                      </a-tooltip>
+                    </div>
+                    <div class="label-item">
+                      <div class="text-item">{{ item.groupName }}</div>
+                      <div class="required-item"></div>
+                    </div>
+                    <div class="input-item">
+                      <div class="toolbox-automate-rules-create-content_rules-and-condition_rules">
+                        <div class="content">
+                          <div class="rules-list" v-for="(valueElse, valueIndex) of item.ruleDetail">
+                            <div class="rules-list-item">
+                              <template v-for="(value, valueElseIndex) of valueElse">
+                                <div class="row-item row-group" v-if="value.variableType == 1">
+                                  <!-- <div class="hint-item"></div>
+                              <div class="label-item">
+                                <div class="text-item"></div>
+                                <div class="required-item"></div>
+                              </div> -->
+                                  <div class="input-item">
+                                    <a-form-model-item
+                                      :label="value.name"
+                                      :ref="value.indicatorCode + valueIndex"
+                                      :prop="
+                                        'ruleList.' +
+                                        index +
+                                        '.ruleDetail.' +
+                                        valueIndex +
+                                        '.' +
+                                        valueElseIndex +
+                                        '.threshold'
+                                      "
+                                      :rules="{
+                                        required: true,
+                                        message: `${value.name}必填`,
+                                        trigger: 'blur',
+                                      }"
+                                      v-if="value.modelType == 'numberText'"
+                                    >
+                                      <a-input-number style="width: 95%;" v-model="value.threshold" :min="0" />{{
+                                        value.dataUnit
+                                      }}
+                                    </a-form-model-item>
+                                    <a-form-model-item
+                                      :label="value.name"
+                                      :ref="value.indicatorCode + valueIndex"
+                                      :prop="
+                                        'ruleList.' +
+                                        index +
+                                        '.ruleDetail.' +
+                                        valueIndex +
+                                        '.' +
+                                        valueElseIndex +
+                                        '.threshold'
+                                      "
+                                      :rules="{
+                                        required: true,
+                                        message: `${value.name}必填`,
+                                        trigger: 'blur',
+                                      }"
+                                      v-else-if="value.modelType == 'text'"
+                                    >
+                                      <a-input v-model="value.threshold" style="width: 95%" />
+                                    </a-form-model-item>
+                                    <a-form-model-item
+                                      :label="value.name"
+                                      :ref="value.indicatorCode + valueIndex"
+                                      :prop="
+                                        'ruleList.' +
+                                        index +
+                                        '.ruleDetail.' +
+                                        valueIndex +
+                                        '.' +
+                                        valueElseIndex +
+                                        '.threshold'
+                                      "
+                                      :rules="{
+                                        required: true,
+                                        message: `${value.name}必选`,
+                                        trigger: 'change',
+                                      }"
+                                      v-else-if="value.modelType == 'select' || value.modelType == 'checkBox'"
+                                    >
+                                      <selectGroup
+                                        v-model="value.threshold"
+                                        :code="value.dictId"
+                                        :multiple="value.dataType == 'string' ? false : true"
+                                        style="width: 95%"
+                                        @clearValidate="clearAll"
+                                      />
+                                    </a-form-model-item>
+                                    <a-form-model-item
+                                      :label="value.name"
+                                      :ref="value.indicatorCode + valueIndex"
+                                      :prop="
+                                        'ruleList.' +
+                                        index +
+                                        '.ruleDetail.' +
+                                        valueIndex +
+                                        '.' +
+                                        valueElseIndex +
+                                        '.threshold'
+                                      "
+                                      :rules="{
+                                        required: true,
+                                        message: `${value.name}必选`,
+                                        trigger: 'change',
+                                      }"
+                                      v-else-if="value.modelType == 'tagBox'"
+                                    >
+                                      <a-select
+                                        mode="tags"
+                                        style="width: 100%"
+                                        placeholder="按回车生成标签"
+                                        v-model="value.threshold"
+                                        dropdownClassName="display-none-selset"
+                                        :token-separators="[',', ' ', ',']"
+                                      >
+                                      </a-select>
+                                    </a-form-model-item>
+                                  </div>
+                                </div>
+                                <div
+                                  class="rules-list-item-delete"
+                                  v-if="item.isCopy == 1"
+                                  @click="addData(item, valueElse, valueIndex)"
                                 >
-                                  <selectGroup
-                                    v-model="value.threshold"
-                                    style="width: 400px"
-                                    :code="value.dictId"
-                                    :multiple="value.dataType == 'string' ? false : true"
-                                    v-if="value.modelType == 'select' || value.modelType == 'checkBox'"
-                                    @clearValidate="clearAll"
-                                  />
-                                  <!-- <checkBoxGroup
-                                    v-model="value.threshold"
-                                    style="width: 400px"
-                                    :code="value.dictId"
-                                    :allValue="true"
-                                    :radioStyle="true"
-                                    v-else-if="value.modelType == 'checkBox'"
-                                  /> -->
-                                </a-form-model-item>
-                              </div>
+                                  {{ valueIndex == 0 ? '复制' : '删除' }}
+                                </div>
+                              </template>
                             </div>
-                          </template>
+                          </div>
                         </div>
                       </div>
                     </div>
                   </div>
+                </template>
+              </div>
+              <div class="moduler">
+                <div class="opt">
+                  <a-button type="default" style="margin-right: 15px" @click="goBack">{{editShow?'取消':'返回'}}</a-button>
+                  <a-button type="primary" style="margin-right: 15px" @click="saveHandler" :loading="saveLoading" v-if="editShow"
+                    >下一步</a-button
+                  >
                 </div>
               </div>
-            </template>
+            </a-form-model>
           </div>
-          <div class="moduler">
-            <div class="opt">
-              <a-button type="default" style="margin-right: 15px" @click="goBack">取消</a-button>
-              <a-button type="primary" style="margin-right: 15px" @click="saveHandler" :loading="saveLoading"
-                >保存</a-button
-              >
-            </div>
-          </div>
-        </a-form-model>
+        </a-spin>
+      </div>
+      <div v-else-if="current == 1">
+        <switchConfig />
       </div>
     </div>
   </div>
@@ -170,6 +376,7 @@ import Treeselect from '@/views/modules/Statistics/components/Treeselect.vue'
 import selectGroup from '@/components/formComponents/selectGroup'
 import checkBoxGroup from '@/components/formComponents/checkBoxGroup'
 import timeRange from '@/components/formComponents/timeRange'
+import switchConfig from './switchConfig'
 let statusList = [
   {
     id: 2,
@@ -262,10 +469,17 @@ export default {
     selectGroup,
     checkBoxGroup,
     timeRange,
+    switchConfig,
   },
   data() {
     return {
-      labelCol: { span: 4 },
+      editShow:false,
+      current: 0,
+      spinLoading: false,
+      allCol: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 18 },
+      },
       wrapperCol: { span: 14 },
       ceshi: [],
       ceshi2: [],
@@ -457,6 +671,16 @@ export default {
     },
   },
   methods: {
+    addData(valueElse, value, index) {
+      console.log(valueElse, value)
+      // alert(1)
+      if (index == 0) {
+        var data = JSON.parse(JSON.stringify(value))
+        valueElse.ruleDetail.push(data)
+      } else {
+        valueElse.ruleDetail.splice(index, 1)
+      }
+    },
     disabledDate(current) {
       return current && current < moment().subtract(1, 'days')
     },
@@ -653,9 +877,14 @@ export default {
             return {
               ...item,
               ruleDetail: item.ruleDetail.map((end) => {
-                return {
-                  ...end,
-                  threshold: isArray(end.threshold) ? JSON.stringify(end.threshold) : end.threshold,
+                if (isArray(end)) {
+                  end.threshold = isArray(end.threshold) ? JSON.stringify(end.threshold) : end.threshold
+                  return [...end]
+                } else {
+                  return {
+                    ...end,
+                    threshold: isArray(end.threshold) ? JSON.stringify(end.threshold) : end.threshold,
+                  }
                 }
               }),
             }
@@ -670,7 +899,8 @@ export default {
           postAction('/ruleAccountThreshold/fillThreshold', params).then((res) => {
             if (res.success) {
               this.saveLoading = false
-              this.goBack()
+              // this.goBack()
+              this.current = 1
             }
           })
         } else {
@@ -720,11 +950,11 @@ export default {
     },
     clearAll(data) {
       this.$nextTick(() => {
-        if (data.length == 0) {
-          setTimeout(() => {
-            this.$refs.ruleForm.clearValidate()
-          }, 100)
-        }
+        // if (data.length == 0) {
+        setTimeout(() => {
+          this.$refs.ruleForm.clearValidate()
+        }, 100)
+        // }
       })
     },
   },
@@ -774,19 +1004,28 @@ export default {
     // })
 
     var data = JSON.parse(localStorage.getItem('getRuleDetail'))
+    this.editShow = data.edit
     if (data.edit) {
+      this.spinLoading = true
       getAction('/ruleTemplate/queryDetailByAccountIdAndTemplateId', {
         templateId: data.id,
         accountId: data.accountId,
       }).then((res) => {
         if (res.success) {
           this.form = res.result
+          this.spinLoading = false
+        } else {
+          this.spinLoading = false
         }
       })
     } else {
-      getAction('/ruleTemplate/queryDetailById', { id: data.id }).then((res) => {
+      this.spinLoading = true
+      getAction('/ruleTemplate/previewTemplate', { id: data.id }).then((res) => {
         if (res.success) {
           this.form = res.result
+          this.spinLoading = false
+        } else {
+          this.spinLoading = false
         }
       })
     }
@@ -837,6 +1076,9 @@ export default {
       font-size: 22px;
       margin-bottom: 20px;
     }
+    .row-group {
+      margin-bottom: 0 !important;
+    }
     .row-item {
       display: flex;
       justify-content: flex-start;
@@ -861,11 +1103,11 @@ export default {
       line-height: 20px;
       height: 20px;
       margin-top: 10px;
-      width: 80px;
-      min-width: 80px;
+      width: 105px;
+      min-width: 105px;
       .text-item {
         font-size: 14px;
-        width: 60px;
+        width: 100px;
       }
     }
     .row-item .required-item {
@@ -961,6 +1203,7 @@ export default {
         display: flex;
         align-items: center;
         position: relative;
+        flex-wrap: wrap;
         .rules-list-item-delete {
           position: absolute;
           right: 24px;

+ 2 - 20
src/views/modules/earlyWarningRules/switchConfig.vue

@@ -150,8 +150,8 @@ export default {
         },
        
         saveHandler(){
-            this.$router.push('/earlyWarningRules/index')
-            this.$bus.$emit('remove', '/earlyWarningRules/switchConfig')
+           this.$router.replace('/earlyWarningRules/useRuleList')
+           this.$bus.$emit('remove', '/earlyWarningRules/ruleModule')
            
         },
 
@@ -211,24 +211,6 @@ export default {
 
     mounted(){
         
-        this.currentRuleId=this.$route.query.id
-        getAction(this.url.fieldList,{   
-            mediaType:1,
-            pageNo:1,
-            pageSize:500,
-        }).then(res=>{
-            console.log(res);
-            if(res.success){ 
-                this.rulesFieldList=res.result.map(item=>{
-                    return {
-                        name:item.dimensionName,
-                        code:item.dimension,
-                        children:item.dimensionList
-                    }
-                }) 
-                this.getTempletDetail()   
-            }            
-        })
 
         // console.log(this.$route.query);
         

+ 6 - 0
src/views/modules/earlyWarningRules/useRuleList.vue

@@ -271,6 +271,7 @@ export default {
     },
 
     handleOk() {
+      this.confirmLoading = true
       getAction('/ruleAccountTemplate/checkAccountTemplate', { accountId: this.accountId }).then((res) => {
         console.log(res)
         if (res.success) {
@@ -282,8 +283,13 @@ export default {
               var data = { id: this.templateId, edit: true, accountId: this.accountId }
               localStorage.setItem('getRuleDetail', JSON.stringify(data))
               this.$router.push('/earlyWarningRules/ruleModule')
+              this.confirmLoading = false
             })
           }
+        } else {
+          this.accountId = ''
+          this.$message.error(res.message)
+          this.confirmLoading = false
         }
       })
     },