licp
2024-08-10 41c2f79abd464e6c063166d680b51f746d6f0456
src/components/do/b6-device-management/b6-data-acquisition-config.vue
@@ -87,23 +87,9 @@
          <el-form-item class="fomItemInput1">
            <template v-slot="label">
              公式:
              <el-tooltip class="itemFomItem" effect="dark" content="求参数最大值,参数个数最少两个,如:MAX(A1,B2)" placement="top">
                <label>MAX()</label>
              </el-tooltip>
              <el-tooltip class="itemFomItem" effect="dark" content="求参数最小值,参数个数最少两个,如:MIN(A1,B2)" placement="top">
                <label>MIN()</label>
              </el-tooltip>
              <el-tooltip class="itemFomItem" effect="dark" content="求和,参数个数最少两个,如:SUM(A1,B2)" placement="top">
                <label>SUM()</label>
              </el-tooltip>
              <el-tooltip class="itemFomItem" effect="dark" content="求绝对值,参数个数最少一个,如:ABS(A1)" placement="top">
                <label>ABS()</label>
              </el-tooltip>
              <el-tooltip class="itemFomItem" effect="dark" content="求平均值,参数个数最少两个个,如:AVERAGE(A1,B2)" placement="top">
                <label>AVERAGE()</label>
              </el-tooltip>
              <el-tooltip class="itemFomItem" effect="dark" content="求中值,参数个数最少两个个,如:MEDIAN(A1,B2)" placement="top">
                <label>MEDIAN()</label>
              <el-tooltip v-for="(formula, key) in formulas" class="itemFomItem" effect="dark" :content="formula.content" :key="key"
                placement="top">
                <label>{{ formula.label }}()</label>
              </el-tooltip>
              <el-input type="textarea" autosi:autosize="{ minRows: 2, maxRows: 4}" ze placeholder="请输入内容"
                v-model="configForm.formula" @change="evalResult">
@@ -184,6 +170,32 @@
  data() {
    // 这里存放数据
    return {
      formulas: [
        {
          label: "MAX",
          content: "求参数最大值,参数个数最少两个,如:MAX(A1,B2)"
        },
        {
          label: "MIN",
          content: "求参数最小值,参数个数最少两个,如:MIN(A1,B2)"
        },
        {
          label: "SUM",
          content: "求和,参数个数最少两个,如:SUM(A1,B2)"
        },
        {
          label: "ABS",
          content: "求绝对值,参数个数最少一个,如:ABS(A1)"
        },
        {
          label: "AVERAGE",
          content: "求平均值,参数个数最少两个个,如:AVERAGE(A1,B2)"
        },
        {
          label: "MEDIAN",
          content: "求中值,参数个数最少两个个,如:MEDIAN(A1,B2)"
        },
      ],
      dialogVisible4: false,
      tableList: [],
      page: {
@@ -192,7 +204,12 @@
      },
      dialogVisible3: false,
      configForm: {
        formula: ""
        formula: "",
        collectUrl: "",
        storageUrl: "",
        entrustCode: "",
        sampleCode: "",
        dbFileName: ""
      },
      domains: [
        {
@@ -338,6 +355,21 @@
        this.$set(this.configForm, "collectUrl", this.tableList[0].collectUrl);
        this.$set(this.configForm, "storageUrl", this.tableList[0].storageUrl);
        this.$set(this.configForm, "ip", this.tableList[0].ip);
        this.$set(
          this.configForm,
          "entrustCode",
          this.tableList[0].entrustCode
        );
        this.$set(
          this.configForm,
          "sampleCode",
          this.tableList[0].sampleCode
        );
        this.$set(
          this.configForm,
          "dbFileName",
          this.tableList[0].dbFileName
        );
      }
    },
    init() {
@@ -352,7 +384,17 @@
        .then(res => {
          this.tableList = res.data;
          this.tableList.forEach(i => {
            // replace(/=/g, ' ')
            let isIncludes = false
            if (i.formula && i.formula != "") {
              this.formulas.forEach(j => {
                if (i.formula.includes(j.label)) {
                  isIncludes = true
                }
              })
            }
            if (!isIncludes && i.formula) {
              i.formula = i.formula.slice(1, -1)
            }
            i.sample = i.sample
              .replace(/"/g, "")
              .replace(/],/g, ";")
@@ -457,7 +499,7 @@
        )
        .then(res => {
          if (res.code == 200) {
            this.tableList = res.data;
            // this.tableList = res.data;
            this.dialogVisible4 = false;
            this.init();
            this.$message.success("操作成功");
@@ -492,7 +534,21 @@
          const data = res.data;
          if (data[0]) {
            this.domains.splice(0, 1);
            this.$set(this.configForm, "formula", data[0].formula);
            let formula = data[0].formula
            let isIncludes = false
            if (formula && formula != "") {
              for (let key in this.formulas) {
                if (formula.includes(this.formulas[key].label)) {
                  isIncludes = true
                }
              }
            }
            if (!isIncludes && formula) {
              let formulaValue = formula.slice(1, -1)
              this.$set(this.configForm, "formula", formulaValue);
            } else {
              this.$set(this.configForm, "formula", data[0].formula);
            }
            data.forEach(i => {
              this.domains.push({
                referx: i.referx,
@@ -516,7 +572,19 @@
            }
          });
          this.domains.forEach((i, index) => {
            i.formula = this.configForm.formula;
            let isIncludes = false
            if (this.configForm.formula && this.configForm.formula !== "") {
              for (let formula in this.formulas) {
                if (this.configForm.formula.includes(this.formulas[formula].label)) {
                  isIncludes = true
                }
              }
            }
            if (isIncludes === false && this.configForm.formula !== "") {
              i.formula = "(" + this.configForm.formula + ")";
            } else {
              i.formula = this.configForm.formula;
            }
            i.deviceId = this.deviceId;
            i.inspectionItem = this.configForm.inspectionItem;
            i.inspectionItemSubclass = this.configForm.inspectionItemSubclass;