printOrder.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <el-card v-loading="loading">
  3. <div style="text-align: center; font-size: 30px; padding: 8px; font-weight: 700">{{ props.rowData.departmentName }}-胜德体育对账单</div>
  4. <div style="text-align: center; font-size: 18px; padding-bottom: 8px; font-weight: 700">( 对账时间: {{ rowData.timePeriod }} )</div>
  5. <div style="height: calc(100vh - 235px - 88px); overflow-y: auto; overflow-x: hidden">
  6. <el-auto-resizer>
  7. <template #default="{ height, width }">
  8. <el-table-v2 :columns="columns" :data="tableData" :width="width" :height="height" fixed :cache="20" :header-height="35" :row-height="35">
  9. <template #row="props">
  10. <Row v-bind="props" />
  11. </template>
  12. </el-table-v2>
  13. </template>
  14. </el-auto-resizer>
  15. </div>
  16. <div style="padding: 4px; text-align: center">
  17. <el-button @click="clickCancel">关 闭</el-button>
  18. <el-button type="primary" @click="deriveExcel()" v-preReClick>导 出</el-button>
  19. </div>
  20. </el-card>
  21. </template>
  22. <script setup>
  23. import { cloneVNode } from "vue";
  24. const { proxy } = getCurrentInstance();
  25. const props = defineProps({
  26. rowData: Object,
  27. activeName: String,
  28. tabsCard: Number,
  29. });
  30. const loading = ref(false);
  31. const tableData = ref([]);
  32. const getAggregate = (data) => {
  33. let total = 0;
  34. if (data && data.length > 0) {
  35. for (let i = 0; i < data.length; i++) {
  36. if (data[i].total) {
  37. total = Number(Math.round((total + data[i].total) * 100) / 100);
  38. }
  39. }
  40. }
  41. return total;
  42. };
  43. watch(
  44. () => props.activeName,
  45. (val) => {
  46. if (val === "order" && !(tableData.value && tableData.value.length > 0)) {
  47. if (props.rowData && props.rowData.id) {
  48. loading.value = true;
  49. proxy.post("/statementOfAccount/getDocumentByOrder", { id: props.rowData.id }).then(
  50. (res) => {
  51. let total = getAggregate(proxy.deepClone(res));
  52. let list = [];
  53. if (res && res.length > 0) {
  54. for (let i = 0; i < res.length; i++) {
  55. if (res[i].skuSpecList && res[i].skuSpecList.length > 0) {
  56. for (let j = 0; j < res[i].skuSpecList.length; j++) {
  57. if (res[i].skuSpecList[j].bomSpecList && res[i].skuSpecList[j].bomSpecList.length > 0) {
  58. for (let y = 0; y < res[i].skuSpecList[j].bomSpecList.length; y++) {
  59. let indexOne = 0;
  60. if (j === 0 && y === 0) {
  61. for (let z = 0; z < res[i].skuSpecList.length; z++) {
  62. if (res[i].skuSpecList[z].bomSpecList && res[i].skuSpecList[z].bomSpecList.length > 0) {
  63. indexOne = Number(indexOne + res[i].skuSpecList[z].bomSpecList.length);
  64. }
  65. }
  66. }
  67. let indexTwo = 0;
  68. if (y === 0) {
  69. indexTwo = res[i].skuSpecList[j].bomSpecList.length;
  70. }
  71. list.push({
  72. wlnCreateTime: res[i].wlnCreateTime,
  73. code: res[i].code,
  74. wlnCode: res[i].wlnCode,
  75. skuSpecCode: res[i].skuSpecList[j].skuSpecCode,
  76. skuSpecName: res[i].skuSpecList[j].skuSpecName,
  77. quantitySKU: res[i].skuSpecList[j].quantity,
  78. subtotal: res[i].skuSpecList[j].subtotal,
  79. bomSpecCode: res[i].skuSpecList[j].bomSpecList[y].bomSpecCode,
  80. bomSpecName: res[i].skuSpecList[j].bomSpecList[y].bomSpecName,
  81. quantityBOM: res[i].skuSpecList[j].bomSpecList[y].quantity,
  82. unitPriceBOM: res[i].skuSpecList[j].bomSpecList[y].unitPrice,
  83. laserLogoSummary: res[i].skuSpecList[j].bomSpecList[y].laserLogoSummary,
  84. laserMitochondrialSummary: res[i].skuSpecList[j].bomSpecList[y].laserMitochondrialSummary,
  85. lssueFeeSummary: res[i].skuSpecList[j].bomSpecList[y].lssueFeeSummary,
  86. deliveryMaterialsFeeSummary: res[i].skuSpecList[j].bomSpecList[y].deliveryMaterialsFeeSummary,
  87. packingLaborSummary: res[i].skuSpecList[j].bomSpecList[y].packingLaborSummary,
  88. managementFeeSummary: res[i].skuSpecList[j].bomSpecList[y].managementFeeSummary,
  89. unitPriceSKU: res[i].skuSpecList[j].unitPrice,
  90. outerBoxPackingFee: res[i].outerBoxPackingFee,
  91. total: res[i].total,
  92. indexOne: indexOne,
  93. indexTwo: indexTwo,
  94. });
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }
  101. list.push({
  102. indexOne: 1,
  103. indexTwo: 1,
  104. total: total,
  105. wlnCreateTime: "总计:",
  106. });
  107. tableData.value = Object.freeze(list);
  108. loading.value = false;
  109. },
  110. (err) => {
  111. console.log(err);
  112. loading.value = false;
  113. }
  114. );
  115. }
  116. }
  117. },
  118. {
  119. deep: true,
  120. immediate: true,
  121. }
  122. );
  123. const emit = defineEmits(["clickCancel"]);
  124. const clickCancel = () => {
  125. emit("clickCancel", "");
  126. };
  127. const deriveExcel = () => {
  128. loading.value = true;
  129. proxy.getFile("/statementOfAccount/exportDocumentByOrder", { id: props.rowData.id }).then(
  130. () => {
  131. emit("clickCancel", true);
  132. // proxy.downloadFile(res, "订单对账单.xlsx");
  133. loading.value = false;
  134. },
  135. (err) => {
  136. console.log(err);
  137. loading.value = false;
  138. }
  139. );
  140. };
  141. const columns = computed(() => {
  142. return [
  143. {
  144. dataKey: "wlnCreateTime",
  145. key: "column-0",
  146. title: "订单时间",
  147. width: 150,
  148. rowIndex: 1,
  149. },
  150. {
  151. dataKey: "code",
  152. key: "column-1",
  153. title: "订单号",
  154. width: 160,
  155. },
  156. {
  157. dataKey: "wlnCode",
  158. key: "column-2",
  159. title: "万里牛单号",
  160. width: 140,
  161. },
  162. {
  163. dataKey: "skuSpecCode",
  164. key: "column-3",
  165. title: "SKU品号",
  166. width: 140,
  167. },
  168. {
  169. dataKey: "skuSpecName",
  170. key: "column-4",
  171. title: "SKU品名",
  172. width: 220,
  173. },
  174. {
  175. dataKey: "quantitySKU",
  176. key: "column-5",
  177. title: "SKU数量",
  178. width: 80,
  179. },
  180. {
  181. dataKey: "bomSpecCode",
  182. key: "column-6",
  183. title: "BOM品号",
  184. width: 140,
  185. },
  186. {
  187. dataKey: "bomSpecName",
  188. key: "column-7",
  189. title: "BOM品名",
  190. width: 260,
  191. },
  192. {
  193. dataKey: "quantityBOM",
  194. key: "column-8",
  195. title: "BOM数量",
  196. width: 80,
  197. },
  198. {
  199. dataKey: "unitPriceBOM",
  200. key: "column-9",
  201. title: "单价",
  202. width: 100,
  203. },
  204. {
  205. dataKey: "laserLogoSummary",
  206. key: "column-10",
  207. title: "激光LOGO",
  208. width: 100,
  209. },
  210. {
  211. dataKey: "laserMitochondrialSummary",
  212. key: "column-11",
  213. title: "激光体位线",
  214. width: 100,
  215. },
  216. {
  217. dataKey: "lssueFeeSummary",
  218. key: "column-12",
  219. title: "代发费",
  220. width: 100,
  221. },
  222. {
  223. dataKey: "deliveryMaterialsFeeSummary",
  224. key: "column-13",
  225. title: "快递包材费",
  226. width: 100,
  227. },
  228. {
  229. dataKey: "packingLaborSummary",
  230. key: "column-14",
  231. title: "包装人工费",
  232. width: 100,
  233. },
  234. {
  235. dataKey: "managementFeeSummary",
  236. key: "column-15",
  237. title: "管理费",
  238. width: 100,
  239. },
  240. {
  241. dataKey: "unitPriceSKU",
  242. key: "column-16",
  243. title: "SKU单价",
  244. width: 100,
  245. },
  246. {
  247. dataKey: "subtotal",
  248. key: "column-17",
  249. title: "小计",
  250. width: 120,
  251. },
  252. {
  253. dataKey: "total",
  254. key: "column-18",
  255. title: "合计",
  256. width: 120,
  257. },
  258. ];
  259. });
  260. const mergeColumnOne = [0, 1, 2, 18];
  261. const mergeColumnTwo = [3, 4, 5, 16, 17];
  262. const Row = ({ rowData, cells }) => {
  263. if (rowData.indexOne > 1) {
  264. for (let i = 0; i < mergeColumnOne.length; i++) {
  265. const cell = cells[mergeColumnOne[i]];
  266. const style = {
  267. ...cell.props.style,
  268. backgroundColor: "#fff",
  269. height: `${rowData.indexOne * 35 - 1}px`,
  270. alignSelf: "flex-start",
  271. zIndex: 1,
  272. };
  273. cells[mergeColumnOne[i]] = cloneVNode(cell, { style });
  274. }
  275. }
  276. if (rowData.indexTwo > 1) {
  277. for (let i = 0; i < mergeColumnTwo.length; i++) {
  278. const cell = cells[mergeColumnTwo[i]];
  279. const style = {
  280. ...cell.props.style,
  281. backgroundColor: "#fff",
  282. height: `${rowData.indexTwo * 35 - 1}px`,
  283. alignSelf: "flex-start",
  284. zIndex: 1,
  285. };
  286. cells[mergeColumnTwo[i]] = cloneVNode(cell, { style });
  287. }
  288. }
  289. return cells;
  290. };
  291. </script>
  292. <style lang="scss" scoped>
  293. ::v-deep(.el-table-v2__header-cell) {
  294. background-color: #eeeeee !important;
  295. }
  296. ::v-deep(.el-card__body) {
  297. padding: 10px !important;
  298. }
  299. </style>