Browse Source

猫舍管理 内容管理 内容推荐 内容分类调用接口

DESKTOP-O04BTUJ\muzen 3 years atrás
parent
commit
6c0f151b09
2 changed files with 41 additions and 46 deletions
  1. 23 27
      src/views/ohplay/content/index.vue
  2. 18 19
      src/views/ohplay/recommend/index.vue

+ 23 - 27
src/views/ohplay/content/index.vue

@@ -9,7 +9,7 @@
       </el-form-item>
       <el-form-item label="内容分类:">
         <el-select v-model="form.type" placeholder="请选择内容分类" clearable>
-          <el-option v-for="item in locationOptions" :key="item.id" :label="item.name" :value='item.id' />
+          <el-option v-for="item in classifyOptions" :key="item.id" :label="item.name" :value='item.id' />
         </el-select>
       </el-form-item>
       <el-form-item label="当前状态:">
@@ -71,8 +71,7 @@
         <el-form :model="dialogForm" ref="dialogForm" :rules="rules" label-width="100px">
           <el-form-item label="推荐位置:" prop="tagId">
             <el-select v-model="dialogForm.tagId" placeholder="请选择推荐位置">
-              <el-option v-for="item in locationOptions" :key="item.value" :label="item.label"
-                :value='item.value' />
+              <el-option v-for="item in classifyOptions" :key="item.id" :label="item.name" :value='item.id' />
             </el-select>
           </el-form-item>
           <el-form-item label="推荐权重:" prop="weight">
@@ -80,7 +79,7 @@
           </el-form-item>
           <el-form-item label="权重唯一:" prop="isOnlyWeight">
             <el-select v-model="dialogForm.isOnlyWeight" placeholder="权重是否唯一">
-              <el-option v-for="item in dict.type.hot_yes_no" :key="item.value" :label="item.label"
+              <el-option v-for="item in onlyOptions" :key="item.value" :label="item.label"
                 :value="item.value" />
             </el-select>
           </el-form-item>
@@ -178,9 +177,10 @@
 </template>
 
 <script>
-import { list, detail, showOrHide, recommend, commentShowOrHide, typeList } from '@/api/ohplay/content'
+import { list, detail, showOrHide, recommend, commentShowOrHide, } from '@/api/ohplay/content'
+import { classifyMixin, typeMixin } from '../mixin/index'
 export default {
-  dicts: ['hot_yes_no'],
+  mixins: [classifyMixin, typeMixin],
   data() {
     return {
       // 遮罩层
@@ -207,18 +207,24 @@ export default {
         isOnlyWeight: '',
         dialogDate: [],
       },
-      // 推荐位置
-      locationOptions: [],
-      // 内容类型
-      typeOptions: [
-        { value: 0, label: '帖子' },
-        { value: 1, label: '图片' }
-      ],
       // 当前状态
-      statusOptions: [
-        { value: 0, label: '显示' },
-        { value: 1, label: '隐藏' }
-      ],
+      statusOptions: [{
+        value: 0,
+        label: '显示'
+      },
+      {
+        value: 1,
+        label: '隐藏'
+      }],
+      // 权重是否唯一
+      onlyOptions: [{
+        value: 0,
+        label: '否'
+      }, {
+        value: 1,
+        label: '是'
+      }],
+
       // 校验
       rules: {
         tagId: [{
@@ -247,7 +253,6 @@ export default {
     }
   },
   mounted() {
-    this.getTypeList()
     this.getList()
   },
   methods: {
@@ -288,15 +293,6 @@ export default {
       })
     },
 
-    // 内容分类
-    getTypeList() {
-      typeList().then(res => {
-        if (res.code === 0) {
-          this.locationOptions = res.data
-        }
-      })
-    },
-
     // 隐藏或显示
     getChange(row, type) {
       showOrHide(row.id, type).then(res => {

+ 18 - 19
src/views/ohplay/recommend/index.vue

@@ -12,13 +12,12 @@
       </el-form-item>
       <el-form-item label="内容分类:">
         <el-select v-model="form.type" placeholder="请选择内容分类" clearable>
-          <el-option v-for="item in locationOptions" :key="item.value" :label="item.label"
-            :value='item.value' />
+          <el-option v-for="item in classifyOptions" :key="item.id" :label="item.name" :value='item.id' />
         </el-select>
       </el-form-item>
       <el-form-item label="当前状态:">
         <el-select v-model="form.recommendStatus" placeholder="请选择当前状态" clearable>
-          <el-option v-for="item in dict.type.recommend_status" :key="item.value" :label="item.label"
+          <el-option v-for="item in statusOptions" :key="item.value" :label="item.label"
             :value='item.value' />
         </el-select>
       </el-form-item>
@@ -148,8 +147,9 @@
 <script>
 import { list, remove } from '@/api/ohplay/recommend'
 import { detail, showOrHide, commentShowOrHide } from '@/api/ohplay/content'
+import { classifyMixin, typeMixin } from '../mixin/index'
 export default {
-  dicts: ['location_type', 'recommend_status'],
+  mixins: [classifyMixin, typeMixin],
   data() {
     return {
       // 遮罩层
@@ -167,19 +167,18 @@ export default {
       // 弹窗
       dialogVisible: false,
       dialogList: {},
-      // 内容类型
-      typeOptions: [
-        { value: 0, label: '帖子' },
-        { value: 1, label: '图片' }
-      ],
-      // 推荐位置
-      locationOptions: [
-        { value: 5, label: '推荐' },
-        { value: 1, label: '生活' },
-        { value: 2, label: '音频' },
-        { value: 3, label: '硬件' },
-        { value: 4, label: '同城' },
-      ],
+
+      // 当前状态
+      statusOptions: [{
+        value: 0,
+        label: '未开始'
+      }, {
+        value: 1,
+        label: '有效'
+      }, {
+        value: 2,
+        label: '失效'
+      }]
     }
   },
   watch: {
@@ -261,10 +260,10 @@ export default {
 
     // 字典翻译
     locationFormatter(row) {
-      return this.selectDictLabel(this.dict.type.location_type, row.recommendLocation)
+      return this.classifyOptions.find(i => i.id === row.recommendLocation).name
     },
     statusFormatter(row) {
-      return this.selectDictLabel(this.dict.type.recommend_status, row.recommendStatus)
+      return this.selectDictLabel(this.statusOptions, row.recommendStatus)
     }
   }
 }