index.vue 5.0 KB

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