index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 #status>
  7. <el-option v-for="i in statusList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
  8. </template>
  9. </component>
  10. </el-col>
  11. <el-col :span="24" class="two">
  12. <component :is="Btn1" @toAdd="toAdd"></component>
  13. </el-col>
  14. <el-col :span="24" class="thr">
  15. <component
  16. :is="CTable"
  17. :fields="fields"
  18. :opera="opera"
  19. :select="false"
  20. :selected="selected"
  21. @handleSelect="handleSelect"
  22. @query="search"
  23. :data="tableData"
  24. :total="total"
  25. @view="toView"
  26. >
  27. </component>
  28. </el-col>
  29. </el-col>
  30. </div>
  31. </template>
  32. <script setup lang="ts">
  33. import store from '@/stores/counter';
  34. import { ElMessage } from 'element-plus';
  35. // #region 组件
  36. import partsSearch from '@common/src/components/frame/c-search.vue';
  37. import CTable from '@common/src/components/frame/c-table.vue';
  38. import Btn1 from '@common/src/components/frame/btn-1.vue';
  39. // #endregion
  40. import type { Ref } from 'vue';
  41. import { ref, onMounted, getCurrentInstance } from 'vue';
  42. import { useRouter } from 'vue-router';
  43. // #region 接口
  44. import { StudioStore } from '@common/src/stores/studio/studios/studio'; // 工作室
  45. import { UnitStudioApplyStore } from '@common/src/stores/studio/role/unitStudioApply'; // 依托单位申请科学家工作室权限表
  46. import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
  47. import type { IQueryResult } from '@/util/types.util';
  48. const studio = StudioStore();
  49. const unitStudioApply = UnitStudioApplyStore();
  50. const sysdictdata = DictDataStore();
  51. const { proxy } = getCurrentInstance() as any;
  52. const router = useRouter();
  53. // #endregion
  54. // 列表数据
  55. let tableData: Ref<any[]> = ref([]);
  56. // 总数
  57. let total: Ref<number> = ref(0);
  58. let skip = 0;
  59. let limit: number = proxy.$limit;
  60. // 列表
  61. let fields: Ref<any[]> = ref([
  62. { label: '序号', options: { type: 'index' } },
  63. { label: '工作室名称', model: 'name', isSearch: true },
  64. { label: '依托单位', model: 'company_name', isSearch: true },
  65. { label: '入驻科学家', model: 'scientist_name', isSearch: true },
  66. { label: '申报日期', model: 'apply_time' },
  67. {
  68. label: '申报状态',
  69. model: 'status',
  70. type: 'select',
  71. format: (i) => {
  72. let data = statusList.value.find((r) => r.dict_value == i);
  73. if (data) return data.dict_label;
  74. },
  75. isSearch: true,
  76. },
  77. ]);
  78. // 操作
  79. let opera: Ref<any[]> = ref([{ label: '申报进度', method: 'view' }]);
  80. // 多选
  81. let selected: Ref<any[]> = ref([]);
  82. // 用户信息
  83. let user: Ref<{ _id: string; name: string; unit_name: string; nick_name: string }> = ref({ _id: '', name: '', unit_name: '', nick_name: '' });
  84. // 查询数据
  85. let searchForm: Ref<{}> = ref({});
  86. // 依托单位信息
  87. let unitInfo: Ref<{ _id: String; status: String }> = ref({ _id: '', status: '' });
  88. // 状态
  89. let statusList: Ref<any[]> = ref([]);
  90. onMounted(async () => {
  91. user.value = store.state.user as { _id: string; name: string; unit_name: string; nick_name: string };
  92. await searchUnit();
  93. await searchOther();
  94. await search({ skip, limit });
  95. });
  96. // 依托单位信息
  97. const searchUnit = async () => {
  98. const res: IQueryResult = await unitStudioApply.query({ unit_id: user.value._id });
  99. let list = res.data as any[];
  100. if (res.total > 0) unitInfo.value = list[0];
  101. };
  102. // 查询
  103. const search = async (e: { skip: number; limit: number }) => {
  104. if (unitInfo && unitInfo.value._id && unitInfo.value.status == '1') {
  105. const { skip, limit } = e;
  106. let info = { limit: limit, skip: skip, ...searchForm.value, company_id: unitInfo.value._id };
  107. const res: IQueryResult = await studio.query(info);
  108. if (res.errcode == 0) {
  109. tableData.value = res.data as any[];
  110. total.value = res.total;
  111. } else ElMessage({ type: 'warning', message: `${res.errmsg}` });
  112. } else {
  113. ElMessage({ type: 'warning', message: `用户未完成信息填报/信息填报未完成审核,无法查询相关信息` });
  114. }
  115. };
  116. // 查询
  117. const partSearch = (form: { [x: string]: any }) => {
  118. searchForm.value = form;
  119. search({ skip, limit });
  120. };
  121. // 添加
  122. const toAdd = () => {
  123. if (unitInfo && unitInfo.value._id && unitInfo.value.status == '1') {
  124. router.push({ path: '/unit/studio/add' });
  125. } else {
  126. ElMessage({ message: '用户未完成信息填报/信息填报未完成审核,无法查询相关信息', type: 'warning' });
  127. }
  128. };
  129. // 申报进度
  130. const toView = (data: { _id: string; status: string }) => {
  131. router.push({ path: '/unit/studio/add', query: { id: data._id, status: data.status } });
  132. };
  133. // 选择
  134. const handleSelect = () => {};
  135. // 查询其他信息
  136. const searchOther = async () => {
  137. // 审核状态
  138. const p1: IQueryResult = await sysdictdata.query({ dict_type: 'studio_studio_status', is_use: '0' });
  139. statusList.value = p1.data as [];
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. .main {
  144. .thr {
  145. margin: 1vw 0 0 0;
  146. }
  147. }
  148. </style>