yuhongqi 1 settimana fa
parent
commit
634123c059

+ 70 - 8
src/views/components/course/userCourseCatalogDetailsZM.vue

@@ -329,7 +329,14 @@
         </el-form-item>
         <el-form-item label="商品选择" v-if="form.isProduct === 1">
           <el-button size="small" type="primary" @click="chooseCourseProduct">选取商品</el-button>
-          <el-table border width="100%" style="margin-top:5px;" :data="form.courseProducts">
+          <el-table
+            border
+            width="100%"
+            class="course-product-table"
+            style="margin-top:5px;"
+            :data="form.courseProducts"
+            max-height="400"
+          >
             <el-table-column label="商品名称" align="center" prop="productName"/>
             <el-table-column label="商品价格" align="center" prop="price"/>
             <el-table-column label="库存" align="center" prop="stock"/>
@@ -400,14 +407,30 @@
                 >{{ tag }}</el-tag>
               </template>
             </el-table-column>
-            <el-table-column label="操作" align="center" width="160px" fixed="right">
+            <el-table-column label="操作" align="center" width="96" class-name="course-product-op-col">
               <template slot-scope="scope">
-                <el-button size="mini" type="text" icon="el-icon-delete"
-                           @click="handleCourseProductDelete(scope.row)">删除
-                </el-button>
-                <el-button size="mini" type="text" icon="el-icon-price-tag"
-                           @click="handleOpenHotSaleTagDialog(scope.row, scope.$index)">添加热卖标签
-                </el-button>
+                <div class="course-product-op-btns">
+                  <el-button
+                    size="mini"
+                    type="text"
+                    icon="el-icon-delete"
+                    @click="handleCourseProductDelete(scope.row)"
+                  >删除</el-button>
+                  <el-button
+                    v-if="getHotSaleTagList(scope.row).length"
+                    size="mini"
+                    type="text"
+                    icon="el-icon-circle-close"
+                    @click="handleClearHotSaleTags(scope.row, scope.$index)"
+                  >清空标签</el-button>
+                  <el-button
+                    v-else
+                    size="mini"
+                    type="text"
+                    icon="el-icon-price-tag"
+                    @click="handleOpenHotSaleTagDialog(scope.row, scope.$index)"
+                  >热卖标签</el-button>
+                </div>
               </template>
             </el-table-column>
           </el-table>
@@ -1187,6 +1210,19 @@ export default {
       this.hotSaleTagDialog.tagInput = row.hotSaleTags || '';
       this.hotSaleTagDialog.visible = true;
     },
+    handleClearHotSaleTags(row, index) {
+      let idx = index;
+      if (idx < 0 || !this.form.courseProducts[idx]) {
+        if (row.productId) {
+          idx = this.form.courseProducts.findIndex(item => item.productId === row.productId);
+        } else if (row.id) {
+          idx = this.form.courseProducts.findIndex(item => item.id === row.id);
+        }
+      }
+      if (idx >= 0 && this.form.courseProducts[idx]) {
+        this.$set(this.form.courseProducts[idx], 'hotSaleTags', '');
+      }
+    },
     confirmHotSaleTag() {
       const tags = (this.hotSaleTagDialog.tagInput || '')
         .split(/[,,]/)
@@ -1994,6 +2030,32 @@ export default {
   align-items: center;
   justify-content: center;
 }
+
+/* 商品子表:操作列垂直居中,避免 fixed 列遮挡最后一行 */
+.course-product-table >>> .course-product-op-col .cell {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  overflow: visible;
+  padding: 6px 4px;
+  line-height: normal;
+}
+
+.course-product-op-btns {
+  display: inline-flex;
+  flex-direction: column;
+  align-items: center;
+  gap: 2px;
+}
+
+.course-product-op-btns .el-button {
+  margin-left: 0 !important;
+  padding: 2px 0;
+}
+
+.course-product-table >>> .el-table__body-wrapper {
+  padding-bottom: 8px;
+}
 </style>
 <style>
 .avatar-uploader .el-upload {

+ 24 - 1
src/views/course/publiccourse/userCourseCategory/index.vue

@@ -114,6 +114,13 @@
           </div>
         </template>
       </el-table-column>
+      <el-table-column label="小程序频道" align="center" prop="appChannelFlag" width="100">
+        <template slot-scope="scope">
+          <el-tag v-if="scope.row.pid === 0 && scope.row.appChannelFlag === 1" size="mini">是</el-tag>
+          <span v-else-if="scope.row.pid === 0">否</span>
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
       <el-table-column label="排序" sortable align="center" prop="sort" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
@@ -162,6 +169,12 @@
         <el-form-item label="排序" prop="sort">
           <el-input-number v-model="form.sort" placeholder="请输入排序" />
         </el-form-item>
+        <el-form-item v-if="isLevelOneCategory" label="小程序频道" prop="appChannelFlag">
+          <el-radio-group v-model="form.appChannelFlag">
+            <el-radio :label="1">是(首页独立 Tab)</el-radio>
+            <el-radio :label="0">否</el-radio>
+          </el-radio-group>
+        </el-form-item>
 
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -291,6 +304,11 @@ export default {
       }
     };
   },
+  computed: {
+    isLevelOneCategory() {
+      return this.form.pid === 0 || this.form.pid === '0' || this.form.pid === null;
+    }
+  },
   created() {
     this.getList();
   },
@@ -339,7 +357,8 @@ export default {
         createTime: null,
         updateTime: null,
         isDel: null,
-        cateType: 1
+        cateType: 1,
+        appChannelFlag: 0
       };
       this.resetForm("form");
     },
@@ -376,6 +395,7 @@ export default {
       getUserCourseCategory(cateId).then(response => {
         this.form = response.data;
         this.form.isShow = response.data.isShow.toString();
+        this.form.appChannelFlag = response.data.appChannelFlag != null ? response.data.appChannelFlag : 0;
         this.open = true;
         this.title = "修改课堂分类";
       });
@@ -384,6 +404,9 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
+          if (this.form.pid !== 0 && this.form.pid !== '0' && this.form.pid != null) {
+            this.form.appChannelFlag = 0;
+          }
           if (this.form.cateId != null) {
             updateUserCourseCategory(this.form).then(response => {
               this.msgSuccess("修改成功");