index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :searchConfig="searchConfig"
  10. highlight-current-row
  11. :action-list="[
  12. {
  13. text: '导出Excel',
  14. action: () => deriveExcel(),
  15. },
  16. ]"
  17. @get-list="getList"
  18. @clickReset="clickReset"
  19. :cellClassName="cellClassName">
  20. <template #purchaseCode="{ item }">
  21. <div>
  22. <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickPurchaseCode(item)">{{ item.purchaseCode }}</a>
  23. </div>
  24. </template>
  25. </byTable>
  26. </el-card>
  27. </div>
  28. </template>
  29. <script setup>
  30. import byTable from "/src/components/byTable/index";
  31. import moment from "moment";
  32. import { ElMessage, ElMessageBox } from "element-plus";
  33. const { proxy } = getCurrentInstance();
  34. const sourceList = ref({
  35. data: [],
  36. pagination: {
  37. total: 0,
  38. pageNum: 1,
  39. pageSize: 10,
  40. purchaseCode: "",
  41. bomSpecCode: "",
  42. bomSpecName: "",
  43. },
  44. });
  45. const loading = ref(false);
  46. const searchConfig = computed(() => {
  47. return [
  48. {
  49. type: "input",
  50. prop: "purchaseCode",
  51. label: "采购单号",
  52. },
  53. {
  54. type: "input",
  55. prop: "bomSpecCode",
  56. label: "品号",
  57. },
  58. {
  59. type: "input",
  60. prop: "bomSpecName",
  61. label: "品名",
  62. },
  63. ];
  64. });
  65. const config = computed(() => {
  66. return [
  67. {
  68. attrs: {
  69. label: "品号",
  70. prop: "bomSpecCode",
  71. width: 150,
  72. },
  73. },
  74. {
  75. attrs: {
  76. label: "品名",
  77. prop: "bomSpecName",
  78. "min-width": 220,
  79. },
  80. },
  81. {
  82. attrs: {
  83. label: "采购单号",
  84. slot: "purchaseCode",
  85. width: 160,
  86. },
  87. },
  88. {
  89. attrs: {
  90. label: "E10采购单号",
  91. prop: "purchaseErpCode",
  92. width: 160,
  93. },
  94. },
  95. {
  96. attrs: {
  97. label: "供应商",
  98. prop: "supplierName",
  99. width: 220,
  100. },
  101. },
  102. {
  103. attrs: {
  104. label: "采购数量",
  105. prop: "purchaseQuantity",
  106. width: 100,
  107. },
  108. },
  109. {
  110. attrs: {
  111. label: "在途数量",
  112. prop: "inTransitQuantity",
  113. width: 100,
  114. },
  115. },
  116. {
  117. attrs: {
  118. label: "交期",
  119. prop: "deliveryDate",
  120. width: 160,
  121. align: "center",
  122. },
  123. },
  124. {
  125. attrs: {
  126. label: "周转率",
  127. prop: "turnoverRate",
  128. width: 100,
  129. },
  130. },
  131. {
  132. attrs: {
  133. label: "90天销量",
  134. prop: "salesQuantity",
  135. width: 100,
  136. },
  137. },
  138. {
  139. attrs: {
  140. label: "库存数量",
  141. prop: "inventoryQuantity",
  142. width: 100,
  143. },
  144. },
  145. ];
  146. });
  147. const getList = async (req, status) => {
  148. if (status) {
  149. sourceList.value.pagination = {
  150. pageNum: sourceList.value.pagination.pageNum,
  151. pageSize: sourceList.value.pagination.pageSize,
  152. };
  153. } else {
  154. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  155. }
  156. loading.value = true;
  157. proxy.post("/purchaseInTransitBom/page", sourceList.value.pagination).then((res) => {
  158. sourceList.value.data = res.rows;
  159. sourceList.value.pagination.total = res.total;
  160. setTimeout(() => {
  161. loading.value = false;
  162. }, 200);
  163. });
  164. };
  165. getList();
  166. const clickReset = () => {
  167. getList("", true);
  168. };
  169. const deriveExcel = () => {
  170. ElMessageBox.confirm("你是否确认此操作", "提示", {
  171. confirmButtonText: "确定",
  172. cancelButtonText: "取消",
  173. type: "warning",
  174. })
  175. .then(() => {
  176. proxy.postFile("/purchaseInTransitBom/export", sourceList.value.pagination).then((res) => {
  177. if (res.type === "application/json") {
  178. const fileReader = new FileReader();
  179. fileReader.onloadend = () => {
  180. const jsonData = JSON.parse(fileReader.result);
  181. ElMessage({ message: jsonData.msg, type: "error" });
  182. };
  183. fileReader.readAsText(res);
  184. } else {
  185. proxy.downloadFile(res, "在途物料-" + moment().format("yyyy-MM-DD") + ".xlsx");
  186. }
  187. });
  188. })
  189. .catch(() => {});
  190. };
  191. const cellClassName = (val) => {
  192. if (val.row.deliveryDate < moment().format("yyyy-MM-DD HH:mm:ss")) {
  193. return "colorDim";
  194. }
  195. };
  196. const clickPurchaseCode = (item) => {
  197. proxy.$router.replace({
  198. path: "/platform_manage/process/processApproval",
  199. query: {
  200. flowKey: "purchase",
  201. flowName: "采购流程",
  202. processType: "20",
  203. id: item.purchaseId,
  204. flowId: item.flowId,
  205. random: proxy.random(),
  206. },
  207. });
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. ::v-deep(.colorDim) {
  212. color: red;
  213. }
  214. </style>