index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. @edit="toEdit"
  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 { StudioStore } from '@common/src/stores/studio/studios/studio'; // 工作室
  42. import { UnitStudioApplyStore } from '@common/src/stores/studio/role/unitStudioApply'; // 依托单位申请科学家工作室权限表
  43. import type { IQueryResult } from '@/util/types.util';
  44. const studio = StudioStore();
  45. const unitStudioApply = UnitStudioApplyStore();
  46. const scientistsettle = ScientistsettleStore();
  47. const { proxy } = getCurrentInstance() as any;
  48. const router = useRouter();
  49. // #endregion
  50. // 列表数据
  51. let tableData: Ref<any[]> = ref([]);
  52. // 总数
  53. let total: Ref<number> = ref(0);
  54. let skip = 0;
  55. let limit: number = proxy.$limit;
  56. // 列表
  57. let fields: Ref<any[]> = ref([
  58. { label: '序号', options: { type: 'index' } },
  59. {
  60. label: '科学家工作室',
  61. model: 'studio_id',
  62. type: 'select',
  63. format: (i) => {
  64. let data = studioList.value.find((r) => r._id == i);
  65. if (data) return data.name;
  66. },
  67. isSearch: true,
  68. },
  69. { label: '科学家名称', model: 'scientist_name', isSearch: true },
  70. { label: '工作单位', model: 'company', isSearch: true },
  71. { label: '职称', model: 'zc', isSearch: true },
  72. ]);
  73. // 操作
  74. let opera: Ref<any[]> = ref([{ label: '修改', method: 'edit' }]);
  75. // 多选
  76. let selected: Ref<any[]> = ref([]);
  77. // 用户信息
  78. let user: Ref<{ _id: string; name: string; unit_name: string; nick_name: string }> = ref({ _id: '', name: '', unit_name: '', nick_name: '' });
  79. // 查询数据
  80. let searchForm: Ref<{}> = ref({});
  81. // 依托单位信息
  82. let unitInfo: Ref<{ _id: String; status: String }> = ref({ _id: '', status: '' });
  83. // 工作室
  84. let studioList: Ref<any[]> = ref([]);
  85. onMounted(async () => {
  86. user.value = store.state.user as { _id: string; name: string; unit_name: string; nick_name: string };
  87. await searchUnit();
  88. await searchOther();
  89. await search({ skip, limit });
  90. });
  91. // 依托单位信息
  92. const searchUnit = async () => {
  93. const res: IQueryResult = await unitStudioApply.query({ unit_id: user.value._id });
  94. let list = res.data as any[];
  95. if (res.total > 0) unitInfo.value = list[0];
  96. };
  97. // 查询
  98. const search = async (e: { skip: number; limit: number }) => {
  99. if (unitInfo && unitInfo.value._id && unitInfo.value.status == '1') {
  100. const { skip, limit } = e;
  101. let info = { limit: limit, skip: skip, ...searchForm.value, company_id: unitInfo.value._id };
  102. const res: IQueryResult = await scientistsettle.query(info);
  103. if (res.errcode == 0) {
  104. tableData.value = res.data as any[];
  105. total.value = res.total;
  106. } else ElMessage({ type: 'warning', message: `${res.errmsg}` });
  107. } else {
  108. ElMessage({ type: 'warning', message: `用户未完成信息填报/信息填报未完成审核,无法查询相关信息` });
  109. }
  110. };
  111. // 查询
  112. const partSearch = (form: { [x: string]: any }) => {
  113. searchForm.value = form;
  114. search({ skip, limit });
  115. };
  116. // 修改
  117. const toEdit = (data: { _id: string }) => {
  118. router.push({ path: '/unit/scientist/add', query: { id: data._id } });
  119. };
  120. // 选择
  121. const handleSelect = () => {};
  122. // 查询其他信息
  123. const searchOther = async () => {
  124. // 工作室
  125. const p1: IQueryResult = await studio.query({ user_id: user.value._id });
  126. studioList.value = p1.data as [];
  127. };
  128. </script>
  129. <style lang="scss" scoped>
  130. .main {
  131. .thr {
  132. margin: 1vw 0 0 0;
  133. }
  134. }
  135. </style>