zouyu
2025-10-23 f294efb8c01ad8b0704a92d51c14dbd55d898874
src/views/CNAS/resourceDemand/device/component/acquisitionConfig.vue
@@ -5,6 +5,7 @@
        <el-col :span="6" style="padding-left: 20px;text-align: left;">数采配置</el-col>
        <el-col :span="18" style="text-align: right;">
          <el-button size="small" type="primary" @click="fileConfiguration">文件配置</el-button>
          <el-button size="small" type="primary" @click="addItem">检验项新增</el-button>
          <el-button size="small" @click="$parent.closeDataVue()">
            <span style="color: #3A7BFA;">返回</span>
          </el-button>
@@ -16,19 +17,19 @@
                :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
                tooltip-effect="dark" height="100%">
        <el-table-column type="index" label="序号" align="center" width="65"></el-table-column>
        <el-table-column prop="deviceName" align="center" min-width="100" label="设备名称"></el-table-column>
        <el-table-column prop="deviceName" align="center" min-width="100" label="设备名称" show-overflow-tooltip></el-table-column>
        <el-table-column prop="sample" align="center" label="检验对象" show-overflow-tooltip
          min-width="150"></el-table-column>
        <el-table-column prop="inspectionItemClass" align="center" label="检验项分类" min-width="120"></el-table-column>
        <el-table-column prop="inspectionItem" align="center" label="检验项" min-width="100"></el-table-column>
        <el-table-column prop="inspectionItemSubclass" align="center" label="检验子项" min-width="100"></el-table-column>
        <el-table-column prop="referx" align="center" label="参照X" min-width="100"></el-table-column>
        <el-table-column prop="x" align="center" label="X"></el-table-column>
        <el-table-column prop="refery" align="center" label="参照Y" min-width="100"></el-table-column>
        <el-table-column prop="y" align="center" label="Y"></el-table-column>
        <el-table-column prop="anotherName" align="center" label="别名" min-width="100"></el-table-column>
        <el-table-column prop="matchingName" align="center" label="匹配名称" min-width="100"></el-table-column>
        <el-table-column prop="formula" align="center" label="公式"></el-table-column>
        <el-table-column prop="inspectionItemClass" align="center" label="检验项分类" min-width="120" show-overflow-tooltip></el-table-column>
        <el-table-column prop="inspectionItem" align="center" label="检验项" min-width="100" show-overflow-tooltip></el-table-column>
        <el-table-column prop="inspectionItemSubclass" align="center" label="检验子项" min-width="100" show-overflow-tooltip></el-table-column>
        <el-table-column prop="referx" align="center" label="参照X" min-width="100" show-overflow-tooltip></el-table-column>
        <el-table-column prop="x" align="center" label="X" show-overflow-tooltip></el-table-column>
        <el-table-column prop="refery" align="center" label="参照Y" min-width="100" show-overflow-tooltip></el-table-column>
        <el-table-column prop="y" align="center" label="Y" show-overflow-tooltip></el-table-column>
        <el-table-column prop="anotherName" align="center" label="别名" min-width="100" show-overflow-tooltip></el-table-column>
        <el-table-column prop="matchingName" align="center" label="匹配名称" min-width="100" show-overflow-tooltip></el-table-column>
        <el-table-column prop="formula" align="center" label="公式" show-overflow-tooltip></el-table-column>
        <el-table-column fixed="right" label="操作" width="120" align="center">
          <template slot-scope="scope">
            <el-button type="text" @click="dataConfig(scope.row)">数采配置</el-button>
@@ -97,7 +98,7 @@
                :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="请输入内容"
              <el-input type="textarea" autosize:autosize="{ minRows: 2, maxRows: 4}"  placeholder="请输入内容"
                v-model="configForm.formula" @change="evalResult">
              </el-input>
            </template>
@@ -149,11 +150,33 @@
        <div class="search_label">文件名称:</div>
        <el-input size="small" placeholder="请输入" clearable v-model="configForm.dbFileName"></el-input>
      </div>
      <div class="search_thing" style="margin-bottom: 14px;">
        <div class="search_label">数据库账号:</div>
        <el-input size="small" placeholder="请输入" clearable v-model="configForm.dbUserName"></el-input>
      </div>
      <div class="search_thing" style="margin-bottom: 14px;">
        <div class="search_label">数据库密码:</div>
        <el-input size="small" placeholder="请输入" clearable v-model="configForm.dbPassword"></el-input>
      </div>
      <div v-if="configForm.fileType === '.mysql'" class="search_thing" style="margin-bottom: 14px;">
        <div class="search_label"><span style="color:red;margin-right: 4px;">*</span>数据库表:</div>
        <el-input size="small" placeholder="请输入" clearable v-model="configForm.dbTable"></el-input>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-row>
          <el-button @click="dialogVisible4 = false">取 消</el-button>
          <el-button type="primary" @click="submitForm4" :loading="upLoad4">确 定</el-button>
        </el-row>
      </span>
    </el-dialog>
    <el-dialog title="添加检验项" :visible.sync="dialogVisible5" width="1000px">
      <lims-table :tableData="tableData5" :column="column5"
                  :isSelection="true" :handleSelectionChange="selectMethod"
                  height="540" :page="page5" :tableLoading="tableLoading5"
                  @pagination="pagination5"></lims-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible5 = false">取 消</el-button>
        <el-button type="primary" @click="submitForm5" :loading="loading5">保 存</el-button>
      </span>
    </el-dialog>
  </div>
@@ -163,12 +186,17 @@
import {
  queryDataAcquisitionConfiguration,
  saveDataAcquisitionConfiguration,
  deleteDataAcquisitionConfiguration, getDeviceById, saveDeviceFileConfiguration, queryProductConfiguration,
  deleteDataAcquisitionConfiguration,
  getDeviceById,
  saveDeviceFileConfiguration,
  queryProductConfiguration,
  getNoConfigProduct,
} from '@/api/cnas/resourceDemand/device.js'
import limsTable from "@/components/Table/lims-table.vue";
export default {
  name: "dataAcquisitionConfig",
  // import 引入的组件需要注入到对象中才能使用
  components: {},
  components: {limsTable},
  props: {
    deviceId: {
      type: Number,
@@ -218,7 +246,10 @@
        entrustCode: "",
        sampleCode: "",
        dbFileName: "",
        fiberOpticRibbon: ""
        fiberOpticRibbon: "",
        dbUserName: "",
        dbPassword: "",
        dbTable: ""
      },
      domains: [
        {
@@ -237,8 +268,11 @@
        { label: "db", value: ".db" },
        { label: "mdb", value: ".mdb" },
        { label: "word", value: ".docx" },
        { label: "excel", value: ".xlsx" },
        { label: "excelxlsx", value: ".xlsx" },
        { label: "excelxls", value: ".xls" },
        { label: "txt", value: ".txt" },
        { label: "mysql", value: ".mysql" },
        { label: "mqtt", value: ".mqtt" },
        { label: "png", value: ".png" }
      ],
      spanList: [],
@@ -286,7 +320,23 @@
          ]
        }
      },
      deleteList: []
      deleteList: [],
      tableData5: [],
      column5: [
        {label: '样品名称', prop: 'sample'},
        {label: '检验项分类', prop: 'inspectionItemClass'},
        {label: '检验项', prop: 'inspectionItem'},
        {label: '检验子项', prop: 'inspectionItemSubclass'},
      ],
      page5: {
        total:0,
        size:20,
        current:1
      },
      tableLoading5: false,
      dialogVisible5: false,
      loading5: false,
      multipleSelection: []
    };
  },
  mounted() {
@@ -319,6 +369,45 @@
      const letterIndex = index % 26;
      return alphabet.charAt(letterIndex) + (index + 1);
    },
    // 打开新增检验项弹框
    addItem () {
      this.dialogVisible5 = true;
      this.getList5()
    },
    getList5() {
      this.tableLoading5 = true;
      getNoConfigProduct({deviceId: this.deviceId, ...this.page5 }).then(res => {
        this.tableLoading5 = false;
        this.tableData5 = res.data.records
        this.page5.total = res.data.total
      }).catch(err => {
        this.tableLoading5 = false;
      })
    },
    pagination5 (page) {
      this.page5.size = page.limit
      this.getList5()
    },
    // 表格选择方法
    selectMethod(val) {
      this.multipleSelection = val
    },
    // 提交新增检验项
    submitForm5 () {
      this.loading5 = true;
      saveDataAcquisitionConfiguration({
        deviceId: this.deviceId,
        dataConfigList: this.multipleSelection,
      }).then(res => {
        this.loading5 = false;
        this.dialogVisible5 = false;
        this.init();
        this.$message.success("添加成功");
      }).catch(err => {
        this.loading5 = false;
      })
    },
    // 打开文件配置弹框
    fileConfiguration() {
      this.dialogVisible4 = true;
      this.getInfo()
@@ -333,7 +422,10 @@
        this.$set(this.configForm, "entrustCode", res.data.entrustCode);
        this.$set(this.configForm, "sampleCode", res.data.sampleCode);
        this.$set(this.configForm, "dbFileName", res.data.dbFileName);
        this.$set(this.configForm, "fiberOpticRibbon", res.data.fiberOpticRibbon)
        this.$set(this.configForm, "fiberOpticRibbon", res.data.fiberOpticRibbon);
        this.$set(this.configForm, "dbUserName", res.data.dbUserName);
        this.$set(this.configForm, "dbPassword", res.data.dbPassword);
        this.$set(this.configForm, "dbTable", res.data.dbTable);
      })
    },
    // 提交文件配置
@@ -347,7 +439,10 @@
        entrustCode: this.configForm.entrustCode,
        sampleCode: this.configForm.sampleCode,
        dbFileName: this.configForm.dbFileName,
        fiberOpticRibbon: this.configForm.fiberOpticRibbon
        fiberOpticRibbon: this.configForm.fiberOpticRibbon,
        dbUserName: this.configForm.dbUserName,
        dbPassword: this.configForm.dbPassword,
        dbTable: this.configForm.dbTable
      });
      this.upLoad4 = true;
      saveDeviceFileConfiguration({ deviceId: this.deviceId, ...obj }).then(res => {
@@ -381,6 +476,7 @@
        structureItemParameterId: row.structureItemParameterId
      }).then(res => {
        const data = res.data;
        console.log("数采配置--",data)
        if (data[0]) {
          this.domains.splice(0, 1);
          let formula = data[0].formula
@@ -432,7 +528,7 @@
                }
              }
            }
            if (isIncludes === false && this.configForm.formula !== "" && this.configForm.formula !== undefined) {
            if (isIncludes === false && this.configForm.formula !== "" && this.configForm.formula !== null && this.configForm.formula !== undefined) {
              i.formula = "(" + this.configForm.formula + ")";
            } else {
              i.formula = this.configForm.formula;
@@ -532,7 +628,7 @@
}
.search_thing {
  width: 350px;
  width: 370px;
  display: flex;
  align-items: center;
}