init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,375 @@
|
||||
Vue.component('band-label-link-goods', {
|
||||
template: `<el-dialog title="绑定商品"
|
||||
:visible.sync="show"
|
||||
:append-to-body="true"
|
||||
:top="'65px'"
|
||||
:before-close="closeBand"
|
||||
:width="'calc(100vw - 160px)'"
|
||||
:custom-class="'max-dialog-content'"
|
||||
:close-on-press-escape="false"
|
||||
:close-on-click-modal="false">
|
||||
<div class="choose-store-goods-box">
|
||||
<div class="chooseGoods" style="height: calc(100vh - 282px)">
|
||||
<div class="chooseGoodsTables">
|
||||
<el-form :inline="true" size="small">
|
||||
<el-form-item label="关键词搜索">
|
||||
<el-input :placeholder="'请输入'+(searchForm.search_type==1?'货号':(searchForm.search_type==2?'条码':'名称'))"
|
||||
v-model="searchForm.search_text"
|
||||
oninput="value=this.value.trim(' ')"
|
||||
type="text"
|
||||
clearable
|
||||
style="width: 300px"
|
||||
@keydown.enter.exact.native.prevent="handleCurrentChange(1)"
|
||||
class="input-with-select">
|
||||
<el-select v-model="searchForm.search_type"
|
||||
style="width: 80px"
|
||||
background slot="prepend">
|
||||
<el-option label="货号" :value="1"></el-option>
|
||||
<el-option label="条码" :value="2"></el-option>
|
||||
<el-option label="名称" :value="3"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<select-goods-category :user-type="operateType"
|
||||
:store-id="storeId"
|
||||
:category-id1.sync="searchForm.firstClass"
|
||||
:category-id2.sync="searchForm.secondClass"
|
||||
:category-id3.sync="searchForm.thirdClass"></select-goods-category>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleCurrentChange(1)" plain>搜索</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template>
|
||||
<el-table :data="goodsList"
|
||||
:header-cell-style="{background:'#F5F7FA',color:'#606266'}"
|
||||
border size="mini">
|
||||
<el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_name" show-overflow-tooltip
|
||||
label="商品名称" min-width="120px"></el-table-column>
|
||||
<el-table-column align="center" label="图片" width="60px">
|
||||
<template slot-scope="scope">
|
||||
<el-image class="goods-img" :src="scope.row.goods_image?scope.row.goods_image:''">
|
||||
<div slot="error" class="image-slot">
|
||||
<i class="el-icon-picture-outline"></i>
|
||||
</div>
|
||||
</el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="specifications" min-width="100" label="规格"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_number" min-width="100" label="货号"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_code" min-width="140" label="条码"></el-table-column>
|
||||
<el-table-column align="center" label="操作" width="80px">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text"
|
||||
size="mini"
|
||||
:disabled="chooseGoodsList.length>=100?true:false"
|
||||
@click="chooseGoods(scope.row)"
|
||||
v-if="checkGoods(scope.row.id)">选择
|
||||
</el-button>
|
||||
<el-button v-else type="text" style="color: #666;" size="mini">已选</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="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:current-page="searchForm.page"
|
||||
:page-sizes="[10]"
|
||||
:page-size="searchForm.limit"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="currentLen">
|
||||
</el-pagination>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="chooseGoodsTables">
|
||||
<el-form :inline="true" class="demo-form-inline" size="small">
|
||||
<el-form-item label="已选商品">
|
||||
<el-input v-model="select_keyword"
|
||||
clearable
|
||||
@input="goodsNull"
|
||||
@keydown.enter.exact.native.prevent="searchChooseGoods"
|
||||
placeholder="请输入商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="searchChooseGoods" plain>搜索</el-button>
|
||||
<el-button v-if="chooseGoodsList.length" @click="toClearChoose">清空已选</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="selected-goods">
|
||||
<el-table :data="showChooseGoodsList"
|
||||
border size="mini"
|
||||
:header-cell-style="{background:'#F5F7FA',color:'#606266'}"
|
||||
height="calc(100vh - 286px)">
|
||||
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_name" show-overflow-tooltip
|
||||
label="商品名称" min-width="120px"></el-table-column>
|
||||
<el-table-column align="center" label="图片" width="60px">
|
||||
<template slot-scope="scope">
|
||||
<el-image class="goods-img" :src="scope.row.goods_image?scope.row.goods_image:''">
|
||||
<div slot="error" class="image-slot">
|
||||
<i class="el-icon-picture-outline"></i>
|
||||
</div>
|
||||
</el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="specifications" min-width="100" label="规格"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_number" min-width="100" label="货号"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_code" min-width="140" label="条码"></el-table-column>
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="deleteSelected(scope.$index)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<div slot="empty" v-if="!loading">未选择商品</div>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" round
|
||||
@click="sureChooseGoods"
|
||||
:disabled="chooseGoodsList.length==0||subLoading?true:false"
|
||||
size="small">
|
||||
<span>确定选择({{chooseGoodsList.length}}/100)</span>
|
||||
<i v-if="subLoading" class="el-icon-loading"></i>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>`,
|
||||
props: {
|
||||
'show': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
'operateType': {
|
||||
type: Number,
|
||||
default: 2,
|
||||
},//1商户 2门店
|
||||
'labelId': {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
'storeId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
'requestUrl': {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
}
|
||||
},//请求地址
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchForm: {
|
||||
search_type: 2,
|
||||
search_text: '',
|
||||
firstClass: '',
|
||||
secondClass: '',
|
||||
thirdClass: '',
|
||||
page: 1,
|
||||
limit: 10,
|
||||
},//待选商品列表搜索选项
|
||||
currentLen: 0,//待选商品总数量
|
||||
loading: false,
|
||||
goodsList: [],//待选商品列表
|
||||
chooseGoodsList: [],//已选商品列表
|
||||
showChooseGoodsList: [],//展示的已选商品列表
|
||||
select_keyword: '',
|
||||
chooseGoodsObj: {},//已选商品id对象
|
||||
subLoading: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//关闭弹框
|
||||
closeBand() {
|
||||
this.searchForm = {
|
||||
search_type: 2,
|
||||
search_text: '',
|
||||
firstClass: '',
|
||||
secondClass: '',
|
||||
thirdClass: '',
|
||||
page: 1,
|
||||
limit: 10,
|
||||
};
|
||||
this.chooseGoodsList = [];
|
||||
this.showChooseGoodsList = [];
|
||||
this.chooseGoodsObj = {};
|
||||
this.select_keyword = '';
|
||||
this.$nextTick(() => {
|
||||
this.$emit('close');
|
||||
})
|
||||
},
|
||||
//即将清空已选
|
||||
toClearChoose() {
|
||||
this.$confirm("确认清空已选商品列表?", "关闭提示", {
|
||||
confirmButtonText: '清空',
|
||||
cancelButtonText: '取消',
|
||||
type: 'info'
|
||||
}).then(() => {
|
||||
this.chooseGoodsList = [];
|
||||
this.showChooseGoodsList = [];
|
||||
this.chooseGoodsObj = {};
|
||||
var goodsList = JSON.parse(JSON.stringify(this.goodsList));
|
||||
this.goodsList = [];
|
||||
this.$nextTick(() => {
|
||||
this.goodsList = goodsList;
|
||||
})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
//确认选择商品
|
||||
sureChooseGoods() {
|
||||
this.$confirm("确认把已选商品与该标签绑定?", "温馨提示", {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
}).then(() => {
|
||||
let ids = [];
|
||||
this.chooseGoodsList.forEach((item) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
this.sendRequest(this.requestUrl.bandGoods,{
|
||||
data: {
|
||||
ids: ids.join(','),
|
||||
label_id: this.labelId,
|
||||
operate_type: this.operateType,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.$message.success(res.message);
|
||||
this.closeBand();
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
})
|
||||
|
||||
},
|
||||
//清空已选搜索关键词
|
||||
goodsNull(e) {
|
||||
if (!e) {
|
||||
this.showChooseGoodsList = this.chooseGoodsList
|
||||
}
|
||||
},
|
||||
//判断商品是否可选
|
||||
checkGoods(goods_id) {
|
||||
return !this.chooseGoodsObj[goods_id];
|
||||
},
|
||||
//点击了选择商品
|
||||
chooseGoods(item) {
|
||||
item = JSON.parse(JSON.stringify(item));
|
||||
this.chooseGoodsObj[item.id] = true;
|
||||
this.chooseGoodsList.unshift(item);
|
||||
if (this.select_keyword) {
|
||||
if (this.fuzzySearch(item.goods_name, this.select_keyword)) {
|
||||
this.showChooseGoodsList.unshift(item);
|
||||
}
|
||||
} else {
|
||||
this.showChooseGoodsList.unshift(item);
|
||||
}
|
||||
var goodsList = JSON.parse(JSON.stringify(this.goodsList));
|
||||
this.goodsList = [];
|
||||
this.goodsList = goodsList;
|
||||
},
|
||||
//删除已选商品
|
||||
deleteSelected(index) {
|
||||
let goods_id = this.showChooseGoodsList[index].id;
|
||||
delete this.chooseGoodsObj[goods_id];
|
||||
this.showChooseGoodsList.splice(index, 1);
|
||||
for (var i in this.chooseGoodsList) {
|
||||
if (this.chooseGoodsList[i].id == goods_id) {
|
||||
this.chooseGoodsList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete goods_id;
|
||||
var goodsList = JSON.parse(JSON.stringify(this.goodsList));
|
||||
this.goodsList = [];
|
||||
this.goodsList = goodsList;
|
||||
},
|
||||
//已选列表搜索
|
||||
searchChooseGoods() {
|
||||
this.showChooseGoodsList = [];
|
||||
if (this.select_keyword == '') {
|
||||
this.showChooseGoodsList = this.chooseGoodsList;
|
||||
} else {
|
||||
for (let i = 0; i < this.chooseGoodsList.length; i++) {
|
||||
if (this.fuzzySearch(this.chooseGoodsList[i].goods_name, this.select_keyword)) {
|
||||
this.showChooseGoodsList.push(this.chooseGoodsList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
//模糊搜索商品名称
|
||||
fuzzySearch(name, keyword) {
|
||||
if (keyword === '' || keyword === undefined) {
|
||||
return true;
|
||||
}
|
||||
let len = 0;
|
||||
let arr = String(keyword).split('');
|
||||
for (let i in arr) {
|
||||
if (name.indexOf(arr[i]) != -1) {
|
||||
len++;
|
||||
}
|
||||
}
|
||||
if (len == arr.length) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
//切换每页数量
|
||||
handleSizeChange(val) {
|
||||
this.searchForm.limit = val;
|
||||
this.searchForm.page = 1;
|
||||
this.getData();
|
||||
},
|
||||
//切换页数
|
||||
handleCurrentChange(val) {
|
||||
this.searchForm.page = val;
|
||||
this.getData();
|
||||
},
|
||||
//获取商品列表
|
||||
getData() {
|
||||
this.goodsList = [];
|
||||
this.loading = true;
|
||||
this.sendRequest('Retail/LabelInventory/getGoodsList',{
|
||||
data: {
|
||||
label_id: this.labelId,
|
||||
operate_type: this.operateType,
|
||||
...this.searchForm,
|
||||
},
|
||||
success: (res) => {
|
||||
this.loading = false;
|
||||
if (res.status == 1) {
|
||||
this.goodsList = res.data.list;
|
||||
this.currentLen = res.data.count;
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
show(n, o) {
|
||||
//监听show的变化,重新渲染列表
|
||||
if (n) {
|
||||
this.getData();
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// console.log('created');
|
||||
// this.getData();
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,209 @@
|
||||
Vue.component('label-link-goods-list', {
|
||||
template: `<el-dialog title="查看已绑定商品" :append-to-body="true" :visible.sync="show"
|
||||
width="80%" :top="'50px'"
|
||||
:before-close="closeDialog"
|
||||
custom-class="customer-el-dialog__body"
|
||||
:close-on-click-modal="false">
|
||||
<el-form :inline="true" size="small">
|
||||
<el-form-item label="关键词搜索">
|
||||
<el-input :placeholder="'请输入'+(searchForm.search_type==1?'货号':(searchForm.search_type==2?'条码':'名称'))"
|
||||
v-model="searchForm.search_text"
|
||||
oninput="value=this.value.trim(' ')"
|
||||
type="text"
|
||||
clearable
|
||||
style="width: 300px"
|
||||
@keydown.enter.exact.native.prevent="pageChange(1)"
|
||||
class="input-with-select">
|
||||
<el-select v-model="searchForm.search_type"
|
||||
style="width: 80px"
|
||||
background slot="prepend">
|
||||
<el-option label="货号" :value="1"></el-option>
|
||||
<el-option label="条码" :value="2"></el-option>
|
||||
<el-option label="名称" :value="3"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<select-goods-category :user-type="operateType"
|
||||
:store-id="storeId"
|
||||
:category-id1.sync="searchForm.firstClass"
|
||||
:category-id2.sync="searchForm.secondClass"
|
||||
:category-id3.sync="searchForm.thirdClass"></select-goods-category>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="pageChange(1)" plain>搜索</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template>
|
||||
<el-table :data="goodsList"
|
||||
:header-cell-style="{background:'#F5F7FA',color:'#606266'}"
|
||||
border size="mini">
|
||||
<el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_name" show-overflow-tooltip
|
||||
label="商品名称" min-width="120px"></el-table-column>
|
||||
<el-table-column align="center" label="图片" width="60px">
|
||||
<template slot-scope="scope">
|
||||
<el-image class="goods-img" :src="scope.row.goods_image?scope.row.goods_image:''">
|
||||
<div slot="error" class="image-slot">
|
||||
<i class="el-icon-picture-outline"></i>
|
||||
</div>
|
||||
</el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="specifications" min-width="100" label="规格"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_number" min-width="100" label="货号"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_code" min-width="140" label="条码"></el-table-column>
|
||||
<el-table-column align="center" label="操作" width="80px">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini"
|
||||
v-if="operate.delLinkGoods"
|
||||
@click="delLinkGoods(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="limitChange"
|
||||
@current-change="pageChange"
|
||||
:current-page="searchForm.page"
|
||||
:page-size="searchForm.limit"
|
||||
:total="currentLen"
|
||||
:pager-count="5"
|
||||
:page-sizes="[10,20,30,40,50,60,70,80,90,100]"
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
</template>
|
||||
</el-dialog>`,
|
||||
props: {
|
||||
'show': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
'labelId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//标签ID
|
||||
'storeId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//门店ID
|
||||
'operateType': {
|
||||
type: Number,
|
||||
default: '',
|
||||
},//操作类型 1商户 2门店
|
||||
'operate': {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},//操作权限
|
||||
'requestUrl': {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
}
|
||||
},//请求地址
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchForm: {
|
||||
search_type: 2,
|
||||
search_text: '',
|
||||
firstClass: '',
|
||||
secondClass: '',
|
||||
thirdClass: '',
|
||||
page: 1,
|
||||
limit: 10,
|
||||
},
|
||||
currentLen: 0,
|
||||
goodsList: [],
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeDialog() {
|
||||
this.searchForm = {
|
||||
search_type: 2,
|
||||
search_text: '',
|
||||
firstClass: '',
|
||||
secondClass: '',
|
||||
thirdClass: '',
|
||||
page: 1,
|
||||
limit: 10,
|
||||
};
|
||||
this.$emit('close');
|
||||
},
|
||||
// 取消绑定商品
|
||||
delLinkGoods(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.delLinkGoods,{
|
||||
data: {
|
||||
ids: id,
|
||||
operate_type: this.operateType,
|
||||
},
|
||||
success: (res) => {
|
||||
this.$loading().close();
|
||||
if (res.status == 1) {
|
||||
this.$message.success(res.message);
|
||||
this.getGoodsList();
|
||||
} else {
|
||||
this.$message.error(res.message)
|
||||
}
|
||||
},
|
||||
})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
// 切换记录每页数量
|
||||
limitChange(val) {
|
||||
this.searchForm.limit = val;
|
||||
this.searchForm.page = 1;
|
||||
this.getGoodsList();
|
||||
},
|
||||
// 切换记录页数
|
||||
pageChange(val) {
|
||||
this.searchForm.page = val;
|
||||
this.getGoodsList();
|
||||
},
|
||||
// 获取绑定的商品列表
|
||||
getGoodsList() {
|
||||
this.loading = true;
|
||||
this.sendRequest('Retail/LabelInventory/getLabelBelongGoods',{
|
||||
data: {
|
||||
label_id: this.labelId,
|
||||
operate_type: this.operateType,
|
||||
...this.searchForm,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.goodsList = res.data.list;
|
||||
this.currentLen = res.data.count * 1;
|
||||
} else {
|
||||
this.goodsList = [];
|
||||
this.currentLen = 0;
|
||||
}
|
||||
this.loading = false;
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
show(n, o) {
|
||||
if (n) {
|
||||
this.pageChange(1);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,286 @@
|
||||
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;
|
||||
})
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* 选择商品标签
|
||||
*/
|
||||
Vue.component('select-goods-label', {
|
||||
template: `<el-select v-model="label_id_arr"
|
||||
:placeholder="placeholder"
|
||||
:disabled="isDisabled"
|
||||
size="small"
|
||||
:class="customerClass"
|
||||
:multiple-limit="10"
|
||||
value-key="id" @change="changeLabel"
|
||||
multiple clearable filterable>
|
||||
<el-option-group v-for="group in dataList"
|
||||
:key="group.id"
|
||||
:label="group.name">
|
||||
<el-option v-for="item in group.list"
|
||||
:key="item.id"
|
||||
:disabled="item.industry_id>0&&(limitIndustryId>0&&limitIndustryId!=item.industry_id||selIndustryId>0&&selIndustryId!=item.industry_id)"
|
||||
:label="item.name"
|
||||
:value="item">
|
||||
</el-option>
|
||||
</el-option-group>
|
||||
</el-select>`,
|
||||
props: {
|
||||
'goodsId': {
|
||||
type: Number,
|
||||
default: '',
|
||||
},//选择商品ID
|
||||
'customerClass': {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '选择商品标签',
|
||||
},
|
||||
'industryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
'type': {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},//提交的来源类型 1商户 2门店
|
||||
'selIndustryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//已选中标签的行业ID
|
||||
'limitIndustryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//限制的行业ID
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
label_id_arr: [],//已选中的标签列表
|
||||
dataList: [],// 数据
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeLabel(val) {
|
||||
if (val && val.length) {
|
||||
let flag = false;
|
||||
for (let i = 0; i < val.length; i++) {
|
||||
if (val[i].industry_id > 0) {
|
||||
this.$emit('update:selIndustryId', val[i].industry_id);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){
|
||||
this.$emit('update:selIndustryId', '');
|
||||
}
|
||||
} else {
|
||||
this.$emit('update:selIndustryId', '');
|
||||
}
|
||||
},
|
||||
//获取标签列表
|
||||
getLabelList() {
|
||||
this.sendRequest('Retail/LabelInventory/getLabelList', {
|
||||
data: {
|
||||
industry_id: this.industryId
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.dataList = res.data.list;
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
//获取商品的标签
|
||||
getGoodsLabel() {
|
||||
this.sendRequest('Retail/LabelInventory/getGoodsLabel', {
|
||||
data: {
|
||||
goods_id: this.goodsId,
|
||||
user_type: this.type,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.label_id_arr = res.data.list;
|
||||
this.changeLabel(this.label_id_arr);
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
//提交标签设置
|
||||
submitLabel(goods_id, callback) {
|
||||
if (goods_id) {
|
||||
let label_ids = [];
|
||||
this.label_id_arr.forEach((item)=>{
|
||||
label_ids.push(item.id);
|
||||
});
|
||||
this.sendRequest('Retail/LabelInventory/addGoodsLabelLink', {
|
||||
data: {
|
||||
label_ids: JSON.stringify(label_ids),
|
||||
goods_id: goods_id,
|
||||
user_type: this.type
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status != 1) {
|
||||
this.$message.error(res.message);
|
||||
} else {
|
||||
typeof callback == "function" && callback();
|
||||
}
|
||||
},
|
||||
})
|
||||
} else {
|
||||
typeof callback == "function" && callback();
|
||||
}
|
||||
},
|
||||
//清除标签选择
|
||||
clearLabel() {
|
||||
this.label_id_arr = [];
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.goodsId > 0) {
|
||||
this.getGoodsLabel();
|
||||
}
|
||||
this.getLabelList();
|
||||
},
|
||||
watch: {
|
||||
goodsId(n) {
|
||||
if (n > 0) {
|
||||
this.getGoodsLabel();
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户