Browse Source

始宁农业管理后台:农户管理

panyong 2 years ago
parent
commit
f8675c03ff

+ 1 - 1
htmldev/shiningManage/src/mixin/page.js

@@ -30,7 +30,7 @@ export default {
         page: this.page,
         page_size: this.page_size,
         ...this.searchForm
-      }, 'get')
+      })
       this.tableLoading = false
       if (this.tableData && code === 200 && data && (Array.isArray(data) || Array.isArray(data.data) || Array.isArray(data.list))) {
         this.tableData = data.data || data.list || data

+ 2 - 0
htmldev/shiningManage/src/router/index.js

@@ -9,6 +9,7 @@ import Layout from '@/layout'
 import Sys from './modules/sys'
 import BusinessManage from './modules/businessManage'
 import ProductManage from './modules/productManage'
+import contentManage from './modules/contentManage'
 
 /**
  * Note: sub-menu only appear when route children.length >= 1
@@ -76,6 +77,7 @@ export const asyncRoutes = [
   },
   BusinessManage,
   ProductManage,
+  contentManage,
   Sys,
   { path: '*', redirect: '/404', hidden: true }
 ]

+ 20 - 0
htmldev/shiningManage/src/router/modules/contentManage.js

@@ -0,0 +1,20 @@
+import Layout from '@/layout'
+
+const contentManage = {
+  path: '/contentManage',
+  component: Layout,
+  redirect: '/contentManage/banner',
+  alwaysShow: true,
+  name: 'contentManage',
+  meta: { title: '内容管理', icon: 'el-icon-s-platform' },
+  children: [
+    {
+      path: 'banner',
+      name: 'businessManageBanner',
+      component: () => import('@/views/contentManage/banner/index'),
+      meta: { title: '农户管理' }
+    }
+  ]
+}
+
+export default contentManage

+ 295 - 0
htmldev/shiningManage/src/views/contentManage/banner/details.vue

@@ -0,0 +1,295 @@
+<template>
+  <div>
+    <el-dialog
+      :title="exData.id ? '编辑': '新增'"
+      :visible.sync="dialog"
+      width="900px"
+      :close-on-click-modal="false"
+      top="50px">
+      <el-form
+        ref="form"
+        :model="form"
+        :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
+            clearable
+            placeholder="请选择轮播图类型">
+            <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
+          prop="rotation_name"
+          :rules="formRules.required"
+          label="标题:">
+          <el-input v-model="form.rotation_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>
+        </el-form-item>
+        <el-form-item
+          prop="rotation_status"
+          :rules="formRules.select"
+          label="是否显示:">
+          <el-select
+            style="width: 100%;"
+            v-model="form.rotation_status"
+            filterable
+            clearable
+            placeholder="请选择是否显示">
+            <el-option
+              :label="item.name"
+              :value="item.value"
+              v-for="item in arrRotationStatus"
+              :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"
+          :rules="formRules.select"
+          label="链接类型:">
+          <el-select
+            style="width: 100%;"
+            v-model="form.rotation_link_type"
+            filterable
+            clearable
+            placeholder="请选择链接类型">
+            <el-option
+              :label="item.name"
+              :value="item.value"
+              v-for="item in arrRotationLinkType"
+              :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">
+          </el-input>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer text-center">
+        <el-button @click="dialog = false">取 消</el-button>
+        <el-button type="primary" :disabled="booLock" @click="handleSubmit">确 定</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { yuan2Fen, fen2Yuan } from '@/utils'
+
+export default {
+  props: {
+    value: {
+      type: Boolean,
+      default: true
+    },
+    exData: {
+      type: Object,
+      default: function () {
+        return {}
+      }
+    }
+  },
+  data() {
+    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': ''
+      },
+      fileList: [],
+      booLock: false
+    }
+  },
+  computed: {
+    arrRotationType() {
+      return this.$store.state.common.arrRotationType
+    },
+    arrRotationStatus() {
+      return this.$store.state.common.arrRotationStatus
+    },
+    rotationChannelList() {
+      return this.$store.state.common.rotationChannelList
+    },
+    arrRotationLinkType() {
+      return this.$store.state.common.arrRotationLinkType
+    }
+  },
+  methods: {
+    beforeAvatarUpload(file) {
+      const isLt2M = file.size / 1024 / 1024 < 5
+      if (!isLt2M) {
+        this.$message.error('上传图片大小不能超过 5MB!')
+      }
+      return isLt2M
+    },
+    handleRemove(file) {
+      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)
+    },
+    handleAvatarSuccess(res) {
+      if (res.code === 200) {
+        const { path } = res.data
+        this.form.rotation_img_url.push(path)
+      } else {
+        this.$message.error('图片上传失败')
+      }
+    },
+    hadnleExceed(files, fileList) {
+      this.$message({
+        message: '最多上传一张',
+        type: 'warning'
+      })
+    },
+    handleSubmit() {
+      const url = this.exData.id ? '/v1/setting/rotation/modify' : '/v1/setting/rotation/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]
+          }
+          if (this.form.rotation_link_type === 1) {
+            postData.rotation_url = ''
+          }
+          this.booLock = true
+          const data = await this.$fetch(url, postData)
+          this.booLock = false
+          if (data.code === 200) {
+            this.$message.success('提交成功')
+            this.$emit('success')
+            this.dialog = false
+          }
+        }
+      })
+    }
+  },
+  mounted() {
+    if (!(this.rotationChannelList.length)) {
+      this.$store.dispatch('common/getRotationChannelList')
+    }
+    if (this.exData.id) {
+      this.$set(this.form, 'id', this.exData.id)
+      this.fileList = [
+        {
+          name: '',
+          url: this.exData.rotation_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') {
+              value = [value]
+            }
+            if (key === 'sort_id') {
+              value = value.toString()
+            }
+            this.$set(this.form, key, value)
+          }
+        }
+      }
+    }
+  },
+  watch: {
+    dialog(val) {
+      if (!val) this.$emit('input', val)
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.top-tip {
+  margin-top: -20px;
+  margin-bottom: 20px;
+}
+
+.af-put-line-radio {
+  display: flex;
+  align-items: center;
+
+  p.lalel {
+    padding: 0 10px;
+  }
+
+  p {
+    padding: 0;
+    margin: 0;
+  }
+}
+</style>

+ 180 - 0
htmldev/shiningManage/src/views/contentManage/banner/index.vue

@@ -0,0 +1,180 @@
+<template>
+  <div class="padding-20">
+    <div class="search-box">
+      <el-form ref="form"
+               :inline="true"
+               :model="searchForm"
+               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>
+        </el-form-item>
+        <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>
+      </el-form>
+    </div>
+    <el-table
+      :data="tableData"
+      stripe
+      v-loading="tableLoading"
+      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">
+        <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]">
+          </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">
+        <template slot-scope="scope">
+          <p>{{ [{}, ...arrRotationLinkType][scope.row.rotation_link_type].name }}</p>
+        </template>
+      </el-table-column>
+      <el-table-column label="H5页面链接" prop="rotation_url" show-overflow-tooltip min-width="140">
+        <template slot-scope="scope">
+          <p>{{ scope.row.rotation_link_type === 2 ? scope.row.rotation_url : '空' }}</p>
+        </template>
+      </el-table-column>
+      <el-table-column label="排序" prop="sort_id"></el-table-column>
+      <el-table-column label="是否显示" prop="rotation_status">
+        <template slot-scope="scope">
+          <p>{{ arrRotationStatus[scope.row.rotation_status].name }}</p>
+        </template>
+      </el-table-column>
+      <el-table-column label="应用包" prop="rotation_channel"></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>
+        </template>
+      </el-table-column>
+    </el-table>
+    <el-pagination
+      class="marginT-20"
+      @size-change="handleSizeChange"
+      @current-change="handleCurrentChange"
+      :hide-on-single-page="true"
+      :current-page="page"
+      :page-size="page_size"
+      :page-sizes="[10, 20, 100, 200, 300, 400]"
+      background
+      layout="total, sizes, prev, pager, next, jumper"
+      :total="totalCount"/>
+    <detail v-if="detailsDialog.show"
+            v-model="detailsDialog.show"
+            :exData="detailsDialog.exData"
+            @success="init"></detail>
+  </div>
+</template>
+
+<script>
+import page from '@/mixin/page'
+import detail from './details'
+
+export default {
+  mixins: [page],
+  components: {
+    detail
+  },
+  data() {
+    return {
+      detailsDialog: {
+        show: false,
+        exData: {}
+      },
+      searchForm: {},
+      tableData: [],
+      tableUrl: '/v1/setting/rotation/list'
+    }
+  },
+  computed: {
+    arrRotationType() {
+      return []
+    },
+    arrRotationStatus() {
+      return []
+    },
+    rotationChannelList() {
+      return []
+    },
+    arrRotationLinkType() {
+      return []
+    }
+  },
+  methods: {
+    add() {
+      this.detailsDialog.exData = {}
+      this.detailsDialog.show = true
+    },
+    edit(row) {
+      this.detailsDialog.exData = row
+      this.detailsDialog.show = true
+    },
+    del(row) {
+      this.$confirm('确定要删除吗', '确认', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(async () => {
+        const data = await this.$fetch('/v1/setting/rotation/delete', { id: row.id }, 'get')
+        if (data.code === 200) {
+          this.$message.success('删除成功')
+          this.init()
+        }
+      }).catch(() => {
+      })
+    }
+  },
+  mounted() {
+    this.init()
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>