printSKU.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div>
  3. <el-card style="height: calc(100vh - 168px); overflow-y: auto; overflow-x: hidden" v-loading="loading">
  4. <div id="tableId">
  5. <el-table :data="tableData" border :row-style="{ height: '35px' }" header-row-class-name="tableHeader" show-summary :summary-method="getSummaries">
  6. <el-table-column label="维度" prop="dimensionality" width="140" />
  7. <el-table-column label="客户" prop="departmentName" width="180" />
  8. <el-table-column label="SKU品号" prop="skuSpecCode" width="180" />
  9. <el-table-column label="SKU品名" prop="skuSpecName" min-width="220" />
  10. <el-table-column label="数量(PCS)" align="center" prop="quantity" width="160" />
  11. <el-table-column label="SKU单价" align="center" prop="unitPrice" width="160" />
  12. <el-table-column label="小计" align="center" width="180">
  13. <template #default="{ row }">
  14. {{ moneyFormat(row.subtotal) }}
  15. </template>
  16. </el-table-column>
  17. <el-table-column label="合计" align="center" width="180">
  18. <template #default="{ row }">
  19. {{ moneyFormat(row.total) }}
  20. </template>
  21. </el-table-column>
  22. </el-table>
  23. </div>
  24. <div style="padding: 8px; text-align: center">
  25. <el-button @click="clickCancel" size="large">关 闭</el-button>
  26. <el-button type="primary" @click="deriveExcel()" size="large" v-preReClick>导 出</el-button>
  27. </div>
  28. </el-card>
  29. </div>
  30. </template>
  31. <script setup>
  32. const { proxy } = getCurrentInstance();
  33. const props = defineProps({
  34. idGroupConcat: String,
  35. });
  36. const loading = ref(false);
  37. const tableData = ref([]);
  38. onMounted(() => {
  39. if (props.idGroupConcat) {
  40. loading.value = true;
  41. proxy.post("/statementOfAccountMerge/getDocumentBySku", { idGroupConcat: props.idGroupConcat }).then(
  42. (res) => {
  43. tableData.value = Object.freeze(res);
  44. loading.value = false;
  45. },
  46. (err) => {
  47. console.log(err);
  48. loading.value = false;
  49. }
  50. );
  51. }
  52. });
  53. const labelList = ref({
  54. 4: "quantity",
  55. 7: "total",
  56. });
  57. const textList = ref({
  58. 3: "胜德体育总经理:",
  59. 4: "申请日期:",
  60. });
  61. const getSummaries = ({ columns, data }) => {
  62. const sums = [];
  63. columns.forEach((column, index) => {
  64. if (index === 0) {
  65. sums[index] = h("div", { class: "" }, [
  66. h("div", {
  67. style: { "text-align": "center", "border-style": "solid", "border-width": "0 1px 1px 0", "border-color": "#ebeef5", padding: "0 12px" },
  68. innerHTML: "总计:",
  69. }),
  70. h("div", {
  71. style: { "text-align": "center", "border-style": "solid", "border-width": "0 1px 1px 0", "border-color": "#ebeef5", padding: "0 12px" },
  72. innerHTML: "备注:",
  73. }),
  74. h("div", {
  75. style: { "text-align": "center", "border-style": "solid", "border-width": "0 1px 1px 0", "border-color": "#ebeef5", padding: "0 12px" },
  76. innerHTML: "交货地点:",
  77. }),
  78. h("div", { style: { "font-size": "16px", "font-weight": 700, padding: "0 12px" }, innerHTML: "申请人:" }),
  79. ]);
  80. return;
  81. } else {
  82. sums[index] = h("div", { class: "" }, [
  83. [1, 2, 3, 5, 6].includes(index)
  84. ? h("div", {
  85. style: {
  86. "text-align": "center",
  87. "border-style": "solid",
  88. "border-width": "0 1px 1px 0",
  89. "border-color": "#ebeef5",
  90. color: "#ebeef5",
  91. padding: "0 12px",
  92. height: "35px",
  93. },
  94. innerHTML: ".",
  95. })
  96. : h("div", {
  97. style: {
  98. "text-align": "center",
  99. "border-style": "solid",
  100. "border-width": "0 1px 1px 0",
  101. "border-color": "#ebeef5",
  102. padding: "0 12px",
  103. height: "35px",
  104. },
  105. innerHTML: getTotal(labelList.value[index]),
  106. }),
  107. h("div", {
  108. style: {
  109. "text-align": "center",
  110. "border-style": "solid",
  111. "border-width": "0 0 1px 0",
  112. "border-color": "#ebeef5",
  113. color: "#ebeef5",
  114. padding: "0 12px",
  115. height: "35px",
  116. },
  117. innerHTML: ".",
  118. }),
  119. h("div", {
  120. style: {
  121. "text-align": "center",
  122. "border-style": "solid",
  123. "border-width": "0 0 1px 0",
  124. "border-color": "#ebeef5",
  125. color: "#ebeef5",
  126. padding: "0 12px",
  127. height: "35px",
  128. },
  129. innerHTML: ".",
  130. }),
  131. [1, 2, 5, 6, 7].includes(index)
  132. ? h("div", {
  133. style: {
  134. "text-align": "center",
  135. "border-style": "solid",
  136. "border-width": "0 0 1px 0",
  137. "border-color": "#ebeef5",
  138. color: "#ebeef5",
  139. padding: "0 12px",
  140. height: "35px",
  141. },
  142. innerHTML: ".",
  143. })
  144. : h("div", { style: { "font-size": "16px", "font-weight": 700, padding: "0 12px", "text-align": "left" }, innerHTML: textList.value[index] }),
  145. ]);
  146. return;
  147. }
  148. });
  149. return sums;
  150. };
  151. const getTotal = (label) => {
  152. let list = tableData.value.map((item) => item[label]);
  153. return Number(Math.round(list.reduce((acc, curr) => acc + curr, 0) * 100) / 100);
  154. };
  155. const emit = defineEmits(["clickCancel"]);
  156. const clickCancel = () => {
  157. emit("clickCancel", "");
  158. };
  159. const deriveExcel = () => {
  160. proxy.getFile("/statementOfAccountMerge/exportDocumentBySku", { idGroupConcat: props.idGroupConcat }).then((res) => {
  161. proxy.downloadFile(res, "SKU对账单.xlsx");
  162. });
  163. // $("#tableId").table2excel({
  164. // exclude: ".noExl",
  165. // sheetName: "SKU对账单",
  166. // filename: "SKU对账单",
  167. // exclude_img: false,
  168. // exclude_links: false,
  169. // exclude_inputs: true,
  170. // });
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. ::v-deep(.el-table thead.is-group th.el-table__cell) {
  175. background-color: white !important;
  176. }
  177. ::v-deep(.el-table__footer-wrapper tbody td.el-table__cell) {
  178. background-color: white !important;
  179. }
  180. ::v-deep(.el-table .el-table__cell) {
  181. padding: 0;
  182. }
  183. ::v-deep(.el-table__footer .cell) {
  184. padding: 0;
  185. }
  186. ::v-deep(.el-table__footer .el-table__cell) {
  187. border-right: 0px;
  188. }
  189. </style>