MrShi
2 天以前 108019e27e8958dbf474b8b9bea3fb5fbf7198d9
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
<template>
  <TableLayout :permissions="['business:category:query']">
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="名称" prop="name">
        <el-input v-model="searchForm.name" clearable placeholder="请输入名称" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <template v-slot:table-wrap>
      <ul class="toolbar">
        <li><el-button type="primary" @click="$refs.operaGoodsCategoryEditWindow.open('新建物品分类', null, 2)" icon="el-icon-plus">新建</el-button></li>
      </ul>
      <el-table
        :height="tableHeightNew"
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
      >
        <el-table-column prop="id" label="ID" min-width="80px"></el-table-column>
        <el-table-column prop="name" label="物品名称" min-width="120px"></el-table-column>
        <el-table-column prop="detail" label="寄存说明" min-width="200px"></el-table-column>
        <el-table-column prop="sortnum" label="分类排序" min-width="100px"></el-table-column>
        <el-table-column label="状态" min-width="80px">
          <template slot-scope="{row}">
            <el-switch
              @change="handleStatusChange($event, row)"
              v-model="row.status"
              active-color="#13ce66"
              inactive-color="#ff4949"
              :active-value="0"
              :inactive-value="1"
            ></el-switch>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="150" fixed="right">
          <template slot-scope="{row}">
            <el-button type="text" @click="handleEdit(row)">编辑</el-button>
            <el-button type="text" @click="deleteById(row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      ></pagination>
    </template>
    <OperaGoodsCategoryEditWindow ref="operaGoodsCategoryEditWindow" @success="search" />
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaGoodsCategoryEditWindow from '@/components/business/OperaGoodsCategoryEditWindow'
import { fetchList, updateStatus, deleteById } from '@/api/business/goodsCategory'
 
export default {
  name: 'GoodsCategoryList',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaGoodsCategoryEditWindow },
  data () {
    return {
      searchForm: {
        name: '',
        status: '',
        type: 2
      }
    }
  },
  created () {
    this.config({
      api: '/business/goodsCategory',
      'field.id': 'id'
    })
    this.search()
  },
  methods: {
    handleEdit (row) {
      this.$refs.operaGoodsCategoryEditWindow.open('编辑物品分类', row, 2)
    },
    handleStatusChange (val, row) {
      updateStatus({ id: row.id, status: val }).then(res => {
        this.$tip.apiSuccess(res || '修改成功')
      }).catch(e => {
        row.status = val === 1 ? 0 : 1
        this.$tip.apiFailed(e)
      })
    }
  }
}
</script>