index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <el-card class="box-card">
  3. <el-tabs v-model="activeName" type="card" @tab-change="changeActiveName">
  4. <el-tab-pane label="成品库" name="first">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. :searchConfig="searchConfig"
  11. highlight-current-row
  12. @get-list="getList"
  13. @clickReset="clickReset">
  14. </byTable>
  15. </el-tab-pane>
  16. <el-tab-pane label="成品库明细" name="second">
  17. <byTable
  18. :source="sourceListTwo.data"
  19. :pagination="sourceListTwo.pagination"
  20. :config="configTwo"
  21. :loading="loading"
  22. :searchConfig="searchConfigTwo"
  23. highlight-current-row
  24. :action-list="[
  25. {
  26. text: '导出Excel',
  27. action: () => clickGiveaway(),
  28. },
  29. ]"
  30. @get-list="getListTwo"
  31. @clickReset="clickResetTwo">
  32. </byTable>
  33. </el-tab-pane>
  34. </el-tabs>
  35. <el-dialog title="上传" v-if="openGiveaway" v-model="openGiveaway" width="600">
  36. <div v-loading="loadingGiveaway">
  37. <el-upload :show-file-list="false" action="##" :http-request="giveawayServerLog" :before-upload="handleBeforeGiveaway">
  38. <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
  39. </el-upload>
  40. <div style="text-align: center; margin: 10px">
  41. <el-button @click="openGiveaway = false" size="large">关 闭</el-button>
  42. </div>
  43. </div>
  44. </el-dialog>
  45. </el-card>
  46. </template>
  47. <script setup>
  48. import byTable from "/src/components/byTable/index";
  49. import { ElMessage, ElMessageBox } from "element-plus";
  50. import moment from "moment";
  51. const { proxy } = getCurrentInstance();
  52. const activeName = ref("first");
  53. const departmentList = ref([{ dictKey: "0", dictValue: "胜德体育" }]);
  54. const sourceList = ref({
  55. data: [],
  56. pagination: {
  57. total: 0,
  58. pageNum: 1,
  59. pageSize: 10,
  60. skuSpecCode: "",
  61. skuSpecName: "",
  62. },
  63. });
  64. const sourceListTwo = ref({
  65. data: [],
  66. pagination: {
  67. total: 0,
  68. pageNum: 1,
  69. pageSize: 10,
  70. skuSpecCode: "",
  71. skuSpecName: "",
  72. orderCode: "",
  73. orderWlnCode: "",
  74. departmentId: "",
  75. },
  76. });
  77. const loading = ref(false);
  78. const searchConfig = computed(() => {
  79. return [
  80. {
  81. type: "input",
  82. prop: "skuSpecCode",
  83. label: "SKU品号",
  84. },
  85. {
  86. type: "input",
  87. prop: "skuSpecName",
  88. label: "SKU品名",
  89. },
  90. ];
  91. });
  92. const searchConfigTwo = computed(() => {
  93. return [
  94. {
  95. type: "input",
  96. prop: "orderCode",
  97. label: "订单号",
  98. },
  99. {
  100. type: "input",
  101. prop: "orderWlnCode",
  102. label: "E10单号",
  103. },
  104. {
  105. type: "input",
  106. prop: "skuSpecCode",
  107. label: "SKU品号",
  108. },
  109. {
  110. type: "input",
  111. prop: "skuSpecName",
  112. label: "SKU品名",
  113. },
  114. {
  115. type: "select",
  116. prop: "departmentId",
  117. data: departmentList.value,
  118. label: "事业部",
  119. },
  120. ];
  121. });
  122. const config = computed(() => {
  123. return [
  124. {
  125. attrs: {
  126. label: "SKU品号",
  127. prop: "skuSpecCode",
  128. "min-width": 140,
  129. },
  130. },
  131. {
  132. attrs: {
  133. label: "SKU品名",
  134. prop: "skuSpecName",
  135. "min-width": 340,
  136. },
  137. },
  138. {
  139. attrs: {
  140. label: "数量",
  141. prop: "quantity",
  142. "min-width": 120,
  143. },
  144. },
  145. ];
  146. });
  147. const configTwo = computed(() => {
  148. return [
  149. {
  150. attrs: {
  151. label: "订单号",
  152. prop: "orderCode",
  153. width: 200,
  154. },
  155. },
  156. {
  157. attrs: {
  158. label: "E10单号",
  159. prop: "orderWlnCode",
  160. width: 140,
  161. },
  162. },
  163. {
  164. attrs: {
  165. label: "事业部",
  166. prop: "departmentName",
  167. width: 120,
  168. },
  169. },
  170. {
  171. attrs: {
  172. label: "SKU品号",
  173. prop: "skuSpecCode",
  174. width: 160,
  175. },
  176. },
  177. {
  178. attrs: {
  179. label: "SKU品名",
  180. prop: "skuSpecName",
  181. },
  182. },
  183. {
  184. attrs: {
  185. label: "数量",
  186. prop: "quantity",
  187. width: 100,
  188. },
  189. },
  190. {
  191. attrs: {
  192. label: "操作类型",
  193. prop: "operationType",
  194. width: 100,
  195. },
  196. render(val) {
  197. if (val == "1") {
  198. return "入库";
  199. } else if (val == "2") {
  200. return "出库";
  201. }
  202. },
  203. },
  204. {
  205. attrs: {
  206. label: "操作时间",
  207. prop: "createTime",
  208. width: 160,
  209. align: "center",
  210. },
  211. },
  212. ];
  213. });
  214. const getDemandData = () => {
  215. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  216. if (res.rows && res.rows.length > 0) {
  217. departmentList.value = departmentList.value.concat(
  218. res.rows.map((item) => {
  219. return {
  220. dictKey: item.id,
  221. dictValue: item.name,
  222. };
  223. })
  224. );
  225. }
  226. });
  227. };
  228. getDemandData();
  229. const getList = async (req, status) => {
  230. if (status) {
  231. sourceList.value.pagination = {
  232. pageNum: sourceList.value.pagination.pageNum,
  233. pageSize: sourceList.value.pagination.pageSize,
  234. };
  235. } else {
  236. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  237. }
  238. loading.value = true;
  239. proxy.post("/inventoryFinished/page", sourceList.value.pagination).then((res) => {
  240. sourceList.value.data = res.rows;
  241. sourceList.value.pagination.total = res.total;
  242. setTimeout(() => {
  243. loading.value = false;
  244. }, 200);
  245. });
  246. };
  247. getList();
  248. const clickReset = () => {
  249. getList("", true);
  250. };
  251. const getListTwo = async (req, status) => {
  252. if (status) {
  253. sourceListTwo.value.pagination = {
  254. pageNum: sourceListTwo.value.pagination.pageNum,
  255. pageSize: sourceListTwo.value.pagination.pageSize,
  256. };
  257. } else {
  258. sourceListTwo.value.pagination = { ...sourceListTwo.value.pagination, ...req };
  259. }
  260. loading.value = true;
  261. proxy.post("/inventoryFinishedOrder/page", sourceListTwo.value.pagination).then((res) => {
  262. sourceListTwo.value.data = res.rows;
  263. sourceListTwo.value.pagination.total = res.total;
  264. setTimeout(() => {
  265. loading.value = false;
  266. }, 200);
  267. });
  268. };
  269. const clickResetTwo = () => {
  270. getListTwo("", true);
  271. };
  272. const changeActiveName = (val) => {
  273. if (val === "first") {
  274. getList();
  275. } else {
  276. getListTwo();
  277. }
  278. };
  279. const openGiveaway = ref(false);
  280. const loadingGiveaway = ref(false);
  281. const clickGiveaway = () => {
  282. loadingGiveaway.value = false;
  283. openGiveaway.value = true;
  284. };
  285. const handleBeforeGiveaway = () => {
  286. loadingGiveaway.value = true;
  287. };
  288. const giveawayServerLog = (params) => {
  289. let file = params.file;
  290. let formFile = new FormData();
  291. formFile.append("file", file);
  292. proxy.postUploadAndDownloadFile("/inventoryFinishedOrder/erpExcelExport", formFile).then(
  293. (res) => {
  294. if (res.type === "application/json") {
  295. const fileReader = new FileReader();
  296. fileReader.onloadend = () => {
  297. const jsonData = JSON.parse(fileReader.result);
  298. ElMessage({ message: jsonData.msg, type: "error" });
  299. loadingGiveaway.value = false;
  300. };
  301. fileReader.readAsText(res);
  302. } else {
  303. ElMessage({ message: "操作成功", type: "success" });
  304. proxy.downloadFile(res, "成品库明细-" + moment().format("yyyy-MM-DD") + ".xlsx");
  305. loadingGiveaway.value = false;
  306. openGiveaway.value = false;
  307. }
  308. },
  309. (err) => {
  310. console.log(err);
  311. loadingGiveaway.value = false;
  312. }
  313. );
  314. };
  315. </script>
  316. <style lang="scss" scoped>
  317. ::v-deep(.el-input-number .el-input__inner) {
  318. text-align: left;
  319. }
  320. </style>