lrf402788946 4 years ago
parent
commit
c03ee7b942

+ 5 - 0
dict/index.js

@@ -1,2 +1,7 @@
 export const newsColumn = ['政务动态', '通知通告', '科技新闻', '媒体聚焦', '信息公开'];
+export const productType = [
+  { label: '科技需求', value: '0' },
+  { label: '技术成果', value: '1' },
+  { label: '商务服务', value: '2' },
+];
 // export default ['政务动态', '通知通告', '科技新闻', '媒体聚焦', '信息公开'];

+ 1 - 0
src/components/adminCommon/frame.vue

@@ -9,6 +9,7 @@
           <el-menu :default-active="$route.path" class="el-menu-vertical-demo" router overflow-y: scroll>
             <el-menu-item index="/adminCenter/homeIndex">首页</el-menu-item>
             <el-menu-item index="/adminCenter/news">新闻管理</el-menu-item>
+            <el-menu-item index="/adminCenter/product">科技成果管理</el-menu-item>
           </el-menu>
         </el-aside>
         <el-main class="main">

+ 61 - 0
src/components/frame/e-upload.vue

@@ -0,0 +1,61 @@
+<template>
+  <div id="e-upload">
+    <el-upload :action="url" :http-request="upload" :list-type="type" :fileList="fileList" :on-remove="onRemove">
+      <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
+    </el-upload>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import axios from 'axios';
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'e-upload',
+  props: {
+    url: { type: String, required: true },
+    type: { type: String, default: 'picture-card' },
+    fileList: { type: Array },
+  },
+  model: {
+    prop: 'fileList',
+    event: 'change',
+  },
+  components: {},
+  data: function() {
+    return {};
+  },
+  created() {},
+  methods: {
+    async upload({ file }) {
+      let formdata = new FormData();
+      formdata.append('file', file, file.name);
+      const res = await axios.post(this.url, formdata, { headers: { 'Content-Type': 'multipart/form-data' } });
+      if (res.status === 200 && res.data.errcode == 0) {
+        const { id, name, uri } = res.data;
+        const obj = { url: uri, name };
+        this.fileList.push(obj);
+      }
+    },
+    onRemove(file) {
+      const index = this.fileList.findIndex(f => f.url === file.url);
+      this.fileList.splice(index, 1);
+    },
+  },
+  computed: {
+    ...mapState(['user', 'menuParams']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+/deep/.el-upload-list__item.is-ready {
+  display: none;
+}
+</style>

+ 9 - 0
src/components/frame/form.vue

@@ -11,6 +11,11 @@
       :style="styles"
       :inline="inline"
     >
+      <el-row type="flex" justify="end" align="middle" v-if="returns">
+        <el-col :span="2">
+          <el-button size="mini" @click="toReturn">返回</el-button>
+        </el-col>
+      </el-row>
       <template v-for="(item, index) in fields">
         <template v-if="!loading">
           <el-form-item v-if="display(item)" :key="'form-field-' + index" :label="getField('label', item)" :prop="item.model" :required="item.required">
@@ -122,6 +127,7 @@ export default {
     submitText: { type: String, default: '保存' },
     inline: { type: Boolean, default: false },
     reset: { type: Boolean, default: true },
+    returns: { type: String },
   },
   components: {
     wangEditor,
@@ -200,6 +206,9 @@ export default {
       let { model, filterReturn } = item;
       if (filterReturn) this.$emit('filterReturn', { data, model });
     },
+    toReturn() {
+      if (this.returns) this.$router.push(this.returns);
+    },
   },
 };
 </script>

+ 43 - 0
src/store/product.js

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