MyApplyWorkflow.vue 5.0 KB

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