|
@@ -14,7 +14,7 @@
|
|
|
v-model.trim="form.educationShowOrganId"
|
|
|
filterable
|
|
|
placeholder="移动端可售分部"
|
|
|
- style="width: 300px !important"
|
|
|
+ style="width: 400px !important"
|
|
|
multiple
|
|
|
clearable
|
|
|
:disabled="addDisabled"
|
|
@@ -36,7 +36,7 @@
|
|
|
v-model.trim="form.courseFeeShowOrganId"
|
|
|
filterable
|
|
|
placeholder="课程收费乐团可售分部"
|
|
|
- style="width: 300px !important"
|
|
|
+ style="width: 400px !important"
|
|
|
multiple
|
|
|
clearable
|
|
|
:disabled="addDisabled"
|
|
@@ -58,7 +58,7 @@
|
|
|
v-model.trim="form.memberFeeShowOrganId"
|
|
|
filterable
|
|
|
placeholder="请选择会员收费团可见分部"
|
|
|
- style="width: 300px !important"
|
|
|
+ style="width: 400px !important"
|
|
|
multiple
|
|
|
clearable
|
|
|
:disabled="addDisabled"
|
|
@@ -80,7 +80,7 @@
|
|
|
v-model.trim="form.freeFeeShowOrganId"
|
|
|
filterable
|
|
|
placeholder="请选择会员收费团可见分部"
|
|
|
- style="width: 300px !important"
|
|
|
+ style="width: 400px !important"
|
|
|
multiple
|
|
|
clearable
|
|
|
:disabled="addDisabled"
|
|
@@ -103,7 +103,7 @@
|
|
|
v-model.trim="form.replacementShowOrganId"
|
|
|
filterable
|
|
|
placeholder="请选择乐器置换可售分部"
|
|
|
- style="width: 300px !important"
|
|
|
+ style="width: 400px !important"
|
|
|
multiple
|
|
|
clearable
|
|
|
:disabled="addDisabled"
|
|
@@ -127,13 +127,18 @@
|
|
|
<tooltip :content="scope.row.name" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column align="center" prop="productSn" label="商品货号">
|
|
|
+ <el-table-column align="center" prop="sn" label="商品货号">
|
|
|
</el-table-column>
|
|
|
- <el-table-column align="center" prop="bankName" label="品牌">
|
|
|
+ <el-table-column align="center" prop="brandName" label="品牌">
|
|
|
</el-table-column>
|
|
|
<el-table-column align="center" prop="skuCode" label="sku编号">
|
|
|
</el-table-column>
|
|
|
- <el-table-column align="center" prop="marketPrice" label="市场价">
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="marketPrice"
|
|
|
+ label="市场价"
|
|
|
+ width="160"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
<el-form-item
|
|
|
:show-message="false"
|
|
@@ -160,7 +165,12 @@
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column align="center" prop="discountPrice" label="零售价">
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="discountPrice"
|
|
|
+ label="零售价"
|
|
|
+ width="160"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
<el-form-item
|
|
|
:show-message="false"
|
|
@@ -191,6 +201,7 @@
|
|
|
align="center"
|
|
|
prop="groupPurchasePrice"
|
|
|
label="团购价"
|
|
|
+ width="160"
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
<el-form-item
|
|
@@ -218,7 +229,44 @@
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column align="center" prop="type" label="商品类型">
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="goodsPrice"
|
|
|
+ label="成本"
|
|
|
+ width="160"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-form-item
|
|
|
+ :show-message="false"
|
|
|
+ class="tableItem"
|
|
|
+ :prop="'goodsList.' + scope.$index + '.goodsPrice'"
|
|
|
+ :rules="[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ validator: validPrice,
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ <el-input-number
|
|
|
+ style="width: 100%!important;"
|
|
|
+ class="number-input"
|
|
|
+ v-model="form.goodsList[scope.$index].goodsPrice"
|
|
|
+ :controls="false"
|
|
|
+ :precision="0"
|
|
|
+ :min="0"
|
|
|
+ placeholder="请选择成本"
|
|
|
+ :disabled="addDisabled"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="type"
|
|
|
+ label="商品类型"
|
|
|
+ width="160"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
<el-form-item
|
|
|
:show-message="false"
|
|
@@ -232,16 +280,28 @@
|
|
|
}
|
|
|
]"
|
|
|
>
|
|
|
- <el-cascader
|
|
|
+ <el-select
|
|
|
v-model.trim="form.goodsList[scope.$index].type"
|
|
|
- :options="categoryList"
|
|
|
- placeholder="商品分类"
|
|
|
- :props="{ checkStrictly: true, expandTrigger: 'hover' }"
|
|
|
- ></el-cascader>
|
|
|
+ style="width: 100%!important;"
|
|
|
+ clearable
|
|
|
+ placeholder="商品类型"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in goodsType"
|
|
|
+ :key="index"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column align="center" prop="goodsCategoryId" label="商品分类">
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="goodsCategoryId"
|
|
|
+ label="商品分类"
|
|
|
+ width="160"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
<el-form-item
|
|
|
:show-message="false"
|
|
@@ -257,11 +317,12 @@
|
|
|
>
|
|
|
<el-select
|
|
|
v-model.trim="form.goodsList[scope.$index].goodsCategoryId"
|
|
|
+ style="width: 100%!important;"
|
|
|
clearable
|
|
|
placeholder="商品分类"
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="(item, index) in goodsType"
|
|
|
+ v-for="(item, index) in categoryList"
|
|
|
:key="index"
|
|
|
:label="item.label"
|
|
|
:value="item.value"
|
|
@@ -277,7 +338,7 @@
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column align="center" prop="sn" label="操作">
|
|
|
+ <el-table-column align="center" prop="sn" label="操作" fixed="right">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button
|
|
|
type="text"
|
|
@@ -289,7 +350,12 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-form>
|
|
|
- <span slot="footer" v-if="!addDisabled" class="dialog-footer">
|
|
|
+ <span
|
|
|
+ slot="footer"
|
|
|
+ v-if="!addDisabled"
|
|
|
+ class="dialog-footer"
|
|
|
+ style="padding-top: 12px;"
|
|
|
+ >
|
|
|
<el-button @click="$listeners.close()">取 消</el-button>
|
|
|
<el-button @click="onShopSubmit('ruleForm')" type="primary"
|
|
|
>确 定</el-button
|
|
@@ -308,14 +374,17 @@
|
|
|
:disabledIds="disabledIds"
|
|
|
@close="recordStatus = false"
|
|
|
@comfirm="onConfirm"
|
|
|
- :categoryList="categoryList"
|
|
|
:goodsBrand="goodsBrand"
|
|
|
/>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { goodsAdd, goodsUpdate, api_goodsGet } from "@/api/businessManager";
|
|
|
+import {
|
|
|
+ goodsAddBatch,
|
|
|
+ goodsUpdate,
|
|
|
+ api_goodsGet
|
|
|
+} from "@/api/businessManager";
|
|
|
import cleanDeep from "clean-deep";
|
|
|
import subShopGoods from "./subShopGoods.vue";
|
|
|
let validPrice = (rule, value, callback) => {
|
|
@@ -393,26 +462,31 @@ export default {
|
|
|
form[i] = row[i];
|
|
|
}
|
|
|
}
|
|
|
- if (row.goodsCategoryId) {
|
|
|
- form.goodsCategoryId = this.formatParentId(
|
|
|
- row.goodsCategoryId,
|
|
|
- this.categoryList
|
|
|
- );
|
|
|
- }
|
|
|
- let ids = row.goodsSubList;
|
|
|
- let goodsList = [];
|
|
|
- ids.forEach(item => {
|
|
|
- goodsList.push({
|
|
|
- name: item.mallGoodsName,
|
|
|
- goodsId: item.mallGoodsId,
|
|
|
- skuStockId: item.sku,
|
|
|
- price: item.price,
|
|
|
- publishStatus: item.goodsStatus,
|
|
|
- productSn: item.productSn,
|
|
|
- goodsPrice: item.goodsPrice // 成本
|
|
|
- });
|
|
|
- });
|
|
|
- form.goodsList = goodsList;
|
|
|
+ const goodsSub =
|
|
|
+ row.goodsSubList && row.goodsSubList.length > 0
|
|
|
+ ? row.goodsSubList[0]
|
|
|
+ : {};
|
|
|
+ form.goodsList = [
|
|
|
+ {
|
|
|
+ name: row.name,
|
|
|
+ sn: row.sn,
|
|
|
+ brandId: row.brand,
|
|
|
+ brandName: row.brandName,
|
|
|
+ type: row.type,
|
|
|
+ goodsCategoryId: row.goodsCategoryId,
|
|
|
+ specification: row.specification,
|
|
|
+ marketPrice: row.marketPrice,
|
|
|
+ discountPrice: row.discountPrice,
|
|
|
+ groupPurchasePrice: row.groupPurchasePrice,
|
|
|
+ groupGoods: row.groupGoods ? 1 : 0,
|
|
|
+ pic: row.image,
|
|
|
+ skuStockId: goodsSub.sku,
|
|
|
+ skuCode: goodsSub.skuCode,
|
|
|
+ goodsPrice: goodsSub.goodsPrice,
|
|
|
+ goodsId: goodsSub.goodsId,
|
|
|
+ publishStatus: goodsSub.goodsStatus
|
|
|
+ }
|
|
|
+ ];
|
|
|
form.id = row.id;
|
|
|
|
|
|
if (row.studentShowOrganId) {
|
|
@@ -447,6 +521,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ validPrice,
|
|
|
async __init() {
|
|
|
let params = {
|
|
|
delFlag: 0,
|
|
@@ -474,7 +549,6 @@ export default {
|
|
|
});
|
|
|
this.categoryList = tempArray;
|
|
|
} catch {}
|
|
|
-
|
|
|
},
|
|
|
formatParentId(id, list, ids = []) {
|
|
|
for (const item of list) {
|
|
@@ -494,70 +568,95 @@ export default {
|
|
|
return ids;
|
|
|
},
|
|
|
onShopSubmit(formName) {
|
|
|
+ let form = Object.assign({}, this.form);
|
|
|
+ if (form.studentShowOrganId) {
|
|
|
+ form.studentShowOrganId = form.studentShowOrganId.join(",");
|
|
|
+ }
|
|
|
+ if (form.educationShowOrganId) {
|
|
|
+ form.educationShowOrganId = form.educationShowOrganId.join(",");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (form.courseFeeShowOrganId) {
|
|
|
+ form.courseFeeShowOrganId = form.courseFeeShowOrganId.join(",");
|
|
|
+ }
|
|
|
+ if (form.memberFeeShowOrganId) {
|
|
|
+ form.memberFeeShowOrganId = form.memberFeeShowOrganId.join(",");
|
|
|
+ }
|
|
|
+ if (form.freeFeeShowOrganId) {
|
|
|
+ form.freeFeeShowOrganId = form.freeFeeShowOrganId.join(",");
|
|
|
+ }
|
|
|
+ if (form.replacementShowOrganId) {
|
|
|
+ form.replacementShowOrganId = form.replacementShowOrganId.join(",");
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ !form.studentShowOrganId &&
|
|
|
+ !form.educationShowOrganId &&
|
|
|
+ !form.courseFeeShowOrganId &&
|
|
|
+ !form.freeFeeShowOrganId &&
|
|
|
+ !form.memberFeeShowOrganId &&
|
|
|
+ !form.replacementShowOrganId
|
|
|
+ ) {
|
|
|
+ this.$message.error("请至少选择一个可见分部");
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.form.goodsList.length <= 0) {
|
|
|
- this.$message.error("请至少添加一个子商品");
|
|
|
+ this.$message.error("请至少添加一个商品");
|
|
|
return;
|
|
|
}
|
|
|
this.$refs[formName].validate(valid => {
|
|
|
if (valid) {
|
|
|
- let form = Object.assign({}, this.form);
|
|
|
let temps = [];
|
|
|
form.goodsList.forEach(item => {
|
|
|
if (item.skuStockId) {
|
|
|
temps.push({
|
|
|
- mallGoodsId: item.goodsId,
|
|
|
- sku: item.skuStockId,
|
|
|
- goodsStatus: item.publishStatus,
|
|
|
- goodsPrice: item.goodsPrice
|
|
|
+ name: item.name,
|
|
|
+ sn: item.sn,
|
|
|
+ brand: item.brandId,
|
|
|
+ type: item.type,
|
|
|
+ goodsCategoryId: item.goodsCategoryId,
|
|
|
+ specification: item.specification,
|
|
|
+ marketPrice: item.marketPrice,
|
|
|
+ discountPrice: item.discountPrice,
|
|
|
+ groupPurchasePrice: item.groupPurchasePrice,
|
|
|
+ groupGoods: 0,
|
|
|
+ studentShowOrganId: form.studentShowOrganId,
|
|
|
+ educationShowOrganId: form.educationShowOrganId,
|
|
|
+ memberFeeShowOrganId: form.memberFeeShowOrganId,
|
|
|
+ courseFeeShowOrganId: form.courseFeeShowOrganId,
|
|
|
+ freeFeeShowOrganId: form.freeFeeShowOrganId,
|
|
|
+ replacementShowOrganId: form.replacementShowOrganId,
|
|
|
+ image: item.pic,
|
|
|
+ goodsSubList: [
|
|
|
+ {
|
|
|
+ mallGoodsId: item.goodsId,
|
|
|
+ sku: item.skuStockId,
|
|
|
+ goodsStatus: item.publishStatus,
|
|
|
+ goodsPrice: item.goodsPrice
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ // brief: item.detailHtml,
|
|
|
+ // desc: ""
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
- form.goodsSubList = temps;
|
|
|
- form.goodsCategoryId =
|
|
|
- form.goodsCategoryId && form.goodsCategoryId.length > 0
|
|
|
- ? form.goodsCategoryId[form.goodsCategoryId.length - 1]
|
|
|
- : null;
|
|
|
- if (form.studentShowOrganId) {
|
|
|
- form.studentShowOrganId = form.studentShowOrganId.join(",");
|
|
|
- }
|
|
|
- if (form.educationShowOrganId) {
|
|
|
- form.educationShowOrganId = form.educationShowOrganId.join(",");
|
|
|
- }
|
|
|
|
|
|
- if (form.courseFeeShowOrganId) {
|
|
|
- form.courseFeeShowOrganId = form.courseFeeShowOrganId.join(",");
|
|
|
- }
|
|
|
- if (form.memberFeeShowOrganId) {
|
|
|
- form.memberFeeShowOrganId = form.memberFeeShowOrganId.join(",");
|
|
|
- }
|
|
|
- if (form.freeFeeShowOrganId) {
|
|
|
- form.freeFeeShowOrganId = form.freeFeeShowOrganId.join(",");
|
|
|
- }
|
|
|
- if (form.replacementShowOrganId) {
|
|
|
- form.replacementShowOrganId = form.replacementShowOrganId.join(",");
|
|
|
- }
|
|
|
- if (
|
|
|
- !form.studentShowOrganId &&
|
|
|
- !form.educationShowOrganId &&
|
|
|
- !form.courseFeeShowOrganId &&
|
|
|
- !form.freeFeeShowOrganId &&
|
|
|
- !form.replacementShowOrganId
|
|
|
- ) {
|
|
|
- this.$message.error("请至少选择一个可见分部");
|
|
|
- return;
|
|
|
- }
|
|
|
- form.goodsList = null;
|
|
|
+ console.log(temps, "temps");
|
|
|
if (this.addType == "create" || this.addType == "copy") {
|
|
|
if (this.form.id) {
|
|
|
// 判断有没有Id,如果有则删除
|
|
|
delete this.form.id;
|
|
|
}
|
|
|
- form.status = "NO"; // 默认上架
|
|
|
- goodsAdd(cleanDeep(form)).then(res => {
|
|
|
+ // form.status = "NO"; // 默认下架
|
|
|
+ temps.forEach(temp => {
|
|
|
+ temp.status = "NO";
|
|
|
+ });
|
|
|
+ goodsAddBatch(cleanDeep(temps)).then(res => {
|
|
|
this.messageTips("保存", res);
|
|
|
});
|
|
|
} else if (this.addType == "update") {
|
|
|
- goodsUpdate(cleanDeep(form)).then(res => {
|
|
|
+ const goods = temps[0];
|
|
|
+ goods.id = this.form.id;
|
|
|
+ goodsUpdate(cleanDeep(goods)).then(res => {
|
|
|
this.messageTips("保存", res);
|
|
|
});
|
|
|
}
|
|
@@ -616,16 +715,34 @@ export default {
|
|
|
const index = this.form.goodsList.findIndex(
|
|
|
goods => goods.skuStockId == item.skuStockId
|
|
|
);
|
|
|
+
|
|
|
if (index == -1) {
|
|
|
+ // 商品型号
|
|
|
+ const spData = item.spData
|
|
|
+ ? JSON.parse(item.spData)
|
|
|
+ : [{ key: "默认" }];
|
|
|
+ let spText = "";
|
|
|
+ spData.forEach(sp => {
|
|
|
+ spText += sp.key + (sp.value ? ":" + sp.value : "");
|
|
|
+ });
|
|
|
+
|
|
|
goodsList.push({
|
|
|
name: item.name,
|
|
|
goodsId: item.goodsId,
|
|
|
+ brandId: item.brandId,
|
|
|
+ brandName: item.brandName,
|
|
|
skuStockId: item.skuStockId,
|
|
|
skuCode: item.skuCode,
|
|
|
+ pic: item.pic,
|
|
|
+ specification: spText,
|
|
|
+ detailHtml: item.detailHtml,
|
|
|
price: item.price,
|
|
|
publishStatus: item.publishStatus,
|
|
|
- productSn: item.productSn,
|
|
|
- goodsPrice: null // 成本
|
|
|
+ sn: item.productSn,
|
|
|
+ marketPrice: null,
|
|
|
+ discountPrice: null,
|
|
|
+ groupPurchasePrice: null,
|
|
|
+ goodsPrice: null
|
|
|
});
|
|
|
}
|
|
|
});
|