ApprovedWorkflow.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. import { queryAuth, addAuth } from '../api/authorization/index.js';
  81. const emit = defineEmits(['refreshStasticCount']);
  82. const customerTask = ref(null);
  83. const selectedTaskId = ref(null);
  84. const isLoading = ref(false);
  85. const isShowMore = ref(true);
  86. const approveDatas = ref([]);
  87. const approveColumns = ref(approvedColumns);
  88. const searchParams = ref({});
  89. const filterParams = ref({});
  90. const pager = reactive({
  91. start: 0,
  92. length: 10,
  93. });
  94. onMounted(() => {
  95. searchDatas(true);
  96. });
  97. // 查询条件时从0开始
  98. const queryDatas = () => {
  99. pager.start = 0;
  100. isShowMore.value = true;
  101. searchDatas(true);
  102. };
  103. // 加载更多时push
  104. const loadMore = () => {
  105. pager.start += 10;
  106. searchDatas();
  107. };
  108. // 查询
  109. const searchDatas = isSearch => {
  110. const params = { ...searchParams.value, ...filterParams.value, ...pager };
  111. searchApprove(params, isSearch);
  112. };
  113. // 获取类型no
  114. const getTypeNo = windowNo => {
  115. pager.start = 0;
  116. isShowMore.value = true;
  117. searchParams.value.windowNo = windowNo;
  118. searchDatas(true);
  119. };
  120. // 通过高级查询搜索
  121. const searchWorkflow = value => {
  122. pager.start = 0;
  123. isShowMore.value = true;
  124. filterParams.value = value;
  125. searchDatas(true);
  126. };
  127. // 查询数据API
  128. const searchApprove = (params, isSearch) => {
  129. isLoading.value = true;
  130. const url = 'api/WorkflowResource/approved';
  131. ajaxApi(url, params).then(
  132. success => {
  133. if (success.errorCode === 0) {
  134. if (success.datas && success.datas.length > 0) {
  135. const allDatas = JSON.parse(JSON.stringify(approveDatas.value));
  136. success.datas.forEach(item => {
  137. item.content = parseContent(item.content);
  138. if (!isSearch) {
  139. allDatas.push(item);
  140. }
  141. });
  142. const ids = new Set(allDatas.map(item => item.id));
  143. approveDatas.value = allDatas.filter(item => ids.has(item.id));
  144. if (isSearch) {
  145. approveDatas.value = success.datas;
  146. }
  147. } else {
  148. if (!isSearch) {
  149. message.info('没有更多数据了。');
  150. isShowMore.value = false;
  151. isLoading.value = false;
  152. return;
  153. }
  154. approveDatas.value = [];
  155. }
  156. } else {
  157. message.warning(success.errorMessage);
  158. }
  159. isLoading.value = false;
  160. },
  161. error => {
  162. isLoading.value = false;
  163. Common.processException(error);
  164. },
  165. );
  166. };
  167. // 跳转到审批页
  168. const goWindow = taskInfo => {
  169. TaskOpenUtil.openHistoryTask(taskInfo).then(
  170. successData => {
  171. if (successData.type === 'newWindow') {
  172. WindowService.open(successData.url, '已处理的', function () {
  173. searchDatas();
  174. emit('refreshStasticCount');
  175. });
  176. } else if (successData.type === 'customerTask') {
  177. // 打开自定义的界面
  178. selectedTaskId.value = taskInfo.id;
  179. customerTask.value.show();
  180. searchDatas();
  181. emit('refreshStasticCount');
  182. }
  183. },
  184. errorData => {
  185. if (errorData != null) {
  186. Notify.error(errorData.title, errorData.message, false);
  187. }
  188. },
  189. );
  190. };
  191. // 选择了taskInfo 先查询授权资源
  192. const selectTaskInfo = taskInfo => {
  193. const params = {
  194. userId: JSON.parse(localStorage.getItem('#LoginInfo')).userId,
  195. recordId: taskInfo.recordId,
  196. windowNo: taskInfo.windowNo,
  197. };
  198. queryAuth(params).then(
  199. success => {
  200. if (success.errorCode === 0) {
  201. goWindow(taskInfo);
  202. } else {
  203. addAuthorization(params, taskInfo);
  204. }
  205. },
  206. err => {
  207. Common.processException(err);
  208. },
  209. );
  210. };
  211. // 增加授权资源
  212. const addAuthorization = (params, taskInfo) => {
  213. addAuth(params).then(
  214. success => {
  215. if (success.errorCode === 0) {
  216. goWindow(taskInfo);
  217. } else {
  218. message.warning(success.errorMessage);
  219. }
  220. },
  221. err => {
  222. Common.processException(err);
  223. },
  224. );
  225. };
  226. // 处理content json
  227. const parseContent = content => {
  228. const x = content;
  229. try {
  230. let content = JSON.parse(x);
  231. let parentForm = '';
  232. if (content != null && content.parentForm != null) {
  233. content.parentForm.forEach(item => {
  234. parentForm = parentForm + item.title + ':' + item.content + ',\n';
  235. });
  236. return parentForm;
  237. } else {
  238. return null;
  239. }
  240. // eslint-disable-next-line no-empty
  241. } catch (e) {}
  242. };
  243. </script>
  244. <style scoped>
  245. .ant-table-wrapper {
  246. margin-top: 8px;
  247. }
  248. </style>