Browse Source

始宁农业管理后台:轮播图管理

panyong 2 years ago
parent
commit
6efef1c736

+ 1 - 1
htmldev/shiningManage/src/router/modules/contentManage.js

@@ -12,7 +12,7 @@ const contentManage = {
       path: 'banner',
       name: 'businessManageBanner',
       component: () => import('@/views/contentManage/banner/index'),
-      meta: { title: '农户管理' }
+      meta: { title: '轮播管理' }
     }
   ]
 }

+ 25 - 1
htmldev/shiningManage/src/store/modules/common.js

@@ -31,7 +31,31 @@ const state = {
         picker.$emit('pick', [start, end])
       }
     }]
-  }
+  },
+  arrLunboStatus: [
+    {
+      value: 0,
+      name: '下架'
+    },
+    {
+      value: 1,
+      name: '上架'
+    }
+  ],
+  arrLunboLinkType: [
+    {
+      value: 0,
+      name: '外链'
+    },
+    {
+      value: 1,
+      name: '小程序链接'
+    },
+    {
+      value: 2,
+      name: '仅图片'
+    }
+  ]
 }
 
 const mutations = {

+ 68 - 112
htmldev/shiningManage/src/views/contentManage/banner/details.vue

@@ -12,120 +12,88 @@
         :rules="formRules"
         label-width="120px">
         <el-form-item
-          prop="rotation_channel"
-          :rules="formRules.select"
-          label="应用包:">
-          <el-select
-            style="width: 100%;"
-            v-model="form.rotation_channel"
-            filterable
-            clearable
-            placeholder="请选择应用包">
-            <el-option
-              v-for="item in rotationChannelList"
-              :key="item.rotation_channel"
-              :label="item.rotation_name"
-              :value="item.rotation_channel">
-            </el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item
-          prop="rotation_type"
-          :rules="formRules.select"
-          label="轮播图类型:">
-          <el-select
-            style="width: 100%;"
-            v-model="form.rotation_type"
-            filterable
+          prop="sort_id"
+          :rules="formRules.required"
+          label="排序:">
+          <el-input
+            v-model="form.sort_id"
+            placeholder="请输入排序值"
             clearable
-            placeholder="请选择轮播图类型">
-            <el-option
-              :label="item.name"
-              :value="item.value"
-              v-for="item in arrRotationType"
-              :key="item.value"></el-option>
-          </el-select>
+            @input="form.sort_id = form.sort_id.replace(/[^\d]$/, '').replace(/^0\d/, '0')"></el-input>
         </el-form-item>
         <el-form-item
-          prop="rotation_name"
+          prop="lunbo_name"
           :rules="formRules.required"
           label="标题:">
-          <el-input v-model="form.rotation_name"
-                    placeholder="请输入标题"
-                    clearable></el-input>
+          <el-input
+            v-model="form.lunbo_name"
+            placeholder="请输入标题"
+            clearable></el-input>
         </el-form-item>
         <el-form-item
-          prop="sort_id"
-          :rules="formRules.required"
-          label="排序:">
-          <el-input v-model="form.sort_id"
-                    placeholder="请输入排序值"
-                    clearable
-                    @input="form.sort_id = form.sort_id.replace(/[^\d]$/, '').replace(/^0\d/, '0')"></el-input>
+          prop="lunbo_img_url"
+          :rules="formRules.uploadImgs"
+          label="图片:">
+          <el-upload
+            :on-remove="(file) => {handleRemove(file, 'lunbo_img_url')}"
+            :on-success="(file) => {handleAvatarSuccess(file, 'lunbo_img_url')}"
+            :before-upload="beforeAvatarUpload"
+            :on-exceed="hadnleExceed"
+            :accept="'image/*'"
+            :limit="1"
+            :file-list="lunbo_img_url"
+            list-type="picture-card"
+            action="/api/upload/img"
+            multiple>
+            <i class="el-icon-plus"></i>
+            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过5M</div>
+          </el-upload>
         </el-form-item>
         <el-form-item
-          prop="rotation_status"
+          prop="lunbo_status"
           :rules="formRules.select"
-          label="是否显示:">
+          label="状态:">
           <el-select
             style="width: 100%;"
-            v-model="form.rotation_status"
+            v-model="form.lunbo_status"
             filterable
             clearable
             placeholder="请选择是否显示">
             <el-option
               :label="item.name"
               :value="item.value"
-              v-for="item in arrRotationStatus"
+              v-for="item in arrLunboStatus"
               :key="item.value"></el-option>
           </el-select>
         </el-form-item>
         <el-form-item
-          prop="rotation_img_url"
-          :rules="formRules.uploadImgs"
-          label="图片:">
-          <el-upload
-            :on-remove="handleRemove"
-            :on-success="handleAvatarSuccess"
-            :before-upload="beforeAvatarUpload"
-            :on-exceed="hadnleExceed"
-            :accept="'image/*'"
-            :limit="1"
-            :file-list="fileList"
-            list-type="picture-card"
-            action="/api/admin/v1/upload/file"
-            multiple>
-            <i class="el-icon-plus"></i>
-            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过5M</div>
-          </el-upload>
-        </el-form-item>
-        <el-form-item
-          prop="rotation_link_type"
+          prop="lunbo_link_type"
           :rules="formRules.select"
           label="链接类型:">
           <el-select
             style="width: 100%;"
-            v-model="form.rotation_link_type"
+            v-model="form.lunbo_link_type"
             filterable
             clearable
             placeholder="请选择链接类型">
             <el-option
               :label="item.name"
               :value="item.value"
-              v-for="item in arrRotationLinkType"
+              v-for="item in arrLunboLinkType"
               :key="item.value"></el-option>
           </el-select>
         </el-form-item>
         <el-form-item
           label="轮播图链接:"
-          prop="rotation_url"
-          v-show="form.rotation_link_type !== 1">
-          <el-input type="textarea"
-                    :rows="4"
-                    placeholder="上限200字符"
-                    maxlength="200"
-                    show-word-limit
-                    v-model="form.rotation_url">
+          prop="lunbo_link_url"
+          v-show="form.lunbo_link_type !== 2">
+          <el-input
+            type="textarea"
+            :rows="4"
+            placeholder="上限200字符"
+            maxlength="200"
+            show-word-limit
+            v-model="form.lunbo_link_url">
           </el-input>
         </el-form-item>
       </el-form>
@@ -138,8 +106,6 @@
 </template>
 
 <script>
-import { yuan2Fen, fen2Yuan } from '@/utils'
-
 export default {
   props: {
     value: {
@@ -157,31 +123,24 @@ export default {
     return {
       dialog: !!this.value,
       form: {
-        'rotation_img_url': [], // 轮播图片地址
-        'rotation_status': '', // 轮播图状态(0无效1有效)
-        'rotation_url': '', // 链接
-        'rotation_name': '', // 轮播图名称
-        'sort_id': '', // 排序ID
-        'rotation_type': '', // 轮播类型(1首页2直播间)
-        'rotation_channel': '', // 应用包
-        'rotation_link_type': ''
+        'sort_id': '', // 排序
+        'lunbo_name': '', // 轮播图名称
+        'lunbo_img_url': [], // 轮播图片
+        'lunbo_status': '', // 状态(0下架1上架)
+        'lunbo_link_type': '', // 链接类型(0外链1小程序)
+        'lunbo_link_url': '' // 跳转地址
+
       },
-      fileList: [],
+      lunbo_img_url: [],
       booLock: false
     }
   },
   computed: {
-    arrRotationType() {
-      return this.$store.state.common.arrRotationType
+    arrLunboStatus() {
+      return this.$store.state.common.arrLunboStatus
     },
-    arrRotationStatus() {
-      return this.$store.state.common.arrRotationStatus
-    },
-    rotationChannelList() {
-      return this.$store.state.common.rotationChannelList
-    },
-    arrRotationLinkType() {
-      return this.$store.state.common.arrRotationLinkType
+    arrLunboLinkType() {
+      return this.$store.state.common.arrLunboLinkType
     }
   },
   methods: {
@@ -192,17 +151,17 @@ export default {
       }
       return isLt2M
     },
-    handleRemove(file) {
+    handleRemove(file, formkey) {
       let path = file.url
       if (file.response && file.response.data) {
         path = file.response.data.path
       }
-      this.form.rotation_img_url = this.form.rotation_img_url.filter(item => item !== path)
+      this.form[formkey] = this.form[formkey].filter(item => item !== path)
     },
-    handleAvatarSuccess(res) {
+    handleAvatarSuccess(res, formkey) {
       if (res.code === 200) {
         const { path } = res.data
-        this.form.rotation_img_url.push(path)
+        this.form[formkey].push(path)
       } else {
         this.$message.error('图片上传失败')
       }
@@ -214,16 +173,16 @@ export default {
       })
     },
     handleSubmit() {
-      const url = this.exData.id ? '/v1/setting/rotation/modify' : '/v1/setting/rotation/add'
+      const url = this.exData.id ? '/api/admin/tlunbo/modify' : '/api/admin/tlunbo/add'
       this.$refs.form.validate(async valid => {
         if (valid) {
           const formData = JSON.parse(JSON.stringify(this.form))
           const postData = {
             ...formData,
-            rotation_img_url: formData.rotation_img_url[0]
+            lunbo_img_url: formData.lunbo_img_url[0]
           }
-          if (this.form.rotation_link_type === 1) {
-            postData.rotation_url = ''
+          if (this.form.lunbo_link_type === 2) {
+            postData.lunbo_link_url = ''
           }
           this.booLock = true
           const data = await this.$fetch(url, postData)
@@ -238,22 +197,19 @@ export default {
     }
   },
   mounted() {
-    if (!(this.rotationChannelList.length)) {
-      this.$store.dispatch('common/getRotationChannelList')
-    }
     if (this.exData.id) {
       this.$set(this.form, 'id', this.exData.id)
-      this.fileList = [
+      this.lunbo_img_url = [
         {
           name: '',
-          url: this.exData.rotation_img_url
+          url: this.exData.lunbo_img_url
         }
       ]
       for (const key in this.exData) {
         if (this.form.hasOwnProperty(key)) {
           let value = this.exData[key]
           if ((Array.isArray(value) && value.length >= 1) || (Object.prototype.toString.call(value) === '[object Object]') || (typeof value === 'string' && value) || typeof value === 'number') {
-            if (key === 'rotation_img_url') {
+            if (key === 'lunbo_img_url') {
               value = [value]
             }
             if (key === 'sort_id') {

+ 36 - 61
htmldev/shiningManage/src/views/contentManage/banner/index.vue

@@ -7,30 +7,7 @@
                clearable
                class="mt-10">
         <el-form-item>
-          <el-select
-            v-model="searchForm.rotation_channel"
-            filterable
-            clearable
-            placeholder="请选择应用包">
-            <el-option
-              v-for="item in rotationChannelList"
-              :key="item.rotation_channel"
-              :label="item.rotation_name"
-              :value="item.rotation_channel">
-            </el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item>
-          <el-select
-            clearable
-            placeholder="请选择轮播图类型"
-            v-model="searchForm.rotation_type">
-            <el-option
-              :label="item.name"
-              :value="item.value"
-              v-for="item in arrRotationType"
-              :key="item.value"></el-option>
-          </el-select>
+
         </el-form-item>
         <el-form-item class="ml-10">
           <el-button icon="el-icon-search" type="primary" @click="searchSubmit">查询</el-button>
@@ -38,7 +15,6 @@
         <el-form-item class="ml-10">
           <el-button icon="el-icon-plus"
                      type="primary"
-                     v-permission="'v1_setting_rotation_add'"
                      @click="add">新增
           </el-button>
         </el-form-item>
@@ -51,45 +27,38 @@
       fit
       class="marginT-10 order-table"
       :max-height="vheight">
-      <el-table-column label="ID" prop="id" min-width="80" fixed></el-table-column>
-      <el-table-column label="轮播图片" prop="rotation_img_url" min-width="100">
+      <el-table-column label="排序" prop="sort_id"></el-table-column>
+      <el-table-column label="标题" prop="lunbo_name" show-overflow-tooltip></el-table-column>
+      <el-table-column label="轮播图片" prop="lunbo_img_url" min-width="100">
         <template slot-scope="scope">
           <el-image
             style="display:block;width: 80px; height: 80px;font-size: 0;"
-            :src="scope.row.rotation_img_url"
-            :preview-src-list="[scope.row.rotation_img_url]">
+            :src="scope.row.lunbo_img_url"
+            :preview-src-list="[scope.row.lunbo_img_url]">
           </el-image>
         </template>
       </el-table-column>
-      <el-table-column label="创建时间" prop="created_at" min-width="160"></el-table-column>
-      <el-table-column label="更新时间" prop="updated_at" min-width="160"></el-table-column>
-      <el-table-column label="轮播图类型" prop="rotation_type" min-width="140">
-        <template slot-scope="scope">
-          <p>{{ [{}, ...arrRotationType][scope.row.rotation_type].name }}</p>
-        </template>
-      </el-table-column>
-      <el-table-column label="标题" prop="rotation_name" show-overflow-tooltip></el-table-column>
-      <el-table-column label="链接类型" prop="rotation_link_type" min-width="140">
+      <el-table-column label="状态" prop="lunbo_status">
         <template slot-scope="scope">
-          <p>{{ [{}, ...arrRotationLinkType][scope.row.rotation_link_type].name }}</p>
+          <p>{{ getLunboStatusText(scope.row.lunbo_status) }}</p>
         </template>
       </el-table-column>
-      <el-table-column label="H5页面链接" prop="rotation_url" show-overflow-tooltip min-width="140">
+      <el-table-column label="链接类型" prop="lunbo_link_type" min-width="140">
         <template slot-scope="scope">
-          <p>{{ scope.row.rotation_link_type === 2 ? scope.row.rotation_url : '空' }}</p>
+          <p>{{ getLunboLinkTypeText(scope.row.lunbo_link_type) }}</p>
         </template>
       </el-table-column>
-      <el-table-column label="排序" prop="sort_id"></el-table-column>
-      <el-table-column label="是否显示" prop="rotation_status">
+      <el-table-column label="跳转地址" prop="lunbo_link_url" show-overflow-tooltip min-width="140">
         <template slot-scope="scope">
-          <p>{{ arrRotationStatus[scope.row.rotation_status].name }}</p>
+          <p>{{ scope.row.lunbo_link_type === 2 ? '空' : scope.row.lunbo_link_url }}</p>
         </template>
       </el-table-column>
-      <el-table-column label="应用包" prop="rotation_channel"></el-table-column>
+      <el-table-column label="创建时间" prop="created_at" min-width="160"></el-table-column>
+      <el-table-column label="更新时间" prop="updated_at" min-width="160"></el-table-column>
       <el-table-column label="操作" width="160">
         <template slot-scope="scope">
-          <el-button type="text" v-permission="'v1_setting_rotation_modify'" @click="edit(scope.row)">编辑</el-button>
-          <el-button type="text" v-permission="'v1_setting_rotation_delete'" @click="del(scope.row)">删除</el-button>
+          <el-button type="text" @click="edit(scope.row)">编辑</el-button>
+          <el-button type="text" @click="del(scope.row)">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -128,21 +97,15 @@ export default {
       },
       searchForm: {},
       tableData: [],
-      tableUrl: '/v1/setting/rotation/list'
+      tableUrl: '/api/admin/tlunbo/list'
     }
   },
   computed: {
-    arrRotationType() {
-      return []
+    arrLunboStatus() {
+      return this.$store.state.common.arrLunboStatus
     },
-    arrRotationStatus() {
-      return []
-    },
-    rotationChannelList() {
-      return []
-    },
-    arrRotationLinkType() {
-      return []
+    arrLunboLinkType() {
+      return this.$store.state.common.arrLunboLinkType
     }
   },
   methods: {
@@ -156,17 +119,29 @@ export default {
     },
     del(row) {
       this.$confirm('确定要删除吗', '确认', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
         type: 'warning'
       }).then(async () => {
-        const data = await this.$fetch('/v1/setting/rotation/delete', { id: row.id }, 'get')
+        const data = await this.$fetch('/api/admin/tlunbo/delete', { id: row.id })
         if (data.code === 200) {
           this.$message.success('删除成功')
           this.init()
         }
       }).catch(() => {
       })
+    },
+    getLunboStatusText(value) {
+      const temp = this.arrLunboStatus.filter(item => item.value === value)
+      if (temp.length > 0) {
+        return temp[0].name
+      }
+      return ''
+    },
+    getLunboLinkTypeText(value) {
+      const temp = this.arrLunboLinkType.filter(item => item.value === value)
+      if (temp.length > 0) {
+        return temp[0].name
+      }
+      return ''
     }
   },
   mounted() {