guhongwei hace 3 años
padre
commit
e0b5119e1f

+ 1 - 0
package.json

@@ -11,6 +11,7 @@
     "@stomp/stompjs": "^6.1.0",
     "axios": "^0.21.1",
     "core-js": "^3.6.5",
+    "echarts": "^5.1.1",
     "element": "^0.1.4",
     "element-ui": "^2.15.1",
     "jsonwebtoken": "^8.5.1",

+ 2 - 2
src/router/index.js

@@ -102,9 +102,9 @@ const router = new VueRouter({
 router.beforeEach((to, from, next) => {
   document.title = `${to.meta.title} `;
   const token = localStorage.getItem('token');
-  if (to.name == 'finance_account') {
+  if (to.path == '/finance/account' || to.path == '/declare/tutor') {
     if (!token) {
-      next('/login');
+      next(`/login?path=${to.path}`);
     } else {
       let user = jwt.decode(token);
       store.commit('setUser', user, { root: true });

+ 6 - 0
src/store/index.js

@@ -8,6 +8,9 @@ import column from '@common/src/store/column';
 import questionnaire from '@common/src/store/question/questionnaire';
 import answer from '@common/src/store/question/answer';
 import organization from '@common/src/store/organization';
+// 直播平台
+import declare from './live/declare';
+import mechanism from './live/mechanism';
 
 const _ = require('lodash');
 
@@ -54,6 +57,9 @@ export default new Vuex.Store({
     questionnaire,
     answer,
     organization,
+    // 直播平台
+    declare,
+    mechanism,
   },
   getters: {
     // 传参,就是menusetting中的key,这样就返回子菜单,如果不传,就返回主菜单

+ 43 - 0
src/store/live/declare.js

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

+ 58 - 0
src/store/live/mechanism.js

@@ -0,0 +1,58 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  mechanism: `/api/live/v0/cysci/mechanism`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.mechanism}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.mechanism}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.mechanism}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.mechanism}/update/${id}`, data);
+    return res;
+  },
+
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.mechanism}/${payload}`);
+    return res;
+  },
+  async password({ commit }, { id, passwd }) {
+    const res = await this.$axios.$post(`${api.mechanism}/password/${id}`, { passwd });
+    return res;
+  },
+  async login({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.mechanism}/login`, payload);
+    const jwt = require('jsonwebtoken');
+    if (res.errcode === 0) {
+      localStorage.setItem('token', res.data);
+      localStorage.setItem('type', 'ZJJG');
+      const user = jwt.decode(res.data);
+      commit('setUser', user, { root: true });
+    }
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 206 - 5
src/views/declare/tutor.vue

@@ -5,7 +5,99 @@
         <el-col :span="24" class="top">
           <top topType="2" @back="$router.push('/')"></top>
         </el-col>
-        <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }"> 机构辅导 </el-col>
+        <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }">
+          <van-form @submit="onSubmit">
+            <van-col span="24" class="one">
+              <van-col span="24" class="one_txt"> 资质资料 </van-col>
+              <van-col span="24" class="one_info">
+                <van-field v-model="form.company" name="申请单位" label="申请单位" readonly />
+                <van-field v-model="form.apply_person" name="申请人" label="申请人" :rules="[{ required: true, message: '请填写申请人' }]" />
+                <van-field v-model="form.phone" name="联系电话" label="联系电话" :rules="[{ required: true, message: '请填写联系电话' }]" />
+                <van-field name="uploader" label="法人复印件">
+                  <template #input>
+                    <van-uploader
+                      :fileList="form.qyfr"
+                      :max-count="1"
+                      :after-read="(file) => toUpload(file, 'qyfr')"
+                      @delete="(file) => toDelete(file, 'qyfr')"
+                    />
+                  </template>
+                </van-field>
+                <van-field name="uploader" label="企业营业执照">
+                  <template #input>
+                    <van-uploader
+                      :fileList="form.yyzz"
+                      :max-count="1"
+                      :after-read="(file) => toUpload(file, 'yyzz')"
+                      @delete="(file) => toDelete(file, 'yyzz')"
+                    />
+                  </template>
+                </van-field>
+                <van-field name="uploader" label="企业利润表">
+                  <template #input>
+                    <van-uploader
+                      :fileList="form.qylr"
+                      :max-count="1"
+                      :after-read="(file) => toUpload(file, 'qylr')"
+                      @delete="(file) => toDelete(file, 'qylr')"
+                    />
+                  </template>
+                </van-field>
+              </van-col>
+            </van-col>
+            <van-col span="24" class="one">
+              <van-col span="24" class="one_txt"> 信息资料 </van-col>
+              <van-col span="24" class="one_info">
+                <van-field
+                  readonly
+                  clickable
+                  name="picker"
+                  :value="form.mechanism_name"
+                  label="中介机构"
+                  placeholder="点击选择机构"
+                  @click="showPicker = true"
+                />
+                <van-popup v-model="showPicker" position="bottom">
+                  <van-picker show-toolbar :columns="mechanismList" value-key="name" @confirm="onConfirm" @cancel="showPicker = false" />
+                </van-popup>
+                <van-field name="uploader" label="法人复印件">
+                  <template #input>
+                    <van-uploader
+                      :fileList="form.mqyfr"
+                      :max-count="1"
+                      :after-read="(file) => toUpload(file, 'mqyfr')"
+                      @delete="(file) => toDelete(file, 'mqyfr')"
+                    />
+                  </template>
+                </van-field>
+                <van-field name="uploader" label="企业营业执照">
+                  <template #input>
+                    <van-uploader
+                      :fileList="form.myyzz"
+                      :max-count="1"
+                      :after-read="(file) => toUpload(file, 'myyzz')"
+                      @delete="(file) => toDelete(file, 'myyzz')"
+                    />
+                  </template>
+                </van-field>
+                <van-field name="uploader" label="企业利润表">
+                  <template #input>
+                    <van-uploader
+                      :fileList="form.mqylr"
+                      :max-count="1"
+                      :after-read="(file) => toUpload(file, 'mqylr')"
+                      @delete="(file) => toDelete(file, 'mqylr')"
+                    />
+                  </template>
+                </van-field>
+              </van-col>
+            </van-col>
+            <van-col span="24" class="btn">
+              <van-button type="danger" round>取消提交</van-button>
+              <van-button type="info" round native-type="submit">确认提交</van-button>
+            </van-col>
+          </van-form>
+        </el-col>
         <el-col :span="24" class="foot"> <footers /> </el-col>
       </el-col>
     </el-row>
@@ -13,7 +105,11 @@
 </template>
 
 <script>
+const _ = require('lodash');
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: upload } = createNamespacedHelpers('upload');
+const { mapActions: declare } = createNamespacedHelpers('declare');
+const { mapActions: mechanism } = createNamespacedHelpers('mechanism');
 export default {
   name: 'tutor',
   props: {},
@@ -21,14 +117,103 @@ export default {
   data: function () {
     return {
       clientHeight: '',
+      form: {},
+      // 中介机构
+      showPicker: false,
+      mechanismList: [],
     };
   },
-  created() {},
+  created() {
+    this.search();
+  },
+  methods: {
+    ...upload(['upload']),
+    ...declare(['create']),
+    ...mechanism(['query']),
+    async search() {
+      if (this.user) {
+        let data = {
+          user_id: this.user.id,
+          company: this.user.name,
+          apply_person: this.user.companyperson,
+          phone: this.user.phone,
+          qyfr: [],
+          yyzz: [],
+          qylr: [],
+          mqyfr: [],
+          myyzz: [],
+          mqylr: [],
+        };
+        this.$set(this, `form`, data);
+      }
+      const res = await this.query();
+      if (this.$checkRes(res)) {
+        this.$set(this, 'mechanismList', res.data);
+      }
+    },
+    async onSubmit() {
+      let data = this.form;
+      const material = this.resetData();
+      const medium_material = this.resetDataMM();
+      if (material.length < 3 || medium_material.length < 3) {
+        this.$message.error('缺少所需资料');
+        return;
+      }
+      data.material = material;
+      data.medium_material = medium_material;
+      let res = await this.create(data);
+      if (this.$checkRes(res)) {
+        this.$toast({ type: 'success', message: '机构辅导申报成功,请耐心等待结果' });
+      } else {
+        this.$toast({ type: 'fail', message: '机构辅导申报失败' });
+      }
+    },
+    async toUpload({ file }, model) {
+      // 上传,赋值
+      const res = await this.upload({ file, dir: 'files' });
+      if (this.$checkRes(res)) {
+        this.$set(this.form, model, [{ name: res.name, url: res.uri }]);
+      }
+    },
+    toDelete(file, model) {
+      const index = this.form[model].findIndex((f) => _.isEqual(f, file));
+      this.form[model].splice(index, 1);
+    },
+    resetData() {
+      let data = _.cloneDeep(this.form);
+      const arr = ['qyfr', 'yyzz', 'qylr'];
+      const res = [];
+      for (const key of arr) {
+        const e = data[key];
+        if (e.length <= 0) continue;
+        const head = _.head(e);
+        res.push(head);
+      }
+      return res;
+    },
+    resetDataMM() {
+      let data = _.cloneDeep(this.form);
+      const arr = ['mqyfr', 'myyzz', 'mqylr'];
+      const res = [];
+      for (const key of arr) {
+        const e = data[key];
+        if (e.length <= 0) continue;
+        const head = _.head(e);
+        res.push(head);
+      }
+      return res;
+    },
+    // 选择中介
+    onConfirm(value) {
+      this.$set(this.form, `mechanism_name`, value.name);
+      this.$set(this.form, `mechanism_id`, value._id);
+      this.showPicker = false;
+    },
+  },
   mounted() {
     let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 80;
     this.$set(this, `clientHeight`, clientHeight);
   },
-  methods: {},
   computed: {
     ...mapState(['user', 'menuParams']),
     pageTitle() {
@@ -51,8 +236,24 @@ export default {
   .info {
     overflow-x: hidden;
     overflow-y: auto;
-    background-color: #f9f9f9;
-    padding: 5px 5px 0 5px;
+    .van-form {
+      float: left;
+      width: 100%;
+    }
+    .one {
+      .one_txt {
+        font-size: 16px;
+        font-weight: bold;
+        padding: 10px;
+      }
+    }
+    .btn {
+      text-align: center;
+      margin: 10px 0;
+      .van-button {
+        margin: 0 10px;
+      }
+    }
   }
   .foot {
     height: 40px;

+ 1 - 1
src/views/index.vue

@@ -35,11 +35,11 @@ export default {
     const res = this.getMenu();
     this.$set(this, `menu`, res);
   },
+  methods: {},
   mounted() {
     let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 90;
     this.$set(this, `clientHeight`, clientHeight);
   },
-  methods: {},
   computed: {
     ...mapState(['user']),
     ...mapGetters(['getMenu']),

+ 3 - 1
src/views/login.vue

@@ -48,7 +48,9 @@ export default {
     async onSubmit() {
       let res = await this.orgLogin({ user: this.form });
       if (this.$checkRes(res)) {
-        this.$router.push({ path: '/finance/reward' });
+        console.log(res);
+        console.log(this.$route.query.path);
+        this.$router.push({ path: this.$route.query.path });
       }
     },
     back() {

+ 1 - 1
vue.config.js

@@ -27,7 +27,7 @@ module.exports = {
         changeOrigin: true,
         ws: false,
       },
-      '/api': {
+      '/api/live': {
         target: 'http://192.168.1.19:9101', //http://192.168.1.19:9200
         changeOrigin: true,
         ws: false,