ApprovedWorkflow.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <a-row type="flex" justify="space-between">
  3. <a-col>
  4. <a-input-search
  5. v-model:value="searchParams.condition"
  6. :placeholder="$t('lang.NeedApproveWorkflow.describe1')"
  7. enter-button="搜索"
  8. allow-clear
  9. style="width: 300px"
  10. @search="queryDatas"
  11. />
  12. </a-col>
  13. <a-col>
  14. <WorkflowType @get-type="getTypeNo" />
  15. <WorkflowSearch :function-type="3" @get-search-params="searchWorkflow" />
  16. </a-col>
  17. </a-row>
  18. <a-table
  19. sticky
  20. bordered
  21. :pagination="false"
  22. :columns="approveColumns"
  23. :data-source="approveDatas"
  24. >
  25. <template #bodyCell="{ column, record }">
  26. <template v-if="column.key === 'title'">
  27. <span v-if="record.category != 'CurdWindow'">
  28. {{ record.name }}
  29. </span>
  30. <span v-else>
  31. {{ record.title }}
  32. </span>
  33. </template>
  34. <template v-if="column.key === 'description'">
  35. <span
  36. v-if="record.category != 'CurdWindow'"
  37. style="white-space: pre-line"
  38. >{{ record.description }}</span>
  39. <span v-else style="white-space: pre-line">{{ record.content }}</span>
  40. </template>
  41. <template v-if="column.key === 'documentStatus'">
  42. <a-tag v-if="record.documentStatus === '已完成'" color="success">
  43. 已完成
  44. </a-tag>
  45. <a-tag v-if="record.documentStatus === '进行中'" color="processing">
  46. 进行中
  47. </a-tag>
  48. </template>
  49. <template v-if="column.key === 'operation'">
  50. <a-button type="link" @click="selectTaskInfo(record)">
  51. {{ $t("lang.NeedApproveWorkflow.viewTasks") }}
  52. </a-button>
  53. </template>
  54. </template>
  55. <template v-if="approveDatas.length > 0 && isShowMore" #footer>
  56. <div style="text-align: center">
  57. <a-button type="link" @click="loadMore">加载更多</a-button>
  58. </div>
  59. </template>
  60. </a-table>
  61. <Loading v-if="isLoading" />
  62. <CustomerTask
  63. ref="customerTask"
  64. :task-id="selectedTaskId"
  65. @closed="() => searchDatas"
  66. />
  67. </template>
  68. <script setup>
  69. import { ref, reactive, defineEmits, onMounted } from 'vue';
  70. import Common from '../common/Common';
  71. import WorkflowType from './WorkflowType.vue';
  72. import WorkflowSearch from './WorkflowSearch.vue';
  73. import { ajaxApi } from '../api/workflow/workflow.js';
  74. import { message } from 'ant-design-vue';
  75. import { approvedColumns } from './configData.js';
  76. import TaskOpenUtil from './TaskOpenUtil.js';
  77. import WindowService from '../common/WindowService.js';
  78. import CustomerTask from './CustomerTask.vue';
  79. import { Notify } from 'pc-component-v3';
  80. const emit = defineEmits(['refreshStasticCount']);
  81. const customerTask = ref(null);
  82. const selectedTaskId = ref(null);
  83. const isLoading = ref(false);
  84. const isShowMore = ref(true);
  85. const approveDatas = ref([]);
  86. const approveColumns = ref(approvedColumns);
  87. const searchParams = ref({});
  88. const filterParams = ref({});
  89. const pager = reactive({
  90. start: 0,
  91. length: 10,
  92. });
  93. onMounted(() => {
  94. searchDatas(true);
  95. });
  96. // 查询条件时从0开始
  97. const queryDatas = () => {
  98. pager.start = 0;
  99. isShowMore.value = true;
  100. searchDatas(true);
  101. };
  102. // 加载更多时push
  103. const loadMore = () => {
  104. pager.start += 10;
  105. searchDatas();
  106. };
  107. // 查询
  108. const searchDatas = isSearch => {
  109. const params = { ...searchParams.value, ...filterParams.value, ...pager };
  110. searchApprove(params, isSearch);
  111. };
  112. // 获取类型no
  113. const getTypeNo = windowNo => {
  114. pager.start = 0;
  115. isShowMore.value = true;
  116. searchParams.value.windowNo = windowNo;
  117. searchDatas(true);
  118. };
  119. // 通过高级查询搜索
  120. const searchWorkflow = value => {
  121. pager.start = 0;
  122. isShowMore.value = true;
  123. filterParams.value = value;
  124. searchDatas(true);
  125. };
  126. // 查询数据API
  127. const searchApprove = (params, isSearch) => {
  128. isLoading.value = true;
  129. const url = 'api/WorkflowResource/approved';
  130. ajaxApi(url, params).then(
  131. success => {
  132. if (success.errorCode === 0) {
  133. if (success.datas && success.datas.length > 0) {
  134. const allDatas = JSON.parse(JSON.stringify(approveDatas.value));
  135. success.datas.forEach(item => {
  136. item.content = parseContent(item.content);
  137. if (!isSearch) {
  138. allDatas.push(item);
  139. }
  140. });
  141. const ids = new Set(allDatas.map(item => item.id));
  142. approveDatas.value = allDatas.filter(item => ids.has(item.id));
  143. if (isSearch) {
  144. approveDatas.value = success.datas;
  145. }
  146. } else {
  147. if (!isSearch) {
  148. message.info('没有更多数据了。');
  149. isShowMore.value = false;
  150. isLoading.value = false;
  151. return;
  152. }
  153. approveDatas.value = [];
  154. }
  155. } else {
  156. message.warning(success.errorMessage);
  157. }
  158. isLoading.value = false;
  159. },
  160. error => {
  161. isLoading.value = false;
  162. Common.processException(error);
  163. },
  164. );
  165. };
  166. // 选择了taskInfo
  167. const selectTaskInfo = taskInfo => {
  168. TaskOpenUtil.openHistoryTask(taskInfo).then(
  169. successData => {
  170. if (successData.type === 'newWindow') {
  171. WindowService.open(successData.url, '已处理的', function () {
  172. searchDatas();
  173. emit('refreshStasticCount');
  174. });
  175. } else if (successData.type === 'customerTask') {
  176. // 打开自定义的界面
  177. selectedTaskId.value = taskInfo.id;
  178. customerTask.value.show();
  179. searchDatas();
  180. emit('refreshStasticCount');
  181. }
  182. },
  183. errorData => {
  184. if (errorData != null) {
  185. Notify.error(errorData.title, errorData.message, false);
  186. }
  187. },
  188. );
  189. };
  190. // 处理content json
  191. const parseContent = content => {
  192. const x = content;
  193. try {
  194. let content = JSON.parse(x);
  195. let parentForm = '';
  196. if (content != null && content.parentForm != null) {
  197. content.parentForm.forEach(item => {
  198. parentForm = parentForm + item.title + ':' + item.content + ',\n';
  199. });
  200. return parentForm;
  201. } else {
  202. return null;
  203. }
  204. // eslint-disable-next-line no-empty
  205. } catch (e) {}
  206. };
  207. </script>
  208. <style scoped>
  209. .ant-table-wrapper {
  210. margin-top: 8px;
  211. }
  212. </style>