2 Commity 65897fcc58 ... b50a6fa987

Autor SHA1 Správa Dátum
  wangzihao b50a6fa987 Merge branch 'dev-web-optimize' of http://git.info666.com/infrared_remote/admin_web into dev-web-optimize 1 rok pred
  wangzihao 76be14eabb add: 按钮配置校验 1 rok pred

+ 1 - 1
ruoyi-ui/src/views/template/addTemplate/blocks/config.js

@@ -74,7 +74,7 @@ const btnFormConfig = function() {
       prop: "defValue",
       label:'默认值',
       attrs: {
-          placeholder: "请输入默认值"
+          placeholder: "请输入功能默认值"
       }
     },
     {

+ 28 - 11
ruoyi-ui/src/views/template/addTemplate/blocks/detailDialog.vue

@@ -84,7 +84,7 @@
         </div>
         <div class="box-set">
           <el-tabs v-if="isShowSeting" v-model="activeName" type="card">
-            <el-tab-pane label="组件基础配置" name="first">
+            <el-tab-pane label="组件基础配置" name="first" v-if="pageArray[currentCpn].type  == 'button'">
               <f-form
                 ref="btnForm"
                 :key="btnFromKey"
@@ -147,7 +147,7 @@ export default {
     return {
       layoutKey:0,
       // tab
-      activeName: 'first',
+      activeName: 'second',
       cpnsList,
       // 数据对象
       fromData:{},
@@ -166,6 +166,7 @@ export default {
       btnFromShow: false,
       btnData: {},
       btnDataConfig: btnFormConfig(),
+      btnFromKey: 0,
       btnRules: {
         typeNum:[{required: true, message: '请选择按钮类型'}],
         defValue:[{required: true, message: '请输入默认值'}],
@@ -173,9 +174,7 @@ export default {
         bootCode:[{required: true, message: '请输入引导码'}],
         bootCodeSend:[{required: true, message: '请输入引导码发送次数'}],
         dateCode:[{required: true, message: '请输入数据码'}],
-        overCode:[{required: true, message: '请输入结束码'}],
       },
-      btnFromKey: 0,
       currentCpn: '', //已选择的组件下标
       isShowSeting:false,
       baseUrl:process.env.VUE_APP_FILE_STATIC,
@@ -345,13 +344,25 @@ export default {
       if (type !='ok') {
         return true
       };
+      // 按钮配置项校验
+      let validateResult = null
+      for(let index = 0; index <= this.pageArray.length-1; index++) {
+        validateResult = this.validateBtn(this.pageArray[index])
+        if (validateResult !== true) {
+          this.isShowSeting = true
+          this.currentCpn = index
+          this.activeName = 'first'
+          this.$message({
+            message: validateResult,
+            type: 'warning'
+          });
+          return false
+        }
+      }
+      // 布局配置项
       const validate = await this.$refs.ruleForm.validate();
-
-      console.log(this.pageArray.map(async (item, index) => await this.$refs['btnForm'+index].validate()))
-
       if (!validate) return false;
 
-
       const params = {
         ...this.fromData,
         components: JSON.stringify(this.pageArray),
@@ -370,6 +381,7 @@ export default {
     },
     // 添加
     addCpns(item) {
+      // this.
       this.pageArray.push({ w: 2, h: 2, x: 1, y: this.pageArray.map(item => item?.y).sort()[this.pageArray.length-1] || 1, i: this.pageArrayCount, ...item })
       this.initBtnFormData(this.pageArray.length-1);
     },
@@ -387,9 +399,14 @@ export default {
     },
     // 校验按钮属性
     validateBtn(obj) {
-      Object.keys(btnRules).find(item => {
-        // if (obj[item])
-      })
+      if (obj.type != 'button') return true
+      for(const item of Object.keys(this.btnRules)) {
+        if (!obj[item]) return this.btnRules[item][0].message
+        if (obj.typeNum == '0' && !obj?.addSubMax) return '加减型需输入最大值'
+        if (obj.typeNum == '0' && !obj?.addSubMin) return '加减型需输入最小值'
+        if (obj.typeNum == '0' && obj?.addSubMax <= obj?.addSubMin) return '加减型最大值要大于最小值'
+      }
+      return true
     }
   },