index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <van-nav-bar
  3. :title="$t('processApproval.name')"
  4. left-text=""
  5. left-arrow
  6. @click-left="onClickLeft"
  7. @click-right="onClickRight"
  8. >
  9. </van-nav-bar>
  10. <van-search
  11. v-model="req.keyword"
  12. :placeholder="$t('common.pleaseEnterKeywords')"
  13. @search="onRefresh"
  14. />
  15. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  16. <div class="list">
  17. <van-list
  18. v-model:loading="loading"
  19. :finished="finished"
  20. :finished-text="$t('common.noMore')"
  21. @load="onLoad"
  22. style="margin-bottom: 60px"
  23. >
  24. <commonList
  25. :data="listData"
  26. @onClick="toDtl"
  27. :config="listConfig"
  28. ></commonList>
  29. </van-list>
  30. </div>
  31. </van-pull-refresh>
  32. </template>
  33. <script setup>
  34. import { ref, getCurrentInstance, onMounted } from "vue";
  35. import commonList from "@/components/common-list.vue";
  36. import { useRoute } from "vue-router";
  37. import { getUserInfo } from "@/utils/auth";
  38. const loading = ref(false);
  39. const route = useRoute();
  40. const req = ref({
  41. pageNum: 1,
  42. keyword: null,
  43. definition: "1",
  44. tenantId: getUserInfo().tenantId,
  45. });
  46. const finished = ref(false);
  47. const proxy = getCurrentInstance().proxy;
  48. const listData = ref([]);
  49. const listConfig = ref([
  50. {
  51. label: proxy.t("processApproval.processType"),
  52. prop: "flowName",
  53. },
  54. {
  55. label: proxy.t("processApproval.initiator"),
  56. prop: "createUserName",
  57. },
  58. {
  59. label: proxy.t("processApproval.processTitle"),
  60. prop: "title",
  61. },
  62. ]);
  63. const onRefresh = () => {
  64. req.value.pageNum = 1;
  65. finished.value = false;
  66. getList("refresh");
  67. };
  68. const onLoad = () => {
  69. getList();
  70. };
  71. const onClickLeft = () => proxy.$router.push("/main/working");
  72. const onClickRight = () => {
  73. proxy.$router.push({
  74. path: "userAdd",
  75. query: {
  76. type: "add",
  77. },
  78. });
  79. };
  80. proxy.uploadDdRightBtn(onClickRight, proxy.t("common.add"));
  81. const toDtl = (row) => {
  82. if (row.status != 1 && row.status != 0) {
  83. proxy.$router.push({
  84. path: "/main/processDtl",
  85. query: {
  86. flowKey: row.flowKey,
  87. id: row.id,
  88. processType: 20,
  89. version: row.version,
  90. businessId: row.businessId,
  91. },
  92. });
  93. return;
  94. }
  95. proxy.post("flowExample/getApprovalRecord", { id: row.id }).then((res) => {
  96. if (res.data.recordList.length > 0) {
  97. let data = res.data.recordList.filter((item) => item.status === 2);
  98. let nodeType = 0;
  99. if (data && data.length > 0) {
  100. nodeType = data[0].nodeType;
  101. }
  102. proxy.$router.push({
  103. path: "/main/processDtl",
  104. query: {
  105. flowKey: row.flowKey,
  106. id: row.id,
  107. processType: nodeType == 1 ? 30 : 10,
  108. version: row.version,
  109. businessId: row.businessId,
  110. },
  111. });
  112. }
  113. });
  114. // proxy.$router.push({
  115. // path: 'processDtl',
  116. // query: {
  117. // flowKey: row.flowKey,
  118. // id: row.id,
  119. // processType: 10,
  120. // },
  121. // })
  122. };
  123. onMounted(() => {
  124. if (route.query) {
  125. getList();
  126. }
  127. });
  128. const getList = (type) => {
  129. loading.value = true;
  130. const postUrl = {
  131. 1: "/flowExample/getToBeProcessedPage",
  132. 2: "/flowExample/getHaveInitiatedPage",
  133. 3: "/flowExample/getProcessedPage",
  134. };
  135. proxy
  136. .post(postUrl[route.query.status], req.value)
  137. .then((res) => {
  138. listData.value =
  139. type === "refresh"
  140. ? res.data.rows
  141. : listData.value.concat(res.data.rows);
  142. if (req.value.pageNum * 10 >= res.data.total) {
  143. finished.value = true;
  144. }
  145. req.value.pageNum++;
  146. loading.value = false;
  147. })
  148. .catch((err) => {
  149. loading.value = false;
  150. });
  151. };
  152. </script>
  153. <style lang="scss" scoped>
  154. .list {
  155. min-height: 70vh;
  156. }
  157. </style>