index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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. :action-list="[
  13. {
  14. text: '盘点登记',
  15. action: () => clickModal(),
  16. },
  17. {
  18. text: '导出Excel',
  19. action: () => clickDerive(),
  20. },
  21. ]"
  22. @get-list="getList"
  23. @clickReset="clickReset">
  24. </byTable>
  25. </el-tab-pane>
  26. <el-tab-pane label="盘点明细" name="second">
  27. <byTable
  28. :source="sourceListTwo.data"
  29. :pagination="sourceListTwo.pagination"
  30. :config="configTwo"
  31. :loading="loading"
  32. :searchConfig="searchConfigTwo"
  33. highlight-current-row
  34. :action-list="[
  35. {
  36. text: '盘点登记',
  37. action: () => clickModal(),
  38. },
  39. ]"
  40. @get-list="getListTwo"
  41. @clickReset="clickResetTwo">
  42. <template #quantity="{ item }">
  43. <div>{{ calculationNum(item) }}</div>
  44. </template>
  45. <template #money="{ item }">
  46. <div>{{ calculationMoney(item) }}</div>
  47. </template>
  48. </byTable>
  49. </el-tab-pane>
  50. </el-tabs>
  51. <el-dialog title="导出Excel文件" v-if="openDerive" v-model="openDerive" width="400">
  52. <el-form :model="formData.data" :rules="rules" ref="derive">
  53. <el-form-item label="仓库" prop="warehouseId">
  54. <el-select v-model="formData.data.warehouseId" placeholder="仓库" clearable style="width: 100%">
  55. <el-option v-for="item in warehouseList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  56. </el-select>
  57. </el-form-item>
  58. </el-form>
  59. <template #footer>
  60. <el-button @click="openDerive = false" size="large">关 闭</el-button>
  61. <el-button type="primary" @click="clickSubmit" v-preReClick>确 认</el-button>
  62. </template>
  63. </el-dialog>
  64. </el-card>
  65. </template>
  66. <script setup>
  67. import byTable from "/src/components/byTable/index";
  68. const { proxy } = getCurrentInstance();
  69. const activeName = ref("first");
  70. const departmentList = ref([{ dictKey: "0", dictValue: "胜德体育" }]);
  71. const warehouseList = ref([]);
  72. const status = ref([
  73. { dictKey: "0", dictValue: "正常" },
  74. { dictKey: "1", dictValue: "异常" },
  75. ]);
  76. const sourceList = ref({
  77. data: [],
  78. pagination: {
  79. total: 0,
  80. pageNum: 1,
  81. pageSize: 10,
  82. departmentId: "",
  83. warehouseId: "",
  84. status: "",
  85. beginTime: "",
  86. endTime: "",
  87. },
  88. });
  89. const sourceListTwo = ref({
  90. data: [],
  91. pagination: {
  92. total: 0,
  93. pageNum: 1,
  94. pageSize: 10,
  95. bomSpecCode: "",
  96. bomSpecName: "",
  97. departmentId: "",
  98. warehouseId: "",
  99. status: "",
  100. beginTime: "",
  101. endTime: "",
  102. },
  103. });
  104. const loading = ref(false);
  105. const searchConfig = computed(() => {
  106. return [
  107. {
  108. type: "select",
  109. prop: "departmentId",
  110. data: departmentList.value,
  111. label: "事业部",
  112. },
  113. {
  114. type: "select",
  115. prop: "warehouseId",
  116. data: warehouseList.value,
  117. label: "仓库",
  118. },
  119. {
  120. type: "select",
  121. prop: "status",
  122. data: status.value,
  123. label: "盘点结果",
  124. },
  125. {
  126. type: "date",
  127. propList: ["beginTime", "endTime"],
  128. label: "盘点日期",
  129. },
  130. ];
  131. });
  132. const searchConfigTwo = computed(() => {
  133. return [
  134. {
  135. type: "input",
  136. prop: "bomSpecCode",
  137. label: "品号",
  138. },
  139. {
  140. type: "input",
  141. prop: "bomSpecName",
  142. label: "品名",
  143. },
  144. {
  145. type: "select",
  146. prop: "departmentId",
  147. data: departmentList.value,
  148. label: "事业部",
  149. },
  150. {
  151. type: "select",
  152. prop: "warehouseId",
  153. data: warehouseList.value,
  154. label: "仓库",
  155. },
  156. {
  157. type: "select",
  158. prop: "status",
  159. data: status.value,
  160. label: "盘点结果",
  161. },
  162. {
  163. type: "date",
  164. propList: ["beginTime", "endTime"],
  165. label: "盘点日期",
  166. },
  167. ];
  168. });
  169. const config = computed(() => {
  170. return [
  171. {
  172. attrs: {
  173. label: "盘点时间",
  174. prop: "createTime",
  175. width: 160,
  176. align: "center",
  177. },
  178. },
  179. {
  180. attrs: {
  181. label: "归属事业部",
  182. prop: "departmentName",
  183. "min-width": 160,
  184. },
  185. },
  186. {
  187. attrs: {
  188. label: "仓库类型",
  189. prop: "warehouseType",
  190. width: 140,
  191. },
  192. render(val) {
  193. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["warehouse_type"]);
  194. },
  195. },
  196. {
  197. attrs: {
  198. label: "仓库名称",
  199. prop: "warehouseName",
  200. "min-width": 200,
  201. },
  202. },
  203. {
  204. attrs: {
  205. label: "入库类型",
  206. prop: "status",
  207. width: 140,
  208. },
  209. render(val) {
  210. return proxy.dictKeyValue(val, status.value);
  211. },
  212. },
  213. {
  214. attrs: {
  215. label: "盘点人",
  216. prop: "checkTaker",
  217. width: 160,
  218. align: "center",
  219. },
  220. },
  221. ];
  222. });
  223. const configTwo = computed(() => {
  224. return [
  225. {
  226. attrs: {
  227. label: "品号",
  228. prop: "bomSpecCode",
  229. width: 160,
  230. },
  231. },
  232. {
  233. attrs: {
  234. label: "品名",
  235. prop: "bomSpecName",
  236. "min-width": 220,
  237. },
  238. },
  239. {
  240. attrs: {
  241. label: "结存单价",
  242. prop: "balanceUnitPrice",
  243. width: 140,
  244. algin: "right",
  245. },
  246. },
  247. {
  248. attrs: {
  249. label: "仓库名称",
  250. prop: "warehouseName",
  251. width: 160,
  252. },
  253. },
  254. {
  255. attrs: {
  256. label: "归属事业部",
  257. prop: "departmentName",
  258. width: 160,
  259. },
  260. },
  261. {
  262. attrs: {
  263. label: "单位",
  264. prop: "bomUnit",
  265. width: 140,
  266. },
  267. },
  268. {
  269. attrs: {
  270. label: "盘前数量",
  271. prop: "surplusStock",
  272. width: 140,
  273. },
  274. },
  275. {
  276. attrs: {
  277. label: "盘后数量",
  278. prop: "checkQuantity",
  279. width: 140,
  280. },
  281. },
  282. {
  283. attrs: {
  284. label: "盘盈/亏数量",
  285. slot: "quantity",
  286. width: 140,
  287. },
  288. },
  289. {
  290. attrs: {
  291. label: "盘盈/亏金额",
  292. slot: "money",
  293. width: 140,
  294. },
  295. },
  296. {
  297. attrs: {
  298. label: "备注",
  299. slot: "remark",
  300. width: 140,
  301. },
  302. },
  303. ];
  304. });
  305. const getList = async (req, status) => {
  306. if (status) {
  307. sourceList.value.pagination = {
  308. pageNum: sourceList.value.pagination.pageNum,
  309. pageSize: sourceList.value.pagination.pageSize,
  310. };
  311. } else {
  312. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  313. }
  314. loading.value = true;
  315. proxy.post("/check/page", sourceList.value.pagination).then((res) => {
  316. sourceList.value.data = res.rows;
  317. sourceList.value.pagination.total = res.total;
  318. setTimeout(() => {
  319. loading.value = false;
  320. }, 200);
  321. });
  322. };
  323. getList();
  324. const clickReset = () => {
  325. getList("", true);
  326. };
  327. const getListTwo = async (req, status) => {
  328. if (status) {
  329. sourceListTwo.value.pagination = {
  330. pageNum: sourceListTwo.value.pagination.pageNum,
  331. pageSize: sourceListTwo.value.pagination.pageSize,
  332. };
  333. } else {
  334. sourceListTwo.value.pagination = { ...sourceListTwo.value.pagination, ...req };
  335. }
  336. loading.value = true;
  337. proxy.post("/checkBom/page", sourceListTwo.value.pagination).then((res) => {
  338. sourceListTwo.value.data = res.rows;
  339. sourceListTwo.value.pagination.total = res.total;
  340. setTimeout(() => {
  341. loading.value = false;
  342. }, 200);
  343. });
  344. };
  345. const clickResetTwo = () => {
  346. getListTwo("", true);
  347. };
  348. const changeActiveName = (val) => {
  349. if (val === "first") {
  350. getList();
  351. } else {
  352. getListTwo();
  353. }
  354. };
  355. const getDemandData = () => {
  356. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  357. if (res.rows && res.rows.length > 0) {
  358. departmentList.value = departmentList.value.concat(
  359. res.rows.map((item) => {
  360. return {
  361. dictKey: item.id,
  362. dictValue: item.name,
  363. };
  364. })
  365. );
  366. }
  367. });
  368. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  369. if (res.rows && res.rows.length > 0) {
  370. warehouseList.value = res.rows.map((item) => {
  371. return {
  372. dictKey: item.id,
  373. dictValue: item.name,
  374. };
  375. });
  376. }
  377. });
  378. };
  379. getDemandData();
  380. const clickModal = () => {
  381. proxy.$router.replace({
  382. path: "/check/add",
  383. query: {
  384. random: proxy.random(),
  385. },
  386. });
  387. };
  388. const calculationNum = (row) => {
  389. let num = 0;
  390. if (row.checkQuantity) {
  391. num = Number(row.checkQuantity);
  392. }
  393. if (row.surplusStock) {
  394. num = Number(num) - Number(row.surplusStock);
  395. }
  396. return num;
  397. };
  398. const calculationMoney = (row) => {
  399. let num = 0;
  400. if (row.checkQuantity) {
  401. num = Number(row.checkQuantity);
  402. }
  403. if (row.surplusStock) {
  404. num = Number(num) - Number(row.surplusStock);
  405. }
  406. if (row.balanceUnitPrice) {
  407. money = Number(Math.round(money * Number(row.balanceUnitPrice) * 100) / 100);
  408. return money;
  409. } else {
  410. return 0;
  411. }
  412. };
  413. const openDerive = ref(false);
  414. const formData = reactive({
  415. data: {
  416. warehouseId: "",
  417. },
  418. });
  419. const rules = ref({
  420. warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
  421. });
  422. const clickDerive = () => {
  423. formData.data.warehouseId = "";
  424. openDerive.value = true;
  425. };
  426. const clickSubmit = () => {
  427. proxy.$refs.derive.validate((valid) => {
  428. if (valid) {
  429. proxy.postFile("/check/inventoryExportExcel", { id: formData.data.warehouseId }).then((res) => {
  430. proxy.downloadFile(res, "盘点.xlsx");
  431. });
  432. }
  433. });
  434. };
  435. </script>
  436. <style lang="scss" scoped>
  437. ::v-deep(.el-input-number .el-input__inner) {
  438. text-align: left;
  439. }
  440. </style>