printSKU.vue 6.4 KB

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