Sfoglia il codice sorgente

更新产品类型字典表

guhongwei 5 anni fa
parent
commit
b287e0a83b

+ 1 - 1
src/layout/layout-part/menus.vue

@@ -4,7 +4,6 @@
       <el-menu-item index="/"> <i class="el-icon-s-grid"></i>首页 </el-menu-item>
       <el-menu-item index="/government/index"> <i class="el-icon-s-grid"></i>科技政务</el-menu-item>
       <el-menu-item index="/policy/index"> <i class="el-icon-s-grid"></i>科技政策</el-menu-item>
-      <el-menu-item index="/supermaket/index"> <i class="el-icon-s-grid"></i>科技超市</el-menu-item>
       <el-menu-item index="/record/index"> <i class="el-icon-s-grid"></i>科技数据</el-menu-item>
       <el-menu-item index="/serve/index"> <i class="el-icon-s-grid"></i>科技服务</el-menu-item>
       <el-menu-item index="/resource/index"> <i class="el-icon-s-grid"></i>科技资源</el-menu-item>
@@ -23,6 +22,7 @@
       </el-submenu>
       <el-menu-item index="/site/index"> <i class="el-icon-s-grid"></i>站点信息管理</el-menu-item>
       <el-menu-item index="/links/index"> <i class="el-icon-attract"></i>友情链接管理</el-menu-item>
+      <el-menu-item index="/supermaket/chanpinType"> <i class="el-icon-s-grid"></i>产品类型字典表</el-menu-item>
     </el-menu>
   </div>
 </template>

+ 60 - 0
src/layout/supermaket/chanpinTypeDetails.vue

@@ -0,0 +1,60 @@
+<template>
+  <div id="recruitDetail">
+    <el-row>
+      <el-col :span="24">
+        <el-col :span="24" class="top">
+          <el-col :span="12" class="topTitle">
+            添加产品类别字典表
+          </el-col>
+          <el-col :span="12" class="topBtn">
+            <el-button type="primary" size="mini" @click="returnBtn()">返回</el-button>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="messgae">
+          <el-form ref="form" :model="form" label-width="100px">
+            <el-form-item label="类别名称">
+              <el-input v-model="form.name"></el-input>
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" @click="onSubmit()">提交</el-button>
+            </el-form-item>
+          </el-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'recruitDetail',
+  props: {
+    form: null,
+  },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    onSubmit() {
+      this.$emit('submitDate', { data: this.form, id: this.form.id });
+    },
+    returnBtn() {
+      this.$router.push({ path: '/supermaket/chanpinType' });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  padding: 15px 0;
+}
+.top .topTitle {
+  text-align: left;
+}
+.top .topBtn {
+  text-align: right;
+  padding: 0 5px;
+}
+</style>

+ 93 - 0
src/layout/supermaket/chanpinTypeList.vue

@@ -0,0 +1,93 @@
+<template>
+  <div id="chanpinTypeList">
+    <el-row>
+      <el-col :span="24" class="info">
+        <el-col :span="24" class="top">
+          <el-col :span="12" class="topTitle">
+            <span>产品类型字典表</span>
+          </el-col>
+          <el-col :span="12" class="topAdd">
+            <el-button type="primary" size="mini" @click="addData()"><i class="el-icon-plus"></i></el-button>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="list">
+          <template>
+            <el-table :data="chanpinTypeList" style="width: 100%">
+              <el-table-column label="序号" type="index" align="center"> </el-table-column>
+              <el-table-column prop="name" label="类别名称" align="center"> </el-table-column>
+              <el-table-column label="操作" align="center">
+                <template slot-scope="scoped">
+                  <el-button type="text" size="small" @click="$router.push({ path: '/supermaket/chanpinTypeDetail', query: { id: scoped.row.id } })"
+                    ><i class="el-icon-edit"></i
+                  ></el-button>
+                  <el-button type="text" size="small" @click="handleDelete(scoped.row)"><i class="el-icon-delete"></i></el-button>
+                </template>
+              </el-table-column>
+            </el-table>
+            <el-col :span="24" class="page">
+              <el-pagination
+                @size-change="handleSizeChange"
+                @current-change="handleCurrentChange"
+                :current-page="currentPage"
+                layout="total, prev, pager, next, jumper"
+                :total="total"
+              >
+              </el-pagination>
+            </el-col>
+          </template>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'chanpinTypeList',
+  props: {
+    chanpinTypeList: null,
+    total: null,
+  },
+  components: {},
+  data: () => ({
+    currentPage: 1,
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    addData() {
+      this.$router.push({ path: '/supermaket/chanpinTypeDetail' });
+    },
+    handleDelete(item) {
+      this.$emit('delete', item);
+    },
+    handleClick(row) {
+      this.$emit('list', { data: row });
+    },
+    handleSizeChange(val) {
+      console.log(`每页 ${val} 条`);
+    },
+    handleCurrentChange(val) {
+      console.log(`当前页: ${val}`);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  padding: 15px 0;
+  border-bottom: 1px solid #cccc;
+}
+.top .topTitle {
+  padding: 0 10px;
+}
+.top .topAdd {
+  padding: 0 10px 0 0;
+  text-align: right;
+}
+.page {
+  padding: 20px 0;
+  text-align: center;
+}
+</style>

+ 10 - 5
src/router/index.js

@@ -41,11 +41,6 @@ export default new Router({
       path: '/policy/messageInfoDetail',
       component: () => import('../views/policy/messageInfoDetail.vue'),
     },
-    // 科技超市
-    {
-      path: '/supermaket/index',
-      component: () => import('../views/supermaket/index.vue'),
-    },
     // 科技数据
     {
       path: '/record/index',
@@ -148,5 +143,15 @@ export default new Router({
       meta: { title: '友情链接' },
       component: () => import('../views/links/detail.vue'),
     },
+    // 产品类型字典表
+    {
+      path: '/supermaket/chanpinType',
+      component: () => import('../views/supermaket/chanpinType.vue'),
+    },
+    // 添加产品类型字典表
+    {
+      path: '/supermaket/chanpinTypeDetail',
+      component: () => import('../views/supermaket/chanpinTypeDetail.vue'),
+    },
   ],
 });

+ 2 - 0
src/store/index.js

@@ -17,6 +17,7 @@ import talentInformation from './talentInformation';
 import talentRecruitment from './talentRecruitment';
 import talentResume from './talentResume';
 import dictionary from './dictionary';
+import protype from './protype';
 
 Vue.use(Vuex);
 
@@ -38,6 +39,7 @@ export default new Vuex.Store({
     talentRecruitment,
     talentResume,
     dictionary,
+    protype,
   },
   state: {},
   mutations: {},

+ 38 - 0
src/store/protype.js

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

+ 58 - 0
src/views/supermaket/chanpinType.vue

@@ -0,0 +1,58 @@
+<template>
+  <div id="chanpinType">
+    <el-row>
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle"></topInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <chanpinTypeList :chanpinTypeList="chanpinTypeList" :total="total" @delete="deleteData"></chanpinTypeList>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import chanpinTypeList from '@/layout/supermaket/chanpinTypeList.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapProtype } = createNamespacedHelpers('protype');
+export default {
+  name: 'chanpinType',
+  props: {},
+  components: {
+    topInfo, //头部信息
+    chanpinTypeList, //产品类型字典表
+  },
+  data: () => ({
+    topTitle: '产品类型字典表',
+    chanpinTypeList: [],
+    total: 1,
+  }),
+  created() {
+    this.search();
+  },
+  computed: {},
+  methods: {
+    ...mapProtype(['query', 'delete', 'fetch']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      this.$set(this, `chanpinTypeList`, res.data);
+      this.$set(this, `total`, res.total);
+    },
+    async deleteData(item) {
+      const res = await this.delete(item.id);
+      this.$checkRes(res, '删除成功', '删除失败');
+      this.search();
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  padding: 20px;
+  margin: 10px 20px;
+  border: 1px solid #ccc;
+  width: 96%;
+}
+</style>

+ 78 - 0
src/views/supermaket/chanpinTypeDetail.vue

@@ -0,0 +1,78 @@
+<template>
+  <div id="chanpinTypeDetail">
+    <el-row>
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle"></topInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <chanpinTypeDetails :form="form" @submitDate="onSubmit"></chanpinTypeDetails>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import chanpinTypeDetails from '@/layout/supermaket/chanpinTypeDetails.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapProtype } = createNamespacedHelpers('protype');
+export default {
+  name: 'messageInfoDetail',
+  props: {},
+  components: {
+    topInfo,
+    chanpinTypeDetails,
+  },
+  data: () => ({
+    topTitle: '添加产品类型字典表',
+    form: {},
+  }),
+  created() {
+    this.search();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  methods: {
+    ...mapProtype(['fetch', 'create', 'update']),
+    async search() {
+      if (this.$route.query.id) {
+        const res = await this.fetch(this.id);
+        this.$set(this, `form`, res.data);
+      }
+    },
+    async onSubmit(form) {
+      let data = this.form;
+      let res;
+      let msg;
+      if (data.id) {
+        res = await this.update(data);
+        msg = `${this.keyWord}修改成功`;
+      } else {
+        res = await this.create(data);
+        msg = `${this.keyWord}添加成功`;
+      }
+      if (this.$checkRes(res, msg)) this.$router.push({ path: '/supermaket/chanpinType' });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  padding: 0 0 10px 0;
+}
+.main {
+  padding: 20px;
+  margin: 10px 20px;
+  border: 1px solid #ccc;
+  width: 96%;
+}
+</style>

+ 0 - 19
src/views/supermaket/index.vue

@@ -1,19 +0,0 @@
-<template>
-  <div id="index">
-    <p>科技超市暂未开通</p>
-  </div>
-</template>
-
-<script>
-export default {
-  name: 'index',
-  props: {},
-  components: {},
-  data: () => ({}),
-  created() {},
-  computed: {},
-  methods: {},
-};
-</script>
-
-<style lang="less" scoped></style>

+ 6 - 0
vue.config.js

@@ -61,6 +61,12 @@ module.exports = {
         ws: true,
         // pathRewrite: { '^/api/affairs': '/api' },
       },
+      '/api/market': {
+        target: 'http://free.liaoningdoupo.com',
+        changeOrigin: true,
+        ws: true,
+        // pathRewrite: { '^/api/affairs': '/api' },
+      },
     },
   },
 };