index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <el-card class="box-card">
  3. <byTable
  4. :source="sourceList.data"
  5. :pagination="sourceList.pagination"
  6. :config="config"
  7. :loading="loading"
  8. :searchConfig="searchConfig"
  9. highlight-current-row
  10. :action-list="[
  11. {
  12. text: '导出Excel',
  13. action: () => deriveExcel(),
  14. },
  15. ]"
  16. @get-list="getList"
  17. @clickReset="clickReset">
  18. </byTable>
  19. </el-card>
  20. </template>
  21. <script setup>
  22. import byTable from "/src/components/byTable/index";
  23. import { ElMessage, ElMessageBox } from "element-plus";
  24. import moment from "moment";
  25. const { proxy } = getCurrentInstance();
  26. const type = ref([
  27. {
  28. dictKey: "1",
  29. dictValue: "制作损坏",
  30. },
  31. {
  32. dictKey: "2",
  33. dictValue: "裸垫质量不良",
  34. },
  35. {
  36. dictKey: "3",
  37. dictValue: "生产错误",
  38. },
  39. {
  40. dictKey: "4",
  41. dictValue: "丢件",
  42. },
  43. {
  44. dictKey: "5",
  45. dictValue: "补单",
  46. },
  47. ]);
  48. const sourceList = ref({
  49. data: [],
  50. pagination: {
  51. total: 0,
  52. pageNum: 1,
  53. pageSize: 10,
  54. type: "",
  55. orderCode: "",
  56. orderWlnCode: "",
  57. skuSpecCode: "",
  58. skuSpecName: "",
  59. beginTime: "",
  60. endTime: "",
  61. },
  62. });
  63. const loading = ref(false);
  64. const searchConfig = computed(() => {
  65. return [
  66. {
  67. type: "select",
  68. prop: "type",
  69. data: type.value,
  70. label: "超领类型",
  71. },
  72. {
  73. type: "input",
  74. prop: "orderCode",
  75. label: "订单号",
  76. },
  77. {
  78. type: "input",
  79. prop: "orderWlnCode",
  80. label: "万里牛单号",
  81. },
  82. {
  83. type: "input",
  84. prop: "skuSpecCode",
  85. label: "SKU品号",
  86. },
  87. {
  88. type: "input",
  89. prop: "skuSpecName",
  90. label: "SKU品名",
  91. },
  92. {
  93. type: "date",
  94. propList: ["beginTime", "endTime"],
  95. label: "日期",
  96. },
  97. ];
  98. });
  99. const config = computed(() => {
  100. return [
  101. {
  102. attrs: {
  103. label: "订单号",
  104. prop: "orderCode",
  105. width: 200,
  106. },
  107. },
  108. {
  109. attrs: {
  110. label: "万里牛单号",
  111. prop: "orderWlnCode",
  112. width: 150,
  113. },
  114. },
  115. {
  116. attrs: {
  117. label: "SKU品号",
  118. prop: "skuSpecCode",
  119. width: 160,
  120. },
  121. },
  122. {
  123. attrs: {
  124. label: "SKU品名",
  125. prop: "skuSpecName",
  126. "min-width": 220,
  127. },
  128. },
  129. {
  130. attrs: {
  131. label: "超领类型",
  132. prop: "typeValue",
  133. width: 130,
  134. },
  135. },
  136. {
  137. attrs: {
  138. label: "仓库名称",
  139. prop: "warehouseName",
  140. width: 150,
  141. },
  142. },
  143. {
  144. attrs: {
  145. label: "超领数量",
  146. prop: "quantity",
  147. width: 120,
  148. },
  149. },
  150. {
  151. attrs: {
  152. label: "超领时间",
  153. prop: "exceedReceiveTime",
  154. width: 160,
  155. },
  156. },
  157. ];
  158. });
  159. const getList = async (req, status) => {
  160. if (status) {
  161. sourceList.value.pagination = {
  162. pageNum: sourceList.value.pagination.pageNum,
  163. pageSize: sourceList.value.pagination.pageSize,
  164. };
  165. } else {
  166. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  167. }
  168. loading.value = true;
  169. proxy.post("/productionExceedReceive/page", sourceList.value.pagination).then((res) => {
  170. sourceList.value.data = res.rows;
  171. sourceList.value.pagination.total = res.total;
  172. setTimeout(() => {
  173. loading.value = false;
  174. }, 200);
  175. });
  176. };
  177. getList();
  178. const clickReset = () => {
  179. getList("", true);
  180. };
  181. const deriveExcel = () => {
  182. ElMessageBox.confirm("你是否确认此操作", "提示", {
  183. confirmButtonText: "确定",
  184. cancelButtonText: "取消",
  185. type: "warning",
  186. })
  187. .then(() => {
  188. proxy.postFile("/productionExceedReceive/exceedReceiveExportExcel", sourceList.value.pagination).then((res) => {
  189. if (res.type === "application/json") {
  190. const fileReader = new FileReader();
  191. fileReader.onloadend = () => {
  192. const jsonData = JSON.parse(fileReader.result);
  193. ElMessage({ message: jsonData.msg, type: "error" });
  194. };
  195. fileReader.readAsText(res);
  196. } else {
  197. proxy.downloadFile(res, "SKU报价看板-" + moment().format("yyyy-MM-DD") + ".xlsx");
  198. }
  199. });
  200. })
  201. .catch(() => {});
  202. };
  203. </script>
  204. <style lang="scss" scoped></style>