286 行
14 KiB
JavaScript
可执行文件
286 行
14 KiB
JavaScript
可执行文件
Vue.component('manage-goods-label', {
|
|
template: `<div>
|
|
<div class="page-tips">
|
|
<p>商品标签用于商城商品搜索</p>
|
|
</div>
|
|
<el-form style="display: flex;padding-bottom: 10px;flex-wrap: wrap;">
|
|
<el-input v-model="searchForm.name" clearable
|
|
@keydown.enter.exact.native.prevent="currentChange(1)"
|
|
style="width:200px;margin-right: 10px" size="small"
|
|
placeholder="标签名称"></el-input>
|
|
<select-industry v-if="operateType==1||storeIndustryId==0" @change="currentChange(1)"
|
|
:industry-id.sync="searchForm.industry_id"
|
|
:show-common="true"></select-industry>
|
|
<el-button type="primary" style="margin-left: 10px" @click="currentChange(1)" size="small">查询</el-button>
|
|
|
|
<el-button v-if="(operateType==1||storeAuth.edit_goods_label==1) && operate.addLabel"
|
|
type="primary" plain
|
|
@click="showAddLabel=true"
|
|
size="small">新增
|
|
</el-button>
|
|
|
|
</el-form>
|
|
<div>
|
|
<el-table :data="dataList" :header-cell-style="{background:'#F5F7FA',color:'#606266'}"
|
|
: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></el-table-column>
|
|
<el-table-column prop="industry_name" align="center" label="行业" show-overflow-tooltip
|
|
min-width="80"></el-table-column>
|
|
<el-table-column prop="goods_num" align="center" label="商品数量" show-overflow-tooltip
|
|
min-width="80"></el-table-column>
|
|
<el-table-column prop="add_time" align="center" label="添加时间" show-overflow-tooltip
|
|
min-width="150"></el-table-column>
|
|
<el-table-column label="操作" width="180" align="center">
|
|
<template slot-scope="scope">
|
|
<el-button type="text" size="mini"
|
|
v-if="operate.bandGoods"
|
|
@click="addGoodsLink(scope.row.id)">绑定商品
|
|
</el-button>
|
|
<el-button type="text" size="mini"
|
|
@click="goodsLinkDetail(scope.row.id)">商品详情
|
|
</el-button>
|
|
<el-button type="text" size="mini"
|
|
style="color:#999"
|
|
v-if="operate.delLabel&&(operateType==1||operateType==2&&scope.row.store_id==storeId&&storeAuth.edit_goods_label==1)"
|
|
@click="delLabel(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"
|
|
:pager-count="5"
|
|
:page-sizes="[10,20,30,40,50,60,70,80,90]"
|
|
:page-size="10"
|
|
:total="count">
|
|
</el-pagination>
|
|
</div>
|
|
<el-dialog :title="ruleForm.id?'编辑标签':'新增标签'" :append-to-body="true"
|
|
:visible.sync="showAddLabel" :before-close="closeEditLabel"
|
|
width="400px">
|
|
<el-form size="small" label-width="80px" :model="ruleForm" :rules="rules" ref="ruleForm" @submit.native.prevent>
|
|
<el-form-item label="所属行业" v-if="operateType==1||storeIndustryId==0" prop="industry_id">
|
|
<select-industry :industry-id.sync="ruleForm.industry_id"></select-industry>
|
|
</el-form-item>
|
|
<el-form-item label="标签名称" prop="name">
|
|
<el-input v-model="ruleForm.name" placeholder="请输入标签名称" maxLength="20"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div style="text-align: center;margin-top: 50px">
|
|
<el-button type="primary" size="medium" @click="saveLabel">保存</el-button>
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
<!--绑定商品-->
|
|
<band-label-link-goods :show="showBindGoodsDialog"
|
|
:label-id="bandGoodsLabelId"
|
|
:operate-type="operateType"
|
|
:store-id="storeId"
|
|
:request-url="requestUrl"
|
|
@close="closeBindGoods"></band-label-link-goods>
|
|
|
|
<label-link-goods-list :show="showBindGoodsDetailsDialog"
|
|
:label-id="bandGoodsLabelId"
|
|
:store-id="storeId"
|
|
:operate-type="operateType"
|
|
:operate="operate"
|
|
:request-url="requestUrl"
|
|
@close="closeSeeGoods"></label-link-goods-list>
|
|
</div>`,
|
|
props: {
|
|
'operateType': {
|
|
type: Number,
|
|
required: true,
|
|
},//1商户 2门店
|
|
'storeId': {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
bandGoodsLabelId: '',//绑定商品的标签ID
|
|
showBindGoodsDialog: false,//是否显示绑定商品弹框
|
|
showBindGoodsDetailsDialog: false,//是否显示已绑定商品弹框
|
|
dataList: [], // 标签数据列表
|
|
storeIndustryId: localStorage.industry_id,//门店的行业ID
|
|
searchForm: {
|
|
name: '',
|
|
industry_id: this.operateType == 2 ? (localStorage.industry_id > 0 ? localStorage.industry_id : '') : '',
|
|
page: 1, // 分页
|
|
limit: 10, // 每页显示条数
|
|
},//搜索表单
|
|
count: 0, // 总条数
|
|
showAddLabel: false, //是否显示添加
|
|
operate: {}, //权限
|
|
ruleForm: {
|
|
id: 0,
|
|
name: '',
|
|
industry_id: this.operateType == 2 ? (localStorage.industry_id > 0 ? localStorage.industry_id : '') : '',
|
|
},//新增、编辑表单
|
|
rules: {
|
|
industry_id: [{message: '请选择所属行业', required: false, trigger: 'change'}],
|
|
name: [{message: '请输入标签名称', required: true, trigger: 'change'}],
|
|
},
|
|
requestUrl: {
|
|
addLabel: '/index.php/Retail/LabelInventory/' + (this.operateType == 1 ? 'addMerchantLabelData' : 'addStoreLabelData'),
|
|
delLabel: '/index.php/Retail/LabelInventory/' + (this.operateType == 1 ? 'delMerchantLabelData' : 'delStoreLabelData'),
|
|
bandGoods: '/index.php/Retail/LabelInventory/' + (this.operateType == 1 ? 'addMerchantLinkGoods' : 'addStoreLinkGoods'),
|
|
delLinkGoods: '/index.php/Retail/LabelInventory/' + (this.operateType == 1 ? 'delMerchantLinkGoods' : 'delStoreLinkGoods'),
|
|
},
|
|
};
|
|
},
|
|
methods: {
|
|
//展示绑定商品
|
|
addGoodsLink(id) {
|
|
this.bandGoodsLabelId = id;
|
|
this.showBindGoodsDialog = true;
|
|
},
|
|
//关闭绑定商品弹框
|
|
closeBindGoods() {
|
|
this.bandGoodsLabelId = '';
|
|
this.showBindGoodsDialog = false;
|
|
this.getLabelList();
|
|
},
|
|
//查看已绑定的商品详情
|
|
goodsLinkDetail(id) {
|
|
this.bandGoodsLabelId = id;
|
|
this.showBindGoodsDetailsDialog = true;
|
|
},
|
|
//关闭绑定商品弹框
|
|
closeSeeGoods() {
|
|
this.bandGoodsLabelId = '';
|
|
this.showBindGoodsDetailsDialog = false;
|
|
this.getLabelList();
|
|
},
|
|
//编辑标签
|
|
editLabel(item) {
|
|
console.log(item);
|
|
this.ruleForm = {...item};
|
|
this.showAddLabel = true;
|
|
},
|
|
closeEditLabel() {
|
|
this.$refs.ruleForm.resetFields();
|
|
this.ruleForm.id = '';
|
|
this.showAddLabel = false;
|
|
},
|
|
/* 获取数据 */
|
|
getLabelList() {
|
|
this.dataList = [];
|
|
this.loading = true;
|
|
this.sendRequest('Retail/LabelInventory/getLabelInventoryList', {
|
|
data: {
|
|
...this.searchForm,
|
|
store_industry_id: this.storeIndustryId,
|
|
operate_type: this.operateType,
|
|
},
|
|
success: (res) => {
|
|
this.loading = false;
|
|
if (res.status == 1) {
|
|
this.count = res.data.count;
|
|
this.dataList = res.data.list;
|
|
}
|
|
},
|
|
error: () => {
|
|
this.loading = false;
|
|
}
|
|
})
|
|
},
|
|
/* 切换每页数量 */
|
|
sizeChange(val) {
|
|
this.searchForm.limit = val;
|
|
this.searchForm.page = 1;
|
|
this.getLabelList();
|
|
},
|
|
|
|
/* 切换页数 */
|
|
currentChange(val) {
|
|
this.searchForm.page = val;
|
|
this.getLabelList();
|
|
},
|
|
//保存标签
|
|
saveLabel() {
|
|
this.$refs.ruleForm.validate((valid) => {
|
|
if (!valid) {
|
|
return false;
|
|
}
|
|
this.$confirm("确认要保存该标签吗?", "温馨提示", {
|
|
confirmButtonText: '保存',
|
|
cancelButtonText: '取消',
|
|
type: 'info'
|
|
}).then(() => {
|
|
this.$loading({
|
|
lock: true,
|
|
text: '保存中,请等待',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(255, 255, 255, 0.7)'
|
|
});
|
|
this.sendRequest(this.requestUrl.addLabel, {
|
|
data: {
|
|
...this.ruleForm,
|
|
operate_type: this.operateType,
|
|
},
|
|
success: (res) => {
|
|
this.$loading().close();
|
|
if (res.status == 1) {
|
|
this.closeEditLabel();
|
|
this.$message.success(res.message);
|
|
|
|
this.getLabelList();
|
|
} else {
|
|
this.$message.error(res.message)
|
|
}
|
|
},
|
|
})
|
|
}).catch(() => {
|
|
})
|
|
});
|
|
},
|
|
//删除标签
|
|
delLabel(id) {
|
|
this.$confirm("确认要删除该标签吗?", "温馨提示", {
|
|
confirmButtonText: '删除',
|
|
cancelButtonText: '取消',
|
|
type: 'info'
|
|
}).then(() => {
|
|
this.$loading({
|
|
lock: true,
|
|
text: '删除中,请等待',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(255, 255, 255, 0.7)'
|
|
});
|
|
this.sendRequest(this.requestUrl.delLabel, {
|
|
data: {
|
|
id: id,
|
|
operate_type: this.operateType,
|
|
},
|
|
success: (res) => {
|
|
this.$loading().close();
|
|
if (res.status == 1) {
|
|
this.$message.success(res.message);
|
|
this.getLabelList();
|
|
} else {
|
|
this.$message.error(res.message)
|
|
}
|
|
},
|
|
})
|
|
}).catch(() => {
|
|
})
|
|
},
|
|
},
|
|
created() {
|
|
this.getLabelList();
|
|
this.checkOperateAuth(this.requestUrl, (data) => {
|
|
this.operate = data;
|
|
})
|
|
},
|
|
}); |