<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>
|