|
@@ -0,0 +1,675 @@
|
|
|
|
+<template>
|
|
|
|
+ <div>
|
|
|
|
+ <el-button type="primary" @click="addGoodsList" style="margin-bottom: 20px"
|
|
|
|
+ >添加</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-form :model="form" :rules="rules" ref="ruleForm" :inline="true">
|
|
|
|
+ <el-alert title="销售渠道" :closable="false" class="alert" type="info" />
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="移动端可售分部"
|
|
|
|
+ prop="educationShowOrganId"
|
|
|
|
+ :label-width="formLabelWidth"
|
|
|
|
+ >
|
|
|
|
+ <select-all
|
|
|
|
+ v-model.trim="form.educationShowOrganId"
|
|
|
|
+ filterable
|
|
|
|
+ placeholder="移动端可售分部"
|
|
|
|
+ style="width: 300px !important"
|
|
|
|
+ multiple
|
|
|
|
+ clearable
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in selects.branchs"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ :label="item.name"
|
|
|
|
+ :value="item.id.toString()"
|
|
|
|
+ ></el-option>
|
|
|
|
+ </select-all>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="课程收费乐团可售分部"
|
|
|
|
+ prop="courseFeeShowOrganId"
|
|
|
|
+ :label-width="formLabelWidth"
|
|
|
|
+ >
|
|
|
|
+ <select-all
|
|
|
|
+ v-model.trim="form.courseFeeShowOrganId"
|
|
|
|
+ filterable
|
|
|
|
+ placeholder="课程收费乐团可售分部"
|
|
|
|
+ style="width: 300px !important"
|
|
|
|
+ multiple
|
|
|
|
+ clearable
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in selects.branchs"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ :label="item.name"
|
|
|
|
+ :value="item.id.toString()"
|
|
|
|
+ ></el-option>
|
|
|
|
+ </select-all>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="会员收费乐团可售分部"
|
|
|
|
+ prop="memberFeeShowOrganId"
|
|
|
|
+ :label-width="formLabelWidth"
|
|
|
|
+ >
|
|
|
|
+ <select-all
|
|
|
|
+ v-model.trim="form.memberFeeShowOrganId"
|
|
|
|
+ filterable
|
|
|
|
+ placeholder="请选择会员收费团可见分部"
|
|
|
|
+ style="width: 300px !important"
|
|
|
|
+ multiple
|
|
|
|
+ clearable
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in selects.branchs"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ :label="item.name"
|
|
|
|
+ :value="item.id.toString()"
|
|
|
|
+ ></el-option>
|
|
|
|
+ </select-all>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="免费乐团可售分部"
|
|
|
|
+ prop="freeFeeShowOrganId"
|
|
|
|
+ :label-width="formLabelWidth"
|
|
|
|
+ >
|
|
|
|
+ <select-all
|
|
|
|
+ v-model.trim="form.freeFeeShowOrganId"
|
|
|
|
+ filterable
|
|
|
|
+ placeholder="请选择会员收费团可见分部"
|
|
|
|
+ style="width: 300px !important"
|
|
|
|
+ multiple
|
|
|
|
+ clearable
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in selects.branchs"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ :label="item.name"
|
|
|
|
+ :value="item.id.toString()"
|
|
|
|
+ ></el-option>
|
|
|
|
+ </select-all>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-if="tenantId == 1"
|
|
|
|
+ label="乐器置换可售分部"
|
|
|
|
+ prop="replacementShowOrganId"
|
|
|
|
+ :label-width="formLabelWidth"
|
|
|
|
+ >
|
|
|
|
+ <select-all
|
|
|
|
+ v-model.trim="form.replacementShowOrganId"
|
|
|
|
+ filterable
|
|
|
|
+ placeholder="请选择乐器置换可售分部"
|
|
|
|
+ style="width: 300px !important"
|
|
|
|
+ multiple
|
|
|
|
+ clearable
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in selects.branchs"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ :label="item.name"
|
|
|
|
+ :value="item.id.toString()"
|
|
|
|
+ ></el-option>
|
|
|
|
+ </select-all>
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ <el-table
|
|
|
|
+ :data="form.goodsList"
|
|
|
|
+ :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
|
|
|
|
+ style="width:100%!important"
|
|
|
|
+ >
|
|
|
|
+ <el-table-column align="center" prop="name" label="商品名称">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <tooltip :content="scope.row.name" />
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" prop="productSn" label="商品货号">
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" prop="bankName" label="品牌">
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" prop="skuCode" label="sku编号">
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" prop="marketPrice" label="市场价">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item
|
|
|
|
+ :show-message="false"
|
|
|
|
+ class="tableItem"
|
|
|
|
+ :prop="'goodsList.' + scope.$index + '.marketPrice'"
|
|
|
|
+ :rules="[
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ validator: validPrice,
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }
|
|
|
|
+ ]"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ style="width: 100%!important;"
|
|
|
|
+ class="number-input"
|
|
|
|
+ v-model="form.goodsList[scope.$index].marketPrice"
|
|
|
|
+ :controls="false"
|
|
|
|
+ :precision="0"
|
|
|
|
+ :min="0"
|
|
|
|
+ placeholder="请选择市场价"
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" prop="discountPrice" label="零售价">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item
|
|
|
|
+ :show-message="false"
|
|
|
|
+ class="tableItem"
|
|
|
|
+ :prop="'goodsList.' + scope.$index + '.discountPrice'"
|
|
|
|
+ :rules="[
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ validator: validPrice,
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }
|
|
|
|
+ ]"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ style="width: 100%!important;"
|
|
|
|
+ class="number-input"
|
|
|
|
+ v-model="form.goodsList[scope.$index].discountPrice"
|
|
|
|
+ :controls="false"
|
|
|
|
+ :precision="0"
|
|
|
|
+ :min="0"
|
|
|
|
+ placeholder="请选择零售价"
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column
|
|
|
|
+ align="center"
|
|
|
|
+ prop="groupPurchasePrice"
|
|
|
|
+ label="团购价"
|
|
|
|
+ >
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item
|
|
|
|
+ :show-message="false"
|
|
|
|
+ class="tableItem"
|
|
|
|
+ :prop="'goodsList.' + scope.$index + '.groupPurchasePrice'"
|
|
|
|
+ :rules="[
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ validator: validPrice,
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }
|
|
|
|
+ ]"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ style="width: 100%!important;"
|
|
|
|
+ class="number-input"
|
|
|
|
+ v-model="form.goodsList[scope.$index].groupPurchasePrice"
|
|
|
|
+ :controls="false"
|
|
|
|
+ :precision="0"
|
|
|
|
+ :min="0"
|
|
|
|
+ placeholder="请选择团购价"
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" prop="type" label="商品类型">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item
|
|
|
|
+ :show-message="false"
|
|
|
|
+ class="tableItem"
|
|
|
|
+ :prop="'goodsList.' + scope.$index + '.type'"
|
|
|
|
+ :rules="[
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: '请选择商品类型',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }
|
|
|
|
+ ]"
|
|
|
|
+ >
|
|
|
|
+ <el-cascader
|
|
|
|
+ v-model.trim="form.goodsList[scope.$index].type"
|
|
|
|
+ :options="categoryList"
|
|
|
|
+ placeholder="商品分类"
|
|
|
|
+ :props="{ checkStrictly: true, expandTrigger: 'hover' }"
|
|
|
|
+ ></el-cascader>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" prop="goodsCategoryId" label="商品分类">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item
|
|
|
|
+ :show-message="false"
|
|
|
|
+ class="tableItem"
|
|
|
|
+ :prop="'goodsList.' + scope.$index + '.goodsCategoryId'"
|
|
|
|
+ :rules="[
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: '请选择商品分类',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }
|
|
|
|
+ ]"
|
|
|
|
+ >
|
|
|
|
+ <el-select
|
|
|
|
+ v-model.trim="form.goodsList[scope.$index].goodsCategoryId"
|
|
|
|
+ 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="publishStatus" label="状态">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-tag :type="scope.row.publishStatus == 1 ? '' : 'danger'">
|
|
|
|
+ {{ scope.row.publishStatus ? "上架" : "下架" }}
|
|
|
|
+ </el-tag>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" prop="sn" label="操作">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-button
|
|
|
|
+ type="text"
|
|
|
|
+ @click.prevent="removeGoodsList(scope.row)"
|
|
|
|
+ :disabled="addDisabled"
|
|
|
|
+ >删除</el-button
|
|
|
|
+ >
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-form>
|
|
|
|
+ <span slot="footer" v-if="!addDisabled" class="dialog-footer">
|
|
|
|
+ <el-button @click="$listeners.close()">取 消</el-button>
|
|
|
|
+ <el-button @click="onShopSubmit('ruleForm')" type="primary"
|
|
|
|
+ >确 定</el-button
|
|
|
|
+ >
|
|
|
|
+ </span>
|
|
|
|
+
|
|
|
|
+ <el-dialog
|
|
|
|
+ title="添加子商品"
|
|
|
|
+ :visible.sync="recordStatus"
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
+ width="1200px"
|
|
|
|
+ append-to-body
|
|
|
|
+ v-if="recordStatus"
|
|
|
|
+ >
|
|
|
|
+ <subShopGoods
|
|
|
|
+ :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 cleanDeep from "clean-deep";
|
|
|
|
+import subShopGoods from "./subShopGoods.vue";
|
|
|
|
+let validPrice = (rule, value, callback) => {
|
|
|
|
+ if ((value == "" && typeof value == "string") || value == null) {
|
|
|
|
+ callback(new Error("请输入金额"));
|
|
|
|
+ } else if (value < 0) {
|
|
|
|
+ callback(new Error("输入金额必须大于或等于0"));
|
|
|
|
+ } else if (value >= 100000) {
|
|
|
|
+ callback(new Error("输入金额必须小于100000"));
|
|
|
|
+ } else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+let validStock = (rule, value, callback) => {
|
|
|
|
+ if ((value == "" && typeof value == "string") || value == null) {
|
|
|
|
+ callback(new Error("请输入库存"));
|
|
|
|
+ } else if (value < 0) {
|
|
|
|
+ callback(new Error("库存数量必须大于或等于0"));
|
|
|
|
+ } else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+export default {
|
|
|
|
+ props: [
|
|
|
|
+ "activeRow",
|
|
|
|
+ "addType",
|
|
|
|
+ "addDisabled",
|
|
|
|
+ "categoryList",
|
|
|
|
+ "selectGoodsList",
|
|
|
|
+ "tenantId",
|
|
|
|
+ "goodsBrand",
|
|
|
|
+ "goodsType"
|
|
|
|
+ ],
|
|
|
|
+ components: {
|
|
|
|
+ subShopGoods
|
|
|
|
+ },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ formLabelWidth: "160px",
|
|
|
|
+ form: {
|
|
|
|
+ goodsList: [],
|
|
|
|
+ studentShowOrganId: null,
|
|
|
|
+ educationShowOrganId: null,
|
|
|
|
+ courseFeeShowOrganId: null,
|
|
|
|
+ memberFeeShowOrganId: null,
|
|
|
|
+ freeFeeShowOrganId: null,
|
|
|
|
+ replacementShowOrganId: null
|
|
|
|
+ },
|
|
|
|
+ goodsTree: [], // 选择商品列表
|
|
|
|
+ rules: {
|
|
|
|
+ // replacementShow: [
|
|
|
|
+ // {
|
|
|
|
+ // required: true,
|
|
|
|
+ // message: "请选择是否参与置换",
|
|
|
|
+ // trigger: "change"
|
|
|
|
+ // }
|
|
|
|
+ // ],
|
|
|
|
+ },
|
|
|
|
+ goodsDetail: {},
|
|
|
|
+ recordStatus: false,
|
|
|
|
+ disabledIds: [] // 选中商品的编号
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ async mounted() {
|
|
|
|
+ if (this.addType !== "create") {
|
|
|
|
+ try {
|
|
|
|
+ const { data } = await api_goodsGet({ id: this.activeRow.id });
|
|
|
|
+ this.goodsDetail = data || {};
|
|
|
|
+ const row = this.goodsDetail;
|
|
|
|
+ let form = this.form;
|
|
|
|
+ for (let i in form) {
|
|
|
|
+ if (i === "brand") {
|
|
|
|
+ form[i] = Number(row[i]);
|
|
|
|
+ } else {
|
|
|
|
+ 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;
|
|
|
|
+ form.id = row.id;
|
|
|
|
+
|
|
|
|
+ if (row.studentShowOrganId) {
|
|
|
|
+ form.studentShowOrganId = row.studentShowOrganId.split(",");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (row.educationShowOrganId) {
|
|
|
|
+ form.educationShowOrganId = row.educationShowOrganId.split(",");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (row.courseFeeShowOrganId) {
|
|
|
|
+ form.courseFeeShowOrganId = row.courseFeeShowOrganId.split(",");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (row.memberFeeShowOrganId) {
|
|
|
|
+ form.memberFeeShowOrganId = row.memberFeeShowOrganId.split(",");
|
|
|
|
+ }
|
|
|
|
+ if (row.freeFeeShowOrganId) {
|
|
|
|
+ form.freeFeeShowOrganId = row.freeFeeShowOrganId.split(",");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (row.replacementShowOrganId) {
|
|
|
|
+ form.replacementShowOrganId = row.replacementShowOrganId.split(",");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (row.organIdList) {
|
|
|
|
+ form.organIdList = row.organIdList.split(",");
|
|
|
|
+ }
|
|
|
|
+ } catch (e) {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ async __init() {
|
|
|
|
+ let params = {
|
|
|
|
+ delFlag: 0,
|
|
|
|
+ rows: 9999
|
|
|
|
+ };
|
|
|
|
+ try {
|
|
|
|
+ const { data } = await api_queryGoodsCategoryList(params);
|
|
|
|
+ const result = data || [];
|
|
|
|
+ let tempArray = [];
|
|
|
|
+ result.forEach(row => {
|
|
|
|
+ let children = [];
|
|
|
|
+ if (row.children && row.children.length > 0) {
|
|
|
|
+ row.children.forEach(child => {
|
|
|
|
+ children.push({
|
|
|
|
+ label: child.name,
|
|
|
|
+ value: child.id
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tempArray.push({
|
|
|
|
+ label: row.name,
|
|
|
|
+ value: row.id,
|
|
|
|
+ children
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ this.categoryList = tempArray;
|
|
|
|
+ } catch {}
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ formatParentId(id, list, ids = []) {
|
|
|
|
+ for (const item of list) {
|
|
|
|
+ if (item.children) {
|
|
|
|
+ const cIds = this.formatParentId(id, item.children, [
|
|
|
|
+ ...ids,
|
|
|
|
+ item.value
|
|
|
|
+ ]);
|
|
|
|
+ if (cIds.includes(id)) {
|
|
|
|
+ return cIds;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (item.value === id) {
|
|
|
|
+ return [...ids, id];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return ids;
|
|
|
|
+ },
|
|
|
|
+ onShopSubmit(formName) {
|
|
|
|
+ if (this.form.goodsList.length <= 0) {
|
|
|
|
+ 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
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ 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;
|
|
|
|
+ if (this.addType == "create" || this.addType == "copy") {
|
|
|
|
+ if (this.form.id) {
|
|
|
|
+ // 判断有没有Id,如果有则删除
|
|
|
|
+ delete this.form.id;
|
|
|
|
+ }
|
|
|
|
+ form.status = "NO"; // 默认上架
|
|
|
|
+ goodsAdd(cleanDeep(form)).then(res => {
|
|
|
|
+ this.messageTips("保存", res);
|
|
|
|
+ });
|
|
|
|
+ } else if (this.addType == "update") {
|
|
|
|
+ goodsUpdate(cleanDeep(form)).then(res => {
|
|
|
|
+ this.messageTips("保存", res);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ let isError = document.getElementsByClassName("is-error");
|
|
|
|
+ isError[0].scrollIntoView({
|
|
|
|
+ block: "center",
|
|
|
|
+ behavior: "smooth"
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ messageTips(title, res) {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.$message.success(title + "成功");
|
|
|
|
+ this.$listeners.close();
|
|
|
|
+ this.$listeners.confirm();
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error(res.msg);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ removeGoodsList(item) {
|
|
|
|
+ this.$confirm("是否删除该商品?", "提示", {
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
+ type: "warning"
|
|
|
|
+ })
|
|
|
|
+ .then(() => {
|
|
|
|
+ const index = this.form.goodsList.indexOf(item);
|
|
|
|
+ if (index !== -1) {
|
|
|
|
+ this.form.goodsList.splice(index, 1);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
|
|
+ },
|
|
|
|
+ addGoodsList() {
|
|
|
|
+ const ids = [];
|
|
|
|
+ this.form.goodsList.forEach(goods => {
|
|
|
|
+ ids.push(goods.skuStockId);
|
|
|
|
+ });
|
|
|
|
+ this.disabledIds = ids;
|
|
|
|
+ this.recordStatus = true;
|
|
|
|
+ },
|
|
|
|
+ onFormClose(formName) {
|
|
|
|
+ // 关闭弹窗重置验证
|
|
|
|
+ this.$refs[formName].resetFields();
|
|
|
|
+ },
|
|
|
|
+ onConfirm(list) {
|
|
|
|
+ // 添加子商品
|
|
|
|
+ console.log(list);
|
|
|
|
+ const goodsList = [];
|
|
|
|
+ (list || []).forEach(item => {
|
|
|
|
+ const index = this.form.goodsList.findIndex(
|
|
|
|
+ goods => goods.skuStockId == item.skuStockId
|
|
|
|
+ );
|
|
|
|
+ if (index == -1) {
|
|
|
|
+ goodsList.push({
|
|
|
|
+ name: item.name,
|
|
|
|
+ goodsId: item.goodsId,
|
|
|
|
+ skuStockId: item.skuStockId,
|
|
|
|
+ skuCode: item.skuCode,
|
|
|
|
+ price: item.price,
|
|
|
|
+ publishStatus: item.publishStatus,
|
|
|
|
+ productSn: item.productSn,
|
|
|
|
+ goodsPrice: null // 成本
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.form.goodsList.push(...goodsList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+.alert {
|
|
|
|
+ margin-bottom: 16px;
|
|
|
|
+}
|
|
|
|
+.shopImage {
|
|
|
|
+ width: 60px;
|
|
|
|
+ height: 60px;
|
|
|
|
+}
|
|
|
|
+.shopDesc {
|
|
|
|
+ max-height: 70px;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.el-select__tags .el-tag.el-tag--info.el-tag--small.el-tag--light {
|
|
|
|
+ max-width: 95px;
|
|
|
|
+}
|
|
|
|
+.hiddenStart {
|
|
|
|
+ ::v-deep .el-form-item__label:before {
|
|
|
|
+ content: "" !important;
|
|
|
|
+ position: absolute;
|
|
|
|
+ color: transparent;
|
|
|
|
+ margin-right: 4px;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.dialog-footer {
|
|
|
|
+ display: block;
|
|
|
|
+ text-align: right;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.number-input {
|
|
|
|
+ ::v-deep .el-input__inner {
|
|
|
|
+ text-align: left;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+.tableItem {
|
|
|
|
+ margin-bottom: 0 !important;
|
|
|
|
+}
|
|
|
|
+</style>
|