spring
2025-02-27 66b3c4c129b05b634d37ac7eac63eff0f0b9f426
src/views/CNAS/resourceDemand/standardMaterialAccept/index.vue
@@ -19,34 +19,10 @@
    </div>
    <div class="table">
      <lims-table :tableData="tableData" :column="columns" :height="'calc(100vh - 250px)'" @pagination="pagination"
                  :page="page" :tableLoading="tableLoading"></lims-table>
        :page="page" :tableLoading="tableLoading"></lims-table>
    </div>
    <AddRecord ref="addRecordRef" @submit="submit"></AddRecord>
  </div>
<!--    <div class="tables">-->
<!--      <ZTTable-->
<!--        :column="columns"-->
<!--        :table-data="tableData"-->
<!--      >-->
<!--        <template slot="action" slot-scope="{ row }">-->
<!--          <el-button type="text" @click="edit(row)">编辑</el-button>-->
<!--        </template>-->
<!--      </ZTTable>-->
<!--      <div class="pagination">-->
<!--        <div></div>-->
<!--        <el-pagination-->
<!--          :page-size="pagination.pageSize"-->
<!--          :page-sizes="[10, 20, 30, 40]"-->
<!--          :total="pagination.total"-->
<!--          layout="total, sizes, prev, pager, next, jumper"-->
<!--          @current-change="handleCurrent"-->
<!--          @size-change="handleSize"-->
<!--        >-->
<!--        </el-pagination>-->
<!--      </div>-->
<!--    </div>-->
<!--    <AddRecord ref="addRecordRef" @submit="submit"></AddRecord>-->
</template>
<script>
@@ -56,6 +32,7 @@
// import AddRecord from './components/AddRecord.vue';
import limsTable from '@/components/Table/lims-table.vue'
import AddRecord from './component/AddRecord.vue';
import {
  getPageAcceptance,
  updateAcceptanc,
@@ -63,8 +40,8 @@
} from '@/api/cnas/resourceDemand/standardMaterialAccept/standardMaterialAccept'
export default {
  components: {
    limsTable
    limsTable,
    AddRecord
  },
  data() {
    return {
@@ -138,8 +115,8 @@
  },
  methods: {
    async getTableData() {
      const res = await  getPageAcceptance(this.form);
      if(res.code === 200){
      const res = await getPageAcceptance(this.form);
      if (res.code === 200) {
        this.tableData = res.data.records;
        this.page.total = res.data.total;
      }
@@ -150,9 +127,9 @@
    },
    async submit(form) {
      const {code} = await form.acceptance.id ? updateAcceptanc(this.form):addAcceptance((this.form));
      if(code == 200) {
        this.$message.success(`${form.acceptance.id ? '编辑':'添加'}成功`)
      const { code } = await form.acceptance.id ? updateAcceptanc(this.form) : addAcceptance((this.form));
      if (code == 200) {
        this.$message.success(`${form.acceptance.id ? '编辑' : '添加'}成功`)
        this.getTableData()
      }
    },
@@ -169,7 +146,7 @@
        url: getAcceptanceDetails,
        params: { id }
      })
      if(code == 200) {
      if (code == 200) {
        return data;
      }
    },
@@ -183,33 +160,8 @@
        url: `${exportAcceptance}`,
        responseType: "blob"
      })
      const blob = new Blob([res], {type: 'application/octet-stream'});
      //将Blob 对象转换成字符串
      let reader = new FileReader();
      reader.readAsText(blob, 'utf-8');
      reader.onload = () => {
        try {
          let result = JSON.parse(reader.result);
          if (result.message) {
            this.$message.error(result.message);
          } else {
            const url = URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = url;
            link.download = '标准物质验收.xlsx';
            link.click();
            this.$message.success('导出成功')
          }
        } catch (err) {
          console.log(err);
          const url = URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = url;
          link.download = '标准物质验收.xlsx';
          link.click();
          this.$message.success('导出成功')
        }
      }
      const blob = new Blob([res], { type: 'application/octet-stream' });
      this.$download.saveAs(blob, '标准物质验收.xlsx');
    },
    // 分页切换