index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. ]" @get-list="getList">
  7. <!-- {
  8. text: '导出Excel',
  9. action: () => deriveExcel(),
  10. }, -->
  11. <template #warehouseName="{ item }">
  12. <div>
  13. <!-- <span v-if="item.opType == 1">{{ item.toWarehouseName }}</span>
  14. <span v-else>{{ item.warehouseName }}</span> -->
  15. <span>{{ item.warehouseName }}</span>
  16. </div>
  17. </template>
  18. </byTable>
  19. </div>
  20. <el-dialog title="打印" v-if="openPdf" v-model="openPdf" width="840px">
  21. <div id="pdfDom" ref="pdfDom" style="width: 776px">
  22. <div class="title">
  23. {{ dictValueLabel(printData.type, typeList) }}单
  24. </div>
  25. <div class="flex-top-bottom">
  26. <div>
  27. <span v-show="printData.corporateName && printData.code">
  28. {{ printData.corporateName }} ({{ printData.code }})</span>
  29. </div>
  30. <div>{{ printData.createTime }}</div>
  31. </div>
  32. <table border="1" style="width: 100%" class="table">
  33. <tr>
  34. <td style="width: 80px">物品编码</td>
  35. <td>物品名称</td>
  36. <td>规格型号</td>
  37. <td style="width: 60px">单位</td>
  38. <td style="width: 60px">数量</td>
  39. <td style="width: 70px">单价</td>
  40. <td style="width: 90px">金额</td>
  41. </tr>
  42. <tr v-for="(row, index) in printData.list" :key="row.id">
  43. <td>{{ row.productCode }}</td>
  44. <td>{{ row.productName }}</td>
  45. <td>{{ row.productSpec }}</td>
  46. <td>{{ dictValueLabel(row.productUnit, productUnit) }}</td>
  47. <td>{{ row.quantity }}</td>
  48. <td>
  49. <!-- {{ dictValueLabel(printData.currency, currencyType) }} -->
  50. <span v-show="row.price">
  51. {{ printData.currency }}
  52. {{ row.price }}
  53. </span>
  54. </td>
  55. <td>
  56. <!-- {{ dictValueLabel(printData.currency, currencyType) }} -->
  57. <span v-show="row.amount">
  58. {{ printData.currency }}
  59. {{ row.amount }}
  60. </span>
  61. </td>
  62. </tr>
  63. </table>
  64. <div class="flex-top-bottom">
  65. <div>仓库名称:{{ printData.warehouseName }}</div>
  66. <div>
  67. 合计金额:{{ getTotalAmount(printData.currency, printData.list) }}
  68. </div>
  69. </div>
  70. </div>
  71. <template #footer ref="printBtn">
  72. <el-button @click="openPdf = false" size="large">关闭</el-button>
  73. <el-button type="primary" v-print="printObj" size="large">打印</el-button>
  74. <el-button type="primary" @click="clickDownload()" size="large">下载PDF</el-button>
  75. </template>
  76. </el-dialog>
  77. </div>
  78. </template>
  79. <script setup>
  80. import { computed, nextTick, ref, toRef } from "vue";
  81. import byTable from "@/components/byTable/index";
  82. const { proxy } = getCurrentInstance();
  83. const route = useRoute();
  84. const opTypeList = ref([
  85. {
  86. label: "入库",
  87. value: "1",
  88. },
  89. {
  90. label: "出库",
  91. value: "2",
  92. },
  93. ]);
  94. const typeList = ref([
  95. {
  96. label: "手动入库",
  97. value: "1",
  98. },
  99. {
  100. label: "手动出库",
  101. value: "2",
  102. },
  103. {
  104. label: "调仓入库",
  105. value: "3",
  106. },
  107. {
  108. label: "待入库入库",
  109. value: "4",
  110. },
  111. {
  112. label: "待出库出库",
  113. value: "5",
  114. },
  115. // {
  116. // label: "组合入库",
  117. // value: "6",
  118. // },
  119. // {
  120. // label: "组合出库",
  121. // value: "7",
  122. // },
  123. // {
  124. // label: "组合拆分入库",
  125. // value: "8",
  126. // },
  127. // {
  128. // label: "组合拆分出库",
  129. // value: "9",
  130. // },
  131. // {
  132. // label: "京东销售出库",
  133. // value: "10",
  134. // },
  135. {
  136. label: "调仓出库",
  137. value: "11",
  138. },
  139. {
  140. label: "销售订单出库",
  141. value: "12",
  142. },
  143. {
  144. label: "退货出库",
  145. value: "13",
  146. },
  147. {
  148. label: "到货入库",
  149. value: "14",
  150. },
  151. // {
  152. // label: "京东退货入库",
  153. // value: "15",
  154. // },
  155. {
  156. label: "完工入库",
  157. value: "17",
  158. },
  159. {
  160. label: "采购到货",
  161. value: "18",
  162. },
  163. {
  164. label: "到货质检",
  165. value: "19",
  166. },
  167. {
  168. label: "生产任务出库",
  169. value: "20",
  170. },
  171. {
  172. label: "工单出库",
  173. value: "21",
  174. },
  175. {
  176. label: "库存盘点修正入库",
  177. value: "22",
  178. },
  179. {
  180. label: "库存盘点修正出库",
  181. value: "23",
  182. },
  183. {
  184. label: "销售合同出库",
  185. value: "24",
  186. },
  187. ]);
  188. const warehouseList = ref([]);
  189. const productUnit = ref([]);
  190. const currencyType = ref([]);
  191. const sourceList = ref({
  192. data: [],
  193. pagination: {
  194. total: 0,
  195. pageNum: 1,
  196. pageSize: 10,
  197. keyword: "",
  198. opType: "",
  199. productId: "",
  200. warehouseId: "",
  201. },
  202. });
  203. const loading = ref(false);
  204. const openPdf = ref(false);
  205. let printData = ref({});
  206. const selectConfig = computed(() => {
  207. return [
  208. {
  209. label: "操作类型",
  210. prop: "opType",
  211. data: opTypeList.value,
  212. },
  213. {
  214. label: "出入库类型",
  215. prop: "type",
  216. data: typeList.value,
  217. },
  218. ];
  219. });
  220. const config = computed(() => {
  221. return [
  222. {
  223. attrs: {
  224. label: "操作类型",
  225. prop: "opType",
  226. width: 80,
  227. },
  228. render(type) {
  229. return proxy.dictValueLabel(type, opTypeList.value);
  230. },
  231. },
  232. {
  233. attrs: {
  234. label: "出入库类型",
  235. prop: "type",
  236. width: 130,
  237. },
  238. render(type) {
  239. return proxy.dictValueLabel(type, typeList.value);
  240. },
  241. },
  242. {
  243. attrs: {
  244. label: "工单号",
  245. prop: "workOrderCode",
  246. width: 110,
  247. },
  248. },
  249. {
  250. attrs: {
  251. label: "仓库名称",
  252. slot: "warehouseName",
  253. },
  254. },
  255. {
  256. attrs: {
  257. label: "物品编码",
  258. prop: "productCode",
  259. width: 110,
  260. },
  261. },
  262. {
  263. attrs: {
  264. label: "物品名称",
  265. prop: "productName",
  266. },
  267. },
  268. {
  269. attrs: {
  270. label: "规格型号",
  271. prop: "productSpec",
  272. },
  273. },
  274. {
  275. attrs: {
  276. label: "单位",
  277. prop: "productUnit",
  278. width: 80,
  279. },
  280. render(unit) {
  281. return proxy.dictValueLabel(unit, productUnit.value);
  282. },
  283. },
  284. {
  285. attrs: {
  286. label: "操作数量",
  287. prop: "quantity",
  288. width: 120,
  289. },
  290. },
  291. {
  292. attrs: {
  293. label: "操作人",
  294. prop: "opUserName",
  295. width: 130,
  296. },
  297. },
  298. {
  299. attrs: {
  300. label: "操作时间",
  301. prop: "createTime",
  302. width: 155,
  303. },
  304. },
  305. // {
  306. // attrs: {
  307. // label: "操作",
  308. // width: "80",
  309. // align: "center",
  310. // },
  311. // renderHTML(row) {
  312. // return [
  313. // {
  314. // attrs: {
  315. // label: "打印",
  316. // type: "primary",
  317. // text: true,
  318. // },
  319. // el: "button",
  320. // click() {
  321. // handlePrintPdf(row);
  322. // },
  323. // },
  324. // ];
  325. // },
  326. // },
  327. ];
  328. });
  329. const getDict = () => {
  330. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  331. if (res.rows && res.rows.length > 0) {
  332. warehouseList.value = res.rows.map((item) => {
  333. return {
  334. label: item.name,
  335. value: item.id,
  336. };
  337. });
  338. }
  339. });
  340. proxy.getDictOne(["unit", "account_currency"]).then((res) => {
  341. productUnit.value = res["unit"].map((x) => ({
  342. label: x.dictValue,
  343. value: x.dictKey,
  344. }));
  345. currencyType.value = res["account_currency"].map((x) => ({
  346. label: x.dictValue,
  347. value: x.dictKey,
  348. }));
  349. });
  350. };
  351. const getList = async (req) => {
  352. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  353. loading.value = true;
  354. proxy
  355. .post("/stockJournalDetails/page", sourceList.value.pagination)
  356. .then((res) => {
  357. sourceList.value.data = res.rows;
  358. sourceList.value.pagination.total = res.total;
  359. setTimeout(() => {
  360. loading.value = false;
  361. }, 200);
  362. });
  363. };
  364. getDict();
  365. onMounted(() => {
  366. if (route.query.productId) {
  367. sourceList.value.pagination.productId = route.query.productId;
  368. }
  369. if (route.query.warehouseId) {
  370. sourceList.value.pagination.warehouseId = route.query.warehouseId;
  371. }
  372. getList();
  373. });
  374. const deriveExcel = () => {
  375. console.log("deriveExcel");
  376. };
  377. const handlePrintPdf = (row) => {
  378. proxy.post("/stockJournal/detail", { id: row.stockJournalId }).then((res) => {
  379. printData.value = res;
  380. printData.value.createTime = printData.value.createTime.slice(0, 10);
  381. openPdf.value = true;
  382. });
  383. };
  384. const getTotalAmount = (currency, arr) => {
  385. let total = arr.reduce((total, cur) => (total += cur.amount), 0);
  386. total = total ? total : "";
  387. if (currency && total) {
  388. return currency + " " + proxy.moneyFormat(total, 2);
  389. } else {
  390. return proxy.moneyFormat(total, 2);
  391. }
  392. };
  393. const clickDownload = () => {
  394. proxy.getPdf(
  395. proxy.dictValueLabel(printData.value.type, typeList.value) + "单"
  396. );
  397. };
  398. const pdfDom = ref(null);
  399. const printObj = ref({
  400. id: "pdfDom",
  401. popTitle: "",
  402. extraCss:
  403. "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css",
  404. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  405. });
  406. </script>
  407. <style lang="scss" scoped>
  408. .tenant {
  409. padding: 20px;
  410. }
  411. ::v-deep(.el-input-number .el-input__inner) {
  412. text-align: left;
  413. }
  414. #pdfDom {
  415. font-size: 12px;
  416. color: #000000;
  417. padding: 60px 30px;
  418. .title {
  419. font-size: 16px;
  420. // font-weight: 700;
  421. margin-bottom: 20px;
  422. text-align: center;
  423. }
  424. .table {
  425. border-collapse: collapse;
  426. border-spacing: 0;
  427. td {
  428. text-align: center;
  429. padding: 8px 0px;
  430. }
  431. }
  432. .flex-top-bottom {
  433. display: flex;
  434. justify-content: space-between;
  435. margin: 5px 0px;
  436. }
  437. }
  438. </style>