index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <van-nav-bar
  3. :title="$t('receipt.name')"
  4. left-text=""
  5. left-arrow
  6. @click-left="onClickLeft"
  7. @click-right="onClickRight"
  8. >
  9. <template #right> {{ $t("receipt.mergePurchase") }} </template>
  10. </van-nav-bar>
  11. <van-search
  12. v-model="req.keyword"
  13. :placeholder="$t('common.pleaseEnterKeywords')"
  14. @search="onRefresh"
  15. />
  16. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  17. <div class="list">
  18. <van-list
  19. v-model:loading="loading"
  20. :finished="finished"
  21. :finished-text="$t('common.noMore')"
  22. @load="getList"
  23. style="margin-bottom: 60px"
  24. >
  25. <commonList
  26. :data="listData"
  27. @onClick="toDtl"
  28. :config="listConfig"
  29. :isCheckbox="true"
  30. @onCheck="handleSelectData"
  31. optionalKey="contractId"
  32. >
  33. </commonList>
  34. </van-list>
  35. </div>
  36. </van-pull-refresh>
  37. </template>
  38. <script setup>
  39. import { ref, getCurrentInstance } from "vue";
  40. import commonList from "@/components/common-list.vue";
  41. import { showSuccessToast, showFailToast } from "vant";
  42. const proxy = getCurrentInstance().proxy;
  43. const onClickLeft = () => proxy.$router.push("/main/working");
  44. const req = ref({
  45. pageNum: 1,
  46. keyword: null,
  47. status: "15",
  48. });
  49. const finished = ref(false);
  50. const onRefresh = () => {
  51. req.value.pageNum = 1;
  52. finished.value = false;
  53. getList("refresh");
  54. };
  55. const loading = ref(false);
  56. const listData = ref([]);
  57. const statusData = ref([
  58. {
  59. label: "草稿",
  60. value: 0,
  61. },
  62. {
  63. label: "审批中",
  64. value: 10,
  65. },
  66. {
  67. label: "驳回",
  68. value: 20,
  69. },
  70. {
  71. label: "审批通过",
  72. value: 30,
  73. },
  74. {
  75. label: "终止",
  76. value: 99,
  77. },
  78. ]);
  79. const payStatusData = ref([]);
  80. const getDict = () => {
  81. proxy.getDictOne(["pay_status"]).then((res) => {
  82. payStatusData.value = res["pay_status"].data.map((x) => ({
  83. label: x.dictValue,
  84. value: x.dictKey,
  85. }));
  86. });
  87. };
  88. getDict();
  89. const getList = (type) => {
  90. loading.value = true;
  91. proxy
  92. .post("/contractProduct/page", req.value)
  93. .then((res) => {
  94. listData.value =
  95. type === "refresh"
  96. ? res.data.rows
  97. : listData.value.concat(res.data.rows);
  98. if (req.value.pageNum * 10 >= res.data.total) {
  99. finished.value = true;
  100. }
  101. req.value.pageNum++;
  102. loading.value = false;
  103. })
  104. .catch(() => {
  105. loading.value = false;
  106. });
  107. };
  108. const toDtl = (row) => {};
  109. const onClickRight = () => {
  110. if (ids && ids.length > 0) {
  111. proxy.$router.push({
  112. path: "/main/processDtl",
  113. query: {
  114. isReceipt: true,
  115. flowKey: "purchase_flow",
  116. ids: JSON.stringify(ids),
  117. contractId: selectData.value[0].contractId,
  118. },
  119. });
  120. } else {
  121. return showFailToast(proxy.t("procureList.pleaseCheckTheData"));
  122. }
  123. };
  124. const listConfig = ref([
  125. {
  126. label: proxy.t("receipt.belongToCompany"),
  127. prop: "corporationName",
  128. },
  129. {
  130. label: proxy.t("receipt.contractCode"),
  131. prop: "contractCode",
  132. },
  133. {
  134. label: proxy.t("receipt.orderTime"),
  135. prop: "contractTime",
  136. },
  137. {
  138. label: proxy.t("receipt.productName"),
  139. prop: "productName",
  140. },
  141. {
  142. label: proxy.t("receipt.pendingProcessing"),
  143. prop: "expendQuantity",
  144. },
  145. ]);
  146. let ids = [];
  147. let selectData = ref([]);
  148. const handleSelectData = (row) => {
  149. ids = [];
  150. selectData.value = row;
  151. row.map((i) => {
  152. ids.push(i.id);
  153. });
  154. };
  155. </script>
  156. <style lang="scss" scoped>
  157. .list {
  158. min-height: 70vh;
  159. }
  160. </style>