spring
2025-02-17 3bada36496edc701f37daf59cd7fe1020b155f38
src/views/standard/standardLibrary/index.vue
@@ -1,7 +1,8 @@
<style scoped>
.standard {
  padding: 10px 0;
  padding-top: 10px;
  display: flex;
  height: calc(100vh - 90px);
}
.left {
@@ -43,7 +44,7 @@
.right {
  margin-left: 5px;
  width: calc(100% - 365px);
  width: calc(100% - 350px);
  height: calc(100% - 40px);
}
@@ -306,7 +307,7 @@
          <el-button
            v-if="isShowCopy"
            size="small"
            style="position: absolute; right: 50px; top: 1px"
            style="position: absolute; right: 20px; top: 1px"
            type="primary"
            @click="openCopyDia"
            >批量复制</el-button
@@ -596,6 +597,7 @@
        </el-pagination>
      </el-row>
    </div>
    <el-dialog :visible.sync="addDia" title="分类添加" width="400px">
      <div class="body">
        <el-row style="line-height: 50px">
@@ -646,305 +648,6 @@
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      :visible.sync="moreEdit"
      class="more-edit"
      title="批量编辑"
      width="90%"
    >
      <div
        class="body"
        style="display: flex; flex-direction: column; height: 85vh"
      >
        <div class="search">
          <div class="search-item">
            <el-row style="width: 25%; margin-bottom: 16px">
              <el-col :span="6" style="text-align: right">
                <!-- <span class="required-span">* </span> -->
                要求值:</el-col
              >
              <el-col :span="16">
                <el-input
                  v-model="moreInfo.ask"
                  :disabled="moreSelects.length == 0"
                  clearable
                  size="small"
                ></el-input>
              </el-col>
            </el-row>
            <el-row style="width: 25%; margin-bottom: 16px">
              <el-col :span="6" style="text-align: right">
                <!-- <span class="required-span">* </span> -->
                要求描述:</el-col
              >
              <el-col
                :span="16"
                style="display: flex; align-items: flex-start; height: 100%"
              >
                <el-input
                  v-model="moreInfo.tell"
                  :autosize="{ minRows: 1, maxRows: 3 }"
                  :disabled="moreSelects.length == 0"
                  clearable
                  size="small"
                  type="textarea"
                ></el-input>
              </el-col>
            </el-row>
            <el-row style="width: 25%; margin-bottom: 16px">
              <el-col :span="6" style="text-align: right">
                <!-- <span class="required-span">* </span> -->
                试验方法:</el-col
              >
              <el-col :span="16">
                <el-select
                  v-model="moreInfo.methodS"
                  :disabled="moreSelects.length == 0"
                  clearable
                  filterable
                  size="small"
                  style="width: 100%"
                >
                  <el-option
                    v-for="(a, ai) in methodList"
                    :key="ai"
                    :label="a.label"
                    :value="a.value"
                  ></el-option>
                </el-select>
              </el-col>
            </el-row>
            <el-row style="width: 25%; margin-bottom: 16px">
              <el-col :span="6" style="text-align: right">
                <!-- <span class="required-span">* </span> -->
                单价(元):</el-col
              >
              <el-col :span="16">
                <el-input
                  v-model="moreInfo.price"
                  :disabled="moreSelects.length == 0"
                  clearable
                  size="small"
                ></el-input>
              </el-col>
            </el-row>
            <el-row style="width: 25%">
              <el-col :span="6" style="text-align: right">
                <!-- <span class="required-span">* </span> -->
                工时系数:</el-col
              >
              <el-col :span="16">
                <el-input
                  v-model="moreInfo.manHour"
                  :disabled="moreSelects.length == 0"
                  clearable
                  size="small"
                ></el-input>
              </el-col>
            </el-row>
            <el-row style="width: 25%">
              <el-col :span="6" style="text-align: right">
                <!-- <span class="required-span">* </span> -->
                模板:</el-col
              >
              <el-col :span="16">
                <el-select
                  v-model="moreInfo.templateId"
                  :disabled="moreSelects.length == 0"
                  filterable
                  placeholder="模板"
                  size="small"
                  style="width: 100%"
                >
                  <el-option
                    v-for="(a, ai) in templateList"
                    :key="ai"
                    :label="a.name"
                    :value="a.id"
                  ></el-option>
                </el-select>
              </el-col>
            </el-row>
            <el-row style="width: 25%">
              <el-col :span="6" style="text-align: right"> 是否启用:</el-col>
              <el-col :span="16">
                <el-select
                  v-model="moreInfo.state"
                  :disabled="moreSelects.length == 0"
                  clearable
                  filterable
                  placeholder="模板"
                  size="small"
                  style="width: 100%"
                >
                  <el-option :value="1" label="启用"></el-option>
                  <el-option :value="0" label="不启用"></el-option>
                </el-select>
              </el-col>
            </el-row>
            <el-row style="width: 100%; margin-top: 8px">
              <el-col
                :span="24"
                style="display: flex; align-items: center; justify-content: end"
              >
                <el-button size="small" type="danger" @click="clearProduct(1)"
                  >重置单价</el-button
                >
                <el-button size="small" type="danger" @click="clearProduct(2)"
                  >重置工时系数</el-button
                >
                <el-button
                  size="small"
                  type="primary"
                  @click="sectionUp(moreSelects)"
                  >设置区间</el-button
                >
                <el-button size="small" @click="moreEdit = false"
                  >取 消</el-button
                >
                <el-button
                  :loading="moreEditLoad"
                  size="small"
                  type="primary"
                  @click="subMoreEdit"
                  >保 存</el-button
                >
              </el-col>
            </el-row>
          </div>
        </div>
        <div v-loading="productTableLoading0" style="flex: 1; overflow-y: auto">
          <el-table
            ref="productTable0"
            :data="productList0"
            :fit="true"
            :row-key="(row) => row.id"
            border
            header-row-class-name="header-class"
            height="96%"
            highlight-current-row
            stripe
            style="width: 100%"
            tooltip-effect="dark"
            @select="handleSelectionChange0"
            @select-all="handleSelectAll0"
            @filter-change="filterHandler"
          >
            <el-table-column type="selection" width="50"> </el-table-column>
            <el-table-column
              label="产品"
              min-width="100"
              prop="sample"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              label="型号"
              min-width="100"
              prop="model"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              :filter-multiple="false"
              :filters="filters0"
              column-key="inspectionItem"
              filter-placement="bottom-start"
              label="检验项"
              min-width="140"
              prop="inspectionItem"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              :filter-multiple="false"
              :filters="filters1"
              column-key="inspectionItemSubclass"
              filter-placement="bottom-start"
              label="检验项子项"
              min-width="140"
              prop="inspectionItemSubclass"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              :filter-multiple="false"
              :filters="filters"
              column-key="sonLaboratory"
              filter-placement="bottom-start"
              label="子实验室"
              prop="sonLaboratory"
              show-overflow-tooltip
              width="130"
            ></el-table-column>
            <el-table-column
              label="要求值"
              min-width="200px"
              prop="ask"
            ></el-table-column>
            <el-table-column
              label="要求描述"
              min-width="220px"
              prop="tell"
            ></el-table-column>
            <el-table-column
              label="试验方法"
              prop="methodS"
              width="200"
            ></el-table-column>
            <el-table-column
              label="条件"
              prop="radius"
              width="200"
            ></el-table-column>
            <el-table-column
              label="计量单位"
              prop="unit"
              show-overflow-tooltip
              width="100"
            ></el-table-column>
            <el-table-column
              label="单价(元)"
              prop="price"
              width="120"
            ></el-table-column>
            <el-table-column
              label="工时系数"
              prop="manHour"
              width="120"
            ></el-table-column>
            <el-table-column
              label="工时分组"
              prop="manHourGroup"
              show-overflow-tooltip
              width="100"
            ></el-table-column>
            <el-table-column label="模板" prop="templateId" width="200">
              <template slot-scope="scope">
                {{
                  templateList.find((item) => item.id == scope.row.templateId)
                    ? templateList.find(
                        (item) => item.id == scope.row.templateId
                      ).name
                    : ""
                }}
              </template>
            </el-table-column>
            <el-table-column
              label="区间"
              prop="section"
              show-overflow-tooltip
              width="120"
            ></el-table-column>
          </el-table>
          <el-pagination
            :current-page="currentPage0"
            :page-size="100"
            :total="total0"
            layout="total, prev, pager, next, jumper"
            style="position: absolute; right: 16px; bottom: 4px"
            @current-change="handleCurrentChange0"
          >
          </el-pagination>
        </div>
      </div>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
@@ -1053,35 +756,6 @@
        ></el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="uploadDia" title="数据导入" width="500px">
      <div style="margin: 0 auto">
        <el-upload
          ref="upload"
          :action="
            VUE_APP_BASE_API + '/standardTree/inExcelOfTree/' + isEquipment
          "
          :auto-upload="false"
          :file-list="fileList"
          :headers="token"
          :limit="1"
          :on-change="beforeUpload"
          :on-error="onError"
          :on-success="onSuccess"
          accept=".xlsx"
          drag
          name="file"
        >
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        </el-upload>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="uploadDia = false">取 消</el-button>
        <el-button :loading="uploading" type="primary" @click="submitUpload()"
          >上 传</el-button
        >
      </span>
    </el-dialog>
    <!-- <bindSupplierDensityDialogAsk v-if="bindSupplierDensityDialog"
                               :bindSupplierDensityDialog="bindSupplierDensityDialog"
                               :currentRow="currentSupplierDensityRow"
@@ -1176,21 +850,9 @@
      total: 0,
      currentPage: 1,
      standardId: 0,
      moreEdit: false,
      moreEditLoad: false,
      moreSelects: [],
      total0: 0,
      currentPage0: 1,
      productList0: [],
      moreInfo: {
        ask: "",
        tell: "",
        methodS: "",
        price: "",
        manHour: "",
        templateId: "",
        state: null,
      },
      methodList: [],
      productTableLoading0: false,
      filters0: [],
@@ -1199,7 +861,6 @@
      inspectionItem: null,
      inspectionItemSubclass: null,
      sonLaboratory: null,
      uploadDia: false,
      token: null,
      fileList: [],
      uploading: false,
@@ -1211,25 +872,8 @@
      isShowCopy: false,
      batchCopyDia: false,
      VUE_APP_BASE_API: process.env.VUE_APP_BASE_API,
      moreSelects: [],
    };
  },
  watch: {
    moreEdit(val) {
      if (!val) {
        this.$refs.productTable0.clearSelection();
        this.moreSelects = [];
        this.currentPage0 = 1;
        this.productList0 = [];
        this.moreInfo = {
          ask: "",
          tell: "",
          methodS: "",
          price: "",
          manHour: "",
          templateId: "",
        };
      }
    },
  },
  mounted() {
    this.selectEnumByCategoryForFactory();
@@ -2061,16 +1705,6 @@
        this.$refs.BatchCopy.getList();
      });
    },
    async handleMore() {
      if (
        (!this.standardId && this.standardId != 0) ||
        this.standardList.length == 0
      ) {
        return this.$message.error("请选择实验室、样品");
      }
      await this.getList();
      this.moreEdit = true;
    },
    selectStandardMethodsSec() {
      selectStandardMethods().then((res) => {
        let data = [];
@@ -2081,33 +1715,6 @@
          });
        });
        this.methodList = data;
      });
    },
    subMoreEdit() {
      if (this.moreSelects.length === 0) {
        return this.$message.error("请选择检验项");
      }
      this.moreEditLoad = true;
      for (let a in this.moreInfo) {
        if (this.moreInfo[a] == "") {
          delete this.moreInfo[a];
        }
      }
      upStandardProducts({
        ids: JSON.stringify(this.moreSelects.map((a) => a.id)),
        standardProductList: this.moreInfo,
      }).then((res) => {
        this.moreEditLoad = false;
        if (res.code == 201) {
          this.$message.error("未保存");
          return;
        }
        this.$message.success("已保存");
        this.currentPage0 = 1;
        this.getList();
        this.rowClick({
          id: this.standardId,
        });
      });
    },
    handleSelectAll0(rows) {
@@ -2184,83 +1791,6 @@
          }
        });
      });
    },
    beforeUpload(file, fileList) {
      if (
        file.raw.type !=
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
      ) {
        this.$message.error("上传文件格式不正确");
        this.$refs.upload.clearFiles();
        return false;
      }
    },
    submitUpload() {
      if (this.$refs.upload.uploadFiles.length == 0) {
        this.$message.error("未选择文件");
        return;
      }
      this.uploading = true;
      this.$refs.upload.submit();
    },
    onSuccess(response, file, fileList) {
      this.$refs.upload.clearFiles();
      this.uploadDia = false;
      this.uploading = false;
      if (response.code == 201) {
        this.$message.error(response.message);
        return;
      }
      this.$message.success("上传成功");
      this.standardList = [];
      this.productList = [];
      this.selectStandardTreeList();
    },
    onError(err, file, fileList) {
      this.$message.error("上传失败");
      this.$refs.upload.clearFiles();
      this.uploading = false;
    },
    clearProduct(type) {
      this.$confirm("是否清空?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          if (type === 1) {
            resetTreeOfPrice({
              tree: this.selectTree,
              standardId: this.standardId,
            }).then((res) => {
              if (res.code == 201) {
                return;
              }
              this.$message.success("已清空");
              this.currentPage0 = 1;
              this.getList();
              this.rowClick({
                id: this.standardId,
              });
            });
          } else if (type === 2) {
            resetTreeOfHour({
              tree: this.selectTree,
              standardId: this.standardId,
            }).then((res) => {
              if (res.code == 201) {
                return;
              }
              this.$message.success("已清空");
              this.currentPage0 = 1;
              this.getList();
              this.rowClick({
                id: this.standardId,
              });
            });
          }
        })
        .catch(() => {});
    },
  },
};