printSKU.vue 6.7 KB

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