MyApplyWorkflow.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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="4" @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="applyDatas"
  24. >
  25. <template #bodyCell="{ column, record }">
  26. <template v-if="column.key === 'description'">
  27. <span style="white-space: pre-line">{{ record.description }} <br />{{ record.content }}</span>
  28. </template>
  29. <template v-if="column.key === 'documentStatus'">
  30. <a-tag v-if="record.documentStatus === '已完成'" color="success">
  31. 已完成
  32. </a-tag>
  33. <a-tag v-if="record.documentStatus === '进行中'" color="processing">
  34. 进行中
  35. </a-tag>
  36. </template>
  37. <template v-if="column.key === 'operation'">
  38. <a-button type="link" @click="selectTaskInfo(record)">
  39. {{ $t("lang.NeedApproveWorkflow.viewTasks") }}
  40. </a-button>
  41. </template>
  42. </template>
  43. <template v-if="applyDatas.length > 0 && isShowMore" #footer>
  44. <div style="text-align: center">
  45. <a-button type="link" @click="loadMore">加载更多</a-button>
  46. </div>
  47. </template>
  48. </a-table>
  49. <Loading v-if="isLoading" />
  50. <CustomerTask
  51. ref="customerTask"
  52. :task-id="selectedTaskId"
  53. @closed="() => searchDatas"
  54. />
  55. </template>
  56. <script setup>
  57. import { ref, reactive, defineEmits, onMounted } from 'vue';
  58. import Common from '../common/Common';
  59. import WorkflowType from './WorkflowType.vue';
  60. import WorkflowSearch from './WorkflowSearch.vue';
  61. import { ajaxApi } from '../api/workflow/workflow.js';
  62. import { message } from 'ant-design-vue';
  63. import { approvedColumns } from './configData.js';
  64. import CustomerTask from './CustomerTask.vue';
  65. import { Uuid } from 'pc-component-v3';
  66. import { queryAuth, addAuth } from '../api/authorization/index.js';
  67. import TaskOpenUtil from './TaskOpenUtil1.js';
  68. import { parseContent } from './parseWorkflowContent.js';
  69. const emit = defineEmits(['refreshStasticCount']);
  70. const customerTask = ref(null);
  71. const selectedTaskId = ref(null);
  72. const isLoading = ref(false);
  73. const isShowMore = ref(true);
  74. const applyDatas = ref([]);
  75. const approveColumns = ref(approvedColumns);
  76. const searchParams = ref({});
  77. const filterParams = ref({});
  78. const pager = reactive({
  79. start: 0,
  80. length: 10,
  81. });
  82. onMounted(() => {
  83. searchDatas();
  84. });
  85. // 查询条件时从0开始
  86. const queryDatas = () => {
  87. pager.start = 0;
  88. isShowMore.value = true;
  89. searchDatas(true);
  90. };
  91. // 加载更多时push
  92. const loadMore = () => {
  93. pager.start += 10;
  94. searchDatas();
  95. };
  96. // 查询
  97. const searchDatas = isSearch => {
  98. const params = { ...searchParams.value, ...filterParams.value, ...pager };
  99. searchApprove(params, isSearch);
  100. };
  101. // 获取类型no
  102. const getTypeNo = windowNo => {
  103. pager.start = 0;
  104. isShowMore.value = true;
  105. searchParams.value.windowNo = windowNo;
  106. searchDatas(true);
  107. };
  108. // 通过高级查询搜索
  109. const searchWorkflow = value => {
  110. pager.start = 0;
  111. isShowMore.value = true;
  112. filterParams.value = value;
  113. searchDatas(true);
  114. };
  115. // 查询数据API
  116. const searchApprove = (params, isSearch) => {
  117. isLoading.value = true;
  118. const url = 'api/WorkflowResource/myApply';
  119. ajaxApi(url, params).then(
  120. success => {
  121. if (success.errorCode === 0) {
  122. if (success.datas && success.datas.length > 0) {
  123. success.datas.forEach(item => {
  124. item.content = parseContent(item.content);
  125. if (!isSearch) {
  126. applyDatas.value.push(item);
  127. }
  128. });
  129. if (isSearch) {
  130. applyDatas.value = success.datas;
  131. }
  132. } else {
  133. if (!isSearch) {
  134. message.info('没有更多数据了。');
  135. isShowMore.value = false;
  136. isLoading.value = false;
  137. return;
  138. }
  139. applyDatas.value = [];
  140. }
  141. } else {
  142. message.warning(success.errorMessage);
  143. }
  144. isLoading.value = false;
  145. },
  146. error => {
  147. isLoading.value = false;
  148. Common.processException(error);
  149. },
  150. );
  151. };
  152. // 跳到审批页
  153. const goWindow = taskInfo => {
  154. if (taskInfo.category === 'DynamicForm') {
  155. window.open(TaskOpenUtil.buildDynamicFormUrl(taskInfo));
  156. return;
  157. }
  158. const type = 'view';
  159. const windowNo = taskInfo.windowNo;
  160. const tabIndex = taskInfo.tabIndex;
  161. const recordId = taskInfo.recordId;
  162. const url =
  163. '/desktop/window1/window-read/' +
  164. type +
  165. '/' +
  166. windowNo +
  167. '/' +
  168. tabIndex +
  169. '/' +
  170. recordId +
  171. '?workflowType=approve&taskInfoId=' +
  172. taskInfo.id +
  173. '&currIndex=1&totalCount=1&canGoBack=false&uuid=' +
  174. Uuid.createUUID();
  175. window.open(Common.getRedirectUrl('#' + url));
  176. };
  177. // 选择了taskInfo 先查询授权资源
  178. const selectTaskInfo = taskInfo => {
  179. const params = {
  180. userId: JSON.parse(localStorage.getItem('#LoginInfo')).userId,
  181. recordId: taskInfo.recordId,
  182. windowNo: taskInfo.windowNo,
  183. };
  184. queryAuth(params).then(
  185. success => {
  186. if (success.errorCode === 0) {
  187. goWindow(taskInfo);
  188. } else {
  189. addAuthorization(params, taskInfo);
  190. }
  191. },
  192. err => {
  193. Common.processException(err);
  194. },
  195. );
  196. };
  197. // 增加授权资源
  198. const addAuthorization = (params, taskInfo) => {
  199. addAuth(params).then(
  200. success => {
  201. if (success.errorCode === 0) {
  202. goWindow(taskInfo);
  203. } else {
  204. message.warning(success.errorMessage);
  205. }
  206. },
  207. err => {
  208. Common.processException(err);
  209. },
  210. );
  211. };
  212. </script>
  213. <style scoped>
  214. .ant-table-wrapper {
  215. margin-top: 8px;
  216. }
  217. </style>