|
@@ -10,22 +10,26 @@
|
|
|
<template #is_use>
|
|
|
<el-option v-for="i in is_useList" :key="i.model" :label="i.label" :value="i.value"></el-option>
|
|
|
</template>
|
|
|
- <template #single_stock>
|
|
|
- <el-select v-model="form.single_stock" placeholder="请选择" style="width: 100%">
|
|
|
- <el-option v-for="i in is_useList" :key="i.model" :label="i.label" :value="i.value"></el-option>
|
|
|
+ <template #shop>
|
|
|
+ <el-select
|
|
|
+ v-model="form.shop"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ remote
|
|
|
+ reserve-keyword
|
|
|
+ :remote-method="shopSearch"
|
|
|
+ placeholder="请输入店铺名称,便于查询商品"
|
|
|
+ :loading="loading"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option v-for="item in shopList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
|
|
|
</el-select>
|
|
|
- <p style="margin: 5px 0 0 0; font-size: 12px">禁用状态不需要填写库存数量,直接使用商品规格库存</p>
|
|
|
</template>
|
|
|
<template #set>
|
|
|
<el-col :span="24" style="margin: 0 0 10px 0">
|
|
|
<el-button type="primary" size="mini" @click="toAdd()">添加规格商品</el-button>
|
|
|
</el-col>
|
|
|
<el-table :data="form.set" border size="mini">
|
|
|
- <el-table-column label="店铺名称" prop="shop_name" align="center">
|
|
|
- <template #default="{ row }">
|
|
|
- <p>{{ row.shop_name }}</p>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
<el-table-column label="商品名称" prop="goods_name" align="center">
|
|
|
<template #default="{ row }">
|
|
|
<p>{{ row.goods_name }}</p>
|
|
@@ -56,9 +60,6 @@
|
|
|
<el-button type="warning" size="mini" @click="toMoney()">计算套装金额</el-button>
|
|
|
</el-col>
|
|
|
</template>
|
|
|
- <template #stock v-if="form.single_stock == '0'">
|
|
|
- <el-input v-model="form.stock" type="number" placeholder="请输入库存数量"></el-input>
|
|
|
- </template>
|
|
|
</data-form>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
@@ -66,25 +67,22 @@
|
|
|
<e-dialog :dialog="dialog" @toClose="toClose">
|
|
|
<template v-slot:info>
|
|
|
<data-form :fields="diaFields" :rules="diaRules" v-model="diaForm" labelWidth="150px" @save="onSubmit" @dataChange="diaChange">
|
|
|
- <template #shop>
|
|
|
+ <template #goods>
|
|
|
<el-select
|
|
|
- v-model="diaForm.shop"
|
|
|
+ v-model="diaForm.goods"
|
|
|
filterable
|
|
|
clearable
|
|
|
remote
|
|
|
reserve-keyword
|
|
|
- :remote-method="shopSearch"
|
|
|
- placeholder="请输入店铺名称,便于查询商品"
|
|
|
+ :remote-method="goodsSearch"
|
|
|
+ placeholder="请输入商品名称,便于查询"
|
|
|
:loading="loading"
|
|
|
- @change="shopSelect"
|
|
|
+ @change="goodsSelect"
|
|
|
style="width: 100%"
|
|
|
>
|
|
|
- <el-option v-for="item in shopList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
|
|
|
+ <el-option v-for="item in goodsList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
|
|
|
</el-select>
|
|
|
</template>
|
|
|
- <template #goods>
|
|
|
- <el-option v-for="item in goodsList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
|
|
|
- </template>
|
|
|
<template #spec>
|
|
|
<el-option v-for="item in specList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
|
|
|
</template>
|
|
@@ -114,15 +112,15 @@ export default {
|
|
|
// form
|
|
|
infoFields: [
|
|
|
{ label: '套装名称', model: 'name' },
|
|
|
+ { label: '店铺名称', model: 'shop', custom: true },
|
|
|
{ label: '是否使用', model: 'is_use', type: 'select' },
|
|
|
{ label: '商品规格组合', model: 'set', custom: true },
|
|
|
{ label: '套装销售金额', model: 'sell_money', type: 'number' },
|
|
|
{ label: '运费', model: 'freight', type: 'number' },
|
|
|
- { label: '单独设置库存', model: 'single_stock', custom: true },
|
|
|
- { label: '库存数量', model: 'stock', custom: true },
|
|
|
],
|
|
|
rules: {
|
|
|
name: [{ required: true, message: '套装名称', trigger: 'blur' }],
|
|
|
+ shop: [{ required: true, message: '店铺', trigger: 'change' }],
|
|
|
is_use: [{ required: true, message: '是否使用', trigger: 'change' }],
|
|
|
sell_money: [{ required: true, message: '套装销售金额', trigger: 'blur' }],
|
|
|
freight: [{ required: true, message: '运费', trigger: 'blur' }],
|
|
@@ -135,8 +133,7 @@ export default {
|
|
|
// 弹框
|
|
|
dialog: { title: '信息管理', show: false, type: '1' },
|
|
|
diaFields: [
|
|
|
- { label: '店铺名称', model: 'shop', custom: true },
|
|
|
- { label: '商品名称', model: 'goods', type: 'select' },
|
|
|
+ { label: '商品名称', model: 'goods', custom: true },
|
|
|
{ label: '规格名称', model: 'spec', type: 'select' },
|
|
|
{ label: '数量', model: 'set_num', type: 'number' },
|
|
|
{ label: '单价', model: 'set_money', type: 'number' },
|
|
@@ -188,20 +185,22 @@ export default {
|
|
|
if (this.$checkRes(res)) this.$set(this, 'shopList', res.data);
|
|
|
this.loading = false;
|
|
|
},
|
|
|
- // 选择-查询商品
|
|
|
- async shopSelect(value) {
|
|
|
- let res = await this.goodsQuery({ shop: value });
|
|
|
+ // 远程查询店铺
|
|
|
+ async goodsSearch(value) {
|
|
|
+ this.loading = true;
|
|
|
+ let res = await this.goodsQuery({ shop: this.form.shop, name: value });
|
|
|
if (this.$checkRes(res)) this.$set(this, 'goodsList', res.data);
|
|
|
- res = await this.shopFetch(value);
|
|
|
- if (this.$checkRes(res)) this.$set(this.diaForm, 'shop_name', res.data.name);
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+ // 选择-查询商品
|
|
|
+ async goodsSelect(value) {
|
|
|
+ let res = await this.specQuery({ goods: value });
|
|
|
+ if (this.$checkRes(res)) this.$set(this, 'specList', res.data);
|
|
|
+ res = await this.goodsFetch(value);
|
|
|
+ if (this.$checkRes(res)) this.$set(this.diaForm, 'goods_name', res.data.name);
|
|
|
},
|
|
|
async diaChange({ model, value }) {
|
|
|
- if (model == 'goods') {
|
|
|
- let res = await this.specQuery({ goods: value });
|
|
|
- if (this.$checkRes(res)) this.$set(this, 'specList', res.data);
|
|
|
- res = await this.goodsFetch(value);
|
|
|
- if (this.$checkRes(res)) this.$set(this.diaForm, 'goods_name', res.data.name);
|
|
|
- } else if (model == 'spec') {
|
|
|
+ if (model == 'spec') {
|
|
|
let res = await this.specFetch(value);
|
|
|
if (this.$checkRes(res)) {
|
|
|
this.$set(this.diaForm, 'spec_name', res.data.name);
|
|
@@ -242,32 +241,18 @@ export default {
|
|
|
// 保存
|
|
|
async toSave({ data }) {
|
|
|
if (data.set.length > 0) {
|
|
|
- let shop = [];
|
|
|
- let goods = [];
|
|
|
- let spec = [];
|
|
|
- for (const p1 of data.set) {
|
|
|
- shop.push(p1.shop);
|
|
|
- goods.push(p1.goods);
|
|
|
- spec.push(p1.spec);
|
|
|
+ console.log(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();
|
|
|
}
|
|
|
- data.shop = _.uniq(shop);
|
|
|
- data.goods = _.uniq(goods);
|
|
|
- data.spec = _.uniq(spec);
|
|
|
- this.toRef(data);
|
|
|
} else {
|
|
|
this.$message({ type: `warning`, message: `还未添加套装商品,不可保存` });
|
|
|
}
|
|
|
},
|
|
|
- async toRef(data) {
|
|
|
- console.log(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();
|
|
|
- }
|
|
|
- },
|
|
|
// 返回
|
|
|
toBack() {
|
|
|
this.$emit('toBack');
|