You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
190 lines
5.0 KiB
190 lines
5.0 KiB
<template>
|
|
<div class="classification-page">
|
|
<div class="toolbar">
|
|
<el-button type="success" @click="addBar">添加一级类别</el-button>
|
|
</div>
|
|
<el-table
|
|
:data="tableData"
|
|
style="width: 100%"
|
|
border
|
|
row-key="id"
|
|
:header-cell-style="{ background: '#EEF3FF', color: '#333333' }"
|
|
:tree-props="{ children: 'childs' }"
|
|
>
|
|
<el-table-column prop="classifyName_ZH" label="商品类别(中文)" />
|
|
<el-table-column prop="classifyName_EN" label="商品类别(英文)" />
|
|
<el-table-column prop="status" label="操作">
|
|
<template slot-scope="scope">
|
|
<el-button type="text" @click.native.prevent="checkRow(scope.row)">查看</el-button>
|
|
<el-button type="text" @click.native.prevent="updateRow(scope.row)">编辑</el-button>
|
|
<el-button type="text" @click.native.prevent="deleteRow(scope.row)">删除</el-button>
|
|
<el-button type="text" @click.native.prevent="setShareSetting(scope.row)">设置分配比例</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<div class="fenye">
|
|
<el-pagination
|
|
:current-page="currentPage"
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
:page-size="10"
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
:total="total"
|
|
@size-change="handleSizeChange"
|
|
@current-change="handleCurrentChange"
|
|
/>
|
|
</div>
|
|
<edit-dialog
|
|
ref="edit"
|
|
:dialog-visible="dialog.isVisible"
|
|
:type="dialog.type"
|
|
@close="editClose"
|
|
@success="getProductCategory"
|
|
/>
|
|
<SharesettingDialog
|
|
ref="shareSettingDialog"/>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import {
|
|
commdityClassGetAll,
|
|
commdityClassDelete
|
|
} from '@/api/renovation'
|
|
import EditDialog from './Edit'
|
|
import SharesettingDialog from '../../../components/Sharesetting';
|
|
export default {
|
|
components: {
|
|
EditDialog,SharesettingDialog
|
|
},
|
|
data() {
|
|
return {
|
|
dialogVisible: false,
|
|
formParams: {
|
|
page: 1,
|
|
pageSize: 10
|
|
},
|
|
total: 1,
|
|
tableData: [],
|
|
currentPage: 1,
|
|
dialog: {
|
|
type: 'add',
|
|
isVisible: false
|
|
}
|
|
}
|
|
},
|
|
created() {
|
|
this.getProductCategory()
|
|
this.getAll(this.formParams)
|
|
},
|
|
methods: {
|
|
setShareSetting(row) {
|
|
this.$refs.shareSettingDialog.showSetting(1, row.classifyId)
|
|
},
|
|
handleSizeChange(val) {
|
|
this.formParams.pageSize = val
|
|
this.getAll(this.formParams)
|
|
},
|
|
handleCurrentChange(val) {
|
|
this.formParams.page = val
|
|
this.getAll(this.formParams)
|
|
},
|
|
fetch(config) {
|
|
const { limit, page } = config
|
|
this.formParams.pageIndex = page || 1
|
|
this.formParams.pageSize = limit || 10
|
|
this.getProductCategory()
|
|
},
|
|
addBar() {
|
|
this.dialog = {
|
|
type: 'add',
|
|
isVisible: true
|
|
}
|
|
this.$refs.edit.setParams({ treeData: [] })
|
|
},
|
|
editClose() {
|
|
this.dialog.isVisible = false
|
|
},
|
|
// 编辑
|
|
updateRow(row) {
|
|
const id = row.classifyId
|
|
this.dialog = {
|
|
type: 'edit',
|
|
isVisible: true
|
|
}
|
|
this.$refs.edit.setParams({
|
|
id: id
|
|
})
|
|
},
|
|
// 查看
|
|
checkRow(row) {
|
|
const id = row.classifyId
|
|
this.dialog = {
|
|
type: 'check',
|
|
isVisible: true
|
|
}
|
|
this.$refs.edit.setParams({
|
|
id
|
|
})
|
|
},
|
|
// 删除
|
|
async deleteRow(row) {
|
|
this.$confirm('此操作将永久删除该类别, 是否继续?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
})
|
|
.then(() => {
|
|
commdityClassDelete({ oneClassifyId: row.classifyId }).then(res => {
|
|
if (res.code === '') {
|
|
this.$message({
|
|
type: 'success',
|
|
message: '删除成功!'
|
|
})
|
|
}
|
|
this.getAll(this.formParams)
|
|
})
|
|
})
|
|
.catch(() => {
|
|
this.$message({
|
|
type: 'info',
|
|
message: '已取消删除'
|
|
})
|
|
})
|
|
},
|
|
|
|
async getProductCategory() {
|
|
this.getAll(this.formParams)
|
|
},
|
|
async getAll(formParams) {
|
|
const res = await commdityClassGetAll(formParams)
|
|
let tempData = res.data.list;
|
|
tempData.forEach((itemData) => {
|
|
if(itemData && itemData.langInfoMap && itemData.langInfoMap['zh']){
|
|
itemData.classifyName_ZH = itemData.langInfoMap['zh'].classifyName;
|
|
}else{
|
|
itemData.classifyName_ZH = "";
|
|
}
|
|
if(itemData && itemData.langInfoMap && itemData.langInfoMap['en']){
|
|
itemData.classifyName_EN = itemData.langInfoMap['en'].classifyName;
|
|
}else{
|
|
itemData.classifyName_EN = "";
|
|
}
|
|
});
|
|
this.tableData = tempData;
|
|
this.total = res.data.total;
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
@import url("../../../styles/elDialog.scss");
|
|
|
|
.classification-page {
|
|
padding: 15px 20px;
|
|
background: #FFFFFF;
|
|
border-radius: 10px;
|
|
.toolbar {
|
|
margin-bottom: 15px;
|
|
text-align: right;
|
|
}
|
|
}
|
|
</style>
|