guhongwei 4 سال پیش
والد
کامیت
239c74c817
5فایلهای تغییر یافته به همراه322 افزوده شده و 7 حذف شده
  1. 5 0
      src/router/index.js
  2. 3 0
      src/store/index.js
  3. 38 0
      src/store/talentInformation.js
  4. 157 0
      src/views/informate/detail.vue
  5. 119 7
      src/views/informate/index.vue

+ 5 - 0
src/router/index.js

@@ -103,6 +103,11 @@ export default new Router({
         {
           path: '/informate',
           component: () => import('../views/informate/index.vue'),
+          meta: { title: '基本信息' },
+        },
+        {
+          path: '/informate/detail',
+          component: () => import('../views/informate/detail.vue'),
           meta: { title: '基本信息管理' },
         },
         {

+ 3 - 0
src/store/index.js

@@ -28,6 +28,8 @@ import talentRecruitment from './talentRecruitment';
 import talentResume from './talentResume';
 // 科技人才-专家信息
 import talentExperts from './talentExperts';
+// 科技人才-基本信息管理
+import talentInformation from './talentInformation';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -50,5 +52,6 @@ export default new Vuex.Store({
     serveNews,
     talentResume,
     talentExperts,
+    talentInformation,
   },
 });

+ 38 - 0
src/store/talentInformation.js

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

+ 157 - 0
src/views/informate/detail.vue

@@ -0,0 +1,157 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="main">
+        <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
+        <el-col :span="24" class="container">
+          <el-col :span="24" class="add">
+            <el-button type="primary" size="mini" @click="back()">返回</el-button>
+          </el-col>
+          <el-col :span="24" v-if="loading">
+            <data-form :data="form" :fields="Fields" :rules="{}" @save="turnSave">
+              <template #options="{item}">
+                <template v-if="item.model == 'column_id'">
+                  <el-option v-for="(item, index) in columnList" :key="index" :label="item.name" :value="item.id"></el-option>
+                </template>
+                <template v-else-if="item.model == 'infotype'">
+                  <el-option label="就业指导" value="就业指导"></el-option>
+                  <el-option label="工作顾问" value="工作顾问"></el-option>
+                  <el-option label="新闻" value="新闻"></el-option>
+                  <el-option label="简历" value="简历"></el-option>
+                  <el-option label="面试" value="面试"></el-option>
+                  <el-option label="其他" value="其他"></el-option>
+                </template>
+              </template>
+              <template #custom="{item,form}">
+                <template v-if="item.model == 'content'">
+                  <wang-editor v-model="form.content" placeholder="请输入信息内容"></wang-editor>
+                </template>
+              </template>
+            </data-form>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import WangEditor from '@c/frame/wang-editor.vue';
+import breadcrumb from '@c/common/breadcrumb.vue';
+import dataForm from '@c/frame/form.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: mapColumn } = createNamespacedHelpers('talentColumn');
+const { mapActions: mapNews } = createNamespacedHelpers('talentInformation');
+export default {
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  name: 'detail',
+  props: {},
+  components: {
+    breadcrumb,
+    dataForm,
+    WangEditor,
+  },
+  data: function() {
+    return {
+      form: {},
+      Fields: [
+        { label: '信息名称', model: 'name' },
+        { label: '发布人', model: 'user_name' },
+        { label: '所属栏目', model: 'column_id', type: 'select' },
+        { label: '信息类型', model: 'infotype', type: 'select' },
+        { label: '信息内容', model: 'content', custom: true },
+      ],
+      loading: true,
+      // 栏目列表
+      columnList: [],
+    };
+  },
+  async created() {
+    await this.searchcol();
+    await this.search();
+  },
+  methods: {
+    ...mapColumn({ colquery: 'query' }),
+    ...mapNews({ newfetch: 'fetch', newcreate: 'create', newupdate: 'update' }),
+    // 查询详情
+    async search() {
+      if (this.id) {
+        this.loading = false;
+        const res = await this.newfetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+          this.loading = true;
+        } else {
+          this.$message({
+            message: res.errmsg,
+            type: 'error',
+          });
+        }
+      }
+    },
+    // 保存信息
+    async turnSave({ data }) {
+      if (data.id) {
+        const res = await this.newupdate(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '修改成功',
+            type: 'success',
+          });
+          this.back();
+        } else {
+          this.$message({
+            message: res.errmsg,
+            type: 'error',
+          });
+        }
+      } else {
+        data.user_id = '1';
+        const res = await this.newcreate(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '添加成功',
+            type: 'success',
+          });
+          this.back();
+        } else {
+          this.$message({
+            message: res.errmsg,
+            type: 'error',
+          });
+        }
+      }
+    },
+    // 返回
+    back() {
+      this.form = {};
+      this.$router.push({ path: '/informate' });
+    },
+    // 查询栏目
+    async searchcol() {
+      let res = await this.colquery();
+      if (res.errcode == 0) {
+        this.$set(this, `columnList`, res.data);
+      }
+    },
+    // 上传图片
+    uploadSuccess({ type, data }) {
+      this.$set(this.form, `${type}`, data.uri);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.add {
+  text-align: right;
+}
+</style>

+ 119 - 7
src/views/informate/index.vue

@@ -1,31 +1,143 @@
 <template>
   <div id="index">
     <el-row>
-      <el-col :span="24">
-        <p>index</p>
+      <el-col :span="24" class="main">
+        <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
+        <el-col :span="24" class="container">
+          <el-col :span="24" class="top">
+            <el-button type="primary" size="mini" @click="$router.push({ path: '/informate/detail' })">添加</el-button>
+          </el-col>
+          <el-col :span="24" class="list">
+            <data-table
+              :fields="fields"
+              :opera="opera"
+              :data="list"
+              :total="total"
+              :toFormat="toFormat"
+              @edit="toEdit"
+              @delete="toDelete"
+              @query="search"
+            ></data-table>
+          </el-col>
+        </el-col>
       </el-col>
     </el-row>
   </div>
 </template>
 
 <script>
+import breadcrumb from '@c/common/breadcrumb.vue';
+import dataTable from '@/components/frame/filter-page-table.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: talentColumn } = createNamespacedHelpers('talentColumn');
+const { mapActions: talentInformation } = createNamespacedHelpers('talentInformation');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
   },
   name: 'index',
   props: {},
-  components: {},
+  components: {
+    breadcrumb,
+    dataTable,
+  },
   data: function() {
-    return {};
+    return {
+      opera: [
+        {
+          label: '修改',
+          icon: 'el-icon-edit',
+          method: 'edit',
+        },
+        {
+          label: '删除',
+          icon: 'el-icon-delete',
+          method: 'delete',
+        },
+      ],
+      fields: [
+        { label: '名称', prop: 'name', filter: 'input' },
+        { label: '所属栏目', prop: 'column_id', format: true },
+
+        { label: '发布人', prop: 'user_name' },
+        { label: '信息类型', prop: 'infotype' },
+      ],
+      list: [],
+      total: 0,
+      column: [],
+    };
+  },
+  async created() {
+    await this.searchcol();
+    await this.search();
+  },
+  methods: {
+    ...talentColumn({ colquery: 'query' }),
+    ...talentInformation(['query', 'delete', 'fetch']),
+    // 查询列表
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      } else {
+        this.$message({
+          message: res.errmsg,
+          type: 'error',
+        });
+      }
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$router.push({ path: 'informate/detail', query: { id: data.id } });
+    },
+    // 删除
+    async toDelete({ data }) {
+      const res = await this.delete(data.id);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '刪除成功',
+          type: 'success',
+        });
+        this.search();
+      } else {
+        this.$message({
+          message: res.errmsg,
+          type: 'error',
+        });
+      }
+    },
+    // 过滤栏目
+    toFormat({ model, value }) {
+      if (model == 'column_id') {
+        const res = this.column.find(f => f.id == value);
+        console.log(res);
+        if (res) return res.name;
+      }
+    },
+    async searchcol() {
+      const res = await this.colquery();
+      if (this.$checkRes(res)) {
+        this.$set(this, `column`, res.data);
+      } else {
+        this.$message({
+          message: res.errmsg,
+          type: 'error',
+        });
+      }
+    },
   },
-  created() {},
-  methods: {},
   computed: {
     ...mapState(['user']),
   },
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.main {
+  .top {
+    text-align: right;
+    margin: 15px 0;
+  }
+}
+</style>