ApprovedWorkflow.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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="searchDatas"
  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. <CommonTable
  19. ref="table"
  20. :columns="approveColumns"
  21. :data-source="approveDatas"
  22. @get-pager="getPageParams"
  23. >
  24. <template #bodyCell="{ column, record }">
  25. <template v-if="column.key === 'title'">
  26. <span v-if="record.category != 'CurdWindow'">
  27. {{ record.name }}
  28. </span>
  29. <span v-else>
  30. {{ record.title }}
  31. </span>
  32. </template>
  33. <template v-if="column.key === 'description'">
  34. <span
  35. v-if="record.category != 'CurdWindow'"
  36. style="white-space: pre-line"
  37. >{{ record.description }}</span>
  38. <span v-else style="white-space: pre-line">{{ record.content }}</span>
  39. </template>
  40. <template v-if="column.key === 'operation'">
  41. <a-button type="link" @click="selectTaskInfo(record)">
  42. {{ $t("lang.NeedApproveWorkflow.viewTasks") }}
  43. </a-button>
  44. </template>
  45. </template>
  46. </CommonTable>
  47. <Loading v-if="isLoading" />
  48. <CustomerTask
  49. ref="customerTask"
  50. :task-id="selectedTaskId"
  51. @closed="() => searchDatas"
  52. />
  53. </template>
  54. <script setup>
  55. import { ref, reactive, defineEmits, onMounted } from 'vue';
  56. import Common from '../common/Common';
  57. import WorkflowType from './WorkflowType.vue';
  58. import WorkflowSearch from './WorkflowSearch.vue';
  59. import CommonTable from '../common/CommonTable.vue';
  60. import { ajaxApi } from '../api/workflow/workflow.js';
  61. import { message } from 'ant-design-vue';
  62. import { approvedColumns } from './configData.js';
  63. import TaskOpenUtil from './TaskOpenUtil.js';
  64. import WindowService from '../common/WindowService.js';
  65. import CustomerTask from './CustomerTask.vue';
  66. import { Notify } from 'pc-component-v3';
  67. const emit = defineEmits(['refreshStasticCount']);
  68. const total = ref(0);
  69. const table = ref(null);
  70. const customerTask = ref(null);
  71. const selectedTaskId = ref(null);
  72. const isLoading = ref(false);
  73. const approveDatas = ref([]);
  74. const approveColumns = ref(approvedColumns);
  75. const searchParams = ref({});
  76. const filterParams = ref({});
  77. const pager = reactive({
  78. start: 1,
  79. length: 20,
  80. });
  81. onMounted(() => {
  82. searchDatas();
  83. });
  84. // 查询,回到第一页
  85. const searchDatas = () => {
  86. table.value.backFirstPage();
  87. };
  88. // 获取分页
  89. const getPageParams = (start, length) => {
  90. pager.start = (start - 1) * length;
  91. pager.length = length;
  92. const params = { ...searchParams.value, ...filterParams.value, ...pager };
  93. searchApprove(params);
  94. };
  95. // 获取类型no
  96. const getTypeNo = windowNo => {
  97. searchParams.value.windowNo = windowNo;
  98. searchDatas();
  99. };
  100. // 通过高级查询搜索
  101. const searchWorkflow = value => {
  102. filterParams.value = value;
  103. searchDatas();
  104. };
  105. // 查询数据API
  106. const searchApprove = params => {
  107. isLoading.value = true;
  108. const url = 'api/WorkflowResource/approved';
  109. ajaxApi(url, params).then(
  110. success => {
  111. if (success.errorCode === 0) {
  112. if (success.datas && success.datas.length > 0) {
  113. success.datas.forEach(item => {
  114. item.content = parseContent(item.content);
  115. });
  116. approveDatas.value = success.datas;
  117. } else {
  118. approveDatas.value = [];
  119. }
  120. } else {
  121. message.warning(success.errorMessage);
  122. }
  123. isLoading.value = false;
  124. },
  125. error => {
  126. isLoading.value = false;
  127. Common.processException(error);
  128. },
  129. );
  130. };
  131. // 选择了taskInfo
  132. const selectTaskInfo = taskInfo => {
  133. TaskOpenUtil.openTask(taskInfo).then(
  134. successData => {
  135. if (successData.type === 'newWindow') {
  136. WindowService.open(successData.url, '待处理', function () {
  137. searchDatas();
  138. emit('refreshStasticCount');
  139. });
  140. } else if (successData.type === 'customerTask') {
  141. // 打开自定义的界面
  142. selectedTaskId.value = taskInfo.id;
  143. customerTask.value.show();
  144. searchDatas();
  145. emit('refreshStasticCount');
  146. }
  147. },
  148. errorData => {
  149. if (errorData != null) {
  150. Notify.error(errorData.title, errorData.message, false);
  151. }
  152. },
  153. );
  154. };
  155. // 处理content json
  156. const parseContent = content => {
  157. const x = content;
  158. try {
  159. let content = JSON.parse(x);
  160. let parentForm = '';
  161. if (content != null && content.parentForm != null) {
  162. content.parentForm.forEach(item => {
  163. parentForm = parentForm + item.title + ':' + item.content + ',\n';
  164. });
  165. return parentForm;
  166. } else {
  167. return null;
  168. }
  169. // eslint-disable-next-line no-empty
  170. } catch (e) {}
  171. };
  172. </script>
  173. <style scoped>
  174. </style>