NeedApproveWorkflow.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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="2" @get-search-params="searchWorkflow" />
  16. </a-col>
  17. </a-row>
  18. <CommonTable
  19. ref="table"
  20. :total="total"
  21. :columns="approveColumns"
  22. :data-source="needApproveDatas"
  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.description }} <br /> {{ 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 { needApproveColumns } 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. import { queryAuth, addAuth } from '../api/authorization/index.js';
  69. const emit = defineEmits(['refreshStasticCount']);
  70. const total = ref(0);
  71. const table = ref(null);
  72. const customerTask = ref(null);
  73. const selectedTaskId = ref(null);
  74. const isLoading = ref(false);
  75. const needApproveDatas = ref([]);
  76. const approveColumns = ref(needApproveColumns);
  77. const searchParams = ref({});
  78. const filterParams = ref({});
  79. const pager = reactive({
  80. start: 1,
  81. length: 20,
  82. });
  83. onMounted(() => {
  84. searchDatas();
  85. });
  86. // 查询,回到第一页
  87. const searchDatas = () => {
  88. table.value.backFirstPage();
  89. };
  90. // 获取分页
  91. const getPageParams = (start, length) => {
  92. pager.start = (start - 1) * length;
  93. pager.length = length;
  94. const params = { ...searchParams.value, ...filterParams.value, ...pager };
  95. searchApprove(params);
  96. };
  97. // 获取类型no
  98. const getTypeNo = windowNo => {
  99. searchParams.value.windowNo = windowNo;
  100. searchDatas();
  101. };
  102. // 通过高级查询搜索
  103. const searchWorkflow = value => {
  104. filterParams.value = value;
  105. searchDatas();
  106. };
  107. // 查询数据API
  108. const searchApprove = params => {
  109. isLoading.value = true;
  110. const url = 'api/WorkflowResource/needApprove';
  111. ajaxApi(url, params).then(
  112. success => {
  113. if (success.errorCode === 0) {
  114. if (success.datas && success.datas.length > 0) {
  115. success.datas.forEach(item => {
  116. item.content = parseContent(item.content);
  117. });
  118. total.value = success.total;
  119. needApproveDatas.value = success.datas;
  120. } else {
  121. total.value = 0;
  122. needApproveDatas.value = [];
  123. }
  124. } else {
  125. message.warning(success.errorMessage);
  126. }
  127. isLoading.value = false;
  128. },
  129. error => {
  130. isLoading.value = false;
  131. Common.processException(error);
  132. },
  133. );
  134. };
  135. // 跳转到审批页
  136. const goWindow = taskInfo => {
  137. TaskOpenUtil.openTask(taskInfo).then(
  138. successData => {
  139. if (successData.type === 'newWindow') {
  140. WindowService.open(successData.url, '待处理', function () {
  141. searchDatas();
  142. emit('refreshStasticCount');
  143. });
  144. } else if (successData.type === 'customerTask') {
  145. // 打开自定义的界面
  146. selectedTaskId.value = taskInfo.id;
  147. customerTask.value.show();
  148. searchDatas();
  149. emit('refreshStasticCount');
  150. }
  151. },
  152. errorData => {
  153. if (errorData != null) {
  154. Notify.error(errorData.title, errorData.message, false);
  155. }
  156. },
  157. );
  158. };
  159. // 选择了taskInfo 先查询授权资源
  160. const selectTaskInfo = taskInfo => {
  161. const params = {
  162. userId: JSON.parse(localStorage.getItem('#LoginInfo')).userId,
  163. recordId: taskInfo.recordId,
  164. windowNo: taskInfo.windowNo,
  165. };
  166. queryAuth(params).then(
  167. success => {
  168. if (success.errorCode === 0) {
  169. goWindow(taskInfo);
  170. } else {
  171. addAuthorization(params, taskInfo);
  172. }
  173. },
  174. err => {
  175. Common.processException(err);
  176. },
  177. );
  178. };
  179. // 增加授权资源
  180. const addAuthorization = (params, taskInfo) => {
  181. addAuth(params).then(
  182. success => {
  183. if (success.errorCode === 0) {
  184. goWindow(taskInfo);
  185. } else {
  186. message.warning(success.errorMessage);
  187. }
  188. },
  189. err => {
  190. Common.processException(err);
  191. },
  192. );
  193. };
  194. // 处理content json
  195. const parseContent = content => {
  196. const x = content;
  197. try {
  198. let content = JSON.parse(x);
  199. let parentForm = '';
  200. if (content != null && content.parentForm != null) {
  201. content.parentForm.forEach(item => {
  202. parentForm = parentForm + item.title + ':' + item.content + ',\n';
  203. });
  204. return parentForm;
  205. } else {
  206. return null;
  207. }
  208. // eslint-disable-next-line no-empty
  209. } catch (e) {}
  210. };
  211. </script>
  212. <style scoped>
  213. </style>