CopyTaskWorkflow.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. <a-button type="link" @click="completeApproval">全部完成审阅</a-button>
  15. <a-select
  16. v-model:value="searchParams.processStatusQuery"
  17. allow-clear
  18. placeholder="请选择审批状态"
  19. style="width: 200px"
  20. @change="statusChange"
  21. >
  22. <a-select-option value="ALL">全部</a-select-option>
  23. <a-select-option value="FINISH">审批完成</a-select-option>
  24. <a-select-option value="RUNNING">审批中</a-select-option>
  25. </a-select>
  26. </a-col>
  27. </a-row>
  28. <a-table
  29. sticky
  30. bordered
  31. :pagination="false"
  32. :columns="approveColumns"
  33. :data-source="copyDatas"
  34. >
  35. <template #bodyCell="{ column, record }">
  36. <template v-if="column.key === 'title'">
  37. <span v-if="record.category != 'CurdWindow'">
  38. {{ record.name }}
  39. </span>
  40. <span v-else>
  41. {{ record.title }}
  42. </span>
  43. </template>
  44. <template v-if="column.key === 'description'">
  45. <span
  46. v-if="record.category != 'CurdWindow'"
  47. style="white-space: pre-line"
  48. >{{ record.description }}</span>
  49. <span v-else style="white-space: pre-line">{{ record.content }}</span>
  50. </template>
  51. <template v-if="column.key === 'documentStatus'">
  52. <a-tag v-if="record.documentStatus === '已完成'" color="success">
  53. 已完成
  54. </a-tag>
  55. <a-tag v-if="record.documentStatus === '进行中'" color="processing">
  56. 进行中
  57. </a-tag>
  58. </template>
  59. <template v-if="column.key === 'operation'">
  60. <a-button type="link" @click="selectTaskInfo(record)">
  61. {{ $t("lang.NeedApproveWorkflow.viewTasks") }}
  62. </a-button>
  63. </template>
  64. </template>
  65. <template v-if="copyDatas.length > 0 && isShowMore" #footer>
  66. <div style="text-align: center">
  67. <a-button type="link" @click="loadMore">加载更多</a-button>
  68. </div>
  69. </template>
  70. </a-table>
  71. <Loading v-if="isLoading" />
  72. <CustomerTask
  73. ref="customerTask"
  74. :task-id="selectedTaskId"
  75. @closed="() => searchDatas"
  76. />
  77. </template>
  78. <script setup>
  79. import { ref, reactive, defineEmits, onMounted } from 'vue';
  80. import Common from '../common/Common';
  81. import { ajaxApi } from '../api/workflow/workflow.js';
  82. import { message } from 'ant-design-vue';
  83. import { approvedColumns } from './configData.js';
  84. import TaskOpenUtil from './TaskOpenUtil.js';
  85. import WindowService from '../common/WindowService.js';
  86. import CustomerTask from './CustomerTask.vue';
  87. import { Notify } from 'pc-component-v3';
  88. import { queryAuth, addAuth } from '../api/authorization/index.js';
  89. const emit = defineEmits(['refreshStasticCount']);
  90. const customerTask = ref(null);
  91. const selectedTaskId = ref(null);
  92. const isLoading = ref(false);
  93. const isShowMore = ref(true);
  94. const copyDatas = ref([]);
  95. const approveColumns = ref(approvedColumns);
  96. const searchParams = ref({
  97. condition: '',
  98. processStatusQuery: 'ALL',
  99. });
  100. const pager = reactive({
  101. start: 0,
  102. length: 10,
  103. });
  104. onMounted(() => {
  105. searchDatas();
  106. });
  107. // 查询条件时从0开始
  108. const queryDatas = () => {
  109. pager.start = 0;
  110. isShowMore.value = true;
  111. searchDatas(true);
  112. };
  113. // 加载更多时push
  114. const loadMore = () => {
  115. pager.start += 10;
  116. searchDatas();
  117. };
  118. // 查询
  119. const searchDatas = isSearch => {
  120. const params = { ...searchParams.value, ...pager };
  121. searchApprove(params, isSearch);
  122. };
  123. // 状态改变事件
  124. const statusChange = value => {
  125. if (!value) searchParams.value.processStatusQuery = 'ALL';
  126. pager.start = 0;
  127. isShowMore.value = true;
  128. searchDatas(true);
  129. };
  130. // 全部完成审阅
  131. const completeApproval = () => {
  132. const _self = this;
  133. isLoading.value = true;
  134. $.ajax({
  135. url: Common.getApiURL('WorkflowResource/completeCopyTasks'),
  136. type: 'post',
  137. dataType: 'json',
  138. contentType: 'application/json',
  139. beforeSend: function (request) {
  140. Common.addTokenToRequest(request);
  141. },
  142. success: function (data) {
  143. isLoading.value = false;
  144. if (data.errorCode === 0) {
  145. _self.$emit('refreshStasticCount');
  146. _self.searchCopyTask();
  147. } else {
  148. Notify.error('错误', data.errorMessage, false);
  149. }
  150. },
  151. error: function (XMLHttpRequest, textStatus, errorThrown) {
  152. isLoading.value = false;
  153. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  154. },
  155. });
  156. };
  157. // 查询数据API
  158. const searchApprove = (params, isSearch) => {
  159. isLoading.value = true;
  160. const url = 'api/WorkflowResource/copyTask';
  161. ajaxApi(url, params).then(
  162. success => {
  163. if (success.errorCode === 0) {
  164. if (success.datas && success.datas.length > 0) {
  165. success.datas.forEach(item => {
  166. item.content = parseContent(item.content);
  167. if (!isSearch) {
  168. copyDatas.value.push(item);
  169. }
  170. });
  171. if (isSearch) {
  172. copyDatas.value = success.datas;
  173. }
  174. } else {
  175. if (!isSearch) {
  176. message.info('没有更多数据了。');
  177. isShowMore.value = false;
  178. isLoading.value = false;
  179. return;
  180. }
  181. copyDatas.value = [];
  182. }
  183. } else {
  184. message.warning(success.errorMessage);
  185. }
  186. isLoading.value = false;
  187. },
  188. error => {
  189. isLoading.value = false;
  190. Common.processException(error);
  191. },
  192. );
  193. };
  194. // 调整审批页
  195. const goWindow = taskInfo => {
  196. if (taskInfo.systemProcess == undefined || taskInfo.systemProcess == false) {
  197. isLoading.value = true;
  198. $.ajax({
  199. url: Common.getApiURL('WorkflowResource/processTaskInfo'),
  200. type: 'get',
  201. dataType: 'json',
  202. contentType: 'application/json',
  203. beforeSend: function (request) {
  204. Common.addTokenToRequest(request);
  205. },
  206. data: {
  207. taskInfoId: taskInfo.id,
  208. },
  209. success: function (data) {
  210. isLoading.value = false;
  211. },
  212. error: function (XMLHttpRequest, textStatus, errorThrown) {
  213. isLoading.value = false;
  214. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  215. },
  216. });
  217. }
  218. TaskOpenUtil.openCopyTask(taskInfo).then(
  219. successData => {
  220. if (successData.type === 'newWindow') {
  221. WindowService.open(successData.url, '抄送我的', function () {
  222. searchDatas();
  223. emit('refreshStasticCount');
  224. });
  225. } else if (successData.type === 'customerTask') {
  226. // 打开自定义的界面
  227. // selectedTaskId.value = taskInfo.id;
  228. // customerTask.value.show();
  229. // searchDatas();
  230. // emit('refreshStasticCount');
  231. }
  232. },
  233. errorData => {
  234. if (errorData != null) {
  235. Notify.error(errorData.title, errorData.message, false);
  236. }
  237. },
  238. );
  239. };
  240. // 选择了taskInfo 先查询授权资源
  241. const selectTaskInfo = taskInfo => {
  242. const params = {
  243. userId: JSON.parse(localStorage.getItem('#LoginInfo')).userId,
  244. recordId: taskInfo.recordId,
  245. windowNo: taskInfo.windowNo,
  246. };
  247. queryAuth(params).then(
  248. success => {
  249. if (success.errorCode === 0) {
  250. goWindow(taskInfo);
  251. } else {
  252. addAuthorization(params, taskInfo);
  253. }
  254. },
  255. err => {
  256. Common.processException(err);
  257. },
  258. );
  259. };
  260. // 增加授权资源
  261. const addAuthorization = (params, taskInfo) => {
  262. addAuth(params).then(
  263. success => {
  264. if (success.errorCode === 0) {
  265. goWindow(taskInfo);
  266. } else {
  267. message.warning(success.errorMessage);
  268. }
  269. },
  270. err => {
  271. Common.processException(err);
  272. },
  273. );
  274. };
  275. // 处理content json
  276. const parseContent = content => {
  277. const x = content;
  278. try {
  279. let content = JSON.parse(x);
  280. let parentForm = '';
  281. if (content != null && content.parentForm != null) {
  282. content.parentForm.forEach(item => {
  283. parentForm = parentForm + item.title + ':' + item.content + ',\n';
  284. });
  285. return parentForm;
  286. } else {
  287. return null;
  288. }
  289. // eslint-disable-next-line no-empty
  290. } catch (e) {}
  291. };
  292. </script>
  293. <style scoped>
  294. .ant-table-wrapper {
  295. margin-top: 8px;
  296. }
  297. </style>