index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div id="index">
  3. <el-col class="main animate__animated animate__backInRight">
  4. <el-col :span="24" class="one">
  5. <component :is="partsSearch" :is_search="true" :fields="fields" @search="partSearch">
  6. <template #studio_id>
  7. <el-option v-for="i in studioList" :key="i._id" :label="i.name" :value="i._id"></el-option>
  8. </template>
  9. </component>
  10. </el-col>
  11. <el-col :span="24" class="two">
  12. <component
  13. :is="CTable"
  14. :fields="fields"
  15. :opera="opera"
  16. :select="false"
  17. :selected="selected"
  18. @handleSelect="handleSelect"
  19. @query="search"
  20. :data="tableData"
  21. :total="total"
  22. @view="toView"
  23. >
  24. </component>
  25. </el-col>
  26. </el-col>
  27. </div>
  28. </template>
  29. <script setup lang="ts">
  30. import store from '@/stores/counter';
  31. import { ElMessage } from 'element-plus';
  32. // #region 组件
  33. import partsSearch from '@/components/c-search.vue';
  34. import CTable from '@/components/c-table.vue';
  35. // #endregion
  36. import type { Ref } from 'vue';
  37. import { ref, onMounted, getCurrentInstance } from 'vue';
  38. import { useRouter } from 'vue-router';
  39. // #region 接口
  40. import { ScientistsettleStore } from '@common/src/stores/studio/studios/scientistsettle'; // 入驻科学家工作室
  41. import { UserStudioApplyStore } from '@common/src/stores/studio/role/userStudioApply'; // 个人账号申请科学家工作室权限表
  42. import { StudioStore } from '@common/src/stores/studio/studios/studio'; // 工作室
  43. import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
  44. import type { IQueryResult } from '@/util/types.util';
  45. const scientistsettle = ScientistsettleStore();
  46. const userStudioApply = UserStudioApplyStore();
  47. const studio = StudioStore();
  48. const sysdictdata = DictDataStore();
  49. const { proxy } = getCurrentInstance() as any;
  50. const router = useRouter();
  51. // #endregion
  52. // 列表数据
  53. let tableData: Ref<any[]> = ref([]);
  54. // 列表
  55. let fields: Ref<any[]> = ref([
  56. { label: '序号', options: { type: 'index' } },
  57. {
  58. label: '工作室名称',
  59. model: 'studio_id',
  60. type: 'select',
  61. format: (i: string) => {
  62. let data = studioList.value.find((r) => r._id == i);
  63. if (data) return data.name || data.apply_name;
  64. },
  65. isSearch: true,
  66. },
  67. { label: '依托单位', model: 'company_name', isSearch: true },
  68. { label: '入驻科学家', model: 'scientist_name' },
  69. {
  70. label: '团队成员',
  71. model: 'team',
  72. format: (i: Array<any>) => {
  73. let name = '';
  74. if (i && i.length > 0) {
  75. let p1 = i.map((i: { name: string }) => i.name);
  76. name = p1.join(',');
  77. return name;
  78. } else {
  79. return '暂无';
  80. }
  81. },
  82. },
  83. ]);
  84. // 操作
  85. let opera: Ref<any[]> = ref([{ label: '详情', method: 'view' }]);
  86. // 多选
  87. let selected: Ref<any[]> = ref([]);
  88. // 总数
  89. let total: Ref<number> = ref(0);
  90. let skip = 0;
  91. let limit: number = proxy.$limit;
  92. // 用户信息
  93. let user: Ref<{ _id: string; name: string; unit_name: string; nick_name: string }> = ref({ _id: '', name: '', unit_name: '', nick_name: '' });
  94. // 查询数据
  95. let searchForm: Ref<{}> = ref({});
  96. // 个人用户信息
  97. let userInfo: Ref<{ _id: String; user_id: String; status: String }> = ref({ _id: '', user_id: '', status: '' });
  98. // 领域
  99. let fieldList: Ref<any[]> = ref([]);
  100. // 工作室信息
  101. let studioList: Ref<any[]> = ref([]);
  102. // 工作室查询列表
  103. let searchStudioList: Ref<any[]> = ref([]);
  104. onMounted(async () => {
  105. user.value = store.state.user as { _id: string; name: string; unit_name: string; nick_name: string };
  106. await searchUser();
  107. await searchOther();
  108. await search({ skip, limit });
  109. await searchStudio();
  110. });
  111. const searchUser = async () => {
  112. const res: IQueryResult = await userStudioApply.query({ user_id: user.value._id });
  113. let list = res.data as any[];
  114. if (res.total > 0) userInfo.value = list[0];
  115. };
  116. const searchStudio = async () => {
  117. const res: IQueryResult = await scientistsettle.query({ scientist_id: userInfo.value._id });
  118. let studio = res.data as any[];
  119. if (res.total > 0) {
  120. let list = [];
  121. for (const val of studio) {
  122. let data = studioList.value.find((r: { id: string }) => r.id == val.studio_id);
  123. if (data) {
  124. let obj = { id: val.id, name: data.name || '', apply_name: data.apply_name };
  125. list.push(obj);
  126. }
  127. }
  128. searchStudioList.value = list;
  129. }
  130. };
  131. // 查询
  132. const search = async (e: { skip: number; limit: number }) => {
  133. if (userInfo && userInfo.value.user_id && userInfo.value.status == '1') {
  134. const { skip, limit } = e;
  135. let info = { limit: limit, skip: skip, ...searchForm.value, user_id: userInfo.value.user_id };
  136. const res: IQueryResult = await scientistsettle.query(info);
  137. tableData.value = res.data as any[];
  138. total.value = res.total;
  139. } else {
  140. ElMessage({ type: 'warning', message: `用户未完成信息填报/信息填报未完成审核,无法查询相关信息` });
  141. }
  142. };
  143. // 查询
  144. const partSearch = (form: { [x: string]: any }) => {
  145. searchForm.value = form;
  146. search({ skip, limit });
  147. };
  148. // 查看详情
  149. const toView = async (data: { studio_id: string }) => {
  150. if (data.studio_id) {
  151. router.push({ path: '/user/scientist/studio/info', query: { id: data.studio_id } });
  152. } else {
  153. ElMessage({ message: '暂无工作室信息', type: 'warning' });
  154. }
  155. };
  156. // 选择
  157. const handleSelect = () => {};
  158. // 查询其他信息
  159. const searchOther = async () => {
  160. // 工作室信息
  161. const p1: IQueryResult = await studio.query();
  162. studioList.value = p1.data as [];
  163. // 领域
  164. const p2: IQueryResult = await sysdictdata.query({ dict_type: 'studio_field' });
  165. fieldList.value = p2.data as [];
  166. };
  167. </script>
  168. <style scoped></style>