guhongwei 2 years ago
parent
commit
f213dde75d

+ 5 - 0
src/router/module/admin.ts

@@ -19,6 +19,11 @@ export default [
     meta: { title: '信息管理' },
     component: () => import('@/views/expo/achieve/dock/detail.vue')
   },
+  {
+    path: '/expo/achieve/dock/expert',
+    meta: { title: '展会专家' },
+    component: () => import('@/views/expo/achieve/dock/expert.vue')
+  },
   {
     path: '/expo/achieve/trans',
     meta: { title: '交易审核管理' },

+ 228 - 0
src/views/expo/achieve/dock/expert.vue

@@ -0,0 +1,228 @@
+<template>
+  <div id="expert">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_back="true" @toBack="toBack" :is_search="true" :fields="fields" @search="toSearch"></cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cButton @toAdd="toAdd"></cButton>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @del="toDel" @use="toUse">
+            <template #icon="{ row, item }">
+              <el-image class="image" v-for="i in row[item.model]" :key="i.url" :src="i.url"></el-image>
+            </template>
+          </cTable>
+        </el-col>
+      </el-col>
+    </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="12" :fields="formFields" :form="form" @save="toSave" label-width="auto">
+            <template #expert>
+              <el-option v-for="i in changeList" :key="i._id" :label="i.name" :value="i._id"></el-option>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import _ from 'lodash';
+import type { Ref } from 'vue';
+import { onMounted, ref, getCurrentInstance } from 'vue';
+import { useRoute } from 'vue-router';
+import { ElMessage } from 'element-plus';
+
+// 接口
+import { DockStore } from '@common/src/stores/allAdmin/dock';
+import { DockExpertStore } from '@common/src/stores/dock/dockExpert';
+import { ExpertStore } from '@common/src/stores/admins/expert';
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const dockAxios = DockStore();
+const dockExpertAxios = DockExpertStore();
+const expertAxios = ExpertStore();
+const dictAxios = DictDataStore();
+
+const { proxy } = getCurrentInstance() as any;
+
+// 路由
+const route = useRoute();
+
+// 加载中
+const loading: Ref<any> = ref(false);
+// 展会信息
+const dockInfo: Ref<any> = ref({});
+// 列表
+let list: Ref<any> = ref([]);
+let total: Ref<number> = ref(0);
+let skip = 0;
+let limit: number = proxy.$limit;
+let fields: Ref<any[]> = ref([
+  { label: '展会', model: 'dock_id', format: (i) => getDict(i, 'dock_id') },
+  { label: '姓名', model: 'name', isSearch: true },
+  { label: '最高学历', model: 'education', isSearch: true },
+  { label: '所在院校', model: 'school', isSearch: true },
+  { label: '头像', model: 'icon', custom: true },
+  { label: '是否使用', model: 'is_use', format: (i) => getDict(i, 'is_use') }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '删除', method: 'del', confirm: true, type: 'danger' },
+  { label: '使/禁用', method: 'use', confirm: true }
+]);
+
+// 查询数据
+const searchForm: Ref<any> = ref({});
+
+// 字典表
+const expertList: Ref<any> = ref([]);
+const isuseList: Ref<any> = ref([]);
+const changeList: Ref<any> = ref([]);
+
+// 弹框
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
+const form: Ref<any> = ref({});
+const formFields: Ref<any[]> = ref([{ label: '参展专家', model: 'expert', type: 'selectMany' }]);
+// 请求
+onMounted(async () => {
+  loading.value = true;
+  await searchOther();
+  await searchDock();
+  await search({ skip, limit });
+  loading.value = false;
+});
+// 查询展会信息
+const searchDock = async () => {
+  let dock_id = route.query.dock_id;
+  if (dock_id) {
+    let res: IQueryResult = await dockAxios.fetch(dock_id);
+    if (res.errcode == '0') {
+      dockInfo.value = res.data;
+    }
+  }
+};
+// 查询
+const search = async (e: { skip: number; limit: number }) => {
+  const { skip, limit } = e;
+  const condition = _.cloneDeep(searchForm.value);
+  let info = { limit: limit, skip: skip, ...condition, dock_id: dockInfo.value._id };
+  let res: IQueryResult = await dockExpertAxios.query(info);
+  if (res.errcode == 0) {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+// 使/禁用
+const toUse = async (data) => {
+  if (data.is_use == '0') data.is_use = '1';
+  else if (data.is_use == '1') data.is_use = '0';
+  let res: IQueryResult = await dockExpertAxios.update(data);
+  if (res.errcode == '0') {
+    ElMessage({ type: `success`, message: `信息维护成功` });
+    search({ skip, limit });
+  }
+};
+const getDict = (e, model) => {
+  if (model == 'dock_id') {
+    return dockInfo.value.title;
+  } else if (model == 'is_use') {
+    let data = isuseList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  }
+};
+// 添加
+const toAdd = () => {
+  let change: any = [];
+  if (total.value > 0) {
+    for (const val of list.value) {
+      for (const p1 of expertList.value) {
+        if (val.expert_id != p1._id) change.push(p1);
+      }
+    }
+  } else {
+    change = expertList.value;
+  }
+  changeList.value = change;
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 提交保存
+const toSave = async (data) => {
+  let list: any = [];
+  // 遍历,取出所需字段
+  for (const val of data.expert) {
+    let value = expertList.value.find((i: any) => i._id == val);
+    if (value) {
+      let object = {
+        dock_id: dockInfo.value._id,
+        expert_id: value._id,
+        name: value.name || '',
+        icon: value.icon || [],
+        education: value.education || '',
+        school: value.school || ''
+      };
+      list.push(object);
+    }
+  }
+  if (list && list.length > 0) {
+    for (const val of list) {
+      let res: IQueryResult = await dockExpertAxios.create(val);
+      if (res.errcode == '0') console.log('1');
+    }
+    ElMessage({ type: `success`, message: `专家添加成功` });
+    toClose();
+  }
+};
+// 关闭弹框
+const toClose = () => {
+  form.value = {};
+  dialog.value = { title: '信息管理', show: false, type: '1' };
+  search({ skip, limit });
+};
+// 删除
+const toDel = async (data) => {
+  let res: IQueryResult = await dockExpertAxios.del(data._id);
+  if (res.errcode == '0') {
+    ElMessage({ type: `success`, message: `刪除信息成功` });
+    search({ skip, limit });
+  }
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 专家
+  res = await expertAxios.query({ status: '1' });
+  if (res.errcode == '0') expertList.value = res.data;
+  // 是否使用
+  res = await dictAxios.query({ type: 'common_use' });
+  if (res.errcode == '0') isuseList.value = res.data;
+};
+// 返回上一页
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
+<style scoped lang="scss">
+.main {
+  .two {
+    margin: 0 0 10px 0;
+  }
+  .thr {
+    .image {
+      width: 50px;
+      height: 50px;
+    }
+  }
+}
+</style>

+ 1 - 1
src/views/expo/achieve/dock/index.vue

@@ -114,7 +114,7 @@ const toDel = async (data) => {
 };
 // 参展专家
 const toExp = (data) => {
-  console.log(data);
+  router.push({ path: '/expo/achieve/dock/expert', query: { dock_id: data._id } });
 };
 const searchOther = async () => {
   let res: IQueryResult;