index.vue 5.5 KB

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