Преглед на файлове

对接取消绑定模板

xiejiebiao преди 2 години
родител
ревизия
02e55d8084
променени са 2 файла, в които са добавени 72 реда и са изтрити 83 реда
  1. 8 1
      src/api/resource/good.js
  2. 64 82
      src/views/Marketing/goods/commodityManageMent/index.vue

+ 8 - 1
src/api/resource/good.js

@@ -79,7 +79,14 @@ export function goodsDel(data) {
         data
     })
 }
-
+// 商品取消绑定规格模板
+export function goodCancelBind(data) {
+    return request({
+        url: `/goods/cancel/spec`,
+        method: 'post',
+        data
+    })
+}
 // 新增每日一练试卷时间
 export function addExamTime(data) {
     return request({

+ 64 - 82
src/views/Marketing/goods/commodityManageMent/index.vue

@@ -1,100 +1,49 @@
 <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="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" @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>
@@ -115,6 +64,7 @@ import {
   goodsUpdateSpec,
   goodsUpdateStatus,
   goodsDel,
+  goodCancelBind
 } from "@/api/resource/good";
 export default {
   name: "CommodityManageMent",
@@ -415,6 +365,23 @@ export default {
     this.search();
   },
   methods: {
+    // 取消规格绑定
+    cancelBind(goodsId) {
+      this.$confirm(`此操作将该商品取消关联规格模板, 是否继续?`, "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          goodCancelBind({
+            goodsId,
+          }).then((res) => {
+            this.$message.success("取消关联成功");
+            this.search(1);
+          });
+        })
+        .catch(() => { });
+    },
     // 批量上下架
     handelBatch(type) {
       let len = this.$refs.tableList.allCheckData.length;
@@ -451,13 +418,13 @@ export default {
             });
           }
         })
-        .catch(() => {});
+        .catch(() => { });
     },
     openClassNum(id) {
       this.specFormData.goodsId = id;
       this.tableRadio = "";
-      // let { specTemplateId } = this.tableData.find((e) => e.goodsId == id);
-      // this.tableRadio = specTemplateId || "";
+      let { specTemplateId } = this.tableData.find((e) => e.goodsId == id);
+      this.tableRadio = specTemplateId || "";
       this.searchGoodsSpecList(id);
       this.dialogVisible = true;
     },
@@ -642,10 +609,13 @@ export default {
 /deep/.el-button {
   border-radius: 8px;
 }
+
 /deep/.el-dialog {
   border-radius: 8px;
+
   .el-dialog__header {
     padding: 0;
+
     .hearders {
       height: 40px;
       display: flex;
@@ -653,14 +623,17 @@ export default {
       justify-content: space-between;
       padding: 0px 18px 0px 20px;
       border-bottom: 1px solid #e2e2e2;
+
       .leftTitle {
         font-size: 14px;
         font-weight: bold;
         color: #2f4378;
       }
+
       .rightBoxs {
         display: flex;
         align-items: center;
+
         img {
           width: 14px;
           height: 14px;
@@ -670,8 +643,10 @@ export default {
       }
     }
   }
+
   .el-dialog__footer {
     padding: 0;
+
     .dialog-footer {
       padding: 0px 40px;
       height: 70px;
@@ -682,6 +657,7 @@ export default {
     }
   }
 }
+
 .imgBox {
   width: 100%;
   // height: 210px;
@@ -691,6 +667,7 @@ export default {
   display: flex;
   flex-direction: column;
   align-items: center;
+
   .imgLabel {
     flex: 1;
     width: 100%;
@@ -699,17 +676,20 @@ export default {
     font-size: 14px;
     cursor: pointer;
     border-radius: 8px;
+
     .msPhoto {
       display: flex;
       justify-content: center;
       align-items: center;
       max-width: 100%;
       max-height: 270px;
+
       img {
         max-width: 100%;
         max-height: 270px;
       }
     }
+
     .imgbbx {
       display: flex;
       flex-direction: column;
@@ -717,6 +697,7 @@ export default {
       justify-content: center;
       width: 100%;
       height: 100%;
+
       i {
         font-weight: bold;
         margin: 14px 0;
@@ -724,6 +705,7 @@ export default {
       }
     }
   }
+
   p {
     margin: 5px 0px;
   }