qx
2025-06-05 53606eac81e6d3a76937c4cb6f45ad61581cb4da
src/views/picture/picture/index.vue
@@ -1,393 +1,1052 @@
<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="体检号" prop="tjNum">
                <el-input v-model="queryParams.tjNum" placeholder="请输入体检号" clearable @keyup.enter.native="handleQuery"
                    style="width: 170px;" />
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="体检号" prop="tjNumber">
        <el-input
          ref="inputName"
          v-model="queryParams.tjNumber"
          placeholder="请输入体检号"
          clearable
          @keyup.enter.native="handleQuery"
          @blur="hb"
          style="width: 170px"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
          style="width: 110px"
        />
      </el-form-item>
      <el-form-item
        label="单位名称"
        prop="tjCompName"
        style="margin-left: 20px"
      >
        <el-select
          :remote-method="getRemoteData"
          v-model="queryParams.tjCompName"
          value-key="drugManufacturerId"
          style="width: 180px"
          remote
          filterable
          placeholder="请选择单位名称"
          clearable
          @change="searchSelect"
        >
          <el-option
            v-for="dict in CompanyList"
            :key="dict.drugManufacturerId"
            :label="dict.cnName"
            :value="dict"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="项目" prop="tcm">
        <el-input
          v-model="queryParams.tcm"
          placeholder="请输入项目"
          clearable
          @keyup.enter.native="handleQuery"
          style="width: 170px"
        />
      </el-form-item>
      <el-form-item
        label="登记时间"
        prop="createTimeList"
        v-show="isCollapsed == 1"
      >
        <el-date-picker
          v-model="createTimeList"
          type="datetimerange"
          align="right"
          :picker-options="pickerOptions"
          style="width: 310px"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="['00:00:00', '23:59:59']"
          format="yyyy-MM-dd HH:mm"
          value-format="yyyy-MM-dd HH:mm"
          @change="dateChangebirthday1"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          size="mini"
          @click="toggleCollapse"
          style="margin-right: 15px"
          v-show="isCollapsed == 0"
          >展开更多</el-button
        >
        <el-button
          type="primary"
          size="mini"
          @click="toggleCollapse3"
          style="margin-right: 15px"
          v-show="isCollapsed == 1"
          >收起更多</el-button
        >
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          style="margin-right: 15px"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-radio-group
      v-model="checkStatus"
      @input="radioChange"
      style="margin: 10px 15px"
    >
      <el-radio-button label="0">未检</el-radio-button>
      <el-radio-button label="1">已检</el-radio-button>
    </el-radio-group>
    <el-row :gutter="20">
      <el-col :span="11">
        <el-table
          v-loading="loading"
          ref="tb"
          :data="pictureList"
          highlight-current-row
          :row-class-name="tableRowClassName"
          @current-change="handleCurrentChange"
          border
          height="520px"
        >
          <el-table-column
            label="体检号"
            align="center"
            prop="tjNumber"
            min-width="130"
          />
          <el-table-column
            label="姓名"
            align="center"
            prop="cusName"
            min-width="80"
          />
          <el-table-column
            label="性别"
            align="center"
            prop="cusSex"
            min-width="50"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.cusSex == '0'">男</span>
              <span v-if="scope.row.cusSex == '1'">女</span>
              <span v-if="scope.row.cusSex == '2'">未知</span>
              <span v-if="scope.row.cusSex == '9'">未说明性别</span>
            </template>
          </el-table-column>
          <el-table-column
            label="身份证号"
            align="center"
            prop="cusIdcard"
            min-width="190"
          />
          <el-table-column
            label="套餐名"
            align="center"
            prop="tcm"
            min-width="100"
          />
          <el-table-column
            label="登记时间"
            align="center"
            prop="tjTime"
            min-width="120"
          />
          <el-table-column
            label="审核状态"
            align="center"
            prop="confirmStatus"
            min-width="80"
          >
            <template slot-scope="scope">
              <span
                :style="{
                  color:
                    scope.row.confirmStatus == '301' ? '#0CB618' : '#EA1B29',
                }"
                v-if="scope.row.confirmStatus == '301'"
                >已通过</span
              >
              <span
                :style="{
                  color:
                    scope.row.confirmStatus == '301' ? '#0CB618' : '#EA1B29',
                }"
                v-if="scope.row.confirmStatus == '299'"
                >已驳回</span
              >
            </template>
          </el-table-column>
        </el-table>
        <div class="pag">
          <div class="pag1">
            <pagination
              v-show="total > 0"
              :total="total"
              :page.sync="queryParams.page"
              :limit.sync="queryParams.pageSize"
              @pagination="submitForm"
            />
          </div>
        </div>
      </el-col>
      <el-col :span="11">
        <el-table
          v-loading="loading"
          ref="mu"
          :data="tableList"
          :row-class-name="tableRowClassName"
          @header-click="handleHeaderClick"
          highlight-current-row
          @selection-change="handleChange"
          border
          style="height: 400px"
        >
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column
            label="科室"
            align="center"
            prop="deptName"
            min-width="100"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="项目"
            align="center"
            prop="proName"
            min-width="150"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="状态"
            align="center"
            prop="type"
            :show-overflow-tooltip="true"
            min-width="100"
          >
            <template slot-scope="scope">
              <span
                v-if="scope.row.type == '0'"
                :style="type == 0 ? { color: 'red' } : { color: '#409EFF' }"
              >
                {{ type == 0 ? "未 检" : "在 检" }}
              </span>
              <span v-if="scope.row.type == '1'">已完成</span>
              <span v-if="scope.row.type == '2'">弃检</span>
              <span v-if="scope.row.type == '3'">延期</span>
            </template>
          </el-table-column>
          <el-table-column label="图片" align="center" min-width="100">
            <template slot-scope="scope">
              <img
                v-if="scope.row.imageUrl"
                :src="scope.row.imageUrl"
                alt="图片"
                style="width: 50px; height: 50px; object-fit: cover"
              />
              <span v-else>无图片</span>
            </template>
          </el-table-column>
          <el-table-column
            label="检查时间"
            align="center"
            prop="bcupdateTime"
            min-width="160"
          />
          <el-table-column label="操作" align="center" width="100">
            <template slot-scope="scope">
              <el-button
                type="text"
                size="small"
                @click="showImagePreview(scope.row.imageUrl)"
                :disabled="!scope.row.imageUrl"
                >查看图片</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <div style="margin-top: 10px">
          <el-form
            :model="form"
            ref="queryForm"
            size="small"
            :inline="false"
            label-width="68px"
          >
            <el-form-item label="检查所见" prop="proResult">
              <el-input
                v-model="form.proResult"
                clearable
                type="textarea"
                @focus="submiepilog"
              />
            </el-form-item>
            <el-form-item label="姓名" prop="name">
                <el-input v-model="queryParams.name" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery"
                    style="width: 110px;" />
            <el-form-item label="检查结论" prop="conclusion">
              <el-input
                v-model="form.conclusion"
                clearable
                type="textarea"
                @focus="submiepilog"
              />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
              <el-upload
                action=""
                :http-request="uploadFile"
                :show-file-list="false"
                accept="image/*"
                :before-upload="beforeUpload"
                style="display: inline-block; margin-right: 10px"
              >
                <el-button
                  type="primary"
                  icon="el-icon-picture"
                  size="mini"
                  :disabled="!isUploadEnabled"
                  >上传图片</el-button
                >
              </el-upload>
              <el-button
                type="primary"
                icon="el-icon-search"
                size="mini"
                @click="submito"
                >提交</el-button
              >
            </el-form-item>
        </el-form>
        <div style="width: 100%; margin-left: 10px;display: flex;">
            <div style="width: 36%; margin-right: 30px;">
                <el-table id="table" v-loading="loading" ref="tb" :data="pictureList"
                    @selection-change="handleSelectionChange" border height="630px">
                    <el-table-column type="selection" width="40" align="center" />
                    <el-table-column label="体检号" align="center" prop="customer.tjNumber" width="160px" />
                    <el-table-column label="姓名" align="center" prop="customer.cusName" width="90px" />
                    <!-- <el-table-column label="身份证" align="center" prop="customer.cusIdcard" width="170px" /> -->
                    <el-table-column label="性别" align="center" prop="customer.cusSex" width="60px">
                        <template slot-scope="scope">
                            {{ scope.row.customer.cusSex === 0 ? "男" : "女" }}
                            <!-- <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.cusSex " /> -->
                        </template>
                    </el-table-column>
                    <!-- <el-table-column label="生日" align="center" prop="customer.cusBrithday" width="110px" /> -->
                    <el-table-column label="手机号" align="center" prop="customer.cusPhone" width="110px" />
                    <el-table-column label="婚姻" align="center" prop="cusMarryStatus" width="70px">
                        <template slot-scope="scope">
                            <dict-tag :options="dict.type.dict_user_marry" :value="scope.row.customer.cusMarryStatus" />
                        </template>
                    </el-table-column>
                    <el-table-column label="民族" align="center" prop="cusNational" width="70px">
                        <template slot-scope="scope">
                            <dict-tag :options="dict.type.dict_user_national" :value="scope.row.customer.cusNational" />
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div style="width: 44%;height: 610px;">
                <el-table v-loading="loading" ref="mu" :data="tableList" @selection-change="handleChange" border>
                    <el-table-column type="selection" width="40" align="center" />
                    <el-table-column label="收费项目" align="center" prop="proName" />
                    <el-table-column label="项目名称" align="center" prop="proName" />
                    <el-table-column label="项目结果" align="center" prop="proResult" />
                    <!-- <el-table-column label="结论" align="center" prop="conclusion" /> -->
                </el-table>
                <div style=" height:390px;margin-top: 10px;">
                    <el-image v-loading="loading" style='height: 390px;width: 100%;' :src="imgsrc + tjNumber + '.png'"
                        :preview-src-list="[imgsrc + tjNumber + '.png']"></el-image>
                </div>
                <div style="margin-top: 20px;">
                    <el-form :model="form" ref="queryForm" size="small" :inline="true" label-width="68px">
                        <el-form-item label="项目结果" prop="proResult">
                            <el-input v-model="form.proResult" clearable />
                        </el-form-item>
                        <el-form-item label="结果结论" prop="conclusion">
                            <el-input v-model="form.conclusion" clearable @focus="submiepilog" />
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-search" size="mini" @click="submito">提交</el-button>
                        </el-form-item>
                    </el-form>
                </div>
                <!-- <div style="display:flex;margin:15px 0px;width: 100%;">
                    <div style="width: 100%;display:flex;">
                        <el-button type="primary" class="default-button-style" size="small"
                            @click="submiepilog">结果结论</el-button>
                        <el-button type="primary" icon="el-icon-s-claim" size="mini" @click="submito">提交</el-button>
                    </div>
                </div> -->
            </div>
          </el-form>
        </div>
      </el-col>
    </el-row>
        <div style="margin-right: 70%;">
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getList" />
        </div>
        <Public ref="aaa"  @add="handleChanges" />
    </div>
    <el-dialog
      title="图片预览"
      :visible.sync="imagePreviewVisible"
      width="60%"
      class="image-preview-dialog"
    >
      <div class="image-container">
        <img :src="currentImageUrl" alt="图片" class="preview-image" />
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="imagePreviewVisible = false"
          >确定</el-button
        >
      </span>
    </el-dialog>
    <Public
      ref="aaa"
      :check-status="checkStatus"
      :pro-result="form.proResult"
      :conclusion="form.conclusion"
      @add="handleChanges"
      :project-list="projectList"
    />
  </div>
</template>
<script>
import {
    getListPicture,
    updatePicture
  getListPicture,
  updatePicture,
  getYxJcList,
  getYxJcXx,
  addYxJcXx,
  getYxJcXxJg,
  tupian,
} from "@/api/picture/picture";
import { getCompany, queryCompany } from "@/api/team/tuanti";
import {
  getCsList,
  confirmOrder,
  cSWebGetPro,
  dataSynchronization,
  qijian,
  yijian,
  resultList,
  typeOne,
  huifu,
} from "@/api/doctor/examination";
import Public from "@/components/public";
export default {
    dicts: [
        "sys_user_sex", "sampling_type", "sys_dict_specimen", "dict_user_marry", "dict_user_national"
    ],
    name: "Picture",
    components:{Public},
    data() {
        return {
            topStyle: { transform: '' },
            r_img: {},
            topShow: false,
            rShow: false,
            // 遮罩层
            loading: true,
            result: true,
            epilog: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            activeName: 'first',
            proResult: '',
            conclusion: "",
            imgsrc: "",
            tjNumber: "",
            // 体检心电图管理表格数据
            pictureList: [],
            tableList: [],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                tjNum: null,
                cusId: null,
                name: null,
                xdt: null,
                proId: null,
                proName: null,
                proResult: null,
                conclusion: null,
  dicts: [
    "sys_user_sex",
    "sampling_type",
    "sys_dict_specimen",
    "dict_user_marry",
    "dict_user_national",
  ],
  name: "Picture",
  components: { Public },
  data() {
    return {
      topStyle: { transform: "" },
      r_img: {},
      topShow: false,
      rShow: false,
      type: null,
      checkStatus: "0",
      loading: true,
      result: true,
      epilog: false,
      selectedRow: null,
      ids: [],
      CheckBox: {},
      isCollapsed: 0,
      single: true,
      multiple: true,
      showSearch: true,
      selectedTjNumber: "",
      createTimeList: "",
      total: 0,
      activeName: "first",
      proResult: "",
      conclusion: "",
      imgsrc: "",
      tjNumber: "",
      pictureList: [],
      tableList: [],
      CompanyList: [],
      projectList: [],
      title: "",
      open: false,
      imagePreviewVisible: false,
      currentImageUrl: "",
      selectList: [],
      isUploadEnabled: false,
      queryParams: {
        page: 1,
        pageSize: 10,
        tjNumber: null,
        compId: null,
        name: null,
        beginTime: null,
        endTime: null,
        tcm: "",
        tjCompName: "",
        checkStatus: null,
      },
      dataobj: {},
      form: {
        proResult: "",
        conclusion: "",
      },
      rules: {},
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
            dataobj: {},
            // 表单参数
            form: {
                proResult: "",
                conclusion: "",
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
            // 表单校验
            rules: {
            }
        };
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  mounted() {
    this.$nextTick(() => {
      this.$refs.inputName.focus();
    });
    this.radioChange(this.checkStatus);
  },
  methods: {
    showImagePreview(url) {
      if (url) {
        this.currentImageUrl = url;
        this.imagePreviewVisible = true;
      }
    },
    created() {
        this.getList();
    beforeUpload(file) {
      const isImage = file.type.startsWith("image/");
      if (!isImage) {
        this.$message.error("只能上传图片文件!");
        return false;
      }
      const isLt5M = file.size / 1024 / 1024 < 5;
      if (!isLt5M) {
        this.$message.error("图片大小不能超过 5MB!");
        return false;
      }
      if (
        !this.selectedRow ||
        !this.selectedRow.proId ||
        !this.selectedTjNumber
      ) {
        this.$message.error("请先选择一个项目!");
        return false;
      }
      return true;
    },
    methods: {
        // 鼠标进入原图空间函数
        enterHandler() {
            // 层罩及放大空间的显示
            this.topShow = true
            this.rShow = true
        },
        // 鼠标移动函数
        moveHandler(event) {
            // 鼠标的坐标位置
            let x = event.offsetX
            let y = event.offsetY
            // 层罩的左上角坐标位置,并对其进行限制:无法超出原图区域左上角
            let topX = (x - 100) < 0 ? 0 : (x - 100)
            let topY = (y - 100) < 0 ? 0 : (y - 100)
            // 对层罩位置再一次限制,保证层罩只能在原图区域空间内
            if (topX > 200) {
                topX = 200
            }
            if (topY > 200) {
                topY = 200
            }
            // 通过 transform 进行移动控制
            this.topStyle.transform = `translate(${topX}px,${topY}px)`
            this.r_img.transform = `translate(-${2 * topX}px,-${2 * topY}px)`
        },
        // 鼠标移出函数
        outHandler() {
            // 控制层罩与放大空间的隐藏
            this.topShow = false
            this.rShow = false
        },
        /** 查询体检心电图管理列表 */
        getList() {
            this.loading = true;
            getListPicture(this.queryParams).then(response => {
                if (response.data.list) {
                    this.pictureList = response.data.list;
                } else {
                    this.$message.warning("查无此人");
                }
    uploadFile(item) {
      const file = item.file;
      const tjNumber = this.selectedTjNumber;
      const proId = this.selectedRow.proId;
                if (this.pictureList.length != 0) {
                    this.$nextTick(() => {
                        this.$refs.tb.toggleRowSelection(this.pictureList[0], true);
                    })
                } else {
                    this.$refs.tb.clearSelection();
                }
                this.total = response.data.total;
                this.loading = false;
            });
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {
                proResult:  null,
                conclusion: null,
            };
            this.resetForm("form");
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.imgsrc = selection[0].picturePath
            this.tjNumber = selection[0].customer.tjNumber
            this.ids = selection.map(item => item.id)
            selection.forEach(element => {
                this.tableList = element.list
                if (this.tableList.length != 0) {
                    this.tableList.forEach(item => {
                        this.form.proResult = item.proResult
                        this.form.conclusion= item.conclusion
                    })
                    this.$nextTick(() => {
                        this.$refs.mu.toggleRowSelection(this.tableList[0], true);
                    })
                } else {
                    this.$refs.mu.clearSelection();
                }
            });
            // this.tableList.forEach(item => {
            //     this.imgsrc = item.xdt
            // })
            if (selection.length > 1) {
                let del_row = selection.shift();
                this.$refs.tb.toggleRowSelection(del_row, false); //设置这一行取消选中
      const fileExtension = file.name.split(".").pop();
      const newFileName = `${tjNumber}_${proId}.${fileExtension}`;
      const formData = new FormData();
      formData.append("file", file, newFileName);
      formData.append("tjh", tjNumber);
      formData.append("proId", proId);
      tupian(formData)
        .then((response) => {
          // console.log('成功了', response);
          if (response.code === 200) {
            this.$message.success("图片上传成功!");
            const index = this.tableList.findIndex(
              (item) => item.proId === proId
            );
            if (index !== -1) {
              // 保存 base64 图像用于显示
              if (response.base64) {
                const base64Image = `data:image/${fileExtension};base64,${response.base64}`;
                this.$set(this.tableList[index], "imageUrl", base64Image);
              }
              // 保存返回的 url
              if (response.url) {
                this.$set(this.tableList[index], "url", response.url);
              }
            }
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        handleChange(selection) {
            selection.forEach(element => {
                this.dataobj = element
            });
        },
        handleChanges(value) {
            this.form.conclusion =value
        },
        submiepilog() {
            this.$refs.aaa.open = true;
            let proId = "1633660948860522585"
            this.$refs.aaa.getList(proId);
        },
        // 确定按钮
        submito() {
            if (this.dataobj) {
                if (this.form.proResult) {
                    this.dataobj.proResult = this.form.proResult
                }
                if (this.form.conclusion) {
                    this.dataobj.conclusion = this.form.conclusion
                }
                updatePicture(this.dataobj).then(res => {
                    this.$modal.msgSuccess("提交成功");
                    this.getList()
                    this.form.proResult = ""
                    this.form.conclusion = ""
                })
          } else {
            this.$message.error("图片上传失败!");
          }
        })
        .catch((error) => {
          // console.log('上传失败', error);
          this.$message.error("图片上传失败!");
        });
    },
    enterHandler() {
      this.topShow = true;
      this.rShow = true;
    },
    moveHandler(event) {
      let x = event.offsetX;
      let y = event.offsetY;
      let topX = x - 100 < 0 ? 0 : x - 100;
      let topY = y - 100 < 0 ? 0 : y - 100;
      if (topX > 200) topX = 200;
      if (topY > 200) topY = 200;
      this.topStyle.transform = `translate(${topX}px,${topY}px)`;
      this.r_img.transform = `translate(-${2 * topX}px,-${2 * topY}px)`;
    },
    outHandler() {
      this.topShow = false;
      this.rShow = false;
    },
    getList() {
      this.loading = true;
      this.queryParams.checkStatus = this.checkStatus;
      this.queryParams.compId = this.CheckBox.drugManufacturerId;
      if (this.createTimeList) {
        this.queryParams.beginTime = this.createTimeList[0];
        this.queryParams.endTime = this.createTimeList[1];
      } else if (this.createTimeList == null) {
        this.queryParams.beginTime = null;
        this.queryParams.endTime = null;
      }
      getCompany(this.queryParams).then((response) => {
        this.CompanyList = response.data;
        this.loading = false;
      });
    },
    getNowTime() {
      var curDate = new Date().getTime();
      var dayNum = 7 * 24 * 3600 * 1000;
      var threeDays = curDate - dayNum;
      var sDay = this.getLocalTime(threeDays);
      var end = this.getLocalTime(curDate);
      this.createTimeList = [sDay, end];
    },
    add0(m) {
      return m < 10 ? "0" + m : m;
    },
    getLocalTime(nS) {
      var time = new Date(nS);
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      return (
        y +
        "-" +
        this.add0(m) +
        "-" +
        this.add0(d) +
        " " +
        this.add0(h) +
        ":" +
        this.add0(mm)
      );
    },
    dateChangebirthday1(val) {
      this.startTime = val;
    },
    handleRowClick(row, column, event) {
      this.name = row.proName;
    },
    getRemoteData(query) {
      if (query) {
        let compName = query;
        queryCompany(compName).then((response) => {
          this.CompanyList = response.data;
        });
      }
    },
    radioChange(value) {
      this.loading = true;
      this.queryParams.checkStatus = value;
      this.form.proResult = "";
      this.form.conclusion = "";
      getYxJcList(this.queryParams).then((res) => {
        if (res.code == 200) {
          this.loading = false;
          if (res.data) {
            this.pictureList = res.data.customers;
            this.total = res.data.total;
            if (this.pictureList.length != 0) {
              this.$nextTick(() => {
                this.$refs.tb.toggleRowSelection(this.pictureList[0], true);
              });
            } else {
                this.$modal.msgSuccess("选择修改项目");
              this.$refs.tb.clearSelection();
            }
        },
        //删除按钮
        handleDelete() {
        },
        // 导出
        handleExport() {
            this.total = res.data.total;
          } else {
            this.pictureList = [];
          }
        }
      });
    },
    cancel() {
      this.open = false;
      this.reset();
    },
    reset() {
      this.form = {
        proResult: null,
        conclusion: null,
      };
      this.resetForm("form");
    },
    hb() {
      if (this.queryParams.tjNumber != null) {
        this.submitForm();
      }
    },
    submitForm() {
      this.loading = true;
      this.queryParams.checkStatus = this.checkStatus;
      this.queryParams.compId = this.CheckBox.drugManufacturerId;
      if (this.createTimeList) {
        this.queryParams.beginTime = this.createTimeList[0];
        this.queryParams.endTime = this.createTimeList[1];
      } else if (this.createTimeList == null) {
        this.queryParams.beginTime = null;
        this.queryParams.endTime = null;
      }
      getYxJcList(this.queryParams).then((res) => {
        if (res.code == 200) {
          this.loading = false;
          if (res.data) {
            this.pictureList = res.data.customers;
            this.total = res.data.total;
            if (this.pictureList.length != 0) {
              this.$nextTick(() => {
                this.$refs.tb.toggleRowSelection(this.pictureList[0], true);
              });
            } else {
              this.$refs.tb.clearSelection();
            }
            this.total = res.data.total;
          } else {
            this.pictureList = [];
          }
        }
      });
    },
    searchSelect(val) {
      this.CheckBox = val;
    },
    handleHeaderClick(column, event) {
      if (column.type === "selection") {
        const checkbox = event.target.closest(".el-checkbox");
        if (checkbox) checkbox.style.display = "none";
      }
    },
    handleQuery() {
      this.queryParams.page = 1;
      this.submitForm();
    },
    resetQuery() {
      this.createTimeList = [];
      this.queryParams = {
        page: 1,
        pageSize: 10,
        tjNumber: null,
        compId: null,
        name: null,
        beginTime: null,
        checkStatus: null,
        endTime: null,
        tjCompName: "",
        tcm: "",
      };
      this.CheckBox.drugManufacturerId = "";
      this.tableList = [];
      this.handleQuery();
      this.loading = true;
    },
    toggleCollapse3() {
      this.isCollapsed = 0;
    },
    toggleCollapse() {
      this.isCollapsed = 1;
    },
    tableRowClassName({ row, rowIndex }) {
      for (let i = 0; i < this.selectList.length; i++) {
        if (row === this.selectList[i]) {
          return "warning-row";
        }
      }
    },
    handleCurrentChange(val) {
      this.selectedRow = val;
      if (!val || !val.tjNumber) {
        console.warn("tjNumber 为空,不调用接口");
        this.tableList = [];
        this.isUploadEnabled = false;
        return;
      }
      this.selectedTjNumber = val.tjNumber;
      this.changtjNumber(val.tjNumber);
    },
    changtjNumber(val) {
      let tjNumber = val;
      this.loading = true;
      getYxJcXx(tjNumber).then((res) => {
        this.tableList = res.data.map((item) => {
          // 如果 imageUrl 存在且是纯 Base64 字符串,添加 data:image 前缀
          if (item.imageUrl && !item.imageUrl.startsWith("data:image")) {
            // 假设图片类型为 png,如果接口提供类型,可以替换为动态值
            item.imageUrl = `data:image/png;base64,${item.imageUrl}`;
          }
          return item;
        });
        this.loading = false;
        this.$nextTick(() => {
          const headerCheckbox = this.$refs.mu.$el.querySelector(
            ".el-table__header .el-checkbox"
          );
          if (headerCheckbox) headerCheckbox.style.display = "none";
          if (this.queryParams.checkStatus == 0) {
            if (this.tableList.length > 0) {
              this.tableList.forEach((item, index) => {
                if (item.type == 0) {
                  const firstRow = item;
                  this.$refs.mu.toggleRowSelection(firstRow, true);
                  this.handleChange([firstRow]);
                }
              });
            }
          } else {
            const firstRow = this.tableList[0];
            this.$refs.mu.toggleRowSelection(firstRow, true);
            this.handleChange([firstRow]);
          }
        });
      });
    },
    qijian(row) {
      const tjNUm = this.selectedTjNumber;
      const proId = row.proId;
      row.isLoading = true;
      if (row.type == "2") {
        huifu(tjNUm, proId).then((res) => {
          if (res.code == 200) {
            cSWebGetPro(tjNUm).then((res) => {
              if (res.code === 200) {
                this.xiangmuList = res.data;
                row.isLoading = false;
              }
            });
          }
        });
      } else {
        qijian(tjNUm, proId).then((res) => {
          if (res.code == 200) {
            cSWebGetPro(tjNUm).then((res) => {
              if (res.code === 200) {
                this.xiangmuList = res.data;
                this.isLoading = false;
              }
            });
          }
        });
      }
    },
    yijian(row) {
      const tjNUm = this.selectedTjNumber;
      const proId = row.proId;
      row.isLoading = true;
      yijian(tjNUm, proId)
        .then((res) => {
          if (res.code == 200) {
            this.$modal.msgSuccess("已检成功");
            cSWebGetPro(tjNUm).then((res) => {
              if (res.code === 200) {
                this.xiangmuList = res.data;
                row.isLoading = false;
              }
            });
          }
        })
        .catch(() => {
          row.isLoading = false;
        });
    },
    handleSelectionChange(selection) {
      this.imgsrc = selection[0].picturePath;
      this.tjNumber = selection[0].customer.tjNumber;
      this.ids = selection.map((item) => item.id);
    }
}
    ;
      if (selection.length > 1) {
        let del_row = selection.shift();
        this.$refs.tb.toggleRowSelection(del_row, false);
      }
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
      selection.forEach((element) => {
        this.tableList = element.list;
        if (this.tableList.length !== 0) {
          this.selectedRow = this.tableList[0];
          this.form.proResult = this.tableList[0].proResult;
          this.form.conclusion = this.tableList[0].conclusion;
          this.$nextTick(() => {
            this.$refs.mu.toggleRowSelection(this.tableList[0], true);
          });
        } else {
          this.selectedRow = null;
          this.$refs.mu.clearSelection();
        }
      });
    },
    handleChange(selection) {
      if (selection.length > 1) {
        let del_row = selection.shift();
        this.$refs.mu.toggleRowSelection(del_row, false);
      }
      this.projectList = selection.map((item) => ({
        proId: item.proId,
        proName: item.proName,
      }));
      this.isUploadEnabled = selection.length > 0;
      if (selection && selection.length > 0) {
        const proId = selection[0].proId;
        const tjNumber = this.selectedTjNumber;
        getYxJcXxJg(tjNumber, proId).then((res) => {
          this.form.proResult = res.data.jcsj;
          this.form.conclusion = res.data.jcjl;
          this.$refs.aaa.updateData(res.data.jcsj, res.data.jcjl);
        });
        this.selectedRow = selection[0];
      }
    },
    handleChanges(value, yxbx) {
      this.form.conclusion = value;
      this.form.proResult = yxbx;
    },
    submiepilog() {
      this.$refs.aaa.open = true;
      let proId = "1633660948860522585";
      this.$refs.aaa.getList(proId);
    },
    submito() {
      if (!this.selectedRow || !this.selectedRow.proId) {
        this.$message.error("请选择提交项目");
        return;
      }
      if (!this.form.proResult && !this.form.conclusion) {
        this.$message.warning("请选择检查所见或检查结论!");
      } else {
        const proId = this.selectedRow.proId;
        const jcsj = this.form.proResult || " ";
        const jcjl = this.form.conclusion || " ";
        const url = this.selectedRow.url || ""; // 获取 url,如果不存在则为空字符串
        addYxJcXx({
          proId: proId,
          tjNumber: this.selectedTjNumber,
          jcsj: jcsj,
          jcjl: jcjl,
          url: url, // 添加 url 参数
        })
          .then((response) => {
            this.form.proResult = "";
            this.form.conclusion = "";
            if (this.tableList.length == 1) {
              this.submitForm();
            } else {
              this.tableList.forEach((item, index) => {
                if (item.type == 0) {
                  this.changtjNumber(this.selectedTjNumber);
                } else {
                  this.submitForm();
                }
              });
            }
          })
          .catch((error) => {
            console.error("提交失败", error);
          });
      }
    },
    handleDelete() {},
    handleExport() {},
  },
};
</script>
<style>
#table .el-table__header-wrapper .el-checkbox {
    display: none;
}
.default-button-style :hover {
    width: 80px;
    border-bottom: none;
  width: 80px;
  border-bottom: none;
}
.rightImg {
    display: inline-block;
    width: 740px;
    height: 800px;
    position: absolute;
    top: 0;
    left: 0;
    /* border: 1px solid red; */
  display: inline-block;
  width: 740px;
  height: 800px;
  position: absolute;
  top: 0;
  left: 0;
}
/* 右边的区域图片放大空间 */
.right {
    margin-left: 412px;
    width: 340px;
    height: 400px;
    border: 1px solid black;
    position: relative;
    overflow: hidden;
  margin-left: 412px;
  width: 340px;
  height: 400px;
  border: 1px solid black;
  position: relative;
  overflow: hidden;
}
/* 一个最高层层罩 */
.maskTop {
    width: 400px;
    height: 400px;
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
  width: 400px;
  height: 400px;
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
}
/* 层罩,通过定位将左上角定位到(0,0) */
.top {
    width: 200px;
    height: 200px;
    background-color: #1890ff;
    opacity: 0.4;
    position: absolute;
    top: 0;
    left: 0;
  width: 200px;
  height: 200px;
  background-color: #1890ff;
  opacity: 0.4;
  position: absolute;
  top: 0;
  left: 0;
}
/* 原图的显示 */
.leftImg {
    width: 400px;
    height: 400px;
    display: inline-block;
  width: 400px;
  height: 400px;
  display: inline-block;
}
/* 原图的容器 */
.left {
    width: 400px;
    height: 400px;
    /* border: 1px solid teal; */
    float: left;
    position: relative;
  width: 400px;
  height: 400px;
  float: left;
  position: relative;
}
.el-upload {
  display: inline-block;
}
.el-table .cell img {
  border-radius: 4px;
}
.image-preview-dialog .el-dialog__body {
  padding: 10px;
  max-height: 60vh;
  overflow-y: auto;
}
.image-container {
  text-align: center;
}
.preview-image {
  max-width: 100%;
  max-height: 50vh;
  object-fit: contain;
}
.dialog-footer {
  text-align: center;
}
</style>