|
@@ -5,6 +5,17 @@
|
|
|
<template #status>
|
|
|
<el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
</template>
|
|
|
+ <template #tags="{ item }">
|
|
|
+ <el-cascader
|
|
|
+ v-model="searchInfo[item.model]"
|
|
|
+ :options="tagsList"
|
|
|
+ :props="propss"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ :show-all-levels="false"
|
|
|
+ @change="changeTags"
|
|
|
+ ></el-cascader>
|
|
|
+ </template>
|
|
|
</data-search>
|
|
|
<data-btn :fields="btnList" @add="toAdd"></data-btn>
|
|
|
<data-table
|
|
@@ -17,7 +28,6 @@
|
|
|
@query="search"
|
|
|
@edit="toEdit"
|
|
|
@puton="toPuton"
|
|
|
- @lower="toLower"
|
|
|
@delete="toDelete"
|
|
|
@spec="toSpec"
|
|
|
@copy="toCopy"
|
|
@@ -27,7 +37,7 @@
|
|
|
<el-row>
|
|
|
<el-col :span="24" style="margin: 0 0 10px 0">
|
|
|
<el-col :span="2"><el-button type="primary" size="mini" @click="toBack()">返回</el-button></el-col>
|
|
|
- <el-col :span="2"><el-button type="primary" size="mini" @click="onSubmit(form)">保存</el-button></el-col>
|
|
|
+ <el-col :span="2"><el-button type="primary" size="mini" @click="toSave(form)">保存</el-button></el-col>
|
|
|
</el-col>
|
|
|
<el-col :span="24">
|
|
|
<data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
|
|
@@ -61,7 +71,9 @@ const { mapActions: actTags } = createNamespacedHelpers('actTags');
|
|
|
export default {
|
|
|
name: 'index',
|
|
|
props: {},
|
|
|
- components: { editor: () => import('@/components/editor.vue') },
|
|
|
+ components: {
|
|
|
+ editor: () => import('@/components/editor.vue'),
|
|
|
+ },
|
|
|
data: function () {
|
|
|
return {
|
|
|
view: 'list',
|
|
@@ -76,7 +88,7 @@ export default {
|
|
|
opera: [
|
|
|
{ label: '修改', method: 'edit' },
|
|
|
{ label: '上架', method: 'puton', display: (i) => i.status == '0' },
|
|
|
- { label: '下架', method: 'lower', display: (i) => i.status == '1' },
|
|
|
+ { label: '下架', method: 'puton', display: (i) => i.status == '1' },
|
|
|
{ label: '库存管理', method: 'spec' },
|
|
|
{ label: '复制', method: 'copy' },
|
|
|
{ label: '删除', method: 'delete', confirm: true, type: 'danger' },
|
|
@@ -85,6 +97,7 @@ export default {
|
|
|
searchFields: [
|
|
|
{ label: '商品名称', model: 'name' },
|
|
|
{ label: '商品状态', model: 'status', type: 'select' },
|
|
|
+ { label: '商品分类', model: 'tags', custom: true },
|
|
|
],
|
|
|
searchInfo: {},
|
|
|
list: [],
|
|
@@ -104,15 +117,14 @@ export default {
|
|
|
{ label: '商品图片', model: 'file', type: 'upload', url: '/files/point/goods/upload' },
|
|
|
{ label: '商品介绍', model: 'brief', custom: true },
|
|
|
],
|
|
|
-
|
|
|
rules: {},
|
|
|
form: {},
|
|
|
// 商品分类
|
|
|
tagsList: [],
|
|
|
props: { multiple: true, label: 'label', value: 'code' },
|
|
|
+ propss: { multiple: false, label: 'label', value: 'code' },
|
|
|
// 活动标签
|
|
|
act_tagsList: [],
|
|
|
-
|
|
|
goodsStatusList: [],
|
|
|
};
|
|
|
},
|
|
@@ -144,6 +156,10 @@ export default {
|
|
|
};
|
|
|
this.$set(this, 'form', obj);
|
|
|
},
|
|
|
+ changeTags(value) {
|
|
|
+ let tags = _.last(value);
|
|
|
+ this.$set(this.searchInfo, `tags`, tags);
|
|
|
+ },
|
|
|
// 复制
|
|
|
async toCopy({ data }) {
|
|
|
this.$confirm('是否确认复制该商品?', '提示', {
|
|
@@ -162,10 +178,13 @@ export default {
|
|
|
},
|
|
|
// 查询其他信息
|
|
|
async searchOthers() {
|
|
|
+ // 商品分类
|
|
|
let res = await this.tree();
|
|
|
if (this.$checkRes(res)) this.$set(this, `tagsList`, res.data);
|
|
|
+ // 商品状态
|
|
|
res = await this.getDict({ code: 'goods_status' });
|
|
|
if (this.$checkRes(res)) this.$set(this, `goodsStatusList`, res.data);
|
|
|
+ // 活动标签
|
|
|
res = await this.actQuery();
|
|
|
if (this.$checkRes(res)) this.$set(this, `act_tagsList`, res.data);
|
|
|
},
|
|
@@ -202,26 +221,15 @@ export default {
|
|
|
return arr.join(';');
|
|
|
},
|
|
|
// 保存
|
|
|
- async onSubmit(data) {
|
|
|
- let res;
|
|
|
- if (data.id) {
|
|
|
- res = await this.update(data);
|
|
|
- } else {
|
|
|
- res = await this.create(data);
|
|
|
- }
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$message({ type: `success`, message: `维护信息成功` });
|
|
|
- this.toBack();
|
|
|
- this.search();
|
|
|
- }
|
|
|
- },
|
|
|
- // 保存
|
|
|
async toSave({ data }) {
|
|
|
let res;
|
|
|
- if (data.id) {
|
|
|
- res = await this.update(data);
|
|
|
+ if (data == '' || data == undefined) {
|
|
|
+ let form = this.form;
|
|
|
+ if (form.id) res = await this.update(form);
|
|
|
+ else res = await this.create(form);
|
|
|
} else {
|
|
|
- res = await this.create(data);
|
|
|
+ if (data.id) res = await this.update(data);
|
|
|
+ else res = await this.create(data);
|
|
|
}
|
|
|
if (this.$checkRes(res)) {
|
|
|
this.$message({ type: `success`, message: `维护信息成功` });
|
|
@@ -236,32 +244,17 @@ export default {
|
|
|
},
|
|
|
// 上架
|
|
|
async toPuton({ data }) {
|
|
|
- this.$confirm('是否确认上架该商品?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- }).then(async () => {
|
|
|
- data.status = '1';
|
|
|
- let res;
|
|
|
- if (data.id) res = await this.update(data);
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$message({ type: `success`, message: `上架成功` });
|
|
|
- }
|
|
|
- this.search();
|
|
|
- });
|
|
|
- },
|
|
|
- // 下架
|
|
|
- async toLower({ data }) {
|
|
|
- this.$confirm('是否确认下架该商品?', '提示', {
|
|
|
+ this.$confirm('是否确认上架/下架该商品?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning',
|
|
|
}).then(async () => {
|
|
|
- data.status = '0';
|
|
|
+ if (data.status == '1') data.status = '0';
|
|
|
+ else data.status = '1';
|
|
|
let res;
|
|
|
if (data._id) res = await this.update(data);
|
|
|
if (this.$checkRes(res)) {
|
|
|
- this.$message({ type: `success`, message: `下架成功` });
|
|
|
+ this.$message({ type: `success`, message: `修改成功` });
|
|
|
}
|
|
|
this.search();
|
|
|
});
|