printSKU.vue 8.5 KB

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