Procházet zdrojové kódy

商品复制完成

谢杰标 před 2 roky
rodič
revize
7836b918dc

+ 17 - 0
src/api/resource/good.js

@@ -9,6 +9,22 @@ export function getSpecList(query) {
     })
 }
 
+// 企业列表
+export function getTenantList(query) {
+    return request({
+        url: '/common/tenant/list',
+        method: 'get',
+        params: query
+    })
+}
+// 商品复制
+export function goodsCopy(data) {
+    return request({
+        url: `/goods/batch/copy/add`,
+        method: 'post',
+        data
+    })
+}
 
 // 新增或修改模板
 export function changeSpec(data) {
@@ -79,6 +95,7 @@ export function goodsDel(data) {
         data
     })
 }
+
 // 商品取消绑定规格模板
 export function goodCancelBind(data) {
     return request({

+ 137 - 32
src/views/Marketing/goods/commodityManageMent/index.vue

@@ -1,49 +1,114 @@
 <template>
   <div id="commodityManageMent">
-    <search-box-new ref="searchBox" :formData="formData" :formList="formList" @search="search" @init="init"
-      :topType="topType" />
-    <table-list ref="tableList" :tableSets="tableSet" :tableData="tableData" :navText="navText" @addClick="addClick"
-      :loading="loading" @editInfo="editInfo" @openClassNum="openClassNum" rowKey="goodsId">
+    <search-box-new
+      ref="searchBox"
+      :formData="formData"
+      :formList="formList"
+      @search="search"
+      @init="init"
+      :topType="topType"
+    />
+    <table-list
+      ref="tableList"
+      :tableSets="tableSet"
+      :tableData="tableData"
+      :navText="navText"
+      @addClick="addClick"
+      :loading="loading"
+      @editInfo="editInfo"
+      @openClassNum="openClassNum"
+      rowKey="goodsId"
+    >
       <template slot="customize">
-        <el-button size="medium" @click="handelBatch(1)" type="success">批量上架</el-button><el-button size="medium"
-          @click="handelBatch(0)" type="success">批量下架</el-button><el-button size="medium" @click="handelBatch(2)"
-          type="warning">批量删除</el-button>
+        <el-button size="medium" @click="handelCopy" type="success"
+          >商品复制</el-button
+        >
+        <el-button size="medium" @click="handelBatch(1)" type="success"
+          >批量上架</el-button
+        >
+        <el-button size="medium" @click="handelBatch(0)" type="success"
+          >批量下架</el-button
+        >
+        <el-button size="medium" @click="handelBatch(2)" type="warning"
+          >批量删除</el-button
+        >
       </template>
       <template slot="btn" slot-scope="props">
-        <el-button v-if="
-          props.scope.row.goodsType == 1 &&
-          props.scope.row.courseNum &&
-          props.scope.row.courseNum > 0 &&
-          props.scope.row.goodsLearningOrder == 0
-        " type="text" @click="setTeacher(props.scope.row)">双师制设置</el-button><el-button
-          v-if="props.scope.row.examRecord" type="text"
-          @click="$refs.dayPracticeSet.open(props.scope.row.goodsId)">每日一练设置</el-button>
-        <el-button type="text" @click="addClick(props.scope.row, 0)">修改</el-button>
+        <el-button
+          v-if="
+            props.scope.row.goodsType == 1 &&
+            props.scope.row.courseNum &&
+            props.scope.row.courseNum > 0 &&
+            props.scope.row.goodsLearningOrder == 0
+          "
+          type="text"
+          @click="setTeacher(props.scope.row)"
+          >双师制设置</el-button
+        ><el-button
+          v-if="props.scope.row.examRecord"
+          type="text"
+          @click="$refs.dayPracticeSet.open(props.scope.row.goodsId)"
+          >每日一练设置</el-button
+        >
+        <el-button type="text" @click="addClick(props.scope.row, 0)"
+          >修改</el-button
+        >
         <el-button type="text" @click="changeStatus(props.scope.row)">{{
-            props.scope.row.goodsStatus === 1 ? "下架" : "上架"
+          props.scope.row.goodsStatus === 1 ? "下架" : "上架"
         }}</el-button>
-        <el-button type="text" v-if="props.scope.row.specTemplateId"
-          @click="cancelBind(props.scope.row.goodsId, 0)">取消绑定</el-button>
+        <el-button
+          type="text"
+          v-if="props.scope.row.specTemplateId"
+          @click="cancelBind(props.scope.row.goodsId, 0)"
+          >取消绑定</el-button
+        >
         <el-button type="text" @click="del(props.scope.row)">删除</el-button>
       </template>
     </table-list>
-    <pagination :total="total" :pageSize="formData.pageSize" :currentPage="formData.pageNum"
-      @handleSizeChange="handleSizeChange" @handleCurrentChange="handleCurrentChange" />
-    <el-dialog :visible.sync="dialogVisible" width="1000px" :show-close="false" :close-on-click-modal="false">
+    <pagination
+      :total="total"
+      :pageSize="formData.pageSize"
+      :currentPage="formData.pageNum"
+      @handleSizeChange="handleSizeChange"
+      @handleCurrentChange="handleCurrentChange"
+    />
+    <el-dialog
+      :visible.sync="dialogVisible"
+      width="1000px"
+      :show-close="false"
+      :close-on-click-modal="false"
+    >
       <div slot="title" class="hearders">
         <div class="leftTitle">关联商品规格</div>
         <div class="rightBoxs">
-          <img src="@/assets/images/Close@2x.png" alt="" @click="dialogVisible = false" />
+          <img
+            src="@/assets/images/Close@2x.png"
+            alt=""
+            @click="dialogVisible = false"
+          />
         </div>
       </div>
       <div style="margin-bottom: 10px">
         <!-- 搜索框 -->
-        <el-input style="width: 230px; margin: 0px 10px" size="small" v-model="specFormData.templateName"
-          placeholder="商品规格模板名称"></el-input>
-        <el-button size="small" type="primary" @click="searchGoodsSpecList(specFormData.goodsId)">查询</el-button>
+        <el-input
+          style="width: 230px; margin: 0px 10px"
+          size="small"
+          v-model="specFormData.templateName"
+          placeholder="商品规格模板名称"
+        ></el-input>
+        <el-button
+          size="small"
+          type="primary"
+          @click="searchGoodsSpecList(specFormData.goodsId)"
+          >查询</el-button
+        >
       </div>
-      <table-list :tableSets="dialogTableSet" :tableData="dialogTableData" :navText="dialogNavText"
-        :radio.sync="tableRadio">
+      <table-list
+        :tableSets="dialogTableSet"
+        :tableData="dialogTableData"
+        :navText="dialogNavText"
+        :radio.sync="tableRadio"
+      >
       </table-list>
       <span slot="footer" class="dialog-footer">
         <el-button @click="dialogVisible = false">取 消</el-button>
@@ -51,6 +116,21 @@
       </span>
     </el-dialog>
     <Day-practice-set-dialog ref="dayPracticeSet"></Day-practice-set-dialog>
+    <Base-dialog
+      title="商品复制机构选择"
+      :isShow.sync="dialogCopyVisible"
+      @submit="goodsCopy"
+    >
+      <el-radio-group v-model="tenantId">
+        <el-radio
+          style="display: block; margin-bottom: 10px"
+          :label="item.tenantId"
+          v-for="item in tenantList"
+          :key="item.tenantId"
+          >{{ item.tenantName }}</el-radio
+        >
+      </el-radio-group>
+    </Base-dialog>
   </div>
 </template>
 
@@ -64,7 +144,9 @@ import {
   goodsUpdateSpec,
   goodsUpdateStatus,
   goodsDel,
-  goodCancelBind
+  goodCancelBind,
+  getTenantList,
+  goodsCopy,
 } from "@/api/resource/good";
 export default {
   name: "CommodityManageMent",
@@ -311,6 +393,7 @@ export default {
       tableData: [], //表单数据
       total: 0, //一共多少条
       dialogVisible: false,
+      dialogCopyVisible: false,
       dialogTableSet: [
         {
           label: "教育类型",
@@ -356,6 +439,8 @@ export default {
         templateName: "",
         goodsId: "",
       },
+      tenantList: [],
+      tenantId: "",
     };
   },
   mounted() {
@@ -380,7 +465,28 @@ export default {
             this.search(1);
           });
         })
-        .catch(() => { });
+        .catch(() => {});
+    },
+    handelCopy() {
+      this.dialogCopyVisible = true;
+      getTenantList().then((res) => {
+        this.tenantList = res.data;
+      });
+    },
+    goodsCopy() {
+      if (!this.tenantId) {
+        return this.$message.warning("请选择机构");
+      }
+      let data = this.$refs.tableList.allCheckData;
+      if (!data.length) {
+        return this.$message.warning("请先勾选商品");
+      }
+      const goodsIds = data.map((item) => item.goodsId);
+      goodsCopy({ goodsIds, tenantId: this.tenantId }).then((res) => {
+        this.dialogCopyVisible = false;
+        this.$refs.tableList.clearMoreActive();
+        this.$message.success("商品复制成功");
+      });
     },
     // 批量上下架
     handelBatch(type) {
@@ -418,7 +524,7 @@ export default {
             });
           }
         })
-        .catch(() => { });
+        .catch(() => {});
     },
     openClassNum(id) {
       this.specFormData.goodsId = id;
@@ -667,7 +773,6 @@ export default {
   display: flex;
   flex-direction: column;
   align-items: center;
-
   .imgLabel {
     flex: 1;
     width: 100%;