Sfoglia il codice sorgente

始宁农业后台:内容管理-VR看菜园

panyong 1 anno fa
parent
commit
508e5c13cc

+ 0 - 5
htmldev/shiningManage/README.md

@@ -232,8 +232,3 @@ yarn build
 
 [测试](http://swago-admin.codedreamit.com/login)
 [生产](http://admin.swago.cn/login)
-
-### TODO List
-
-* 内容管理-VR看菜园
-  * 缺列表、新增、编辑、删除接口

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

@@ -31,6 +31,12 @@ const contentManage = {
       name: 'contentManageVideo',
       component: () => import('@/views/contentManage/video/index'),
       meta: { title: '村长说农事', icon: 'el-icon-video-camera' }
+    },
+    {
+      path: 'VR',
+      name: 'contentManageVR',
+      component: () => import('@/views/contentManage/vr/index'),
+      meta: { title: 'VR看菜园', icon: 'el-icon-view' }
     }
   ]
 }

+ 243 - 0
htmldev/shiningManage/src/views/contentManage/vr/details.vue

@@ -0,0 +1,243 @@
+<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="vr_name"
+          :rules="formRules.required"
+          label="vr名称:">
+          <el-input
+            v-model="form.vr_name"
+            placeholder="请输入vr名称"
+            clearable></el-input>
+        </el-form-item>
+        <el-form-item
+          prop="vr_url"
+          :rules="formRules.required"
+          label="vr地址:">
+          <el-input
+            type="textarea"
+            :rows="2"
+            placeholder="请输入vr地址"
+            v-model="form.vr_url">
+          </el-input>
+        </el-form-item>
+        <el-form-item
+          prop="vr_introduce"
+          :rules="formRules.required"
+          label="vr介绍:">
+          <el-input
+            type="textarea"
+            :rows="4"
+            placeholder="请输入vr介绍"
+            v-model="form.vr_introduce">
+          </el-input>
+        </el-form-item>
+        <el-form-item
+          prop="vr_img_url"
+          :rules="formRules.uploadImgs"
+          label="vr封面:">
+          <el-upload
+            :on-remove="(file) => {handleRemove(file, 'vr_img_url')}"
+            :on-success="(file) => {handleAvatarSuccess(file, 'vr_img_url')}"
+            :before-upload="beforeAvatarUpload"
+            :on-exceed="hadnleExceed"
+            :accept="'image/*'"
+            :limit="1"
+            :file-list="vr_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="status"
+          :rules="formRules.select"
+          label="状态:">
+          <el-select
+            style="width: 100%;"
+            v-model="form.status"
+            filterable
+            clearable
+            placeholder="请选择是否显示">
+            <el-option
+              :label="item.name"
+              :value="item.value"
+              v-for="item in arrLunboStatus"
+              :key="item.value"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item
+          prop="top"
+          :rules="formRules.select"
+          label="是否置顶:">
+          <el-select
+            style="width: 100%;"
+            v-model="form.top"
+            filterable
+            clearable
+            placeholder="请选择是否置顶">
+            <el-option
+              :label="item.name"
+              :value="item.value"
+              v-for="item in arrProductIsRecommend"
+              :key="item.value"></el-option>
+          </el-select>
+        </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>
+export default {
+  props: {
+    value: {
+      type: Boolean,
+      default: true
+    },
+    exData: {
+      type: Object,
+      default: function () {
+        return {}
+      }
+    }
+  },
+  data() {
+    return {
+      dialog: !!this.value,
+      form: {
+        'vr_name': '', // vr名称
+        'vr_url': '', // vr地址
+        'vr_introduce': '', // vr介绍
+        'vr_img_url': [], // vr封面地址
+        'status': 0, // 状态 0下架 1上架
+        'top': 0 // 是否置顶 0否 1是
+      },
+      vr_img_url: [],
+      booLock: false
+    }
+  },
+  computed: {
+    arrLunboStatus() {
+      return this.$store.state.common.arrLunboStatus
+    },
+    arrProductIsRecommend() {
+      return this.$store.state.common.arrProductIsRecommend
+    }
+  },
+  methods: {
+    beforeAvatarUpload(file) {
+      const isLt2M = file.size / 1024 / 1024 < 5
+      if (!isLt2M) {
+        this.$message.error('上传图片大小不能超过 5MB!')
+      }
+      return isLt2M
+    },
+    handleRemove(file, formkey) {
+      let path = file.url
+      if (file.response && file.response.data) {
+        path = file.response.data.path
+      }
+      this.form[formkey] = this.form[formkey].filter(item => item !== path)
+    },
+    handleAvatarSuccess(res, formkey) {
+      if (res.code === 200) {
+        const { path } = res.data
+        this.form[formkey].push(path)
+      } else {
+        this.$message.error('图片上传失败')
+      }
+    },
+    hadnleExceed(files, fileList) {
+      this.$message({
+        message: '最多上传一张',
+        type: 'warning'
+      })
+    },
+    handleSubmit() {
+      const url = this.exData.id ? '/api/admin/vr/modify' : '/api/admin/vr/add'
+      this.$refs.form.validate(async valid => {
+        if (valid) {
+          const formData = JSON.parse(JSON.stringify(this.form))
+          const postData = {
+            ...formData,
+            vr_img_url: formData.vr_img_url[0]
+          }
+          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.exData.id) {
+      this.$set(this.form, 'id', this.exData.id)
+      this.vr_img_url = [
+        {
+          name: '',
+          url: this.exData.vr_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 === 'vr_img_url') {
+              value = [value]
+            }
+            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>

+ 171 - 0
htmldev/shiningManage/src/views/contentManage/vr/index.vue

@@ -0,0 +1,171 @@
+<template>
+  <div class="padding-20">
+    <div class="search-box">
+      <el-form
+        ref="form"
+        :inline="true"
+        :model="searchForm"
+        clearable
+        class="mt-10">
+        <el-form-item label="vr名称:">
+          <el-input v-model="searchForm.vr_name" placeholder="请输入vr名称" clearable></el-input>
+        </el-form-item>
+        <el-form-item label="状态:">
+          <el-select
+            v-model="searchForm.status"
+            filterable
+            clearable
+            placeholder="请选择状态">
+            <el-option
+              v-for="item in arrLunboStatus"
+              :key="item.value"
+              :label="item.name"
+              :value="item.value">
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="创建时间:">
+          <el-date-picker
+            :editable="false"
+            v-model="time"
+            @change="timearr => {timearr ? (searchForm.start_time = timearr[0] + ' 00:00:00', searchForm.end_time = timearr[1] + ' 23:59:59') : searchForm.start_time = searchForm.end_time = undefined}"
+            type="daterange"
+            value-format="yyyy-MM-dd"
+            start-placeholder="开始时间"
+            end-placeholder="结束时间"
+          ></el-date-picker>
+        </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"
+                     @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="名称" prop="vr_name" show-overflow-tooltip></el-table-column>
+      <el-table-column label="介绍" prop="vr_introduce" show-overflow-tooltip min-width="140"></el-table-column>
+      <el-table-column label="地址" prop="vr_url" show-overflow-tooltip min-width="140"></el-table-column>
+      <el-table-column label="vr封面" prop="vr_img_url" min-width="100">
+        <template slot-scope="scope">
+          <el-image
+            style="display:block;width: 80px; height: 80px;font-size: 0;"
+            :src="scope.row.vr_img_url"
+            :preview-src-list="[scope.row.vr_img_url]">
+          </el-image>
+        </template>
+      </el-table-column>
+      <el-table-column label="状态" prop="status">
+        <template slot-scope="scope">
+          <p>{{ getText(arrLunboStatus, scope.row.status) }}</p>
+        </template>
+      </el-table-column>
+      <el-table-column label="是否置顶" prop="top">
+        <template slot-scope="scope">
+          <p>{{ getText(arrProductIsRecommend, scope.row.top) }}</p>
+        </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="操作" width="160">
+        <template slot-scope="scope">
+          <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>
+    <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: {}
+      },
+      time: [],
+      searchForm: {},
+      tableData: [],
+      tableUrl: '/api/admin/vr/list'
+    }
+  },
+  computed: {
+    arrLunboStatus() {
+      return this.$store.state.common.arrLunboStatus
+    },
+    arrProductIsRecommend() {
+      return this.$store.state.common.arrProductIsRecommend
+    }
+  },
+  methods: {
+    add() {
+      this.detailsDialog.exData = {}
+      this.detailsDialog.show = true
+    },
+    edit(row) {
+      this.detailsDialog.exData = row
+      this.detailsDialog.show = true
+    },
+    del(row) {
+      this.$confirm('确定要删除吗', '确认', {
+        type: 'warning'
+      }).then(async () => {
+        const data = await this.$fetch('/api/admin/vr/delete', { id: row.id })
+        if (data.code === 200) {
+          this.$message.success('删除成功')
+          this.init()
+        }
+      }).catch(() => {
+      })
+    },
+    getText(arr, value) {
+      const temp = arr.filter(item => item.value === value)
+      if (temp.length > 0) {
+        return temp[0].name
+      }
+      return ''
+    }
+  },
+  mounted() {
+    this.init()
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>