liding
2026-09-21 94e0abbf193f9e1fc953716ca7868d74cd14a2cd
src/views/standard/model/index.vue
@@ -1,98 +1,48 @@
<template>
  <div class="standard-template">
  <div class="capacity-scope">
    <div class="search">
      <div class="search_thing">
        <div class="search_label">模板名称:</div>
        <div class="search_input">
          <el-input
            v-model="queryParams.name"
            clearable
            placeholder="请输入"
            size="small"
            @keyup.enter.native="refreshTable()"
          ></el-input>
      <div class="search_box">
        <div class="search_item">
          <span class="search_label">检验项目</span>
          <el-input v-model="queryParams.name" clearable placeholder="请输入" size="small"
                    @keyup.enter.native="refreshTable()"></el-input>
        </div>
        <div class="search_button">
          <el-button type="primary" size="mini" @click="refreshTable">查询</el-button>
          <el-button size="mini" @click="refresh">重置</el-button>
        </div>
      </div>
      <div class="search_thing" style="padding-left: 30px">
        <el-button size="small" @click="refresh()">重 置</el-button>
        <el-button size="small" type="primary" @click="refreshTable()"
          >查 询</el-button
        >
      </div>
      <div class="btn">
        <el-button
          v-if="checkPermi(['standard:model:add'])"
          size="small"
          type="primary"
          @click="openAdd"
          >新增</el-button
        >
        <!-- <el-button
          v-if="checkPermi(['standard:model:copy'])"
          size="small"
          @click="copyTemplate"
          >复制模版</el-button
        > -->
      <div>
        <el-button v-if="checkPermi(['standard:model:add'])" size="small" type="primary" @click="openAdd">新增</el-button>
      </div>
    </div>
    <lims-table
      :tableData="tableData"
      :column="column"
      :page="page"
      :tableLoading="tableLoading"
      :height="'calc(100vh - 250px)'"
      style="padding: 20px; padding-top: 0"
      @pagination="pagination"
    ></lims-table>
    <el-dialog
      :before-close="isClose"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :visible.sync="isShow"
      title="模板编制"
      width="85%"
    >
    <lims-table :tableData="tableData" :column="column" :page="page" :tableLoading="tableLoading"
      :height="'calc(100vh - 250px)'" @pagination="pagination"></lims-table>
    <el-dialog :before-close="isClose" :close-on-click-modal="false" :close-on-press-escape="false"
      :visible.sync="isShow" title="模板编制" width="85%">
      <div v-if="isShow" style="width: 100%; height: 82vh; overflow: auto">
        <Excel
          v-loading="loading"
          :data="row.thing"
          :execlTitle="row.name"
        ></Excel>
        <Excel v-loading="loading" :data="row.thing" :execlTitle="row.name"></Excel>
      </div>
    </el-dialog>
    <el-dialog
      :before-close="closeCopyTem"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :visible.sync="isShowCopyTem"
      :title="title"
      width="35%"
    >
      <el-form
        ref="copyForm"
        :model="copyForm"
        :rules="copyFormRules"
        label-position="right"
        label-width="80px"
      >
        <el-form-item label="模版编号" prop="number">
    <el-dialog :before-close="closeCopyTem" :close-on-click-modal="false" :close-on-press-escape="false"
      :visible.sync="isShowCopyTem" :title="title" width="35%" :modal-append-to-body="false">
      <el-form ref="copyForm" :model="copyForm" :rules="copyFormRules" label-position="right" label-width="80px">
        <el-form-item label="检验依据" prop="number">
          <el-input v-model="copyForm.number" clearable size="small"></el-input>
        </el-form-item>
        <el-form-item label="模版名称" prop="name">
        <el-form-item label="检验项目" prop="name">
          <el-input v-model="copyForm.name" clearable size="small"></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="copyForm.remark" clearable size="small"></el-input>
        </el-form-item>
        <el-form-item label="价格(元)" prop="price">
          <el-input v-model="copyForm.price" clearable size="small"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeCopyTem">取 消</el-button>
        <el-button
          :loading="submitCopyInfoLoading"
          type="primary"
          @click="submitCopyInfo"
          >确 定</el-button
        >
        <el-button :loading="submitCopyInfoLoading" type="primary" @click="submitCopyInfo">确 定</el-button>
      </span>
    </el-dialog>
  </div>
@@ -109,8 +59,8 @@
  delStandardTemplate,
  getEditTemplatePreparation,
} from "@/api/standard/model";
import { checkPermi } from "@/utils/permission"; // 权限判断函数
export default {
  name: 'Model',
  components: {
    Excel,
    limsTable,
@@ -132,35 +82,35 @@
        number: "",
        name: "",
        remark: "",
        price: "",
        id: "",
      },
      copyFormRules: {
        name: [{ required: true, message: "请输入模版名称", trigger: "blur" }],
        name: [{ required: true, message: "请输入检验项目", trigger: "blur" }],
      },
      queryParams: {
        name: null,
      },
      tableData: [],
      column: [
        { label: "模板编号", prop: "number" },
        { label: "模板名称", prop: "name" },
        { label: "检验依据", prop: "number" },
        { label: "检验项目", prop: "name" },
        { label: "备注", prop: "remark" },
        { label: "价格(元)", prop: "price" },
        { label: "创建用户", prop: "createUserName" },
        { label: "创建时间", prop: "createTime" },
        { label: "创建时间", prop: "createTime", width: "160" },
        { label: "更新用户", prop: "updateUserName" },
        { label: "修改时间", prop: "updateTime" },
        { label: "修改时间", prop: "updateTime", width: "160" },
        {
          dataType: "action",
          fixed: "right",
          label: "操作",
          width: "320px",
          operation: [
            {
              name: "编辑",
              type: "text",
              clickFun: (row) => {
                this.title = "编辑";
                this.copyForm = row;
                this.copyForm = this.HaveJson(row);
                this.isShowCopyTem = true;
              },
              showHide: (row) => {
@@ -217,7 +167,6 @@
    this.getList();
  },
  methods: {
    checkPermi,
    getList() {
      this.tableLoading = true;
      let param = { ...this.queryParams, ...this.page };
@@ -239,7 +188,10 @@
      this.page.size = limit;
      this.getList();
    },
    refreshTable(e) {
    refreshTable(event) {
      if (event && typeof event.preventDefault === 'function') {
        event.preventDefault(); // 阻止默认行为
      }
      this.page.current = 1;
      this.getList();
    },
@@ -269,17 +221,17 @@
            name: this.copyForm.name,
            number: this.copyForm.number,
            remark: this.copyForm.remark,
            price: this.copyForm.price === "" || this.copyForm.price == null ? null : this.copyForm.price,
          };
          switch (this.title) {
            case "新增":
              delete params.id;
              addStandardTemplate(params)
                .then((res) => {
                  if (res.code == 201) return;
                  this.isShowCopyTem = false;
                  this.submitCopyInfoLoading = false;
                  this.$message.success("新增成功");
                  this.refreshTable("page");
                  this.getList();
                })
                .catch((err) => {
                  console.log("copyTemplate----", err);
@@ -290,7 +242,6 @@
              params.thing = this.copyForm.thing ? this.copyForm.thing : "";
              upStandardTemplate(params)
                .then((res) => {
                  if (res.code == 201) return;
                  this.isShowCopyTem = false;
                  this.submitCopyInfoLoading = false;
                  this.$message.success("修改成功");
@@ -304,7 +255,6 @@
            case "复制模版":
              copyStandardTemplate(params)
                .then((res) => {
                  if (res.code == 201) return;
                  this.isShowCopyTem = false;
                  this.submitCopyInfoLoading = false;
                  this.$message.success("复制成功");
@@ -335,12 +285,11 @@
      })
        .then(() => {
          delStandardTemplate({ id: row.id }).then((res) => {
            if (res.code == 201) return;
            this.$message.success("删除成功");
            this.refreshTable("page");
          });
        })
        .catch(() => {});
        .catch(() => { });
    },
    templateWrite(row) {
      getEditTemplatePreparation({ id: row.id }).then((res) => {
@@ -348,7 +297,7 @@
          return;
        }
        this.row = row;
        this.row.thing = res.msg;
        this.row.thing = res.data;
        this.isShow = true;
      });
    },
@@ -364,7 +313,7 @@
        .then(() => {
          this.closed();
        })
        .catch(() => {});
        .catch(() => { });
    },
    closed() {
      this.loading = true;
@@ -409,7 +358,6 @@
        thing: JSON.stringify(data),
        name: luckysheet.getWorkbookName(["name"]),
      }).then((res) => {
        if (res.code == 201) return;
        this.loading = false;
        this.$message.success("已保存");
        this.isShow = false;
@@ -434,31 +382,27 @@
<style scoped>
.search {
  background-color: #fff;
  height: 80px;
  height: 46px;
  display: flex;
  justify-content: space-between;
}
.search_box {
  display: flex;
}
.search_item {
  margin-bottom: 18px;
  margin-right: 10px;
  display: flex;
  align-items: center;
  position: relative;
  line-height: 32px;
}
.search_thing {
  width: 350px;
  display: flex;
  align-items: center;
}
.search_label {
  width: 90px;
  width: 88px;
  font-size: 14px;
  text-align: right;
  font-weight: 700;
  color: #606266;
}
.search_input {
  width: calc(100% - 110px);
}
.btn {
  position: absolute;
  right: 14px;
  top: 20px;
.search_button {
  line-height: 26px;
}
</style>