index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.model" :label="i.dict_label" :value="i.dict_value"></el-option>
  9. </template>
  10. <template #studio_id>
  11. <el-option v-for="i in studioList" :key="i.id" :label="i.name" :value="i.id"></el-option>
  12. </template>
  13. </component>
  14. </el-col>
  15. <el-col :span="24" class="two">
  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. @exam="toExam"
  27. >
  28. <template #file="{ row, item }">
  29. <el-link v-for="(i, index) in row[item.model]" :key="index" :href="i.url" target="_blank">{{ i.name }}</el-link>
  30. </template>
  31. </component>
  32. </el-col>
  33. </el-col>
  34. </el-row>
  35. <component :is="CDialog" :dialog="dialog" @handleClose="handleClose">
  36. <template v-slot:info>
  37. <component :is="CForm" :fields="infoFields" :rules="rules" :form="form" labelWidth="auto" @save="toSave">
  38. <template #status>
  39. <el-option v-for="(item, index) in statusList" :key="index" :label="item.dict_label" :value="item.dict_value"></el-option>
  40. </template>
  41. </component>
  42. </template>
  43. </component>
  44. </div>
  45. </template>
  46. <script setup lang="ts">
  47. import store from '@/stores/counter';
  48. import moment from 'moment';
  49. // #region 组件
  50. import partsSearch from '@/components/c-search.vue';
  51. import CTable from '@/components/c-table.vue';
  52. import CForm from '@/components/c-form.vue';
  53. import CDialog from '@/components/c-dialog.vue';
  54. // #endregion
  55. import type { Ref } from 'vue';
  56. import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
  57. import type { FormRules } from 'element-plus';
  58. import { ElMessage } from 'element-plus';
  59. import { useRoute } from 'vue-router';
  60. // #region 接口
  61. import { ApplyflairStore } from '@common/src/stores/studio/studios/applyflair'; // 列表
  62. import { StudioStore } from '@common/src/stores/studio/studios/studio'; // 列表
  63. import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
  64. import { MessageStore } from '@common/src/stores/studio/other/message'; // 系统消息
  65. import { UnitStudioApplyStore } from '@common/src/stores/studio/role/unitStudioApply';
  66. import type { IQueryResult } from '@/util/types.util';
  67. const applyflair = ApplyflairStore();
  68. const studio = StudioStore();
  69. const sysdictdata = DictDataStore();
  70. const message = MessageStore();
  71. const unitStudioApply = UnitStudioApplyStore();
  72. const { proxy } = getCurrentInstance() as any;
  73. let route = useRoute();
  74. // #endregion
  75. // 列表数据
  76. let tableData: Ref<any[]> = ref([]);
  77. // 列表
  78. let fields: Ref<any[]> = ref([
  79. { label: '序号', options: { type: 'index' } },
  80. {
  81. label: '工作室名称',
  82. model: 'studio_id',
  83. type: 'select',
  84. format: (i) => {
  85. let data = studioList.value.find((r) => r._id == i);
  86. if (data) return data.name;
  87. },
  88. isSearch: true,
  89. },
  90. { label: '依托单位名称', model: 'company_name' },
  91. { label: '申请时间', model: 'apply_time' },
  92. { label: '评估文件', model: 'file', custom: true },
  93. {
  94. label: '审核状态',
  95. model: 'status',
  96. type: 'select',
  97. format: (i) => {
  98. let data = statusList.value.find((r) => r.dict_value == i);
  99. if (data) return data.dict_label;
  100. },
  101. isSearch: true,
  102. },
  103. ]);
  104. // 操作
  105. let opera: Ref<any[]> = ref([{ label: '审核', method: 'exam', type: 'warning', display: (i) => i.status == '0' }]);
  106. // 多选
  107. let selected: Ref<any[]> = ref([]);
  108. // 总数
  109. let total: Ref<number> = ref(0);
  110. let skip = 0;
  111. let limit: number = proxy.$limit;
  112. // 查询数据
  113. let searchForm: Ref<{}> = ref({});
  114. // 弹框
  115. const dialog: Ref<{ type: string; show: boolean; title: string }> = ref({ type: '1', show: false, title: '信息管理' });
  116. // 审核表单
  117. let form: Ref<{}> = ref({});
  118. // 必填项
  119. const rules = reactive<FormRules>({
  120. status: [{ required: true, message: '请选择审核状态', trigger: 'change' }],
  121. remark: [{ required: true, message: '请输入审核意见', trigger: 'blur' }],
  122. });
  123. // 表单
  124. let infoFields: Ref<any[]> = ref([
  125. { label: '审核状态', model: 'status', type: 'select' },
  126. { label: '审核意见', model: 'remark', type: 'textarea' },
  127. ]);
  128. // 状态
  129. let statusList: Ref<any[]> = ref([]);
  130. // 工作室列表
  131. let studioList: Ref<any[]> = ref([]);
  132. let user = store.state.user as { _id: string };
  133. onMounted(async () => {
  134. await searchOther();
  135. await search({ skip, limit });
  136. });
  137. // 查询
  138. const search = async (e: { skip: number; limit: number }) => {
  139. const { skip, limit } = e;
  140. let info: Ref<{ limit: number; skip: number; searchForm: object; studio_id: string | string[] }> = ref({
  141. limit: limit,
  142. skip: skip,
  143. searchForm: searchForm.value,
  144. studio_id: '',
  145. });
  146. if (route.query.studio_id) info.value.studio_id = route.query.studio_id;
  147. const res: IQueryResult = await applyflair.query(info.value);
  148. tableData.value = res.data as any[];
  149. total.value = res.total;
  150. };
  151. // 查询
  152. const partSearch = (form: { [x: string]: any }) => {
  153. searchForm.value = form;
  154. search({ skip, limit });
  155. };
  156. // 审核
  157. const toExam = (data: object) => {
  158. form.value = data;
  159. dialog.value = { title: '信息管理', show: true, type: '1' };
  160. };
  161. // 审核保存
  162. const toSave = async (data: { _id: string; status: string }) => {
  163. let obj = { _id: data._id, status: data.status };
  164. let res: IQueryResult = await applyflair.update(obj);
  165. if (res.errcode == 0) {
  166. ElMessage({ type: 'success', message: '维护信息成功' });
  167. createMess(data);
  168. } else ElMessage({ type: 'warning', message: `${res.errmsg}` });
  169. };
  170. // 发送系统消息
  171. const createMess = async (data) => {
  172. let res = await unitStudioApply.fetch(data.user_id);
  173. let p1: any = res.data as {};
  174. if (res.errcode == 0) {
  175. let obj = {
  176. user_id: user._id,
  177. title: '审核通知',
  178. send_time: moment().format('YYYY-MM-DD HH:mm:ss'),
  179. type: '3',
  180. user: [{ id: data.user_id, company: data.company_name, phone: p1.phone }],
  181. content: '您好,您所申请《' + data.studio_name + '》的保留资质,' + `${data.status == '1' ? '已通过审核' : '未通过审核'}` + ',原因:' + data.remark,
  182. };
  183. let arr = await message.create(obj);
  184. if (arr.errcode == 0) {
  185. ElMessage({ type: 'success', message: '系统信息发送成功' });
  186. handleClose();
  187. }
  188. }
  189. };
  190. // 关闭弹窗
  191. const handleClose = () => {
  192. form.value = {};
  193. search({ skip, limit });
  194. dialog.value = { title: '信息管理', show: false, type: '' };
  195. };
  196. // 选择
  197. const handleSelect = () => {};
  198. // 查询其他信息
  199. const searchOther = async () => {
  200. // 字典表---审核状态
  201. const p1: IQueryResult = await sysdictdata.query({ dict_type: 'studio_status' });
  202. statusList.value = p1.data as [];
  203. // 角色
  204. const p2: IQueryResult = await studio.query({ status: '1' });
  205. studioList.value = p2.data as [];
  206. };
  207. </script>
  208. <style lang="scss" scoped></style>