文件
mashangyoujiu/Public/Retail/js/goods-label/label-link-goods-list.js

209 行
9.3 KiB
JavaScript
可执行文件

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);
}
},
},
});