123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <template>
- <div class="pa-3 white">
- <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
- <m-table
- v-loading="loading"
- :items="items"
- :headers="headers"
- :page-size="pageInfo.size"
- :page-current="pageInfo.current"
- :total="total"
- @page-change="onPageChange"
- >
- <template #card-tools>
- <m-button type="orange" icon="el-icon-plus" @click="onAdd">申报</m-button>
- </template>
- <template #actions="{ row }">
- <m-button type="primary" text @click="onEdit(row)">编辑</m-button>
- <m-button type="danger" text @click="onDelete(row)">删除</m-button>
- </template>
- </m-table>
- <AccumulatePointsApplyEdit ref="accumulatePointsApplyEditRefs"></AccumulatePointsApplyEdit>
- </div>
- </template>
- <script>
- import {
- getAccumulatePointList,
- deleteAccumulatePoint
- } from '@/api/accumulatePoint'
- import AccumulatePointsApplyEdit from './accumulatePointsApplyEdit.vue'
- export default {
- name: 'accumulatePointsEntering',
- components: {
- AccumulatePointsApplyEdit
- },
- data () {
- return {
- searchItems: [
- {
- label: '名称',
- prop: 'name',
- type: 'input',
- options: {
- placeholder: '请输入名称'
- }
- }
- ],
- searchValues: {
- name: null
- },
- headers: [
- { label: '名称', prop: 'name' },
- { label: '状态', prop: 'status' },
- { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
- ],
- items: [],
- total: 0,
- pageInfo: {
- current: 1,
- size: 10
- },
- loading: false
- }
- },
- created () {
- this.onInit()
- },
- methods: {
- async onInit () {
- this.loading = true
- try {
- const { data } = await getAccumulatePointList({
- ...this.searchValues,
- ...this.pageInfo
- })
- this.items = data.records
- this.total = data.total
- } catch (error) {
- this.$message.error(error)
- } finally {
- this.loading = false
- }
- },
- onAdd () {
- this.$refs.accumulatePointsApplyEditRefs.open()
- },
- onEdit (item) {
- this.$refs.accumulatePointsApplyEditRefs.open(item)
- },
- onDelete (row) {
- this.$confirm('确定删除吗?', '提示')
- .then(async () => {
- try {
- await deleteAccumulatePoint({ id: row.id })
- this.$message.success('删除成功')
- this.onInit()
- } catch (error) {
- this.$message.error(error)
- }
- })
- .catch(_ => {})
- },
- onSearch () {
- this.pageInfo.current = 1
- this.onInit()
- },
- onPageChange (index) {
- this.pageInfo.current = index
- this.onInit()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- /* 自定义样式 */
- </style>
|