فهرست منبع

Merge branch 'master' of http://git.cc-lotus.info/zkzx/zkzx_user

YY 1 سال پیش
والد
کامیت
acf859b65e

+ 2 - 2
src/util/axios-wrapper.ts

@@ -102,7 +102,7 @@ export class AxiosWrapper {
       });
       // if (util.token && util.token !== null) axios.defaults.headers.common.Authorization = util.token;
       const token = localStorage.getItem('token');
-      const apiToken = sessionStorage.getItem('apiToken');
+      const apiToken = localStorage.getItem('apiToken');
       if (token) axios.defaults.headers.common['token'] = token;
       if (apiToken) axios.defaults.headers.common['api-token'] = apiToken;
       const res = await axios.request({
@@ -124,7 +124,7 @@ export class AxiosWrapper {
       }
       // 处理apiToken
       const { apiToken: at, ...others } = returnData;
-      if (at) sessionStorage.setItem('apiToken', at);
+      if (at) localStorage.setItem('apiToken', at);
       return others;
     } catch (err: any) {
       let errmsg = '接口请求失败,请稍后重试';

+ 0 - 1
src/views/basic/parts/c-company.vue

@@ -90,7 +90,6 @@ const toSave = async (data) => {
   } else {
     ElMessage({ message: `${res.errmsg}`, type: 'error' });
   }
-  console.log(data);
 };
 // 查询其他信息
 const searchOther = async () => {

+ 3 - 8
src/views/basic/parts/c-expert.vue

@@ -12,9 +12,6 @@
           <template #icon>
             <cUpload :model="`${'icon'}`" :limit="1" url="/files/expert/upload" :list="form.icon" listType="picture-card" @change="onUpload"></cUpload>
           </template>
-          <template #status>
-            <el-option v-for="(i, index) in statusList" :key="index" :label="i.label" :value="i.value"></el-option>
-          </template>
         </cForm>
       </el-col>
     </el-row>
@@ -55,14 +52,14 @@ const fields: Ref<any> = ref([
   { label: '所属行业', model: 'industry' },
   { label: '所属辖区', model: 'area', type: 'select' },
   { label: '身份证号', model: 'card' },
+  { label: '职务职称', model: 'zwzc' },
+  { label: '所在院校', model: 'school' },
+  { label: '所学专业', model: 'major' },
   { label: '出生日期', model: 'birth', type: 'date' },
   { label: 'qq&&微信', model: 'qqwx' },
-  { label: '所在院校', model: 'school' },
   { label: '最高学历', model: 'education' },
-  { label: '所学专业', model: 'major' },
   { label: '单位名称', model: 'company' },
   { label: '头像图片', model: 'icon', custom: true },
-  { label: '职务职称', model: 'zwzc' },
   { label: '擅长领域', model: 'expertise', type: 'textarea' },
   { label: '工作经历', model: 'workexperience', type: 'textarea' },
   { label: '科研综述', model: 'scientific', type: 'textarea' },
@@ -73,7 +70,6 @@ const fields: Ref<any> = ref([
 const rules = reactive<FormRules>({});
 
 // 字典表
-const statusList: Ref<any> = ref([]);
 const codeList: Ref<any> = ref([]);
 const areaList: Ref<any> = ref([]);
 
@@ -104,7 +100,6 @@ const toSave = async (data) => {
   } else {
     ElMessage({ message: `${res.errmsg}`, type: 'error' });
   }
-  console.log(data);
 };
 // 查询其他信息
 const searchOther = async () => {

+ 152 - 18
src/views/basic/parts/c-personal.vue

@@ -1,8 +1,24 @@
 <template>
-  <div id="c-personal">
+  <div id="c-company">
     <el-row>
-      <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
-        <el-col :span="24" class="one">系统首页</el-col>
+      <el-col :span="24" class="company" v-loading="loading">
+        <cForm :fields="fields" :rules="rules" :form="form" labelWidth="auto" :span="12">
+          <template #code>
+            <el-option v-for="i in codeList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+          </template>
+          <template #area>
+            <el-option v-for="i in areaList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+          </template>
+          <template #icon>
+            <cUpload :model="`${'icon'}`" :limit="1" url="/files/expert/upload" :list="form.icon" listType="picture-card" @change="onUpload"></cUpload>
+          </template>
+          <template v-slot:submit>
+            <el-button type="primary" @click="toSave" v-if="is_expert == '1'">提交保存</el-button>
+            <el-button type="primary" @click="toRise" v-if="is_expert == '1'">升级专家</el-button>
+            <el-button type="primary" @click="riseSave" v-if="is_expert == '2'">提交升级</el-button>
+            <el-button type="danger" @click="toCancel" v-if="is_expert == '2'">取消提交</el-button>
+          </template>
+        </cForm>
       </el-col>
     </el-row>
   </div>
@@ -11,28 +27,146 @@
 <script setup lang="ts">
 // 基础
 import type { Ref } from 'vue';
-// reactive,
-import { onMounted, ref, getCurrentInstance } from 'vue';
+import { onMounted, ref, toRefs, reactive } from 'vue';
+import type { FormRules } from 'element-plus';
+import { ElMessage } from 'element-plus';
 // 接口
-//import { TestStore } from '@common/src/stores/test';
-//import type { IQueryResult } from '@/util/types.util';
-//const testAxios = TestStore();
-const { proxy } = getCurrentInstance() as any;
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import { PersonalStore } from '@common/src/stores/admins/personal'; // 个人用户
+import { ExpertStore } from '@common/src/stores/admins/expert'; // 专家
+import type { IQueryResult } from '@/util/types.util';
+const personalAxios = PersonalStore();
+const dictAxios = DictDataStore();
+const expertAxios = ExpertStore();
+
+// 组件传值
+const props = defineProps({
+  user: { type: Boolean, default: () => {} }
+});
+const { user } = toRefs(props);
+
 // 加载中
 const loading: Ref<any> = ref(false);
-// 分页数据
-//  const skip = 0;
-//  const limit = proxy.limit;;
+// 表单
+const form: Ref<any> = ref({});
+const fields: Ref<any> = ref([
+  { label: '邀请码', model: 'code', type: 'select', options: { disabled: true } },
+  { label: '账号', model: 'account', options: { disabled: true } },
+  { label: '用户名', model: 'name' },
+  { label: '手机号', model: 'phone' },
+  { label: '电子邮箱', model: 'email' },
+  { label: '联系地址', model: 'address' },
+  { label: '办公电话', model: 'work_phone' },
+  { label: '所属行业', model: 'industry' },
+  { label: '所属辖区', model: 'area', type: 'select' },
+  { label: '身份证号', model: 'card' },
+  { label: '职务职称', model: 'zwzc' },
+  { label: '所在院校', model: 'school' },
+  { label: '所学专业', model: 'major' }
+]);
+const rules = reactive<FormRules>({});
+
+// 升级为专家属性
+const is_expert: Ref<any> = ref('1');
+
+// 字典表
+const areaList: Ref<any> = ref([]);
+const codeList: Ref<any> = ref([]);
+
 // 请求
 onMounted(async () => {
   loading.value = true;
-  //  await search({ skip, limit });
+  await searchOther();
+  await search();
   loading.value = false;
 });
-//const search = async (e: { skip: number; limit: number }) => {
-//  const info = { skip: e.skip, limit: e.limit, ...searchInfo.value  };
-//  const res: IQueryResult = await testAxios.query(info);
-//  console.log(res);
-//};
+const search = async () => {
+  let users: any = user.value;
+  if (users && users._id) {
+    let res: IQueryResult = await personalAxios.fetch(users._id);
+    if (res.errcode == '0') form.value = res.data;
+  }
+};
+// 提交保存
+const toSave = async (data) => {
+  let res: IQueryResult = await personalAxios.update(data);
+  if (res.errcode == '0') {
+    ElMessage({ message: `信息修改成功`, type: 'success' });
+    search();
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+};
+
+// 升级为专家
+const toRise = () => {
+  is_expert.value = '2';
+  let list = [
+    { label: '出生日期', model: 'birth', type: 'date' },
+    { label: 'qq&&微信', model: 'qqwx' },
+    { label: '最高学历', model: 'education' },
+    { label: '单位名称', model: 'company' },
+    { label: '头像图片', model: 'icon', custom: true },
+    { label: '擅长领域', model: 'expertise', type: 'textarea' },
+    { label: '工作经历', model: 'workexperience', type: 'textarea' },
+    { label: '科研综述', model: 'scientific', type: 'textarea' },
+    { label: '承担项目', model: 'undertakingproject', type: 'textarea' },
+    { label: '科技奖励', model: 'scienceaward', type: 'textarea' },
+    { label: '社会任职', model: 'social', type: 'textarea' }
+  ];
+  fields.value = [...fields.value, ...list];
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+// 提交升级专家
+//个人账号改为停用。创建专家数据,type:6
+const riseSave = async () => {
+  let object = form.value;
+  let res: IQueryResult;
+  // 改个人账号为停用
+  res = await personalAxios.update({ _id: object._id, status: '-1' });
+  if (res.errcode == '0') {
+    console.log('修改数据成功,删除不必要信息,创建专家数据');
+    object.user_id = object._id;
+    delete object._id;
+    object.type = '6';
+    res = await expertAxios.create(object);
+    if (res.errcode == '0') {
+      ElMessage({ message: `账号升级专家成功,自动退出登录`, type: 'success' });
+      toLogout();
+    } else {
+      ElMessage({ message: `${res.errmsg}`, type: 'error' });
+    }
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+};
+// 取消升级
+const toCancel = () => {
+  location.reload();
+};
+// 退出登录
+const toLogout = () => {
+  localStorage.removeItem('token');
+  window.location.href = `${import.meta.env.VITE_APP_HOST}`;
+};
+
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 辖区
+  res = await dictAxios.query({ type: 'jl_area' });
+  if (res.errcode == '0') areaList.value = res.data;
+  // 邀请码
+  res = await dictAxios.query({ type: 'account_code' });
+  if (res.errcode == '0') {
+    let list = res.data as any;
+    list = list.filter((i) => i.value != 'CJGLY');
+    codeList.value = list;
+  }
+};
+// watch(test, (newVal: any) => {});
 </script>
 <style scoped lang="scss"></style>

+ 2 - 0
src/views/home/index.vue

@@ -10,6 +10,7 @@
 
 <script setup lang="ts">
 // 基础
+import store from '@/stores/counter';
 import type { Ref } from 'vue';
 // reactive,
 import { onMounted, ref, getCurrentInstance } from 'vue';
@@ -27,6 +28,7 @@ const loading: Ref<any> = ref(false);
 onMounted(async () => {
   loading.value = true;
   //  await search({ skip, limit });
+  console.log(store.state.user);
   loading.value = false;
 });
 //const search = async (e: { skip: number; limit: number }) => {