index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <el-col :span="24" class="one">
  6. <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch">
  7. <template #type>
  8. <el-option v-for="(i, index) in typeList" :key="index" :label="i.label" :value="i.value"></el-option>
  9. </template>
  10. <template #status>
  11. <el-option v-for="(i, index) in statusList" :key="index" :label="i.label" :value="i.value"></el-option>
  12. </template>
  13. </cSearch>
  14. </el-col>
  15. <el-col :span="24" class="thr">
  16. <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @view="toView" @file="toFile"> </cTable>
  17. </el-col>
  18. </el-col>
  19. </el-row>
  20. </div>
  21. </template>
  22. <script lang="ts" setup>
  23. import _ from 'lodash';
  24. import type { Ref } from 'vue';
  25. import { ref, onMounted, getCurrentInstance } from 'vue';
  26. import { ElMessage } from 'element-plus';
  27. import { useRouter } from 'vue-router';
  28. // 接口
  29. import { TranstionStore } from '@common/src/stores/patent/transtion';
  30. import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
  31. import type { IQueryResult } from '@/util/types.util';
  32. import store from '@/stores/counter';
  33. const transAxios = TranstionStore();
  34. const dictAxios = DictDataStore();
  35. // 路由
  36. const router = useRouter();
  37. const { proxy } = getCurrentInstance() as any;
  38. // 加载中
  39. const loading = ref(false);
  40. // 列表数据
  41. let list: Ref<any> = ref([]);
  42. let total: Ref<number> = ref(0);
  43. let skip = 0;
  44. let limit: number = proxy.$limit;
  45. let fields: Ref<any[]> = ref([
  46. { label: '申请号', model: 'create_number' },
  47. { label: '专利名称', model: 'patent_name', isSearch: true },
  48. { label: '交易类型', model: 'type', format: (i: any) => getDict(i, 'type'), isSearch: true, type: 'select' },
  49. { label: '联系人', model: 'contact' },
  50. { label: '手机号', model: 'phone' },
  51. { label: '状态', model: 'status', format: (i: any) => getDict(i, 'status'), isSearch: true, type: 'select' }
  52. ]);
  53. // 操作
  54. let opera: Ref<any[]> = ref([
  55. { label: '查看', method: 'view' },
  56. { label: '交易归档', method: 'file', confirm: true, type: 'warning', display: (i: any) => i.status == '6' }
  57. ]);
  58. // 查询数据
  59. let searchForm: Ref<any> = ref({});
  60. // 字典表
  61. const typeList: Ref<any> = ref([]);
  62. const statusList: Ref<any> = ref([]);
  63. onMounted(async () => {
  64. loading.value = false;
  65. await searchOther();
  66. await search({ skip, limit });
  67. loading.value = false;
  68. });
  69. // 查询
  70. const search = async (e: { skip: number; limit: number }) => {
  71. let user = store.state.user;
  72. const { skip, limit } = e;
  73. const condition = _.cloneDeep(searchForm.value);
  74. let info = { limit: limit, skip: skip, ...condition, mech_id: user._id, status: '6' };
  75. let res: IQueryResult = await transAxios.query(info);
  76. if (res.errcode == 0) {
  77. list.value = res.data;
  78. total.value = res.total;
  79. }
  80. };
  81. const toSearch = (query) => {
  82. searchForm.value = query;
  83. search({ skip, limit });
  84. };
  85. const getDict = (value, model) => {
  86. if (model == 'type') {
  87. let data = typeList.value.find((i) => i.value == value);
  88. if (data) return data.label;
  89. else return '暂无';
  90. } else if (model == 'status') {
  91. let data = statusList.value.find((i) => i.value == value);
  92. if (data) return data.label;
  93. else return '暂无';
  94. }
  95. };
  96. // 查看
  97. const toView = (data) => {
  98. router.push({ path: '/common/trans/info', query: { id: data._id } });
  99. };
  100. // 交易归档
  101. const toFile = async (data) => {
  102. data.status = '7';
  103. let res: IQueryResult = await transAxios.update(data);
  104. if (res.errcode == '0') {
  105. ElMessage({ message: '交易归档成功,交易完成', type: 'success' });
  106. toClose();
  107. } else {
  108. ElMessage({ message: `${res.errmsg}`, type: 'error' });
  109. }
  110. };
  111. // 查询其他信息
  112. const searchOther = async () => {
  113. let res: IQueryResult;
  114. // 类型
  115. res = await dictAxios.query({ type: 'patent_trans_type' });
  116. if (res.errcode == '0') typeList.value = res.data;
  117. // 状态
  118. res = await dictAxios.query({ type: 'patent_trans_status' });
  119. if (res.errcode == '0') {
  120. let list: any = res.data as [];
  121. statusList.value = list;
  122. }
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .main {
  127. .one {
  128. margin: 0 0 10px 0;
  129. }
  130. .two {
  131. margin: 0 0 10px 0;
  132. }
  133. }
  134. </style>