init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
247
Public/Retail/common/js/manage-brand.js
可执行文件
247
Public/Retail/common/js/manage-brand.js
可执行文件
@@ -0,0 +1,247 @@
|
||||
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();
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,451 @@
|
||||
/**
|
||||
* 选择商品分类(不选到底)
|
||||
*/
|
||||
Vue.component('select-goods-category', {
|
||||
template: `<div style="display: inline-block;vertical-align: top" >
|
||||
<el-select :size="size" clearable :disabled="isDisabled" filterable
|
||||
@change="changeGoodsClass1($event)"
|
||||
value-key="id"
|
||||
v-model="id1" :placeholder="placeholder1">
|
||||
<el-option-group v-for="group in goodsClass1"
|
||||
: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"
|
||||
:label="item.class_name"
|
||||
:value="item">
|
||||
</el-option>
|
||||
</el-option-group>
|
||||
</el-select>
|
||||
<el-select :size="size" clearable :disabled="isDisabled" filterable v-if="goodsClass2.length"
|
||||
@change="changeGoodsClass2($event)"
|
||||
v-model="id2" :placeholder="placeholder2">
|
||||
<el-option
|
||||
v-for="item in goodsClass2"
|
||||
:key="item.id"
|
||||
:label="item.class_name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-select :size="size" clearable :disabled="isDisabled" filterable v-if="goodsClass3.length"
|
||||
@change="changeGoodsClass3($event)"
|
||||
v-model="id3" :placeholder="placeholder3">
|
||||
<el-option
|
||||
v-for="item in goodsClass3"
|
||||
:key="item.id"
|
||||
:label="item.class_name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>`,
|
||||
props: {
|
||||
'categoryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//已选中的最后一级分类ID
|
||||
'categoryId1': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//已选中的一级分类
|
||||
'categoryId2': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//已选中的二级分类
|
||||
'categoryId3': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//已选中的三级分类
|
||||
'userType': {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},//获取分类的用户类型 1商户 2门店
|
||||
'storeId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//门店ID在userType等于2时,并且是商户选择门店商品时可能会传
|
||||
'getChild': {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},//是否需要选择二三级分类
|
||||
'placeholder1': {
|
||||
type: String,
|
||||
default: '选择一级分类',
|
||||
},
|
||||
'placeholder2': {
|
||||
type: String,
|
||||
default: '选择二级分类',
|
||||
},
|
||||
'placeholder3': {
|
||||
type: String,
|
||||
default: '选择三级分类',
|
||||
},
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
'size': {
|
||||
type: String,
|
||||
default: 'small'
|
||||
},
|
||||
'unitData': {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
}
|
||||
},//初始选中的分类ID列表
|
||||
'selIndustryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//已选中分类的行业ID
|
||||
'limitIndustryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//限制的行业ID
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
goodsClass1: [],
|
||||
goodsClass2: [],
|
||||
goodsClass3: [],
|
||||
id1: '',
|
||||
id2: '',
|
||||
id3: '',
|
||||
category_id: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getGoodsClass(pid, type, fn) {
|
||||
if (type == 1 && this.goodsClass1.length) {
|
||||
this.setClassData(type, this.goodsClass1);
|
||||
typeof fn == "function" && this.$nextTick(() => {
|
||||
fn();
|
||||
});
|
||||
} else {
|
||||
this.sendRequest('Retail/MerCate/getChooseClassList', {
|
||||
data: {
|
||||
pid: pid,
|
||||
type: type,
|
||||
user_type: this.userType,
|
||||
store_id: this.storeId,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.setClassData(type, res.data);
|
||||
typeof fn == "function" && this.$nextTick(() => {
|
||||
fn();
|
||||
})
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
setClassData(type, data) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
this.goodsClass1 = [];
|
||||
this.goodsClass1 = data;
|
||||
this.id1 = '';
|
||||
this.goodsClass2 = [];
|
||||
this.id2 = '';
|
||||
this.goodsClass3 = [];
|
||||
this.id3 = '';
|
||||
this.category_id = '';
|
||||
break;
|
||||
case 2:
|
||||
this.goodsClass2 = [];
|
||||
this.goodsClass2 = data;
|
||||
this.id2 = '';
|
||||
this.goodsClass3 = [];
|
||||
this.id3 = '';
|
||||
this.category_id = '';
|
||||
break;
|
||||
case 3:
|
||||
this.goodsClass3 = [];
|
||||
this.goodsClass3 = data;
|
||||
this.id3 = '';
|
||||
this.category_id = '';
|
||||
break;
|
||||
}
|
||||
},
|
||||
changeGoodsClass1(val, fn) {
|
||||
if (!val) {
|
||||
this.goodsClass2 = [];
|
||||
this.id2 = '';
|
||||
this.goodsClass3 = [];
|
||||
this.id3 = '';
|
||||
this.category_id = '';
|
||||
if (typeof fn != "function") {
|
||||
this.$nextTick(() => {
|
||||
this.callback();
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (this.getChild) {
|
||||
this.getGoodsClass(val.id, 2, () => {
|
||||
if (!this.goodsClass2.length) {
|
||||
this.category_id = this.id1.id;
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (typeof fn == "function") {
|
||||
fn();
|
||||
} else {
|
||||
this.callback();
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
this.category_id = this.id1.id;
|
||||
this.$nextTick(() => {
|
||||
if (typeof fn == "function") {
|
||||
fn();
|
||||
} else {
|
||||
this.callback();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
changeGoodsClass2(val, fn) {
|
||||
if (!val) {
|
||||
this.goodsClass3 = [];
|
||||
this.id3 = '';
|
||||
this.category_id = '';
|
||||
if (typeof fn != "function") {
|
||||
this.$nextTick(() => {
|
||||
this.callback();
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.getGoodsClass(val, 3, () => {
|
||||
if (!this.goodsClass3.length) {
|
||||
this.category_id = this.id2;
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (typeof fn == "function") {
|
||||
fn();
|
||||
} else {
|
||||
this.callback();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
changeGoodsClass3(val, fn) {
|
||||
if (!val) {
|
||||
this.id3 = '';
|
||||
this.category_id = '';
|
||||
} else {
|
||||
this.category_id = this.id3;
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (typeof fn == "function") {
|
||||
fn();
|
||||
} else {
|
||||
this.callback();
|
||||
}
|
||||
})
|
||||
},
|
||||
callback() {
|
||||
this.$emit('update:categoryId1', this.id1 ? this.id1.id : '');
|
||||
this.$emit('update:categoryId2', this.id2);
|
||||
this.$emit('update:categoryId3', this.id3);
|
||||
this.$emit('update:categoryId', this.category_id);
|
||||
this.$emit('update:selIndustryId', this.id1 ? this.id1.industry_id : '');
|
||||
this.$emit('change', {
|
||||
category_id: this.category_id,
|
||||
industry_id: this.id1 ? this.id1.industry_id : '',
|
||||
category: [this.id1 ? this.id1.id : '', this.id2, this.id3],
|
||||
});
|
||||
},
|
||||
unitClass(data) {
|
||||
//已选中一级分类
|
||||
this.getGoodsClass(0, 1, () => {
|
||||
if (data[0]) {
|
||||
for (let i = 0; i < this.goodsClass1.length; i++) {
|
||||
for (let j = 0; j < this.goodsClass1[i].list.length; j++) {
|
||||
if (data[0] == this.goodsClass1[i].list[j].id) {
|
||||
this.id1 = {...this.goodsClass1[i].list[j]};//一级分类赋值
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.category_id = this.id1.id;
|
||||
if (data[1] && this.getChild) {
|
||||
//已选中二级分类
|
||||
//获取二级分类列表
|
||||
this.changeGoodsClass1(this.id1, () => {
|
||||
this.id2 = data[1];//二级分类赋值
|
||||
this.category_id = this.id2;
|
||||
if (data[2]) {
|
||||
//已选中三级分类
|
||||
//获取三级分类列表
|
||||
this.changeGoodsClass2(this.id2, () => {
|
||||
this.id3 = data[2];//三级分类赋值
|
||||
this.category_id = this.id3;
|
||||
this.callback();
|
||||
});
|
||||
} else {
|
||||
this.callback();
|
||||
this.setClassData(3, []);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.callback();
|
||||
this.setClassData(2, []);
|
||||
}
|
||||
} else {
|
||||
this.callback();
|
||||
this.setClassData(1, this.goodsClass1);
|
||||
}
|
||||
})
|
||||
},
|
||||
clearCategory() {
|
||||
this.unitClass(['', '', '']);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
created() {
|
||||
this.unitClass(this.unitData);
|
||||
},
|
||||
watch: {
|
||||
unitData: {
|
||||
deep: true,
|
||||
handler(n, o) {
|
||||
this.unitClass(n);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 选择商品分类(选到底)
|
||||
*/
|
||||
Vue.component('select-goods-category-deep', {
|
||||
template: `<el-cascader :size="size"
|
||||
v-model="category"
|
||||
placeholder="请选择商品分类"
|
||||
clearable
|
||||
ref="category"
|
||||
:disabled="isDisabled"
|
||||
:props="goodsClassList"
|
||||
:class="customerClass"
|
||||
filterable></el-cascader>`,
|
||||
props: {
|
||||
'unitCategory': {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
}
|
||||
},//初始选中的分类ID列表['1','2','3']
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '请选择商品分类',
|
||||
},
|
||||
'customerClass': {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
'userType': {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},//获取分类的用户类型 1商户 2门店
|
||||
'storeId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//门店ID在userType等于2时,或者是商户选择门店商品时可能会传
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
'size': {
|
||||
type: String,
|
||||
default: 'small'
|
||||
},
|
||||
'categoryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
}
|
||||
},
|
||||
data() {
|
||||
let _this = this;
|
||||
return {
|
||||
category: [],//被选中的商品分类信息
|
||||
goodsClassList: {
|
||||
lazy: true,
|
||||
emitPath: true,
|
||||
lazyLoad(node, resolve) {
|
||||
_this.handleGoodsClassList(node, resolve);
|
||||
},
|
||||
},//供选择的分类列表
|
||||
temp_category_id: [],//初始选中的分类ID列表['1','2','3']
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//处理商品分类
|
||||
handleGoodsClassList(node, resolve) {
|
||||
const {value} = node;
|
||||
let list = this.getGoodsClassList(value ? value.id : 0);
|
||||
resolve(list);
|
||||
},
|
||||
//获取商品分类
|
||||
getGoodsClassList(pid) {
|
||||
let data = [];
|
||||
$.ajax({
|
||||
url: '/index.php/Retail/MerCate/getGoodsClassify',
|
||||
type: 'post',
|
||||
data: {
|
||||
pid: pid,
|
||||
user_type: this.userType,
|
||||
store_id: this.storeId,
|
||||
},
|
||||
async: false,
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
data = res.data.map((item) => {
|
||||
let obj = {
|
||||
value: item,
|
||||
label: item.class_name,
|
||||
leaf: item.leaf,
|
||||
};
|
||||
if (this.temp_category_id.length && this.temp_category_id[0].id == item.id) {
|
||||
this.temp_category_id.splice(0, 1);
|
||||
this.category.push(item);
|
||||
obj.children = this.getGoodsClassList(item.id);
|
||||
}
|
||||
return obj;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return data;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.temp_category_id = this.unitCategory;
|
||||
},
|
||||
watch: {
|
||||
//监听分类切换
|
||||
category: {
|
||||
deep: true,
|
||||
handler(n) {
|
||||
let id = '';
|
||||
if (n && n.length) id = n[n.length - 1].id;
|
||||
this.$emit('update:categoryId', id);
|
||||
this.$emit('change', id);
|
||||
}
|
||||
},
|
||||
//监听分类切换
|
||||
categoryId(n, o) {
|
||||
if (n == '') {
|
||||
this.category = [];
|
||||
this.$refs.category.$refs.panel.clearCheckedNodes();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* 选择行业
|
||||
*/
|
||||
Vue.component('select-industry', {
|
||||
template: `<el-select v-model="industry_id"
|
||||
:placeholder="placeholder"
|
||||
:disabled="isDisabled"
|
||||
size="small"
|
||||
@change="changeIndustry"
|
||||
clearable filterable>
|
||||
<el-option v-for="item in dataList"
|
||||
:value-key="item.id"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>`,
|
||||
props: {
|
||||
'industryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//选择的行业ID
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '选择行业'
|
||||
},
|
||||
'showCommon': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否显示公共行业
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
industry_id: '',//已选中的行业id
|
||||
dataList: [],// 数据
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//切换行业
|
||||
changeIndustry(val) {
|
||||
this.$emit('update:industryId', val);
|
||||
this.$emit('change', val);
|
||||
},
|
||||
//获取行业列表
|
||||
getIndustryList() {
|
||||
this.dataList = [];
|
||||
$.ajax({
|
||||
url: '/index.php/Retail/StoreIndustry/getIndustrySelect',
|
||||
type: 'post',
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
if (res.data.list.length) {
|
||||
this.dataList = res.data.list;
|
||||
this.$nextTick(() => {
|
||||
if (this.showCommon) {
|
||||
this.dataList.unshift({
|
||||
id: '0',
|
||||
name: '公共行业',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.industry_id = this.industryId;
|
||||
this.getIndustryList();
|
||||
},
|
||||
watch: {
|
||||
industryId(n) {
|
||||
this.industry_id = n;
|
||||
}
|
||||
}
|
||||
});
|
||||
235
Public/Retail/common/js/select-store.js
可执行文件
235
Public/Retail/common/js/select-store.js
可执行文件
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* 选择一个门店
|
||||
*/
|
||||
Vue.component('select-store', {
|
||||
template: `<el-select v-model="store"
|
||||
:placeholder="placeholder"
|
||||
:disabled="isDisabled"
|
||||
size="small"
|
||||
@change="changeStore"
|
||||
value-key="id"
|
||||
clearable filterable>
|
||||
<el-option v-for="item in dataList"
|
||||
:key="item.id"
|
||||
:label="item.store_name"
|
||||
:disabled="item.id==disabledStoreId?true:false"
|
||||
:value="item">
|
||||
<template v-if="showStatus">
|
||||
<span style="float: left">{{item.store_name}}</span>
|
||||
<span style="float: right; color: #8492A6; font-size: 12px">{{item.store_status==1?'关闭':'开启'}}</span>
|
||||
</template>
|
||||
</el-option>
|
||||
</el-select>`,
|
||||
props: {
|
||||
'storeId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//选择的门店ID
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '选择门店',
|
||||
},//选择的门店ID
|
||||
'storeStatus': {
|
||||
type: Number,
|
||||
default: 3,
|
||||
},//门店状态 1开启的门店 2关闭的门店 3开启和关闭的门店
|
||||
'showStatus': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否显示门店状态
|
||||
'industryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//筛选的行业ID
|
||||
'storeIndustryId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//已选门店的行业ID
|
||||
'strictIndustry': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否是严格模式筛选行业下的门店
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
'disabledStoreId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//禁止选择的门店ID
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
store: '',//已选中的门店信息
|
||||
dataList: [],// 数据
|
||||
page: 1,
|
||||
limit: 20,
|
||||
loadSuccess: false,
|
||||
timer: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//切换门店
|
||||
changeStore() {
|
||||
this.$emit('update:storeId', this.store && this.store.id ? this.store.id : '');
|
||||
this.$emit('update:storeIndustryId', this.store && this.store.industry_id ? this.store.industry_id : '');
|
||||
this.$emit('change', this.store && this.store.id ? this.store.id : '');
|
||||
},
|
||||
//获取门店列表
|
||||
getStoreList() {
|
||||
this.sendRequest('Retail/Store/getStoreLimitList', {
|
||||
data: {
|
||||
page: this.page,
|
||||
limit: this.limit,
|
||||
store_status: this.storeStatus,
|
||||
industry_id: this.industryId,
|
||||
strict_industry: this.strictIndustry ? 1 : 0,
|
||||
},
|
||||
success: (res) => {
|
||||
this.loadSuccess = true;
|
||||
if (res.status == 1) {
|
||||
if (this.page == 1) {
|
||||
this.dataList = res.data;
|
||||
} else {
|
||||
this.dataList.push.apply(this.dataList, res.data);
|
||||
}
|
||||
this.unitStore()
|
||||
if (this.limit == res.data.length) {
|
||||
this.page++;
|
||||
this.getStoreList();
|
||||
}
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
unitStore() {
|
||||
console.log(123);
|
||||
if (this.timer) return
|
||||
this.timer = setInterval(() => {
|
||||
if (this.loadSuccess) {
|
||||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
let flag = false;
|
||||
for (let i in this.dataList) {
|
||||
if (this.storeId == this.dataList[i].id) {
|
||||
this.store = {...this.dataList[i]};
|
||||
flag = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
this.store = '';
|
||||
}
|
||||
this.changeStore();
|
||||
}
|
||||
}, 500)
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getStoreList();
|
||||
},
|
||||
watch: {
|
||||
storeId(n) {
|
||||
if (this.store && this.store.id && n != this.store.id || n && !this.store) this.unitStore();
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 选择多个门店
|
||||
*/
|
||||
Vue.component('select-store-multiple', {
|
||||
template: `<el-select v-model="store_id_arr"
|
||||
:placeholder="placeholder"
|
||||
:disabled="isDisabled"
|
||||
size="small" style="width:100%;max-width: 600px"
|
||||
@change="changeStore"
|
||||
multiple clearable filterable>
|
||||
<el-option v-for="item in dataList"
|
||||
:value-key="item.id"
|
||||
:key="item.id"
|
||||
:label="item.store_name"
|
||||
:value="item.id">
|
||||
<template v-if="showStatus">
|
||||
<span style="float: left">{{ item.store_name }}</span>
|
||||
<span style="float: right; color: #8492A6; font-size: 12px;padding-right: 16px;">{{item.store_status==1?'关闭':'开启'}}</span>
|
||||
</template>
|
||||
</el-option>
|
||||
</el-select>`,
|
||||
props: {
|
||||
'storeIdArr': {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
},//选择的门店ID列表
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '选择门店',
|
||||
},//选择的门店ID
|
||||
'storeStatus': {
|
||||
type: Number,
|
||||
default: 3,
|
||||
},//门店状态 1开启的门店 2关闭的门店 3开启和关闭的门店
|
||||
'showStatus': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否显示门店状态
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
store_id_arr: '',//已选中的门店ID列表
|
||||
dataList: [],// 数据
|
||||
page: 1,
|
||||
limit: 20,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//切换门店
|
||||
changeStore(val) {
|
||||
this.$emit('update:storeIdArr', val);
|
||||
this.$emit('change', val);
|
||||
},
|
||||
//获取门店列表
|
||||
getStoreList() {
|
||||
this.sendRequest('Retail/Store/getStoreLimitList', {
|
||||
data: {
|
||||
page: this.page,
|
||||
limit: this.limit,
|
||||
store_status: this.storeStatus,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
if (this.page == 1) {
|
||||
this.dataList = res.data;
|
||||
} else {
|
||||
this.dataList.push.apply(this.dataList, res.data);
|
||||
}
|
||||
if (this.limit == res.data.length) {
|
||||
this.page++;
|
||||
this.getStoreList();
|
||||
}
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.store_id_arr = [...this.storeIdArr];
|
||||
this.getStoreList();
|
||||
},
|
||||
watch: {
|
||||
storeIdArr(n) {
|
||||
this.store_id_arr = [...n];
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* 选择门店的供货商
|
||||
*/
|
||||
Vue.component('select-store-supplier', {
|
||||
template: `<el-select v-model="supplier_id"
|
||||
:placeholder="placeholder"
|
||||
:disabled="isDisabled"
|
||||
size="small"
|
||||
@change="changeSupplier"
|
||||
clearable filterable>
|
||||
<el-option v-for="item in dataList"
|
||||
:value-key="item.id"
|
||||
:key="item.id"
|
||||
:label="item.supplier_name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>`,
|
||||
props: {
|
||||
'supplierId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//门店ID
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '选择供货商',
|
||||
},//选择的供货商ID
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
supplier_id: '',//已选中的供货商id
|
||||
dataList: [],// 数据
|
||||
page: 1,
|
||||
limit: 20,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//切换供货商
|
||||
changeSupplier(val) {
|
||||
this.$emit('update:supplierId', val);
|
||||
this.$emit('change', val);
|
||||
},
|
||||
//获取供货商列表
|
||||
getSupplierList() {
|
||||
this.sendRequest('Retail/SSupplier/getUsedSupplierList', {
|
||||
data: {
|
||||
page: this.page,
|
||||
limit: this.limit,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.dataList = res.data;
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.supplier_id = this.supplierId == '0' ? '' : this.supplierId;
|
||||
this.getSupplierList();
|
||||
},
|
||||
watch: {
|
||||
supplierId(n) {
|
||||
this.supplier_id = n == '0' ? '' : n;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 选择商户的供货商
|
||||
*/
|
||||
Vue.component('select-mer-supplier', {
|
||||
template: `<el-select v-model="supplier_id"
|
||||
:placeholder="placeholder"
|
||||
:disabled="isDisabled"
|
||||
size="small"
|
||||
@change="changeSupplier"
|
||||
clearable filterable>
|
||||
<el-option v-for="item in dataList"
|
||||
:value-key="item.id"
|
||||
:key="item.id"
|
||||
:label="item.supplier_name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>`,
|
||||
props: {
|
||||
'supplierId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//门店ID
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '选择供货商',
|
||||
},//选择的供货商ID
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
supplier_id: '',//已选中的供货商id
|
||||
dataList: [],// 数据
|
||||
page: 1,
|
||||
limit: 20,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//切换供货商
|
||||
changeSupplier(val) {
|
||||
this.$emit('update:supplierId', val);
|
||||
this.$emit('change', val);
|
||||
},
|
||||
//获取供货商列表
|
||||
getSupplierList() {
|
||||
this.sendRequest('Retail/Supplier/getUsedSupplierList', {
|
||||
data: {
|
||||
page: this.page,
|
||||
limit: this.limit,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.dataList = res.data;
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.supplier_id = this.supplierId == '0' ? '' : this.supplierId;
|
||||
this.getSupplierList();
|
||||
},
|
||||
watch: {
|
||||
supplierId(n) {
|
||||
this.supplier_id = n == '0' ? '' : n;
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* 选择单个会员等级
|
||||
*/
|
||||
Vue.component('select-vip-grade', {
|
||||
template: `<el-select v-model="grade_id"
|
||||
:placeholder="placeholder"
|
||||
:disabled="isDisabled"
|
||||
size="small"
|
||||
clearable filterable>
|
||||
<el-option v-for="(item,index) in dataList"
|
||||
@click.native="changeGrade(index)"
|
||||
:value-key="item.id"
|
||||
:key="item.id"
|
||||
:label="item.grade_name"
|
||||
:value="item.id">
|
||||
<template v-if="showDiscount">
|
||||
<span style="float: left">{{ item.grade_name }}</span>
|
||||
<span style="float: right; color: #8492A6; font-size: 12px">{{(item.discount*100)/10}}折</span>
|
||||
</template>
|
||||
</el-option>
|
||||
</el-select>`,
|
||||
props: {
|
||||
'gradeId': {
|
||||
type: String,
|
||||
default: '',
|
||||
},//选择的会员等级ID
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '选择会员等级',
|
||||
},//选择的会员等级ID
|
||||
'showDiscount': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否显示等级折扣
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
'integralRange': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否需要等级积分范围
|
||||
'minIntegral': {},
|
||||
'maxIntegral': {},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
grade_id: '',//已选中的会员等级id
|
||||
dataList: [],// 数据
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//切换会员等级
|
||||
changeGrade(index) {
|
||||
this.$emit('update:gradeId', index !== null ? this.dataList[index].id : '');
|
||||
if (this.integralRange) {
|
||||
this.$emit('update:minIntegral', index !== null ? this.dataList[index].min_integral : '');
|
||||
this.$emit('update:maxIntegral', index !== null ? this.dataList[index].max_integral : '');
|
||||
this.$emit('change', index !== null ? this.dataList[index].id : '', {
|
||||
minIntegral: index !== null ? this.dataList[index].min_integral : '',
|
||||
maxIntegral: index !== null ? this.dataList[index].max_integral : '',
|
||||
});
|
||||
} else {
|
||||
this.$emit('change', index !== null ? this.dataList[index].id : '');
|
||||
}
|
||||
},
|
||||
//获取会员等级列表
|
||||
getGradeList() {
|
||||
this.sendRequest('Retail/Vip/getVipGradeList', {
|
||||
data: {
|
||||
integralRange: this.integralRange
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.dataList = res.data;
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.grade_id = this.gradeId == '0' ? '' : this.gradeId;
|
||||
this.getGradeList();
|
||||
},
|
||||
watch: {
|
||||
grade_id(n) {
|
||||
if (!n) {
|
||||
this.changeGrade(null)
|
||||
}
|
||||
},
|
||||
gradeId(n) {
|
||||
this.grade_id = n == '0' ? '' : n;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 选择多个会员
|
||||
*/
|
||||
Vue.component('select-vip-grade-multiple', {
|
||||
template: `<el-select v-model="grade_id_arr"
|
||||
:placeholder="placeholder"
|
||||
:disabled="isDisabled"
|
||||
size="small" style="width:100%;max-width: 600px"
|
||||
@change="changeGrade"
|
||||
multiple clearable filterable>
|
||||
<el-option v-for="item in dataList"
|
||||
:value-key="item.id"
|
||||
:key="item.id"
|
||||
:label="item.grade_name"
|
||||
:value="item.id">
|
||||
<template v-if="showDiscount">
|
||||
<span style="float: left">{{ item.grade_name }}</span>
|
||||
<span style="float: right; color: #8492A6; font-size: 12px;padding-right: 16px;">{{(item.discount*100)/10}}折</span>
|
||||
</template>
|
||||
</el-option>
|
||||
</el-select>`,
|
||||
props: {
|
||||
'gradeIdArr': {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
},//选择的会员等级ID
|
||||
'placeholder': {
|
||||
type: String,
|
||||
default: '选择会员等级',
|
||||
},//选择的会员等级ID
|
||||
'showDiscount': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否显示等级折扣
|
||||
'isDisabled': {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},//是否禁止修改
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
grade_id_arr: '',//已选中的会员等级id
|
||||
dataList: [],// 数据
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//切换会员等级
|
||||
changeGrade(val) {
|
||||
this.$emit('update:gradeIdArr', val);
|
||||
this.$emit('change', val);
|
||||
},
|
||||
//获取会员等级列表
|
||||
getGradeList() {
|
||||
this.sendRequest('/index.php/Retail/Vip/getVipGradeList', {
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.dataList = res.data;
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.grade_id_arr = [...this.gradeIdArr];
|
||||
this.getGradeList();
|
||||
},
|
||||
watch: {
|
||||
gradeIdArr(n) {
|
||||
this.grade_id_arr = [...n];
|
||||
}
|
||||
}
|
||||
})
|
||||
在新工单中引用
屏蔽一个用户