247 行
9.8 KiB
JavaScript
可执行文件
247 行
9.8 KiB
JavaScript
可执行文件
Vue.component('template-manage-brand', {
|
|
template: `<div>
|
|
<div style="display: flex;padding-bottom: 10px;flex-wrap: wrap;">
|
|
<el-input v-model="searchForm.name" clearable style="width:200px;margin-right: 10px" size="small"
|
|
@keydown.enter.exact.native.prevent="searchData"
|
|
placeholder="品牌名称"></el-input>
|
|
<date-picker-range :date-time.sync="searchForm.add_time"></date-picker-range>
|
|
|
|
</el-date-picker>
|
|
<el-button type="primary" @click="searchData" size="small">查询</el-button>
|
|
<el-button v-if="operate.goodsBrandAdd"
|
|
type="primary" plain
|
|
@click="showAddBrand=true"
|
|
size="small">新增
|
|
</el-button>
|
|
</div>
|
|
<div>
|
|
<template>
|
|
<el-table :data="brandList" :highlight-current-row="true" border size="small" max-height="500">
|
|
<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
|
|
<el-table-column prop="name" align="center" label="名称" min-width="150"
|
|
:show-overflow-tooltip="true"></el-table-column>
|
|
<el-table-column prop="addtime" align="center" label="添加时间" :show-overflow-tooltip="true"
|
|
min-width="150"></el-table-column>
|
|
<el-table-column label="操作" width="100" align="center">
|
|
<template slot-scope="scope">
|
|
<el-button type="text" size="mini" @click="editBrand(scope.row)">编辑</el-button>
|
|
<el-button type="text" style="color:#999" size="mini" @click="delBrand(scope.row.id)">删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
<div slot="empty" v-if="!loading">暂无数据</div>
|
|
<div slot="empty" v-else><span class="el-icon-loading"></span></div>
|
|
</el-table>
|
|
<el-pagination
|
|
@size-change="sizeChange"
|
|
@current-change="currentChange"
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
:current-page="page"
|
|
:pager-count="5"
|
|
:page-sizes="[10,20,30,40,50,60,70,80,90]"
|
|
:page-size="10"
|
|
:total="count">
|
|
</el-pagination>
|
|
</template>
|
|
</div>
|
|
<el-dialog :title="addForm.id==0?'新增品牌':'编辑品牌'" :append-to-body="true" :visible.sync="showAddBrand" width="400px">
|
|
<el-form size="small">
|
|
<el-form-item label="品牌名称">
|
|
<el-input v-model="addForm.name" maxLength="20"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<el-button type="primary" size="small" @click="saveBrand">保存</el-button>
|
|
</el-dialog>
|
|
</div>`,
|
|
props: {
|
|
'type': {
|
|
type: Number,
|
|
default: 1,
|
|
},//请求用户类型 1商户 2门店
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
brandList: [], // 数据
|
|
searchForm: {
|
|
add_time: '',
|
|
name: '',
|
|
},//搜索表单
|
|
page: 1, // 分页
|
|
limit: 10, // 每页显示条数
|
|
count: 0, // 总条数
|
|
showAddBrand: false, //是否显示添加
|
|
operate: {}, //权限
|
|
addForm: {
|
|
id: 0,
|
|
name: '',
|
|
},//新增、编辑表单
|
|
};
|
|
},
|
|
|
|
methods: {
|
|
/* 获取数据 */
|
|
getBrandList() {
|
|
this.brandList = [];
|
|
this.loading = true;
|
|
$.ajax({
|
|
url: '/index.php/Retail/GoodsBrand/getGoodsBrandList',
|
|
type: "post",
|
|
data: {
|
|
page: this.page,
|
|
limit: this.limit,
|
|
type: this.type,
|
|
...this.searchForm,
|
|
},
|
|
success: (res) => {
|
|
this.loading = false;
|
|
if (res.status == 1) {
|
|
this.count = res.total;
|
|
this.brandList = res.data;
|
|
}
|
|
},
|
|
error: () => {
|
|
this.loading = false;
|
|
}
|
|
})
|
|
},
|
|
|
|
//查询
|
|
searchData() {
|
|
this.page = 1;
|
|
this.getBrandList();
|
|
},
|
|
/* 切换每页数量 */
|
|
sizeChange(val) {
|
|
this.limit = val;
|
|
this.page = 1;
|
|
this.getBrandList();
|
|
},
|
|
|
|
/* 切换页数 */
|
|
currentChange(val) {
|
|
this.page = val;
|
|
this.getBrandList();
|
|
},
|
|
//编辑
|
|
editBrand(item) {
|
|
this.addForm = {
|
|
id: item.id,
|
|
name: item.name,
|
|
};
|
|
this.showAddBrand = true;
|
|
},
|
|
//保存品牌
|
|
saveBrand() {
|
|
this.$confirm("确认要保存该品牌的设置吗?", "温馨提示", {
|
|
confirmButtonText: '保存',
|
|
cancelButtonText: '取消',
|
|
type: 'info'
|
|
}).then(() => {
|
|
this.$loading({
|
|
lock: true,
|
|
text: '保存中,请等待',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(255, 255, 255, 0.7)'
|
|
});
|
|
$.ajax({
|
|
url: '/index.php/Retail/GoodsBrand/goodsBrandAdd',
|
|
type: "post",
|
|
data: this.addForm,
|
|
success: (res) => {
|
|
this.$loading().close();
|
|
if (res.status == 1) {
|
|
this.showAddBrand = false;
|
|
this.$message({
|
|
message: res.msg,
|
|
type: 'success',
|
|
duration: 1000
|
|
});
|
|
this.getBrandList();
|
|
this.addForm = {
|
|
id: 0,
|
|
name: '',
|
|
};
|
|
} else {
|
|
this.$message({
|
|
message: res.msg,
|
|
type: 'error',
|
|
duration: 1500
|
|
})
|
|
}
|
|
},
|
|
error: () => {
|
|
this.$loading().close();
|
|
}
|
|
})
|
|
}).catch(() => {
|
|
})
|
|
},
|
|
//删除品牌
|
|
delBrand(id) {
|
|
this.$confirm("确认要删除该品牌吗?", "温馨提示", {
|
|
confirmButtonText: '删除',
|
|
cancelButtonText: '取消',
|
|
type: 'info'
|
|
}).then(() => {
|
|
this.$loading({
|
|
lock: true,
|
|
text: '删除中,请等待',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(255, 255, 255, 0.7)'
|
|
});
|
|
$.ajax({
|
|
url: '/index.php/Retail/GoodsBrand/delGoodsBrand',
|
|
type: "post",
|
|
data: {
|
|
id: id
|
|
},
|
|
success: (res) => {
|
|
this.$loading().close();
|
|
if (res.status == 1) {
|
|
this.$message({
|
|
message: res.msg,
|
|
type: 'success',
|
|
duration: 1000
|
|
});
|
|
this.getBrandList();
|
|
} else {
|
|
this.$message({
|
|
message: res.msg,
|
|
type: 'error',
|
|
duration: 1500
|
|
})
|
|
}
|
|
},
|
|
error: () => {
|
|
this.$loading().close();
|
|
}
|
|
})
|
|
}).catch(() => {
|
|
})
|
|
},
|
|
//获取用户权限
|
|
getOperate() {
|
|
var auth_list = {
|
|
goodsBrandAdd: '/index.php/Retail/GoodsBrand/goodsBrandAdd',
|
|
};
|
|
$.ajax({
|
|
url: '/index.php/Retail/Component/checkOperateAuth',
|
|
type: "post",
|
|
data: {
|
|
auth_list: JSON.stringify(auth_list),
|
|
},
|
|
success: (res) => {
|
|
if (res.status == 1) {
|
|
this.operate = res.data;
|
|
}
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
created: function () {
|
|
this.getOperate();
|
|
this.getBrandList();
|
|
},
|
|
}) |