index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
  5. highlight-current-row :action-list="[ {
  6. text: '导出Excel',
  7. action: () => deriveExcel(),
  8. },]" @get-list="getList">
  9. <template #warehouseName="{ item }">
  10. <div>
  11. <!-- <span v-if="item.opType == 1">{{ item.toWarehouseName }}</span>
  12. <span v-else>{{ item.warehouseName }}</span> -->
  13. <span>{{ item.warehouseName }}</span>
  14. </div>
  15. </template>
  16. </byTable>
  17. </div>
  18. <el-dialog :title="'修正数量'" v-model="dialogVisible" width="500" destroy-on-close>
  19. <byForm v-loading="submitLoading" :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
  20. </byForm>
  21. <template #footer>
  22. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  23. <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading">
  24. 确 定
  25. </el-button>
  26. </template>
  27. </el-dialog>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { ElMessage, ElMessageBox } from "element-plus";
  32. import byTable from "@/components/byTable/index";
  33. import byForm from "@/components/byForm/index";
  34. const { proxy } = getCurrentInstance();
  35. const route = useRoute();
  36. const opTypeList = ref([
  37. {
  38. label: "入库",
  39. value: "1",
  40. },
  41. {
  42. label: "出库",
  43. value: "2",
  44. },
  45. ]);
  46. const typeList = ref([
  47. {
  48. label: "手动入库",
  49. value: "1",
  50. },
  51. {
  52. label: "手动出库",
  53. value: "2",
  54. },
  55. {
  56. label: "调仓入库",
  57. value: "3",
  58. },
  59. {
  60. label: "待入库入库",
  61. value: "4",
  62. },
  63. {
  64. label: "待出库出库",
  65. value: "5",
  66. },
  67. {
  68. label: "组合入库",
  69. value: "6",
  70. },
  71. {
  72. label: "组合出库",
  73. value: "7",
  74. },
  75. {
  76. label: "组合拆分入库",
  77. value: "8",
  78. },
  79. {
  80. label: "组合拆分出库",
  81. value: "9",
  82. },
  83. {
  84. label: "京东销售出库",
  85. value: "10",
  86. },
  87. {
  88. label: "调仓出库",
  89. value: "11",
  90. },
  91. {
  92. label: "销售订单出库",
  93. value: "12",
  94. },
  95. {
  96. label: "退货出库",
  97. value: "13",
  98. },
  99. {
  100. label: "到货入库",
  101. value: "14",
  102. },
  103. {
  104. label: "京东退货入库",
  105. value: "15",
  106. },
  107. {
  108. label: "采购到货入库",
  109. value: "18",
  110. },
  111. {
  112. label: "到货质检",
  113. value: "19",
  114. },
  115. {
  116. label: "生产任务出库",
  117. value: "20",
  118. },
  119. {
  120. label: "良品转次品",
  121. value: "21",
  122. },
  123. {
  124. label: "次品转良品",
  125. value: "22",
  126. },
  127. ]);
  128. const warehouseList = ref([]);
  129. const productUnit = ref([]);
  130. const sourceList = ref({
  131. data: [],
  132. pagination: {
  133. total: 0,
  134. pageNum: 1,
  135. pageSize: 10,
  136. keyword: "",
  137. opType: "",
  138. productId: "",
  139. },
  140. });
  141. const loading = ref(false);
  142. const selectConfig = computed(() => {
  143. return [
  144. {
  145. label: "操作类型",
  146. prop: "opType",
  147. data: opTypeList.value,
  148. },
  149. {
  150. label: "出入库类型",
  151. prop: "type",
  152. data: typeList.value,
  153. },
  154. ];
  155. });
  156. const config = computed(() => {
  157. return [
  158. {
  159. attrs: {
  160. label: "操作类型",
  161. prop: "opType",
  162. width: 100,
  163. },
  164. render(type) {
  165. return proxy.dictValueLabel(type, opTypeList.value);
  166. },
  167. },
  168. {
  169. attrs: {
  170. label: "关联单号",
  171. prop: "linkCode",
  172. },
  173. },
  174. {
  175. attrs: {
  176. label: "物流单号",
  177. prop: "logisticsCode",
  178. },
  179. },
  180. {
  181. attrs: {
  182. label: "物流/快递公司",
  183. prop: "logisticsCompanyName",
  184. },
  185. },
  186. {
  187. attrs: {
  188. label: "出入库类型",
  189. prop: "type",
  190. width: 120,
  191. },
  192. render(type) {
  193. return proxy.dictValueLabel(type, typeList.value);
  194. },
  195. },
  196. {
  197. attrs: {
  198. label: "仓库名称",
  199. slot: "warehouseName",
  200. },
  201. },
  202. {
  203. attrs: {
  204. label: "物品编码",
  205. prop: "productCustomCode",
  206. },
  207. },
  208. {
  209. attrs: {
  210. label: "物品名称",
  211. prop: "productName",
  212. },
  213. },
  214. {
  215. attrs: {
  216. label: "规格",
  217. prop: "productSpec",
  218. },
  219. },
  220. {
  221. attrs: {
  222. label: "单位",
  223. prop: "productUnit",
  224. width: 100,
  225. },
  226. render(unit) {
  227. return proxy.dictValueLabel(unit, productUnit.value);
  228. },
  229. },
  230. {
  231. attrs: {
  232. label: "操作数量",
  233. prop: "quantity",
  234. width: 100,
  235. },
  236. },
  237. {
  238. attrs: {
  239. label: "操作人",
  240. prop: "opUserName",
  241. width: 120,
  242. },
  243. },
  244. {
  245. attrs: {
  246. label: "操作时间",
  247. prop: "createTime",
  248. width: 160,
  249. },
  250. },
  251. {
  252. attrs: {
  253. label: "操作",
  254. width: "80",
  255. align: "center",
  256. },
  257. // 渲染 el-button,一般用在最后一列。
  258. renderHTML(row) {
  259. return [
  260. row.type == "18"
  261. ? {
  262. attrs: {
  263. label: "修正",
  264. type: "primary",
  265. text: true,
  266. },
  267. el: "button",
  268. click() {
  269. getDtl(row);
  270. },
  271. }
  272. : {},
  273. ];
  274. },
  275. },
  276. ];
  277. });
  278. const getDict = () => {
  279. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  280. if (res.rows && res.rows.length > 0) {
  281. warehouseList.value = res.rows.map((item) => {
  282. return {
  283. label: item.name,
  284. value: item.id,
  285. };
  286. });
  287. }
  288. });
  289. proxy.getDictOne(["unit"]).then((res) => {
  290. productUnit.value = res["unit"].map((x) => ({
  291. label: x.dictValue,
  292. value: x.dictKey,
  293. }));
  294. });
  295. };
  296. const getList = async (req) => {
  297. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  298. loading.value = true;
  299. proxy
  300. .post("/stockJournalDetails/pageByWdly", sourceList.value.pagination)
  301. .then((res) => {
  302. sourceList.value.data = res.rows;
  303. sourceList.value.pagination.total = res.total;
  304. setTimeout(() => {
  305. loading.value = false;
  306. }, 200);
  307. });
  308. };
  309. getDict();
  310. onMounted(() => {
  311. if (route.query.productId) {
  312. sourceList.value.pagination.productId = route.query.productId;
  313. }
  314. getList();
  315. });
  316. const deriveExcel = () => {
  317. ElMessage({
  318. message: "请稍后",
  319. type: "success",
  320. });
  321. proxy
  322. .postTwo("/stockJournalDetails/exportExcel", sourceList.value.pagination)
  323. .then(
  324. (res) => {
  325. exportData(res, "出入库流水.xlsx");
  326. },
  327. (err) => {
  328. return ElMessage({
  329. message: "请重试",
  330. type: "info",
  331. });
  332. }
  333. );
  334. };
  335. const exportData = (res, name) => {
  336. const content = res;
  337. const blob = new Blob([content], { type: "application/ms-excel" });
  338. const fileName = name;
  339. if ("download" in document.createElement("a")) {
  340. // 非IE下载
  341. const elink = document.createElement("a");
  342. elink.download = fileName;
  343. elink.style.display = "none";
  344. elink.href = URL.createObjectURL(blob);
  345. document.body.appendChild(elink);
  346. elink.click();
  347. URL.revokeObjectURL(elink.href); // 释放URL 对象
  348. document.body.removeChild(elink);
  349. } else {
  350. navigator.msSaveBlob(blob, fileName);
  351. }
  352. };
  353. const dialogVisible = ref(false);
  354. const submitLoading = ref(false);
  355. const formData = reactive({
  356. data: {},
  357. });
  358. const formOption = reactive({
  359. inline: true,
  360. labelWidth: 100,
  361. itemWidth: 100,
  362. rules: [],
  363. });
  364. const byform = ref(null);
  365. const formConfig = reactive([
  366. {
  367. type: "input",
  368. label: "原来数量",
  369. prop: "oldQuantity",
  370. disabled: true,
  371. itemWidth: 50,
  372. },
  373. {
  374. type: "number",
  375. label: "修正数量",
  376. prop: "quantity",
  377. precision: 0,
  378. min: 0,
  379. controls: false,
  380. itemWidth: 50,
  381. },
  382. ]);
  383. const rules = ref({
  384. quantity: [{ required: true, message: "请输入修正数量", trigger: "blur" }],
  385. });
  386. const getDtl = (row) => {
  387. formData.data = {
  388. id: row.id,
  389. oldQuantity: row.quantity || "0",
  390. quantity: null,
  391. };
  392. dialogVisible.value = true;
  393. };
  394. const submitForm = () => {
  395. byform.value.handleSubmit((valid) => {
  396. submitLoading.value = true;
  397. proxy.post("/stockJournalDetails/editQuantity", formData.data).then(
  398. (res) => {
  399. ElMessage({
  400. message: "操作成功",
  401. type: "success",
  402. });
  403. dialogVisible.value = false;
  404. submitLoading.value = false;
  405. getList();
  406. },
  407. (err) => (submitLoading.value = false)
  408. );
  409. });
  410. };
  411. </script>
  412. <style lang="scss" scoped>
  413. .tenant {
  414. padding: 20px;
  415. }
  416. ::v-deep(.el-input-number .el-input__inner) {
  417. text-align: left;
  418. }
  419. </style>