ソースを参照

首页轮播管理

reloaded 5 年 前
コミット
13f6acd8a2

+ 161 - 0
src/layout/banner/bannerForm.vue

@@ -0,0 +1,161 @@
+<template>
+  <div id="bannerForm">
+    <el-row>
+      <el-col :span="24" class="top">
+        <span class="shu"></span><span class="title">{{ formTitle }}</span>
+      </el-col>
+      <el-col :span="24" class="form">
+        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+          <el-form-item label="图片名称" prop="name">
+            <el-input v-model="ruleForm.name" placeholder="请输入地区名称"></el-input>
+          </el-form-item>
+          <el-form-item label="路径" prop="url">
+            <uploadImage :limit="1" :data="ruleForm.url" :url="`/files/financial/custom/upload`" @uploadSuccess="uploadSuccess" @remove="remove"></uploadImage>
+          </el-form-item>
+          <el-form-item label="排序" prop="order">
+            <el-input v-model="ruleForm.order" placeholder="请输入排序"></el-input>
+          </el-form-item>
+
+          <el-col :span="24" class="clickBtn">
+            <el-form-item>
+              <el-button type="primary" size="small" @click="submitForm('ruleForm')">提交</el-button>
+              <el-button size="small" @click="resetForm('ruleForm')">取消</el-button>
+            </el-form-item>
+          </el-col>
+        </el-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import uploadImage from '@/layout/custom/uploadImage.vue';
+export default {
+  name: 'bannerForm',
+  props: {
+    ruleForm: null,
+    rolesList: null,
+    formTitle: null,
+    loading: null,
+  },
+  components: {
+    uploadImage,
+  },
+  data: () => ({
+    rules: {
+      name: [{ required: true, message: '请输入地区名称', trigger: 'blur' }],
+      url: [{ required: true, message: '请输入路径', trigger: 'blur' }],
+    },
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    submitForm() {
+      this.$emit('submitForm', { data: this.ruleForm });
+    },
+    resetForm() {
+      this.$emit('resetForm');
+    },
+    uploadSuccess({ data }) {
+      this.$set(this.ruleForm, 'url', data.uri);
+    },
+    remove(file) {
+      this.$set(this.ruleForm, 'url', '');
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+p {
+  padding: 0;
+  margin: 0;
+}
+.top .shu {
+  float: left;
+  width: 4px;
+  height: 20px;
+  background: rgba(233, 2, 29, 1);
+}
+.top .title {
+  float: left;
+  padding: 0 10px;
+  font-size: 16px;
+  font-family: Source Han Sans SC;
+  font-weight: bold;
+  color: rgba(40, 40, 40, 1);
+}
+/deep/.el-textarea__inner {
+  min-height: 100px !important;
+}
+/deep/.select {
+  width: 632px;
+}
+.selects {
+  width: 473px;
+  margin: 0 15px 0 0;
+}
+/deep/.el-radio__input.is-checked + .el-radio__label {
+  color: #e9021d;
+}
+/deep/.el-radio__input.is-checked .el-radio__inner {
+  border-color: #e9021d;
+  background: #e9021d;
+}
+/deep/.el-checkbox__input.is-checked + .el-checkbox__label {
+  color: #e9021d;
+}
+/deep/.el-checkbox__input.is-checked .el-checkbox__inner,
+.el-checkbox__input.is-indeterminate .el-checkbox__inner {
+  background-color: #e9021d;
+  border-color: #e9021d;
+}
+/deep/.el-checkbox-button,
+.el-checkbox-button__inner {
+  margin: 0 15px 0 0;
+}
+/deep/.el-checkbox-button__inner {
+  padding: 7px 5px;
+  border: 1px solid #ccc;
+  border-radius: 5px;
+}
+/deep/.el-checkbox-button__inner:hover {
+  color: #e9021d;
+}
+/deep/.el-checkbox-button:first-child .el-checkbox-button__inner {
+  border-left: 1px solid #ccc;
+  border-radius: 5px;
+}
+/deep/.el-checkbox-button:last-child .el-checkbox-button__inner {
+  border-radius: 5px;
+}
+/deep/.el-checkbox-button.is-checked .el-checkbox-button__inner {
+  color: #e9021d;
+  background-color: #ffffff;
+  border-color: #e9021d;
+}
+/deep/.el-checkbox-button.is-checked .el-checkbox-button__inner {
+  box-shadow: none;
+}
+/deep/.el-switch.is-checked .el-switch__core {
+  border-color: #e9021d;
+  background-color: #e9021d;
+}
+.clickBtn .el-button {
+  width: 100px;
+  height: 40px;
+  padding: 0;
+  color: #ffffff;
+  background: #b9b9b9;
+  border-radius: 4px;
+  margin: 40px;
+}
+.clickBtn {
+  text-align: center;
+  margin: 40px 0;
+  border-top: 1px solid #ccc;
+}
+.clickBtn .el-button:first-child {
+  background-color: #e9021d;
+}
+</style>

+ 127 - 0
src/layout/banner/bannerList.vue

@@ -0,0 +1,127 @@
+<template>
+  <div id="bannerList">
+    <el-row>
+      <el-col :span="24">
+        <el-table
+          ref="debtTable"
+          :data="debtTable"
+          tooltip-effect="dark"
+          :default-sort="{ prop: 'date', order: 'descending' }"
+          style="width: 100%"
+          @selection-change="handleSelectionChange"
+        >
+          <el-table-column type="selection" align="center"> </el-table-column>
+
+          <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
+          <el-table-column property="name" label="图片名称" align="center"> </el-table-column>
+          <el-table-column label="图片" align="center">
+            <template slot-scope="scope">
+              <span> <el-image v-if="scope.row.url" :src="scope.row.url" style="height:20px;width:20px " @click="showImage(scope.row.url)"></el-image></span>
+            </template>
+          </el-table-column>
+          <el-table-column property="order" label="排序" align="center"> </el-table-column>
+
+          <el-table-column label="操作" align="center" width="300px">
+            <template slot-scope="scope">
+              <el-button @click="$router.push({ path: '/banner/detail', query: { id: scope.row.id } })" type="text"><i class="el-icon-edit"></i></el-button>
+              <el-button class="delete" @click.prevent="deleteRow(scope.row.id)" type="text"><i class="el-icon-delete"></i></el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <el-row>
+          <el-pagination
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+            :current-page="currentPage"
+            background
+            layout="total,  prev, pager, next, jumper"
+            :total="total"
+            :page-size="pageSize"
+          >
+          </el-pagination>
+        </el-row>
+      </el-col>
+    </el-row>
+    <el-dialog :visible.sync="dialogVisible" width="30%">
+      <el-image :src="elImage" style="height:100%;width:100% "></el-image>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'bannerList',
+  props: {
+    debtTable: null,
+    total: null,
+  },
+  components: {},
+  data: () => ({
+    currentPage: 0,
+    pageSize: 10,
+    dialogVisible: false,
+    elImage: '',
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    handleSizeChange(val) {
+      console.log(`每页 ${val} 条`);
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val;
+    },
+    deleteRow(id) {
+      this.$emit('deleteRow', id);
+    },
+
+    handleCurrentChange(currentPage) {
+      this.$emit('handleCurrentChange', { skip: (currentPage - 1) * this.pageSize, limit: this.pageSize, currentPage });
+    },
+    showImage(image) {
+      if (image) {
+        this.$set(this, `elImage`, image);
+        this.$set(this, `dialogVisible`, true);
+      } else {
+        this.$set(this, `dialogVisible`, false);
+      }
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+/deep/.el-checkbox__input.is-checked .el-checkbox__inner {
+  background-color: red;
+  border-color: red;
+}
+/deep/.el-checkbox__input.is-indeterminate .el-checkbox__inner {
+  background-color: red;
+  border-color: red;
+}
+/deep/.el-table th {
+  background-color: #f5f6fa;
+  padding: 8px 0;
+}
+/deep/.el-table td {
+  padding: 11px 0;
+}
+.other {
+  color: #f36302;
+}
+.view {
+  color: #f36302;
+}
+.edit {
+  color: #2ccc02;
+}
+.delete {
+  color: #e9021d;
+}
+/deep/.el-pagination {
+  padding: 26px 20px;
+}
+/deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
+  background-color: red;
+}
+</style>

+ 3 - 2
src/layout/layout-part/menus.vue

@@ -74,11 +74,12 @@
           <el-menu-item index="/institution/index/1">股权信息</el-menu-item>
         </el-menu-item-group>
       </el-submenu>
-      <el-menu-item index="/zhidao/index"> <i class="el-icon-s-grid"></i>指导单位管理</el-menu-item>
-      <el-menu-item index="/news/index"> <i class="el-icon-s-grid"></i>新闻中心管理</el-menu-item>
+      <!-- <el-menu-item index="/zhidao/index"> <i class="el-icon-s-grid"></i>指导单位管理</el-menu-item>
+      <el-menu-item index="/news/index"> <i class="el-icon-s-grid"></i>新闻中心管理</el-menu-item> -->
       <el-menu-item index="/companyidentify/index"> <i class="el-icon-s-grid"></i>企业认证管理</el-menu-item>
       <el-menu-item index="/character/index"> <i class="el-icon-s-grid"></i>角色管理</el-menu-item>
       <el-menu-item index="/region/index"> <i class="el-icon-s-grid"></i>地区管理</el-menu-item>
+      <el-menu-item index="/banner/index"> <i class="el-icon-s-grid"></i>首页轮播管理</el-menu-item>
     </el-menu>
   </div>
 </template>

+ 10 - 0
src/router/index.js

@@ -216,6 +216,16 @@ const routes = [
     name: 'login',
     component: () => import('../views/login.vue'),
   },
+  // 首页轮播管理-列表
+  {
+    path: '/banner/index',
+    component: () => import('../views/banner/index.vue'),
+  },
+  // 首页轮播管理-详情
+  {
+    path: '/banner/detail',
+    component: () => import('../views/banner/detail.vue'),
+  },
 ];
 const router = new VueRouter({
   mode: 'history',

+ 38 - 0
src/store/banner.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  bannerInfo: `/api/financial/banner`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.bannerInfo}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.bannerInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.bannerInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.bannerInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.bannerInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 2 - 0
src/store/index.js

@@ -21,6 +21,7 @@ import login from './login';
 import financeclaim from './financeclaim';
 import * as muta from './user/mutations';
 import * as states from './user/state';
+import banner from './banner';
 
 Vue.use(Vuex);
 
@@ -45,6 +46,7 @@ export default new Vuex.Store({
     login,
     dictionary,
     financeclaim,
+    banner,
   },
   state: { ...states },
   mutations: { ...muta },

+ 108 - 0
src/views/banner/detail.vue

@@ -0,0 +1,108 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="debt">
+        <el-col :span="24" class="top">
+          <detailTopInfo :topTitle="topTitle" :display="display"></detailTopInfo>
+        </el-col>
+        <el-col :span="24" class="main">
+          <el-col :span="24" class="info">
+            <bannerForm :ruleForm="ruleForm" :formTitle="formTitle" @submitForm="submitForm" @resetForm="resetForm" :loading="loading"></bannerForm>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import detailTopInfo from '@/layout/common/detailTopInfo.vue';
+import detailTop from '@/layout/common/detailTop.vue';
+import bannerForm from '@/layout/banner/bannerForm.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: banner } = createNamespacedHelpers('banner');
+export default {
+  name: 'detail',
+  props: {},
+  components: {
+    detailTopInfo, //头部导航
+
+    bannerForm, //添加其他用户
+  },
+  data: () => ({
+    display: 'block',
+    topTitle: '地区信息管理',
+    formTitle: '地区管理',
+    ruleForm: {
+      passwd: '123456',
+      roles: [],
+    },
+    loading: true,
+  }),
+  created() {
+    this.searchInfo();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  methods: {
+    ...banner(['query', 'fetch', 'update', 'create']),
+    async searchInfo() {
+      if (this.id) {
+        const res = await this.fetch(this.id);
+        if (`${res.errcode}` === '0') {
+          this.$set(this, `ruleForm`, res.data);
+        } else {
+          this.$message.error(result.errmsg ? result.errmsg : 'error');
+        }
+      }
+    },
+    // 提交
+    async submitForm({ data }) {
+      let res;
+      if (this.id) {
+        res = await this.update(data);
+        if (res.errcode === 0) {
+          this.$message({
+            message: '信息修改成功',
+            type: 'success',
+          });
+        }
+      } else {
+        res = await this.create(data);
+        if (res.errcode === 0) {
+          this.$message({
+            message: '信息创建成功',
+            type: 'success',
+          });
+        }
+      }
+      if (this.$checkRes(res)) this.resetForm();
+
+      console.log(res.data);
+    },
+    // 取消
+    resetForm() {
+      this.$router.push({ path: '/banner/index' });
+    },
+    // 返回
+    goBack() {
+      this.$router.go(-1);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  height: 50px;
+  margin: 0 0 10px 0;
+}
+.main {
+  min-height: 765px;
+  background: #ffffff;
+  padding: 20px;
+}
+</style>

+ 98 - 0
src/views/banner/index.vue

@@ -0,0 +1,98 @@
+<template>
+  <div id="index">
+    <el-col :span="24" class="debt">
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle" :display="display" @add="add"></topInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="search">
+          <searchInfo @sousuo="sousuo"></searchInfo>
+        </el-col>
+
+        <el-col :span="24" class="list">
+          <bannerList :debtTable="debtTable" @handleCurrentChange="handleCurrentChange" :total="total" @deleteRow="deleteRow"></bannerList>
+        </el-col>
+      </el-col>
+    </el-col>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/common/topInfo.vue';
+import searchInfo from '@/layout/common/searchInfo.vue';
+import bannerList from '@/layout/banner/bannerList.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: banner } = createNamespacedHelpers('banner');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    topInfo, //头部导航
+    searchInfo, //搜素
+    bannerList, //角色列表
+  },
+  data: () => ({
+    topTitle: '首页轮播管理',
+    display: 'bck',
+    total: 0,
+    debtTable: [],
+    info: [],
+  }),
+  created() {
+    this.searchInfo();
+  },
+  computed: {},
+  methods: {
+    ...banner(['query', 'delete']),
+
+    async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
+      info = this.info;
+      const res = await this.query({ skip, limit, ...info });
+      console.log(res.data);
+
+      this.$set(this, `debtTable`, res.data);
+      this.$set(this, `total`, res.total);
+    },
+    // 添加
+    add() {
+      this.$router.push({ path: '/banner/detail' });
+    },
+    // 删除
+    async deleteRow(id) {
+      const res = await this.delete(id);
+      this.$checkRes(res, '删除成功', '删除失败');
+      this.searchInfo();
+    },
+    //分页
+    async handleCurrentChange({ skip, limit, currentPage }) {
+      const res = await this.query({ skip, limit });
+      this.$set(this, `debtTable`, res.data);
+    },
+    //搜索
+    async sousuo(search) {
+      console.log(search);
+      this.$set(this, `info`, search);
+      this.searchInfo();
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  height: 50px;
+  margin: 0 0 10px 0;
+}
+.main {
+  height: 765px;
+  background: #ffffff;
+}
+.search {
+  width: 97%;
+  height: 35px;
+  margin: 20px;
+}
+.list {
+  padding: 0 20px;
+}
+</style>