lex преди 1 година
родител
ревизия
c227f9c68e

+ 110 - 62
src/api/businessManager.js

@@ -1,136 +1,184 @@
 // 通用设置api文件
-import request from '@/utils/request'
-import qs from 'qs'
-let api = '/api-web'
+import request from "@/utils/request";
+import request2 from "@/utils/request2";
+import qs from "qs";
+let api = "/api-web";
 // 分页查询商品(教材、辅件)列表
-export function goodsQuery (data) {
+export function goodsQuery(data) {
   return request({
-    url: api + '/goods/queryPage',
-    method: 'get',
+    url: api + "/goods/queryPage",
+    method: "get",
     params: data
-  })
+  });
 }
 
 // 根据商品(教材、辅件)编号查询商品(教材、辅件)
-export function goodsSingleQuery (data) {
+export function goodsSingleQuery(data) {
   return request({
     url: api + `/goods/get/${data}`,
-    method: 'get'
-  })
+    method: "get"
+  });
 }
 
 // 修改上架下架状态
-export function updateGoodsStatus (data) {
+export function updateGoodsStatus(data) {
   return request({
     url: api + `/goods/updateGoodsStatus`,
-    method: 'post',
+    method: "post",
     data: qs.stringify(data)
-  })
+  });
 }
 
 // 新增商品(教材、辅件)
-export function goodsAdd (data) {
+export function goodsAdd(data) {
   return request({
-    url: api + '/goods/add',
-    method: 'post',
-    data: qs.stringify(data)
-  })
+    url: api + "/goods/add",
+    method: "post",
+    data: data
+  });
 }
 
 // 修改商品(教材、辅件)
-export function goodsUpdate (data) {
+export function goodsUpdate(data) {
   return request({
-    url: api + '/goods/update',
-    method: 'post',
-    data: qs.stringify(data)
-  })
+    url: api + "/goods/update",
+    method: "post",
+    data: data
+  });
 }
 
 // 删除商品(教材、辅件)
-export function goodsDelete (data) {
+export function goodsDelete(data) {
   return request({
     url: api + `/goods/del/${data}`,
-    method: 'post'
-  })
+    method: "post"
+  });
 }
 
 // 参数列表
-export function categoryListTree (data) {
+export function categoryListTree(data) {
   return request({
-    url: api + '/category/queryPage',
-    method: 'get',
+    url: api + "/category/queryPage",
+    method: "get",
     params: data
-  })
+  });
 }
 
 // 新增、修改商品类型
-export function categoryUpSet (data) {
+export function categoryUpSet(data) {
   return request({
-    url: api + '/category/upset',
-    method: 'post',
+    url: api + "/category/upset",
+    method: "post",
     data: data
-  })
+  });
 }
 
 // 删除商品分类
-export function categoryUpSetDel (data) {
+export function categoryUpSetDel(data) {
   return request({
     url: api + `/category/del`,
-    method: 'post',
+    method: "post",
     data: qs.stringify(data)
-  })
+  });
 }
 
 // 更换列表
-export function getSubjectChangeList (data) {
+export function getSubjectChangeList(data) {
   return request({
-    url: api + '/subjectChange/queryPage',
-    method: 'get',
+    url: api + "/subjectChange/queryPage",
+    method: "get",
     params: data
-  })
+  });
 }
 // 更新成本差
-export function updateCostMargin (data) {
+export function updateCostMargin(data) {
   return request({
     url: api + `/subjectChange/updateCostMargin`,
-    method: 'post',
+    method: "post",
     data: qs.stringify(data)
-  })
+  });
 }
 // 进货清单
-export function getGoodsProcurements (data) {
+export function getGoodsProcurements(data) {
   return request({
-    url: api + '/goodsProcurement/queryGoodsProcurements',
-    method: 'get',
+    url: api + "/goodsProcurement/queryGoodsProcurements",
+    method: "get",
     params: data
-  })
+  });
 }
 // 添加进货清单
 
-export function createGoodsProcurements (data) {
+export function createGoodsProcurements(data) {
   return request({
-    url: api + '/goods/addGoodsProcurement',
-    method: 'post',
+    url: api + "/goods/addGoodsProcurement",
+    method: "post",
     params: data
-  })
+  });
 }
 
-
 // 获取新课表列表
-export function getCourseSchedule (data) {
+export function getCourseSchedule(data) {
   return request({
-    url: api + '/swTempJc/queryPageForCourseSchedule',
-    method: 'get',
+    url: api + "/swTempJc/queryPageForCourseSchedule",
+    method: "get",
     params: data
-  })
+  });
 }
 
-
 // 新订单列表
-export function getOrderPage (data) {
+export function getOrderPage(data) {
   return request({
-    url: api + '/swTempJc/queryPageForExtensionOrder',
-    method: 'get',
+    url: api + "/swTempJc/queryPageForExtensionOrder",
+    method: "get",
     params: data
-  })
+  });
+}
+
+// 查询商城商品
+export function api_queryGoodsSubByPage(data) {
+  return request2({
+    url: api + `/goods/queryGoodsSubByPage`,
+    method: "GET",
+    params: data,
+    data: {}
+  });
+}
+
+// 查询商品类型
+export function api_queryGoodsTypeList(data) {
+  return request2({
+    url: api + `/goods/queryGoodsTypeList`,
+    method: "GET",
+    params: data,
+    data: {}
+  });
+}
+
+// 查询商品分类
+export function api_queryGoodsCategoryList(data) {
+  return request2({
+    url: api + `/goods/queryGoodsCategoryList`,
+    method: "GET",
+    params: data,
+    data: {}
+  });
+}
+
+// 查询商品品牌
+export function api_queryGoodsBrandList(data) {
+  return request2({
+    url: api + `/goods/queryGoodsBrandList`,
+    method: "GET",
+    params: data,
+    data: {}
+  });
+}
+
+// 查询商品详情
+export function api_goodsGet(data) {
+  return request2({
+    url: api + `/goods/get/` + data.id,
+    method: "GET",
+    data: {}
+  });
 }

+ 247 - 112
src/views/businessManager/shopManager/model/combinationProducts.vue

@@ -1,6 +1,79 @@
 <template>
   <div>
     <el-form :model="form" :rules="rules" ref="ruleForm" :inline="true">
+      <el-alert
+        title="子商品信息"
+        :closable="false"
+        class="alert"
+        type="info"
+      />
+      <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="price" label="销售价格">
+        </el-table-column>
+        <el-table-column align="center" prop="skuStockId" label="sku编号">
+        </el-table-column>
+        <el-table-column align="center" prop="sn" label="成本">
+          <template slot-scope="scope">
+            <el-form-item
+              :show-message="false"
+              class="tableItem"
+              :prop="'goodsList.' + scope.$index + '.goodsPrice'"
+              :rules="[
+                {
+                  required: true,
+                  message: '请输入成本',
+                  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="sn" 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)"
+              >删除</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-button
+        icon="el-icon-circle-plus-outline"
+        plain
+        type="info"
+        style="width: 100%;margin: 20px 0;"
+        @click="addGoodsList"
+        :disabled="addDisabled"
+        >添加子商品</el-button
+      >
       <el-alert title="基础信息" :closable="false" class="alert" type="info" />
       <el-form-item label="商品名称" prop="name" :label-width="formLabelWidth">
         <el-input
@@ -21,28 +94,20 @@
         ></el-input>
       </el-form-item>
       <el-form-item label="品牌" prop="brand" :label-width="formLabelWidth">
-        <el-input
-          style="width: 220px !important"
+        <el-select
           v-model.trim="form.brand"
           :disabled="addDisabled"
-          placeholder="请输入品牌"
-        ></el-input>
+          style="width: 220px !important"
+          placeholder="请选择品牌"
+        >
+          <el-option
+            v-for="(item, index) in goodsBrand"
+            :key="index"
+            :label="item.label"
+            :value="item.value"
+          ></el-option>
+        </el-select>
       </el-form-item>
-      <!-- <el-form-item label="所属分部" :label-width="formLabelWidth" prop="organIdList">
-          <select-all v-model.trim="form.organIdList"
-                     filterable
-                     placeholder="请选择所属分部"
-                     style="width: 100% !important"
-                     multiple
-                     :disabled="addDisabled || addType == 'update'"
-                     @change="onOrganChange"
-                     clearable>
-            <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="type" :label-width="formLabelWidth">
         <el-select
           v-model.trim="form.type"
@@ -92,7 +157,7 @@
         ></el-input>
       </el-form-item>
 
-      <div v-for="(goodsList, index) in form.goodsList" :key="index">
+      <!-- <div v-for="(goodsList, index) in form.goodsList" :key="index">
         <el-form-item
           :label="'商品' + (index + 1)"
           :label-width="formLabelWidth"
@@ -133,7 +198,7 @@
             style="margin-left: 5px"
           ></el-button>
         </div>
-      </div>
+      </div> -->
       <el-alert title="价格信息" :closable="false" class="alert" type="info" />
       <el-form-item
         label="市场价"
@@ -384,11 +449,28 @@
       </el-form-item>
     </el-form>
     <span slot="footer" v-if="!addDisabled" class="dialog-footer">
-      <el-button @click="routeShopStatus = false">取 消</el-button>
+      <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>
@@ -397,12 +479,13 @@ import {
   goodsQuery,
   goodsAdd,
   goodsUpdate,
+  api_goodsGet,
   goodsDelete,
   updateGoodsStatus
 } from "@/api/businessManager";
 import cleanDeep from "clean-deep";
 import ImageCropper from "@/components/ImageCropper";
-import { goodsType } from "@/utils/searchArray";
+import subShopGoods from "./subShopGoods.vue";
 let validPrice = (rule, value, callback) => {
   if ((value == "" && typeof value == "string") || value == null) {
     callback(new Error("请输入金额"));
@@ -424,13 +507,22 @@ let validStock = (rule, value, callback) => {
   }
 };
 export default {
-  props: ["addDisabled", "categoryList", "selectGoodsList", "tenantId"],
+  props: [
+    "activeRow",
+    "addType",
+    "addDisabled",
+    "categoryList",
+    "selectGoodsList",
+    "tenantId",
+    "goodsBrand",
+    "goodsType"
+  ],
   components: {
-    ImageCropper
+    ImageCropper,
+    subShopGoods
   },
   data() {
     return {
-      goodsType: goodsType,
       formLabelWidth: "160px",
       form: {
         sn: null,
@@ -451,11 +543,7 @@ export default {
         stockWarning: null,
         image: null,
         complementGoodsIdList: null,
-        goodsList: [
-          {
-            id: null
-          }
-        ],
+        goodsList: [],
         brief: null,
         desc: null,
         replacementShow: null,
@@ -480,12 +568,6 @@ export default {
             required: true,
             message: "请输入品牌",
             trigger: "blur"
-          },
-          {
-            min: 2,
-            max: 30,
-            message: "长度在 2 到 30 个字符",
-            trigger: "blur"
           }
         ],
         supplyChannel: [
@@ -522,13 +604,13 @@ export default {
             trigger: "change"
           }
         ],
-        goodsCategoryId: [
-          {
-            required: true,
-            message: "请选择商品类型",
-            trigger: "change"
-          }
-        ],
+        // goodsCategoryId: [
+        //   {
+        //     required: true,
+        //     message: "请选择商品类型",
+        //     trigger: "change"
+        //   }
+        // ],
         specification: [
           {
             required: true,
@@ -623,6 +705,7 @@ export default {
           }
         ]
       },
+      goodsDetail: {},
       cropperOptions: {
         autoCrop: true, //是否默认生成截图框
         autoCropWidth: 300, //默认生成截图框宽度
@@ -630,24 +713,97 @@ export default {
         fixedBox: true, //是否固定截图框大小 不允许改变
         previewsCircle: false, //预览图是否是圆形
         title: "商品图片" //模态框上显示的标题
-      }
+      },
+      recordStatus: false,
+      disabledIds: [] // 选中商品的编号
     };
   },
-  mounted() {},
+  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];
+          }
+        }
+        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.courseViewType) {
+          form.courseViewType = row.courseViewType.split(",");
+        }
+
+        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 {
+        //
+      }
+    }
+  },
   methods: {
     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 tempIds = [];
+          let temps = [];
           form.goodsList.forEach(item => {
-            if (item.id) {
-              tempIds.push(item.id);
+            if (item.skuStockId) {
+              temps.push({
+                mallGoodsId: item.goodsId,
+                sku: item.skuStockId,
+                goodsStatus: item.publishStatus,
+                goodsPrice: item.goodsPrice
+              });
             }
           });
-          form.complementGoodsIdList = tempIds.join(",");
-          // form.courseViewType = form.courseViewType.join(",");
-          // form.organIdList = form.courseViewType.join(",");
+          form.goodsSubList = temps;
           if (form.studentShowOrganId) {
             form.studentShowOrganId = form.studentShowOrganId.join(",");
           }
@@ -707,77 +863,25 @@ export default {
     messageTips(title, res) {
       if (res.code == 200) {
         this.$message.success(title + "成功");
-        this.getList();
-        this.routeShopStatus = false;
+        this.$listeners.close();
+        this.$listeners.confirm();
       } else {
         this.$message.error(res.msg);
       }
     },
-    onGoodsChange() {
-      let selectGoodsList = this.selectGoodsList;
-      let goodsList = this.form.goodsList;
-      let tempIds = [];
-      goodsList.forEach(item => {
-        if (item.id) {
-          tempIds.push(item.id);
-        }
-      });
-      selectGoodsList.forEach(item => {
-        if (tempIds.includes(item.id)) {
-          item.disabled = true;
-        } else {
-          item.disabled = false;
-        }
-      });
-
-      this.calcPrice();
-    },
     removeGoodsList(item) {
-      let tempId = item.id;
-      let selectGoodsList = this.selectGoodsList;
-      selectGoodsList.forEach(item => {
-        if (item.id == tempId) {
-          item.disabled = false;
-        }
-      });
-
       const index = this.form.goodsList.indexOf(item);
       if (index !== -1) {
         this.form.goodsList.splice(index, 1);
       }
-
-      this.calcPrice();
     },
     addGoodsList() {
-      this.form.goodsList.push({
-        id: null
-      });
-    },
-
-    calcPrice() {
-      let selectGoodsList = this.selectGoodsList;
-      let form = this.form;
-      let goodsList = form.goodsList;
-      let tempIds = [];
-      goodsList.forEach(item => {
-        if (item.id) {
-          tempIds.push(item.id);
-        }
-      });
-      let groupPurchasePrice = 0,
-        marketPrice = 0,
-        discountPrice = 0;
-      selectGoodsList.forEach(item => {
-        if (tempIds.includes(item.id)) {
-          groupPurchasePrice += item.groupPurchasePrice;
-          marketPrice += item.marketPrice;
-          discountPrice += item.discountPrice;
-        }
+      const ids = [];
+      this.form.goodsList.forEach(goods => {
+        ids.push(goods.skuStockId);
       });
-
-      form.groupPurchasePrice = Number(groupPurchasePrice.toFixed(2));
-      form.discountPrice = Number(discountPrice.toFixed(2));
-      form.marketPrice = Number(marketPrice.toFixed(2));
+      this.disabledIds = ids;
+      this.recordStatus = true;
     },
     onFormClose(formName) {
       // 关闭弹窗重置验证
@@ -785,13 +889,35 @@ export default {
     },
     cropSuccess(data) {
       this.form.image = data.data.url;
+    },
+    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,
+            price: item.price,
+            publishStatus: item.publishStatus,
+            productSn: item.productSn,
+            goodsPrice: null // 成本
+          });
+        }
+      });
+      this.form.goodsList.push(...goodsList);
     }
   }
 };
 </script>
 <style lang="scss" scoped>
 .alert {
-  margin-bottom: 22px;
+  margin-bottom: 16px;
 }
 .shopImage {
   width: 60px;
@@ -818,4 +944,13 @@ export default {
   display: block;
   text-align: right;
 }
+
+.number-input {
+  ::v-deep .el-input__inner {
+    text-align: left;
+  }
+}
+.tableItem {
+  margin-bottom: 0 !important;
+}
 </style>

+ 270 - 0
src/views/businessManager/shopManager/model/subShopGoods.vue

@@ -0,0 +1,270 @@
+<!--  -->
+<template>
+  <div>
+    <save-form
+      :inline="true"
+      class="searchForm"
+      ref="searchForm"
+      @submit="onSearch"
+      @reset="onReset"
+      :model="searchForm"
+      save-key="subShopGoods"
+    >
+      <el-form-item prop="keyword">
+        <el-input
+          v-model.trim="searchForm.keyword"
+          clearable
+          placeholder="商品名称"
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="productSn">
+        <el-input
+          v-model.trim="searchForm.productSn"
+          clearable
+          placeholder="商品货号"
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="productCategoryId">
+        <el-select
+          v-model.trim="searchForm.productCategoryId"
+          clearable
+          placeholder="商品分类"
+        >
+          <el-option
+            v-for="item in categoryList"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value"
+          >
+          </el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item prop="brandId">
+        <el-select
+          v-model.trim="searchForm.brandId"
+          clearable
+          placeholder="商品品牌"
+        >
+          <el-option
+            v-for="(item, index) in goodsBrand"
+            :key="index"
+            :label="item.label"
+            :value="item.value"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item prop="publishStatus">
+        <el-select
+          v-model.trim="searchForm.publishStatus"
+          clearable
+          placeholder="上架状态"
+        >
+          <el-option label="上架" :value="1"></el-option>
+          <el-option label="下架" :value="0"></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="danger" native-type="submit">搜索</el-button>
+        <el-button type="primary" native-type="reset">重置</el-button>
+      </el-form-item>
+    </save-form>
+    <div class="tableWrap">
+      <el-table
+        :data="tableList"
+        :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
+        @selection-change="handleSelectionChange"
+        @select="onTableSelect"
+        ref="multipleSelection"
+      >
+        <el-table-column
+          type="selection"
+          width="55"
+          :selectable="onSelectable"
+        ></el-table-column>
+        <el-table-column
+          align="center"
+          prop="name"
+          label="商品名称"
+          width="200px"
+        >
+          <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="brandName" label="品牌">
+        </el-table-column>
+        <el-table-column align="center" prop="skuStockId" label="sku编号">
+        </el-table-column>
+        <el-table-column align="center" prop="price" label="销售价格">
+        </el-table-column>
+        <el-table-column align="center" prop="stock" label="剩余库存">
+        </el-table-column>
+        <el-table-column align="center" prop="sn" label="采购价">
+        </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>
+      <pagination
+        sync
+        save-key="subShopGoods"
+        :total.sync="pageInfo.total"
+        :page.sync="pageInfo.page"
+        :limit.sync="pageInfo.limit"
+        :page-sizes="pageInfo.page_size"
+        @pagination="getList"
+      />
+    </div>
+    <div class="dialog-footer">
+      <el-button @click="onClose()">取 消</el-button>
+      <el-button type="primary" @click="onSubmit()">确 定</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+import pagination from "@/components/Pagination/index";
+import { api_queryGoodsSubByPage } from "@/api/businessManager";
+export default {
+  props: ["disabledIds", "categoryList", "goodsBrand"],
+  components: {
+    pagination
+  },
+  data() {
+    return {
+      pageInfo: {
+        // 分页规则
+        limit: 10, // 限制显示条数
+        page: 1, // 当前页
+        total: 0, // 总条数
+        page_size: [10, 20, 40, 50] // 选择限制显示条数
+      },
+      searchForm: {
+        keyword: null,
+        productSn: null,
+        publishStatus: null,
+        productCategoryId: null,
+        brandId: null
+      },
+      tableList: [],
+      isNewPage: false,
+      selectList: []
+    };
+  },
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {
+    console.log(this.employeeInfoId);
+    this.getList();
+  },
+  methods: {
+    getList() {
+      let params = Object.assign({}, this.searchForm);
+      // params.organId = this.organId;
+      params.rows = this.pageInfo.limit;
+      params.page = this.pageInfo.page;
+      api_queryGoodsSubByPage(params).then(res => {
+        if (res.code == 200 && res.data) {
+          this.tableList = res.data.rows;
+          this.pageInfo.total = res.data.total;
+
+          let idList = this.selectList.map(group => {
+            return group.skuStockId;
+          });
+          this.isNewPage = true;
+          this.$nextTick(() => {
+            this.tableList.forEach(course => {
+              if (idList.indexOf(course.skuStockId) != -1) {
+                this.$refs.multipleSelection.toggleRowSelection(course, true);
+              }
+            });
+            this.isNewPage = false;
+          });
+        }
+      });
+    },
+    onSearch() {
+      this.pageInfo.page = 1;
+      this.getList();
+    },
+    onReset() {
+      // 重置
+      this.$refs.searchForm.resetFields();
+      this.getList();
+    },
+    onClose() {
+      this.$listeners.close();
+    },
+    onSubmit() {
+      console.log(this.selectList, "Select");
+      this.$listeners.comfirm(this.selectList);
+      this.onClose();
+    },
+    onSelectable(row) {
+      return !this.disabledIds.includes(row.skuStockId);
+    },
+    handleSelectionChange(arr) {
+      if (arr.length > 0) {
+        // 有可能加 有可能减
+        this.selectList = this.selectList.concat(arr);
+        // 去重
+        this.selectList = this.$helpers.lodash.uniqBy(
+          this.selectList,
+          "skuStockId"
+        );
+      }
+      // else if(){}
+      else {
+        if (this.isNewPage) return;
+        // 有2种 1是新页
+        // 2是点击反选
+        let idList = this.selectList.map(course => {
+          return course.skuStockId;
+        });
+        this.$nextTick(() => {
+          let tableIdList = [];
+          this.tableList.forEach(course => {
+            tableIdList.push(course.skuStockId);
+            if (idList.indexOf(course.skuStockId) != -1) {
+              this.$refs.tableList.toggleRowSelection(course, false);
+              // 删除这个元素
+            }
+          });
+          this.selectList = this.$helpers.lodash.remove(
+            this.selectList,
+            function(item) {
+              return tableIdList.indexOf(item.skuStockId) == -1;
+            }
+          );
+          if (this.selectList.length <= 0) {
+            this.clearCom();
+          }
+        });
+      }
+    },
+    onTableSelect(rows, row) {
+      let idList = this.selectList.map(course => {
+        return course.skuStockId;
+      });
+      if (idList.indexOf(row.skuStockId) != -1) {
+        this.selectList.splice(idList.indexOf(row.skuStockId), 1);
+        if (this.selectList.length <= 0) {
+          this.clearCom();
+        }
+      }
+    }
+  }
+};
+</script>
+<style lang="less" scoped>
+.dialog-footer {
+  padding-top: 20px;
+  width: 100%;
+  text-align: center;
+}
+</style>

+ 189 - 142
src/views/businessManager/shopManager/shopList.vue

@@ -171,6 +171,20 @@
             ></el-option>
           </el-select>
         </el-form-item>
+        <el-form-item prop="brandId">
+          <el-select
+            v-model.trim="searchForm.brandId"
+            clearable
+            placeholder="商品品牌"
+          >
+            <el-option
+              v-for="(item, index) in goodsBrand"
+              :key="index"
+              :label="item.label"
+              :value="item.value"
+            ></el-option>
+          </el-select>
+        </el-form-item>
         <el-form-item prop="status">
           <el-select
             v-model.trim="searchForm.status"
@@ -206,7 +220,7 @@
           </el-table-column>
           <el-table-column align="center" prop="sn" label="货号">
           </el-table-column>
-          <el-table-column align="center" prop="brand" label="品牌">
+          <el-table-column align="center" prop="brandName" label="品牌">
           </el-table-column>
           <el-table-column
             align="center"
@@ -282,24 +296,13 @@
               }}</span>
             </template>
           </el-table-column>
-          <el-table-column
-            align="center"
-            prop="stockCount"
-            label="内部库存"
-            v-if="tenantId == 1"
-            :key="Math.random()"
-          >
+          <el-table-column align="center" prop="stockCount" label="库存">
             <template slot-scope="scope">
-              <!-- 先判断是否是组合商品 -->
-              <span v-if="scope.row.complementGoodsIdList">
-                {{ scope.row.stockCount ? scope.row.stockCount : "" }}
-              </span>
-              <span v-else>{{ scope.row.stockCount }}</span>
+              <span>{{ scope.row.stockCount }}</span>
             </template>
           </el-table-column>
-          <el-table-column align="center" prop="taxStockCount" label="税务库存">
+          <!-- <el-table-column align="center" prop="taxStockCount" label="税务库存">
             <template slot-scope="scope">
-              <!-- 先判断是否是组合商品 -->
               <span v-if="scope.row.complementGoodsIdList">
                 {{ scope.row.taxStockCount ? scope.row.taxStockCount : "" }}
               </span>
@@ -316,7 +319,7 @@
             <template slot-scope="scope">
               {{ scope.row.stockType | stockTypeStatus }}
             </template>
-          </el-table-column>
+          </el-table-column> -->
           <el-table-column align="center" prop="marketPrice" label="市场价(元)">
             <template slot-scope="scope">
               {{ scope.row.marketPrice | moneyFormat }}
@@ -426,12 +429,12 @@
                 >查看</el-button
               >
 
-              <el-button
+              <!-- <el-button
                 v-if="permission('/shopOperation/copyShop')"
                 @click="onShopOperation('copy', scope.row)"
                 type="text"
                 >复制</el-button
-              >
+              > -->
               <!-- <el-button v-if="scope.row.status == 0"
                          v-permission="'goods/del'"
                          @click="onDelete(scope.row)"
@@ -458,10 +461,16 @@
       width="1000px"
     >
       <combinationProducts
+        :activeRow="activeRow"
+        :addType="addType"
         :addDisabled="addDisabled"
         :categoryList="categoryList"
+        :goodsBrand="goodsBrand"
+        :goodsType="goodsType"
         :selectGoodsList="selectGoodsList"
         :tenantId="tenantId"
+        @close="routeShopStatus = false"
+        @confirm="getList"
       />
     </el-dialog>
   </div>
@@ -476,14 +485,17 @@ import {
   goodsAdd,
   goodsUpdate,
   goodsDelete,
-  updateGoodsStatus
+  updateGoodsStatus,
+  api_queryGoodsTypeList,
+  api_queryGoodsCategoryList,
+  api_queryGoodsBrandList
 } from "@/api/businessManager";
+import { goodsType } from "@/utils/searchArray";
 import qs from "qs";
 import cleanDeep from "clean-deep";
 import Tooltip from "@/components/Tooltip/index";
 import { Export } from "@/utils/downLoadFile";
 import { getToken, getTenantId } from "@/utils/auth";
-import { goodsType } from "@/utils/searchArray";
 import load from "@/utils/loading";
 import { permission } from "@/utils/directivePage";
 
@@ -499,8 +511,9 @@ export default {
   name: "shopList",
   data() {
     return {
-      goodsType: goodsType,
+      goodsType: goodsType || [], // 商品类型
       categoryList: [],
+      goodsBrand: [], // 商品品牌
       goodsLoading: false,
       organId: null,
       orderDate: null,
@@ -524,7 +537,8 @@ export default {
         memberFeeShowOrganId: null,
         freeFeeShowOrganId: null,
         replacementShowOrganId: null,
-        studentShowOrganId: null
+        studentShowOrganId: null,
+        brandId: null
       },
       headers: {
         Authorization: getToken(),
@@ -549,7 +563,7 @@ export default {
         copy: "复制"
       },
       addDisabled: false,
-
+      activeRow: {},
       selectGoodsList: [],
       tenantId: ""
     };
@@ -567,25 +581,60 @@ export default {
     init() {
       this.getList();
       this.getCategory();
+      // this.getGoodsType();
+      this.getGoodsBrand();
     },
-    getCategory() {
+    /** 商品分类 */
+    async getCategory() {
       let params = {
-        delFlag: 0,
+        // delFlag: 0,
         rows: 9999
       };
-      categoryListTree(params).then(res => {
-        let result = res.data;
-        if (res.code == 200) {
-          let tempArray = [];
-          result.rows.forEach(row => {
-            tempArray.push({
-              label: row.name,
-              value: row.id
-            });
+      try {
+        const { data } = await api_queryGoodsCategoryList(params);
+        console.log(data, "data");
+        const result = data || [];
+        let tempArray = [];
+        result.forEach(row => {
+          tempArray.push({
+            label: row.name,
+            value: row.id
           });
-          this.categoryList = tempArray;
-        }
-      });
+        });
+        this.categoryList = tempArray;
+      } catch {}
+    },
+    /** 商品类型 */
+    async getGoodsType() {
+      try {
+        const { data } = await api_queryGoodsTypeList({ rows: 999 });
+        console.log(data, "getGoodsType");
+        const result = data || [];
+        let tempArray = [];
+        result.forEach(row => {
+          tempArray.push({
+            label: row.name,
+            value: row.id
+          });
+        });
+        this.goodsType = tempArray;
+      } catch {}
+    },
+    /** 商品品牌 */
+    async getGoodsBrand() {
+      try {
+        const { data } = await api_queryGoodsBrandList({ rows: 999 });
+        console.log(data, "getGoodsBrand");
+        const result = data || [];
+        let tempArray = [];
+        result.forEach(row => {
+          tempArray.push({
+            label: row.name,
+            value: row.id
+          });
+        });
+        this.goodsBrand = tempArray;
+      } catch {}
     },
     async onUpdate(row, type) {
       let title = type == 1 ? "你是否下架该商品?" : "你是否上架该商品?";
@@ -680,44 +729,44 @@ export default {
       this.getList();
     },
     onShopComAdd() {
-      this.form = {
-        sn: null,
-        brand: null,
-        supplyChannel: null,
-        name: null,
-        type: null,
-        goodsCategoryId: null,
-        specification: null,
-        marketPrice: null,
-        discountPrice: null,
-        groupPurchasePrice: null,
-        clientShow: null,
-        educationalShow: null,
-        musicGroupShow: null,
-        organIdList: [],
-        courseViewType: [],
-        stockWarning: null,
-        image: null,
-        complementGoodsIdList: null,
-        goodsList: [
-          {
-            id: null
-          }
-        ],
-        brief: null,
-        desc: null,
-        replacementShow: null
-      };
-      this.onValidGoodsStatus();
-      this.routeShopStatus = true;
+      // this.form = {
+      //   sn: null,
+      //   brand: null,
+      //   supplyChannel: null,
+      //   name: null,
+      //   type: null,
+      //   goodsCategoryId: null,
+      //   specification: null,
+      //   marketPrice: null,
+      //   discountPrice: null,
+      //   groupPurchasePrice: null,
+      //   clientShow: null,
+      //   educationalShow: null,
+      //   musicGroupShow: null,
+      //   organIdList: [],
+      //   courseViewType: [],
+      //   stockWarning: null,
+      //   image: null,
+      //   complementGoodsIdList: null,
+      //   goodsList: [
+      //     {
+      //       id: null
+      //     }
+      //   ],
+      //   brief: null,
+      //   desc: null,
+      //   replacementShow: null
+      // };
+      // this.onValidGoodsStatus();
       this.addType = "create";
       this.addDisabled = false;
+      this.routeShopStatus = true;
 
-      this.$nextTick(res => {
-        if (this.$refs["ruleForm"]) {
-          this.$refs["ruleForm"].resetFields();
-        }
-      });
+      // this.$nextTick(res => {
+      //   if (this.$refs["ruleForm"]) {
+      //     this.$refs["ruleForm"].resetFields();
+      //   }
+      // });
     },
     onOrganChange(val) {
       if (val && val.length > 0) {
@@ -743,92 +792,90 @@ export default {
     },
     onShopOperation(type, row) {
       // 添加或修改
-
-      let params = {
-        type: type
-      };
-      if (row) {
-        params.id = row.id;
-      }
-      let paramInfo = JSON.stringify(params);
+      // let params = {
+      //   type: type
+      // };
+      // if (row) {
+      //   params.id = row.id;
+      // }
+      // let paramInfo = JSON.stringify(params);
       this.addType = type;
       this.addDisabled = type == "look" ? true : false;
       // 判断是否是修改组合商品
-      if (
-        (type == "update" || type == "look" || type == "copy") &&
-        row.complementGoodsIdList
-      ) {
-        this.routeShopStatus = true;
-
-        let form = this.form;
-        for (let i in form) {
-          form[i] = row[i];
-        }
-        let ids = row.complementGoodsIdList.split(",");
-        let goodsList = [];
-        ids.forEach(item => {
-          goodsList.push({
-            id: Number(item)
-          });
-        });
-        form.goodsList = goodsList;
-        form.id = row.id;
+      if (type == "update" || type == "look" || type == "copy") {
+        this.activeRow = row;
+        // let form = this.form;
+        // for (let i in form) {
+        //   form[i] = row[i];
+        // }
+        // let ids = row.complementGoodsIdList.split(",");
+        // let goodsList = [];
+        // ids.forEach(item => {
+        //   goodsList.push({
+        //     id: Number(item)
+        //   });
+        // });
+        // form.goodsList = goodsList;
+        // form.id = row.id;
 
-        if (row.courseViewType) {
-          form.courseViewType = row.courseViewType.split(",");
-        }
+        // if (row.courseViewType) {
+        //   form.courseViewType = row.courseViewType.split(",");
+        // }
 
-        if (row.studentShowOrganId) {
-          form.studentShowOrganId = row.studentShowOrganId.split(",");
-        }
+        // if (row.studentShowOrganId) {
+        //   form.studentShowOrganId = row.studentShowOrganId.split(",");
+        // }
 
-        if (row.educationShowOrganId) {
-          form.educationShowOrganId = row.educationShowOrganId.split(",");
-        }
+        // if (row.educationShowOrganId) {
+        //   form.educationShowOrganId = row.educationShowOrganId.split(",");
+        // }
 
-        if (row.courseFeeShowOrganId) {
-          form.courseFeeShowOrganId = row.courseFeeShowOrganId.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.memberFeeShowOrganId) {
+        //   form.memberFeeShowOrganId = row.memberFeeShowOrganId.split(",");
+        // }
+        // if (row.freeFeeShowOrganId) {
+        //   form.freeFeeShowOrganId = row.freeFeeShowOrganId.split(",");
+        // }
 
-        if (row.replacementShowOrganId) {
-          form.replacementShowOrganId = row.replacementShowOrganId.split(",");
-        }
+        // if (row.replacementShowOrganId) {
+        //   form.replacementShowOrganId = row.replacementShowOrganId.split(",");
+        // }
 
         // if (row.organIdList) {
         //   form.organIdList = row.organIdList.split(",");
 
         // }
-        this.getAllGoodsList();
+        // this.getAllGoodsList();
 
-        this.onValidGoodsStatus();
-      } else {
-        let pageTitle = "添加";
-        if (type == "update") {
-          pageTitle = "修改";
-        } else if (type == "look") {
-          pageTitle = "查看";
-        } else if (type == "copy") {
-          pageTitle = "复制";
-        }
-        this.$router.push(
-          {
-            path: "/shopManager/shopOperation",
-            query: {
-              paramInfo
-            }
-          },
-          route => {
-            route.meta.title = pageTitle + "商品";
-          }
-        );
+        // this.onValidGoodsStatus();
+
+        this.routeShopStatus = true;
       }
+      //  else {
+      //   let pageTitle = "添加";
+      //   if (type == "update") {
+      //     pageTitle = "修改";
+      //   } else if (type == "look") {
+      //     pageTitle = "查看";
+      //   } else if (type == "copy") {
+      //     pageTitle = "复制";
+      //   }
+      //   this.$router.push(
+      //     {
+      //       path: "/shopManager/shopOperation",
+      //       query: {
+      //         paramInfo
+      //       }
+      //     },
+      //     route => {
+      //       route.meta.title = pageTitle + "商品";
+      //     }
+      //   );
+      // }
     },
     beforeUpload(file) {
       // console.log(file.type)

+ 2 - 2
vue.config.js

@@ -18,8 +18,8 @@ const name = defaultSettings.title || "管乐迷后台管理系统"; // page tit
 // let target = "https://online.dayaedu.com"; //线上
 // let target = 'http://192.168.3.20:8000' //邹璇
 // let target = "http://192.168.0.127:8000"; //勇哥
-// let target = "http://192.168.3.14:8005"; // 原谅
-let target = "https://dev.dayaedu.com"; //测试环境
+let target = "http://192.168.3.14:8000"; // 原谅
+// let target = "https://dev.dayaedu.com"; //测试环境
 // All configuration item explanations can be find in https://cli.vuejs.org/config/
 module.exports = {
   /**