qx
qx
2025-03-13 25c777002fb57397320b65b830cc805b29f7c23a
src/components/jianceResult/index.vue
@@ -1,15 +1,36 @@
<template>
  <div>
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <el-table :data="dataList" ref="elTable" v-loading="loading" border @selection-change="handleSelectionChange">
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body @close="quxiao">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px" @submit.native.prevent="handleQuery">
        <el-form-item label="内容" prop="xmg">
          <el-input v-model="queryParams.xmgz" placeholder="请输入内容" clearable
            style="width: 130px;"  @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        </el-form-item>
        <el-form-item label="检测结果" prop="xmg">
          <el-input
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4 }"
            v-model="selectedContent"
            placeholder=""
            style="width: 400px;"
            clearable
          />
        </el-form-item>
      </el-form>
      <el-table :data="dataList" ref="elTable" v-loading="loading" border @selection-change="handleSelectionChange" style="max-height: 360px; overflow-y: auto;">
        <el-table-column type="selection" width="40" align="center" />
        <el-table-column label="标号" prop="aid" align="center" />
        <el-table-column label="结论值" prop="ruleStr" align="center" />
        <el-table-column label="参考范围" prop="reference" align="center" />
        <el-table-column label="参考范围" prop="reference" align="center" />
        <el-table-column label="简码" prop="jm" align="center" />
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="open = false">取 消</el-button>
        <el-button @click="quxiao">取 消</el-button>
        <el-button type="primary" @click="handleOk">确 定</el-button>
      </span>
    </el-dialog>
@@ -39,39 +60,79 @@
      },
      list: [],
      fList: {},
      queryParams: { xmgz: '' }
    };
  },
  mounted() {
  },
  methods: {
    handleOk() {
        this.open = false
        this.$emit('add', this.list);
        this.list = [];  // 清空已选列表
        this.queryParams.xmgz = '';  // 清空查询参数
    },
    quxiao(){
      this.open = false
      this.$emit('add', this.list);
      this.queryParams = {
        xmgz: ''
      }
      this.list = [];  // 清空已选列表
    },
    handleQuery() {
      this.getList();
    },
    handleSelectionChange(selection) {
      if (selection.length > 1) {
        // 如果选择了多行,保留最后一行
        this.$refs.elTable.clearSelection();  // 清空所有选择
        this.$refs.elTable.toggleRowSelection(selection[selection.length - 1]);  // 重新选择最后一项
      }
      // 获取最后选择的行
      this.list = [selection[selection.length - 1]];
    },
    getList() {
      this.loading = true;
      selectZT({
        proId: this.proId
        proId: this.proId,
        xmgz: this.queryParams.xmgz
      }).then((res) => {
        if (res.data) {
        if (res.data.length > 0) {
          this.open = true
          this.dataList = res.data;
          this.loading = false;
        } else {
          this.dataList = res.data;
          this.loading = false;
        }
      });
    },
    handleSelectionChange(selection) {
      this.list = selection
      console.log(this.list);
    },
    getList(row,date) {
      console.log(row)
     this.proId=row.proId
      this.loading = true;
      selectZT({
        proId: this.proId,
        xmgz: this.queryParams.xmgz
      }).then((res) => {
        if (res.data.length > 0) {
          this.open = true
          this.dataList = res.data;
          this.loading = false;
        } else {
          this.dataList = res.data;
          this.loading = false;
        }
      });
    },
  },
  computed: {
    selectedContent: {
      get() {
        return this.list.map(item => item.ruleStr).join(',');
      },
      set(value) {
        // 手动编辑时同步回list(需要根据实际数据结构调整)
        this.list = value.split(',').map(str => ({
          ...this.dataList.find(item => item.ruleStr === str.trim()),
          ruleStr: str.trim()
        })).filter(Boolean);
      }
    }
  },
};
</script>