printBOM.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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" prop="proofingFeeSummary" width="100" />
  21. <el-table-column label="小计" align="center" width="120">
  22. <template #default="{ row }">
  23. {{ moneyFormat(row.subtotal) }}
  24. </template>
  25. </el-table-column>
  26. <el-table-column label="合计" align="center" width="120">
  27. <template #default="{ row }">
  28. {{ moneyFormat(row.total) }}
  29. </template>
  30. </el-table-column>
  31. </el-table-column>
  32. </el-table>
  33. </div>
  34. <div style="padding: 4px; text-align: center">
  35. <el-button type="primary" v-if="judgeOneKeyStatus()" @click="clickOneKeyStatus()" :loading="loadingOneKey" v-preReClick>一键出库</el-button>
  36. <el-button @click="clickCancel">关 闭</el-button>
  37. <el-button type="primary" @click="deriveExcel()" v-preReClick>导 出</el-button>
  38. </div>
  39. </el-card>
  40. </template>
  41. <script setup>
  42. import { ElMessage } from "element-plus";
  43. import moment from "moment";
  44. const { proxy } = getCurrentInstance();
  45. const props = defineProps({
  46. rowData: Object,
  47. tabValues: Object,
  48. });
  49. const loading = ref(false);
  50. const tableData = ref([]);
  51. const tabsCard = ref();
  52. watch(
  53. () => props.tabValues,
  54. (val) => {
  55. if (val.activeName === "bom" && val.tabsCard != tabsCard.value) {
  56. tabsCard.value = val.tabsCard;
  57. if (props.rowData && props.rowData.id) {
  58. loading.value = true;
  59. proxy.post("/statementOfAccount/getDocumentByBom", { id: props.rowData.id, orderClassify: props.tabValues.tabsCard }).then(
  60. (res) => {
  61. tableData.value = Object.freeze(res);
  62. loading.value = false;
  63. },
  64. (err) => {
  65. console.log(err);
  66. loading.value = false;
  67. }
  68. );
  69. }
  70. }
  71. if (val.activeName === "bom" && val.tabsCard === 5) {
  72. getOrder();
  73. }
  74. },
  75. {
  76. deep: true,
  77. immediate: true,
  78. }
  79. );
  80. const labelList = ref({
  81. 2: "quantity",
  82. 4: "laserLogoSummary",
  83. 5: "laserMitochondrialSummary",
  84. 6: "lssueFeeSummary",
  85. 7: "deliveryMaterialsFeeSummary",
  86. 8: "packingLaborSummary",
  87. 9: "managementFeeSummary",
  88. 10: "proofingFeeSummary",
  89. 11: "subtotal",
  90. 12: "total",
  91. });
  92. const textList = ref({
  93. 1: "胜德体育总经理:",
  94. 2: "申请日期:",
  95. });
  96. const getSummaries = ({ columns, data }) => {
  97. const sums = [];
  98. columns.forEach((column, index) => {
  99. if (index === 0) {
  100. sums[index] = h("div", { class: "" }, [
  101. h("div", {
  102. style: { "text-align": "center", "border-style": "solid", "border-width": "0 1px 1px 0", "border-color": "#ebeef5", padding: "0 12px" },
  103. innerHTML: "总计:",
  104. }),
  105. h("div", {
  106. style: { "text-align": "center", "border-style": "solid", "border-width": "0 1px 1px 0", "border-color": "#ebeef5", padding: "0 12px" },
  107. innerHTML: "备注:",
  108. }),
  109. h("div", {
  110. style: { "text-align": "center", "border-style": "solid", "border-width": "0 1px 1px 0", "border-color": "#ebeef5", padding: "0 12px" },
  111. innerHTML: "交货地点:",
  112. }),
  113. h("div", { style: { "font-size": "16px", "font-weight": 700, padding: "0 12px" }, innerHTML: "申请人:" }),
  114. ]);
  115. return;
  116. } else {
  117. sums[index] = h("div", { class: "" }, [
  118. [1, 3].includes(index)
  119. ? h("div", {
  120. style: {
  121. "text-align": "center",
  122. "border-style": "solid",
  123. "border-width": "0 1px 1px 0",
  124. "border-color": "#ebeef5",
  125. color: "#ebeef5",
  126. padding: "0 12px",
  127. height: "35px",
  128. },
  129. innerHTML: ".",
  130. })
  131. : h("div", {
  132. style: {
  133. "text-align": "center",
  134. "border-style": "solid",
  135. "border-width": "0 1px 1px 0",
  136. "border-color": "#ebeef5",
  137. padding: "0 12px",
  138. height: "35px",
  139. },
  140. innerHTML: getTotal(labelList.value[index]),
  141. }),
  142. h("div", {
  143. style: {
  144. "text-align": "center",
  145. "border-style": "solid",
  146. "border-width": "0 0 1px 0",
  147. "border-color": "#ebeef5",
  148. color: "#ebeef5",
  149. padding: "0 12px",
  150. height: "35px",
  151. },
  152. innerHTML: ".",
  153. }),
  154. h("div", {
  155. style: {
  156. "text-align": "center",
  157. "border-style": "solid",
  158. "border-width": "0 0 1px 0",
  159. "border-color": "#ebeef5",
  160. color: "#ebeef5",
  161. padding: "0 12px",
  162. height: "35px",
  163. },
  164. innerHTML: ".",
  165. }),
  166. [1, 2].includes(index)
  167. ? h("div", { style: { "font-size": "16px", "font-weight": 700, padding: "0 12px", "text-align": "left" }, innerHTML: textList.value[index] })
  168. : h("div", {
  169. style: {
  170. "text-align": "center",
  171. "border-style": "solid",
  172. "border-width": "0 0 1px 0",
  173. "border-color": "#ebeef5",
  174. color: "#ebeef5",
  175. padding: "0 12px",
  176. height: "35px",
  177. },
  178. innerHTML: ".",
  179. }),
  180. ]);
  181. return;
  182. }
  183. });
  184. return sums;
  185. };
  186. const getTotal = (label) => {
  187. let list = tableData.value.map((item) => item[label]);
  188. return Number(Math.round(list.reduce((acc, curr) => acc + curr, 0) * 100) / 100);
  189. };
  190. const emit = defineEmits(["clickCancel"]);
  191. const clickCancel = () => {
  192. emit("clickCancel", "");
  193. };
  194. const deriveExcel = () => {
  195. ElMessage("导出文件中,请稍后");
  196. loading.value = true;
  197. proxy.getFile("/statementOfAccount/exportDocumentByBom", { id: props.rowData.id, orderClassify: props.tabValues.tabsCard }).then(
  198. (res) => {
  199. if (res.type === "application/json") {
  200. const fileReader = new FileReader();
  201. fileReader.onloadend = () => {
  202. const jsonData = JSON.parse(fileReader.result);
  203. ElMessage({ message: jsonData.msg, type: "error" });
  204. };
  205. fileReader.readAsText(res);
  206. } else {
  207. proxy.downloadFile(res, "BOM对账单-" + moment().format("yyyy-MM-DD") + ".xlsx");
  208. loading.value = false;
  209. }
  210. },
  211. (err) => {
  212. console.log(err);
  213. loading.value = false;
  214. }
  215. );
  216. };
  217. const orderList = ref([]);
  218. const loadingOneKey = ref(false);
  219. const judgeOneKeyStatus = () => {
  220. let status = true;
  221. if (proxy.useUserStore().user.userId !== "1") {
  222. status = false;
  223. } else {
  224. if (!(props.tabValues.tabsCard === 5 && orderList.value && orderList.value.length > 0)) {
  225. status = false;
  226. }
  227. }
  228. return status;
  229. };
  230. const getOrder = () => {
  231. proxy.post("/statementOfAccountMerge/getNotSalesOutOfWarehouseOrder", { idGroupConcat: props.rowData.id }).then((res) => {
  232. if (res && res.length > 0) {
  233. orderList.value = res;
  234. } else {
  235. orderList.value = [];
  236. }
  237. });
  238. };
  239. const clickOneKeyStatus = () => {
  240. loadingOneKey.value = true;
  241. proxy.post("/statementOfAccountMerge/salesOutOfWarehouse", orderList.value).then(
  242. () => {
  243. ElMessage({ message: "操作完成", type: "success" });
  244. getOrder();
  245. loadingOneKey.value = false;
  246. },
  247. (err) => {
  248. console.log(err);
  249. loadingOneKey.value = false;
  250. }
  251. );
  252. };
  253. </script>
  254. <style lang="scss" scoped>
  255. ::v-deep(.el-table thead.is-group th.el-table__cell) {
  256. background-color: white !important;
  257. }
  258. ::v-deep(.el-table__footer-wrapper tbody td.el-table__cell) {
  259. background-color: white !important;
  260. }
  261. ::v-deep(.el-table .el-table__cell) {
  262. padding: 0;
  263. }
  264. ::v-deep(.el-table__footer .cell) {
  265. padding: 0;
  266. }
  267. ::v-deep(.el-table__footer .el-table__cell) {
  268. border-right: 0px;
  269. }
  270. ::v-deep(.el-card__body) {
  271. padding: 10px !important;
  272. }
  273. </style>