Crunchy
2025-04-29 e5454b769d44a34af423bf87ac8a740bf8c20341
src/views/CNAS/resourceDemand/standardMaterialAccept/index.vue
@@ -1,76 +1,51 @@
<template>
  <div class="capacity-scope">
    <div class="search">
      <div>
        <el-form :model="form" ref="form" size="small" :inline="true">
          <el-form-item label="物质名称">
            <el-input v-model="form.search"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="reset">重 置</el-button>
            <el-button type="primary" @click="getTableData">查 询</el-button>
          </el-form-item>
        </el-form>
    <div style="display: flex;justify-content: space-between">
      <div style="display: flex;">
        <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
          <span style="width: 88px;font-size: 14px;font-weight: 700;color: #606266;">物质名称</span>
          <el-input size="small" placeholder="请输入" clearable v-model="form.name"
                    @keyup.enter.native="getTableData"></el-input>
        </div>
        <div style="line-height: 30px;">
          <el-button type="primary" @click="getTableData" size="mini">查询</el-button>
          <el-button @click="reset" size="mini">重置</el-button>
        </div>
      </div>
      <div>
      <div style="line-height: 30px;">
        <el-button icon="el-icon-plus" size="small" type="primary" @click="openDialog">添加验收</el-button>
        <el-button size="small" type="primary" @click="exportExcel">导出</el-button>
      </div>
    </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">
        <template slot="action" slot-scope="{ row }">
          <el-button type="text" @click="edit(row)">编辑</el-button>
        </template>
      </lims-table>
    </div>
    <AddRecord ref="addRecordRef" @submit="submit"></AddRecord>
    <AddRecord ref="addRecordRef" v-if="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>
// import axios from "axios";
// import { getPageAcceptance, addAcceptance, updateAcceptance, getAcceptanceDetails, exportAcceptance } from "@/assets/api/api";
// import ZTTable from '@/components/caorui/ZTTable/index.vue';
// import AddRecord from './components/AddRecord.vue';
import limsTable from '@/components/Table/lims-table.vue'
import AddRecord from './component/AddRecord.vue';
import {
  getPageAcceptance,
  updateAcceptanc,
  addAcceptance
  getPageAcceptance, getAcceptanceDetails, exportFeStandardSubstanceAcceptance, updateAcceptance, addAcceptance
} from '@/api/cnas/resourceDemand/standardMaterialAccept/standardMaterialAccept'
export default {
  components: {
    limsTable
    limsTable,
    AddRecord
  },
  data() {
    return {
      form: {
        search: undefined
        name: undefined
      },
      addRecordRef: false,
      columns: [
        {
          label: "出场编号",
@@ -137,56 +112,42 @@
    this.getTableData()
  },
  methods: {
    async getTableData() {
      const res = await getPageAcceptance(this.form);
      if (res.code === 200) {
    getTableData() {
      this.tableLoading = true
      getPageAcceptance({...this.form, ...this.page}).then(res => {
        this.tableLoading = false
        this.tableData = res.data.records;
        this.page.total = res.data.total;
      }
      }).catch(error => {
        this.tableLoading = false
      })
    },
    openDialog() {
      this.$refs.addRecordRef.openDialog()
    },
    async submit(form) {
      const { code } = await form.acceptance.id ? updateAcceptanc(this.form) : addAcceptance((this.form));
      if (code == 200) {
        this.$message.success(`${form.acceptance.id ? '编辑' : '添加'}成功`)
        this.getTableData()
      }
    },
    async edit(row) {
      const res = await this.getDetail(row.id)
      this.$refs.addRecordRef.openDialog({
        acceptance: res.acceptance,
        list: res.list
      this.addRecordRef = true;
      this.$nextTick(() => {
        this.$refs.addRecordRef.openDialog()
      })
    },
    async getDetail(id) {
      const { code, data } = await axios({
        method: 'get',
        url: getAcceptanceDetails,
        params: { id }
    submit() {
      this.addRecordRef = false;
      this.getTableData()
    },
    edit(row) {
      this.addRecordRef = true;
      this.$nextTick(() => {
        this.$refs.addRecordRef.openDialog(row.id)
      })
      if (code == 200) {
        return data;
      }
    },
    reset() {
      this.form.search = undefined
      this.form.name = undefined
      this.getTableData()
    },
    async exportExcel() {
      const res = await axios({
        method: "get",
        url: `${exportAcceptance}`,
        responseType: "blob"
      exportFeStandardSubstanceAcceptance().then(res => {
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, '标准物质验收.xlsx');
      })
      const blob = new Blob([res], { type: 'application/octet-stream' });
      this.$download.saveAs(blob, '标准物质验收.xlsx');
    },
    // 分页切换
    pagination(page) {
      this.page.size = page.limit
@@ -197,6 +158,10 @@
</script>
<style scoped>
.capacity-scope {
  padding: 20px !important;
}
.search {
  height: 46px;
  display: flex;