瀏覽代碼

无效数据默认值修改

FinalYu 1 年之前
父節點
當前提交
d22f5907ba

+ 1 - 0
chuanyi_client2/src/utils/cqcyCode.js

@@ -5,6 +5,7 @@ export default {
     'host': '192.168.1.99',
 
     'clientRole': 'ClientRole',
+    'invalidData': 'com#',
 
     '100': '系统提示',
 

+ 98 - 43
chuanyi_client2/src/views/data_model/index.vue

@@ -87,12 +87,18 @@
           <el-input v-model="dataModelForm.remark" placeholder="请输入名称" maxlength="20" show-word-limit></el-input>
         </el-form-item>
         <el-form-item label="四则运算表达式" prop="operationRule">
-          <el-input v-model="dataModelForm.operationRule" style="width: calc(100% - 85px);" maxlength="100" show-word-limit placeholder="请输入四则运算表达式"></el-input>
-          <el-button @click="testEditEvent" style="float: right;width: 80px;">测试</el-button>
+          <el-input v-model="dataModelForm.operationRule" maxlength="100" show-word-limit placeholder="请输入四则运算表达式"></el-input>
           <span style="font-size: 12px;">
             提示:四则运算支持的英文符号&nbsp;【<b>+</b>】、【<b>-</b>】、【<b>*</b>】、【<b>/</b>】、【<b>()</b>】,真实数据值使用固定字符串&nbsp;【<b>calcVal</b>】
           </span>
         </el-form-item>
+        <el-form-item label="测试数据值" prop="testVal">
+          <el-input v-model="dataModelForm.testVal" style="width: calc(100% - 85px);" maxlength="6" placeholder="请输入测试数据值"></el-input>
+          <el-button @click="testEditEvent" style="float: right;width: 80px;">测试</el-button>
+          <span style="font-size: 12px;">
+            测试结果:{{ calcValResult }}
+          </span>
+        </el-form-item>
         <el-form-item style="text-align: center;">
           <el-button type="primary" @click="saveDataModelEvent">确定</el-button>
           <el-button @click="dialogClose">取消</el-button>
@@ -100,6 +106,35 @@
       </el-form>
     </el-dialog>
 
+    <!-- 测试数据模型 -->
+    <el-dialog
+        title="四则运算表达式验证"
+        width="650px"
+        top="10vh"
+        center
+        v-dialog-drag
+        v-if="dialogDataModelTestVisible"
+        :before-close="dialogClose"
+        :visible.sync="dialogDataModelTestVisible"
+        :close-on-click-modal="false"
+        :append-to-body="true">
+      <el-form ref="dataModelTestForm" :model="dataModelTestForm" label-width="110px" label-position="top">
+        <el-form-item label="四则运算表达式" prop="operationRule">
+          <el-input v-model="dataModelTestForm.operationRule" readonly placeholder="请输入四则运算表达式"></el-input>
+        </el-form-item>
+        <el-form-item label="测试数据值" prop="testVal">
+          <el-input v-model="dataModelTestForm.testVal" style="width: calc(100% - 85px);" maxlength="6" placeholder="请输入测试数据值"></el-input>
+          <el-button @click="testByIdEvent" style="float: right;width: 80px;">测试</el-button>
+          <span style="font-size: 12px;">
+            测试结果:{{ calcValResult }}
+          </span>
+        </el-form-item>
+        <el-form-item style="text-align: center;">
+          <el-button @click="dialogClose">取消</el-button>
+        </el-form-item>
+      </el-form>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -109,8 +144,7 @@ import {
   customCompare, showAlertMsgWin,
   showAlertWin,
   showConfirmWin,
-  showLoading,
-  showPromptWin
+  showLoading
 } from '@/utils/cqcy'
 import {
   addDataModel,
@@ -129,18 +163,26 @@ export default {
     return {
       breadcrumbList: ['数据模型'],
       dialogDataModelVisible: false,
+      dialogDataModelTestVisible: false,
       dialogDataModelTitle: '新增数据模型',
       tablePage: 1,
       tableLimit: 10,
       tableTotal: 0,
       tableData: [],
       searchTxt: '',
+      calcValResult: '',
       dataModelForm: {
         id: '',
         mathParameter: 'calcVal',
         operationRule: '',
+        testVal: '',
         remark: ''
       },
+      dataModelTestForm: {
+        id: '',
+        operationRule: '',
+        testVal: ''
+      },
       dataModelRules: {
         operationRule: [
           { required: true, message: '表达式不能为空', trigger: 'blur' },
@@ -196,8 +238,10 @@ export default {
         id: '',
         mathParameter: 'calcVal',
         operationRule: '',
+        testVal: '',
         remark: ''
       }
+      this.calcValResult = ''
       this.dialogDataModelTitle = '新增数据模型'
       this.dialogDataModelVisible = true
     },
@@ -208,6 +252,7 @@ export default {
         loading.close()
         this.dialogDataModelTitle = '编辑数据模型'
         this.dataModelForm = res.data
+        this.calcValResult = ''
         this.dialogDataModelVisible = true
       }).catch((e) => {
         loading.close()
@@ -217,61 +262,67 @@ export default {
     /** 新增编辑测试 */
     testEditEvent() {
       let txt = this.dataModelForm.operationRule
+      let testVal = this.dataModelForm.testVal
       this.validateCalc(null, txt, (e) => {
         if (e) {
           showAlertMsgWin(this, null, e.message)
           return
         }
-        this.handleTest(null, null, txt)
-      })
-    },
-    /** 测试数据模型值 */
-    handleTest(index, row, ruleModel) {
-      showPromptWin(this, '四则运算表达式验证', '请输入数值', '', (val) => {
-        if (!/^(\-)?\d+(\.\d{1,2})?$/.test(val)) {
-          return '请输入正确的数字'
-        }
-        if (val.length > 6) {
-          return '请输入小于6位的数字'
-        }
-      }, (value) => {
-        const loading = showLoading(this, '计算中,请稍候···')
-        if (ruleModel) {
-          let params = {
-            'parameter': 'calcVal',
-            'mathString': ruleModel,
-            'dataValue': value
-          }
-          testDataModelByModel(params).then(res => {
-            loading.close()
-            let bds = ruleModel
-            bds = bds.replaceAll(/calcVal/g, value)
-            bds += '='
-            bds += res.data
-            showAlertWin(this, '计算结果', bds)
-          }).catch((e) => {
-            loading.close()
-            showAlertWin(this, null, e)
-          })
+        if (!/^(\-)?\d+(\.\d{1,2})?$/.test(testVal)) {
+          showAlertMsgWin(this, null, '请输入正确的测试数据值')
           return
         }
+        const loading = showLoading(this, '计算中,请稍候···')
         let params = {
-          'id': row.id,
-          'dataValue': value
+          'parameter': 'calcVal',
+          'mathString': txt,
+          'dataValue': testVal
         }
-        testDataModelById(params).then(res => {
+        testDataModelByModel(params).then(res => {
           loading.close()
-          let bds = row.operationRule
-          bds = bds.replaceAll(/calcVal/g, value)
+          let bds = txt
+          bds = bds.replaceAll(/calcVal/g, testVal)
           bds += '='
           bds += res.data
-          showAlertWin(this, '计算结果', bds)
+          this.calcValResult = bds
         }).catch((e) => {
           loading.close()
           showAlertWin(this, null, e)
         })
       })
     },
+    /** 列表测试 */
+    testByIdEvent() {
+      let txt = this.dataModelTestForm.operationRule
+      let testVal = this.dataModelTestForm.testVal
+      let id = this.dataModelTestForm.id
+      if (!/^(\-)?\d+(\.\d{1,2})?$/.test(testVal)) {
+        showAlertMsgWin(this, null, '请输入正确的测试数据值')
+        return
+      }
+      const loading = showLoading(this, '计算中,请稍候···')
+      let params = {
+        'id': id,
+        'dataValue': testVal
+      }
+      testDataModelById(params).then(res => {
+        loading.close()
+        let bds = txt
+        bds = bds.replaceAll(/calcVal/g, testVal)
+        bds += '='
+        bds += res.data
+        this.calcValResult = bds
+      }).catch((e) => {
+        loading.close()
+        showAlertWin(this, null, e)
+      })
+    },
+    /** 测试数据模型值 */
+    handleTest(index, row, ruleModel) {
+      this.dataModelTestForm.operationRule = row.operationRule
+      this.dataModelTestForm.id = row.id
+      this.dialogDataModelTestVisible = true
+    },
     /** 删除数据模型 */
     handleDelete(index, row) {
       showConfirmWin(this, null, '您确定要删除该表达式吗?', () => {
@@ -360,13 +411,17 @@ export default {
     },
     /** 弹出层关闭事件 */
     dialogClose(done) {
+      this.calcValResult = ''
       this.getAllDataModel()
       if (typeof(done) === 'function') {
-        this.$refs['dataModelForm'].resetFields()
+        if (this.$refs['dataModelForm']) this.$refs['dataModelForm'].resetFields()
+        if (this.$refs['dataModelTestForm']) this.$refs['dataModelTestForm'].resetFields()
         done()
       } else {
         this.dialogDataModelVisible = false
-        this.$refs['dataModelForm'].resetFields()
+        this.dialogDataModelTestVisible = false
+        if (this.$refs['dataModelForm']) this.$refs['dataModelForm'].resetFields()
+        if (this.$refs['dataModelTestForm']) this.$refs['dataModelTestForm'].resetFields()
       }
     }
   }

+ 6 - 5
chuanyi_client2/src/views/my_report/index.vue

@@ -452,6 +452,7 @@ import {exportExcel} from '@/utils/export'
 import {getAllUserGroup} from "@/api/user";
 import {mapGetters} from "vuex";
 import {insertLuckysheetEChart} from "@/utils/luckysheettool";
+import cqcyCode from "@/utils/cqcyCode";
 
 export default {
   name: "index",
@@ -976,7 +977,7 @@ export default {
                   let p_c = parseInt(item.c)
                   if (type.valType == '2') p_r += i
                   else p_c += i
-                  luckysheet.setCellValue(p_r, p_c, (dataList[i] != null && dataList[i] != undefined) ? dataList[i] : '')
+                  luckysheet.setCellValue(p_r, p_c, (dataList[i] != null && dataList[i] != undefined) ? dataList[i] : cqcyCode['invalidData'])
                 }
               }
             })
@@ -1216,7 +1217,7 @@ export default {
             let r = p_r
             if (showInfo.valType == '2') r += j
             else c += j
-            luckysheet.setCellValue(r, c, (dataList[j] != null && dataList[j] != undefined) ? (dataList[j] + '') : '')
+            luckysheet.setCellValue(r, c, (dataList[j] != null && dataList[j] != undefined) ? (dataList[j] + '') : cqcyCode['invalidData'])
           }
         })
       })
@@ -1342,17 +1343,17 @@ export default {
         x += 1
         y = 0
         let { dataList, dataTimeList, itemName } = data
-        itemName = (itemName != null && itemName != undefined) ? itemName : ''
+        itemName = (itemName != null && itemName != undefined) ? itemName : cqcyCode['invalidData']
         luckysheet.setCellValue(x, y, itemName)
         dataList.forEach((val, j) => {
           y = j + 1
           let _date = luckysheet.getCellValue(0, y)
           if (!_date) {
-            let text = (dataTimeList[j] != null && dataTimeList[j] != undefined) ? dataTimeList[j] : ''
+            let text = (dataTimeList[j] != null && dataTimeList[j] != undefined) ? dataTimeList[j] : cqcyCode['invalidData']
             if (text.length > 19) text = text.substring(0, 19)
             luckysheet.setCellValue(0, y, text)
           }
-          val = (val != null && val != undefined) ? val : ''
+          val = (val != null && val != undefined) ? val : cqcyCode['invalidData']
           luckysheet.setCellValue(x, y, val)
         })
       })

+ 6 - 5
chuanyi_client2/src/views/run_config/index.vue

@@ -556,6 +556,7 @@ import {exportExcel} from '@/utils/export'
 import {getAllUserGroup} from "@/api/user";
 import {mapGetters} from "vuex";
 import {insertLuckysheetEChart} from "@/utils/luckysheettool";
+import cqcyCode from "@/utils/cqcyCode";
 
 export default {
   name: "index",
@@ -1173,7 +1174,7 @@ export default {
                   let p_c = parseInt(item.c)
                   if (type.valType == '2') p_r += i
                   else p_c += i
-                  luckysheet.setCellValue(p_r, p_c, (dataList[i] != null && dataList[i] != undefined) ? dataList[i] : '')
+                  luckysheet.setCellValue(p_r, p_c, (dataList[i] != null && dataList[i] != undefined) ? dataList[i] : cqcyCode['invalidData'])
                 }
               }
             })
@@ -1436,7 +1437,7 @@ export default {
             let r = p_r
             if (showInfo.valType == '2') r += j
             else c += j
-            luckysheet.setCellValue(r, c, (dataList[j] != null && dataList[j] != undefined) ? (dataList[j] + '') : '')
+            luckysheet.setCellValue(r, c, (dataList[j] != null && dataList[j] != undefined) ? (dataList[j] + '') : cqcyCode['invalidData'])
           }
         })
       })
@@ -1586,17 +1587,17 @@ export default {
         x += 1
         y = 0
         let { dataList, dataTimeList, itemName } = data
-        itemName = (itemName != null && itemName != undefined) ? itemName : ''
+        itemName = (itemName != null && itemName != undefined) ? itemName : cqcyCode['invalidData']
         luckysheet.setCellValue(x, y, itemName)
         dataList.forEach((val, j) => {
           y = j + 1
           let _date = luckysheet.getCellValue(0, y)
           if (!_date) {
-            let text = (dataTimeList[j] != null && dataTimeList[j] != undefined) ? dataTimeList[j] : ''
+            let text = (dataTimeList[j] != null && dataTimeList[j] != undefined) ? dataTimeList[j] : cqcyCode['invalidData']
             if (text.length > 19) text = text.substring(0, 19)
             luckysheet.setCellValue(0, y, text)
           }
-          val = (val != null && val != undefined) ? val : ''
+          val = (val != null && val != undefined) ? val : cqcyCode['invalidData']
           luckysheet.setCellValue(x, y, val)
         })
       })