Crunchy
2025-03-17 0a26d58a3906b9e13946c7cb46fae51a0de98920
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<template>
  <div>
    <div class="flex">
      <el-button icon="el-icon-plus" size="small" type="primary" @click="showDialog">
        添加项目
      </el-button>
<!--      <el-button icon="el-icon-upload2" size="small" @click="exportExcel">-->
<!--        导出-->
<!--      </el-button>-->
    </div>
    <limsTable
      :column="columns"
      :height="'25vh'"
      :isSelection="true"
      :table-data="tableData"
      @pagination="pagination"
      :page="page"
      style="margin-top: 18px;"
    >
      <template v-slot:operation="scope">
        <el-button size="small" type="text" @click="deleteData(scope.row)">删除</el-button>
      </template>
    </limsTable>
    <AddProject ref="AddProjectRef" @submit="fetchData"/>
  </div>
</template>
 
<script>
import limsTable from '@/components/Table/lims-table.vue'
import Edit from "./Edit.vue"
import AddProject from './AddProject.vue';
import {
  deleteProcurementSuppliesExpends,
  procurementSuppliesExpendlist
} from "@/api/cnas/externalService/serviceAndSupplyPro/serviceAndSupplyPro";
 
export default {
  components: {limsTable, Edit, AddProject},
  data() {
    return {
      columns: [
        // {
        //   label: "编号"
        // },
        {
          label: "项目名称",
          prop: "listName"
        },
        {
          label: "消耗数量",
          prop: "amount"
        },
        {
          label: "录入人",
          prop: "enterUserName"
        },
        {
          label: "最近更新人",
          prop: "updateUserName"
        },
        {
          label: "最近更新日期",
          prop: "updateTime"
        },
        {
          label: "操作",
          dataType: "slot",
          slot: "operation"
        }
      ],
      tableData: [],
      page: {
        current: 1,
        size: 20,
        total: 0
      },
      listId: 0,
      row: undefined
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    fetchListId(row) {
      if(row) {
        this.listId = row.id
        this.row = row
      }
      this.fetchData()
    },
    async fetchData() {
      if (this.listId === 0) return
      procurementSuppliesExpendlist({
        procurementSuppliesListId:this.listId,
        ...this.page
      }).then(res => {
        if (res.code === 200) {
          this.tableData = res.data
        }
      })
    },
    pagination (page) {
      this.page.size = page.limit
      this.fetchData()
    },
    showDialog() {
      this.$refs.AddProjectRef.openDialog(this.row);
    },
    deleteData(row) {
      deleteProcurementSuppliesExpends({ expendId:row.expendId}).then(res => {
        if (res.code === 200) {
          this.$message.success('删除成功')
          this.fetchData()
        }
      })
    },
    exportExcel() {
    }
  }
}
</script>
 
<style scoped>
.flex {
  text-align: right;
}
 
.pagination {
  padding-top: 15px;
  padding-right: 10px;
  display: flex;
  justify-content: space-between
}
</style>