MyApplyWorkflow.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.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. const emit = defineEmits(['refreshStasticCount']);
  68. const customerTask = ref(null);
  69. const selectedTaskId = ref(null);
  70. const isLoading = ref(false);
  71. const isShowMore = ref(true);
  72. const applyDatas = ref([]);
  73. const approveColumns = ref(approvedColumns);
  74. const searchParams = ref({});
  75. const filterParams = ref({});
  76. const pager = reactive({
  77. start: 0,
  78. length: 10,
  79. });
  80. onMounted(() => {
  81. searchDatas();
  82. });
  83. // 查询条件时从0开始
  84. const queryDatas = () => {
  85. pager.start = 0;
  86. isShowMore.value = true;
  87. searchDatas(true);
  88. };
  89. // 加载更多时push
  90. const loadMore = () => {
  91. pager.start += 10;
  92. searchDatas();
  93. };
  94. // 查询
  95. const searchDatas = isSearch => {
  96. const params = { ...searchParams.value, ...filterParams.value, ...pager };
  97. searchApprove(params, isSearch);
  98. };
  99. // 获取类型no
  100. const getTypeNo = windowNo => {
  101. pager.start = 0;
  102. isShowMore.value = true;
  103. searchParams.value.windowNo = windowNo;
  104. searchDatas(true);
  105. };
  106. // 通过高级查询搜索
  107. const searchWorkflow = value => {
  108. pager.start = 0;
  109. isShowMore.value = true;
  110. filterParams.value = value;
  111. searchDatas(true);
  112. };
  113. // 查询数据API
  114. const searchApprove = (params, isSearch) => {
  115. isLoading.value = true;
  116. const url = 'api/WorkflowResource/myApply';
  117. ajaxApi(url, params).then(
  118. success => {
  119. if (success.errorCode === 0) {
  120. if (success.datas && success.datas.length > 0) {
  121. success.datas.forEach(item => {
  122. item.content = parseContent(item.content);
  123. if (!isSearch) {
  124. applyDatas.value.push(item);
  125. }
  126. });
  127. if (isSearch) {
  128. applyDatas.value = success.datas;
  129. }
  130. } else {
  131. if (!isSearch) {
  132. message.info('没有更多数据了。');
  133. isShowMore.value = false;
  134. isLoading.value = false;
  135. return;
  136. }
  137. applyDatas.value = [];
  138. }
  139. } else {
  140. message.warning(success.errorMessage);
  141. }
  142. isLoading.value = false;
  143. },
  144. error => {
  145. isLoading.value = false;
  146. Common.processException(error);
  147. },
  148. );
  149. };
  150. // 跳到审批页
  151. const goWindow = taskInfo => {
  152. const type = 'view';
  153. const windowNo = taskInfo.windowNo;
  154. const tabIndex = taskInfo.tabIndex;
  155. const recordId = taskInfo.recordId;
  156. const url =
  157. '/desktop/window/window-read/' +
  158. type +
  159. '/' +
  160. windowNo +
  161. '/' +
  162. tabIndex +
  163. '/' +
  164. recordId +
  165. '?workflowType=approve&taskInfoId=' +
  166. taskInfo.id +
  167. '&currIndex=1&totalCount=1&canGoBack=false&uuid=' +
  168. Uuid.createUUID();
  169. window.open(Common.getRedirectUrl('#' + url));
  170. };
  171. // 选择了taskInfo 先查询授权资源
  172. const selectTaskInfo = taskInfo => {
  173. const params = {
  174. userId: JSON.parse(localStorage.getItem('#LoginInfo')).userId,
  175. recordId: taskInfo.recordId,
  176. windowNo: taskInfo.windowNo,
  177. };
  178. queryAuth(params).then(
  179. success => {
  180. if (success.errorCode === 0) {
  181. goWindow(taskInfo);
  182. } else {
  183. addAuthorization(params, taskInfo);
  184. }
  185. },
  186. err => {
  187. Common.processException(err);
  188. },
  189. );
  190. };
  191. // 增加授权资源
  192. const addAuthorization = (params, taskInfo) => {
  193. addAuth(params).then(
  194. success => {
  195. if (success.errorCode === 0) {
  196. goWindow(taskInfo);
  197. } else {
  198. message.warning(success.errorMessage);
  199. }
  200. },
  201. err => {
  202. Common.processException(err);
  203. },
  204. );
  205. };
  206. // 处理content json
  207. const parseContent = content => {
  208. const x = content;
  209. try {
  210. let content = JSON.parse(x);
  211. let parentForm = '';
  212. if (content != null && content.parentForm != null) {
  213. content.parentForm.forEach(item => {
  214. parentForm = parentForm + item.title + ':' + item.content + ',\n';
  215. });
  216. return parentForm;
  217. } else {
  218. return null;
  219. }
  220. // eslint-disable-next-line no-empty
  221. } catch (e) {}
  222. };
  223. </script>
  224. <style scoped>
  225. .ant-table-wrapper {
  226. margin-top: 8px;
  227. }
  228. </style>