printBOM.vue 7.7 KB

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