Crunchy
2025-04-29 e5454b769d44a34af423bf87ac8a740bf8c20341
src/views/CNAS/externalService/serviceAndSupplyPro/component/Store.vue
@@ -1,33 +1,19 @@
<template>
  <div>
    <div style="
        display: flex;
        justify-content: flex-end;
        margin-right: 20px;
        margin-bottom: 20px;
      ">
      <el-button icon="el-icon-plus" size="small" type="primary" @click="addOrUpdateStore('add')">添加
      </el-button>
      <el-button icon="el-icon-download" size="small" @click="importExcel">
        导出excel
      </el-button>
    <div style="display: flex;justify-content: flex-end;margin-bottom: 10px;">
      <el-button size="small" type="primary" @click="searchList">刷新</el-button>
      <el-button icon="el-icon-plus" size="small" type="primary" @click="addOrUpdateStore('add')">添加</el-button>
      <el-button icon="el-icon-download" size="small" @click="importExcel">导出excel</el-button>
    </div>
    <div class="table">
      <limsTable
        :column="tableColumn"
        :height="'calc(100vh - 20em)'"
        :table-data="storageTableData"
        :table-loading="tableLoading"
        style="padding: 0 10px;margin-bottom: 16px"
        :page="page"
        @pagination="pagination">
      <limsTable :column="tableColumn" :height="'calc(100vh - 20em)'" :table-data="storageTableData"
        :table-loading="tableLoading" :page="page" @pagination="pagination">
      </limsTable>
    </div>
    <!-- 编辑-新增弹框 -->
    <el-dialog :before-close="handleClose" :close-on-click-modal="false"
               :close-on-press-escape="false" :title="title"
               :visible.sync="dialogVisible" width="70%">
    <el-dialog :before-close="handleClose" :close-on-click-modal="false" :close-on-press-escape="false" :title="title"
      :visible.sync="dialogVisible" width="70%">
      <!-- 入库单 -->
      <div>
        <div style="display: flex; align-items: center">
@@ -51,19 +37,17 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="入库日期">
              <el-date-picker v-model="form.storageTime" format="yyyy-MM-dd"
                              placeholder="选择日期"
                              size="small"
                              style="width: 100%" type="date" value-format="yyyy-MM-dd"></el-date-picker>
              <el-date-picker v-model="form.storageTime" format="yyyy-MM-dd" placeholder="选择日期" size="small"
                style="width: 100%" type="date" value-format="yyyy-MM-dd"></el-date-picker>
            </el-form-item>
          </el-col>
            <el-col :span="12">
              <el-form-item label="入库人">
                <el-select v-model="form.storageUser" size="small" style="width: 100%">
                  <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          <el-col :span="12">
            <el-form-item label="入库人">
              <el-select v-model="form.storageUser" size="small" style="width: 100%">
                <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入库说明">
              <el-input v-model="form.remark" :rows="2" placeholder="请输入内容" type="textarea">
@@ -106,11 +90,10 @@
              </el-input>
            </div>
          </div>
          <el-button size="mini" type="primary"
            @click="addTableData">添加
          <el-button size="mini" type="primary" @click="addTableData">添加
          </el-button>
        </div>
        <el-table :data="consumables" style="margin-top: 10px">
        <el-table :data="consumables" style="margin-top: 10px" :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border>
          <el-table-column label="编号" type="index" width="120px"></el-table-column>
          <el-table-column label="货号" prop="itemNumber"></el-table-column>
          <el-table-column label="类别" prop="type"></el-table-column>
@@ -225,7 +208,7 @@
          label: '登记人',
          prop: 'registrantName',
          minWidth: '160'
        },{
        }, {
          label: '登记日期',
          prop: 'registrantTime',
          minWidth: '100'
@@ -263,12 +246,6 @@
      consumableOptions: [],
      options: [],
      storageTableData: [],
      searchForm: {
        orderBy: {
          field: "id",
          order: "desc",
        },
      },
      saveLoading: false,
    };
  },
@@ -322,7 +299,7 @@
    // 添加表格数据
    addTableData() {
      this.$nextTick()
      console.log('this.consumableOptions',this.consumableOptions)
      console.log('this.consumableOptions', this.consumableOptions)
      this.consumableOptions.forEach(item => {
        if (item.id === this.formTwo.id) {
          this.consumables.push({
@@ -343,13 +320,12 @@
      this.consumables.splice(index, 1);
    },
    // 打开弹框
    addOrUpdateStore(type,row) {
    addOrUpdateStore(type, row) {
      if (type === 'edit') {
        this.dialogType = "update";
        selectStoreById({id:row.id}).then(res => {
          if (res.code === 201) return
        selectStoreById({ id: row.id }).then(res => {
          this.consumables = res.data.consumables
          this.form = {...res.data.store}
          this.form = { ...res.data.store }
        }).catch(err => {
          console.log('err---', err);
        })
@@ -359,11 +335,11 @@
      this.dialogVisible = true;
    },
    // 查询列表
    searchList () {
    searchList() {
      this.tableLoading = true
      storeList({...this.page,...this.searchForm}).then(res => {
      storeList({ ...this.page}).then(res => {
        this.tableLoading = false
        if (res.code === 200){
        if (res.code === 200) {
          this.storageTableData = res.data.records
          this.page.total = res.data.total
        }
@@ -374,10 +350,9 @@
    },
    // 导出excel
    async importExcel() {
      exportProcurementSuppliesStoreExcel({parentId:this.contentsId}).then(res => {
        const blob = new Blob([res], {type: 'application/octet-stream'});
      exportProcurementSuppliesStoreExcel({ parentId: this.contentsId }).then(res => {
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, '耗材入库.xlsx')
        this.$message.success('导出成功')
      })
    },
    handleClose() {
@@ -404,11 +379,11 @@
    // 获取所有用户
    getUserList() {
      selectUserCondition().then((res) => {
          this.users = res.data;
        });
        this.users = res.data;
      });
    },
    async fetchListOptions() {
      procurementSuppliesList({contentsId: this.contentsId}).then(res => {
      procurementSuppliesList({ contentsId: this.contentsId }).then(res => {
        if (res.code === 200) {
          this.consumableOptions = res.data.records
        }
@@ -416,20 +391,20 @@
    },
    // 删除
    deleteStore (row) {
    deleteStore(row) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.tableLoading = true
        console.log('row>>>>>>>>>>>>>>s',row)
        console.log('row>>>>>>>>>>>>>>s', row)
        deleteStore({
          id:row.id,
          consumablesId:row.consumablesId
          id: row.id,
          consumablesId: row.consumablesId
        }).then(res => {
          this.tableLoading = false
          if (res.code === 200){
          if (res.code === 200) {
            this.$message.success('删除成功')
            this.searchList()
          }
@@ -457,10 +432,12 @@
.el-dialog {
  margin: 6vh auto 50px !important;
}
.el-dialog__body {
  max-height: 42em;
  overflow-y: auto;
}
.input-form {
  display: flex;
  margin: 10px 0;