AllocationForm.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <ContainerQuery>
  3. <div slot="left">
  4. <el-dropdown
  5. v-if="$accessCheck($Access.AllocationFormAddAllocate)"
  6. type="primary"
  7. split-button
  8. @click="$router.push('/stock/WarehouseManagement/AddAllocationForm')"
  9. >
  10. 新建调拨
  11. <el-dropdown-menu slot="dropdown">
  12. <el-dropdown-item>
  13. <div class="dropdown-div" @click="getAllAllocate(1)">导出</div>
  14. </el-dropdown-item>
  15. </el-dropdown-menu>
  16. </el-dropdown>
  17. </div>
  18. <div v-if="$accessCheck($Access.AllocationFormSearchAllocate)" slot="more">
  19. <el-form :inline="true" size="small">
  20. <el-form-item>
  21. <el-input
  22. v-model="search_form.keyword"
  23. placeholder="调拨单号/商品名称"
  24. style="width: 220px"
  25. clearable
  26. @keyup.enter.native="pageChange(1)"
  27. @clear="pageChange(1)"
  28. >
  29. <el-button
  30. slot="append"
  31. icon="el-icon-search"
  32. @click="pageChange(1)"
  33. ></el-button>
  34. </el-input>
  35. </el-form-item>
  36. <el-form-item>
  37. <el-select
  38. v-model="search_form.inStatus"
  39. placeholder="调入仓库"
  40. clearable
  41. style="width: 150px"
  42. @change="pageChange(1)"
  43. >
  44. <el-option
  45. v-for="item in outWare"
  46. :key="item.id"
  47. :label="item.warehouseName"
  48. :value="item.id"
  49. ></el-option>
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item>
  53. <el-select
  54. v-model="search_form.outStatus"
  55. placeholder="调出仓库"
  56. clearable
  57. style="width: 150px"
  58. @change="pageChange(1)"
  59. >
  60. <el-option
  61. v-for="item in outWare"
  62. :key="item.id"
  63. :label="item.warehouseName"
  64. :value="item.id"
  65. ></el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item>
  69. <el-select
  70. v-model="search_form.status"
  71. clearable
  72. style="width: 150px"
  73. placeholder="审核状态"
  74. @change="pageChange(1)"
  75. >
  76. <el-option
  77. v-for="item in order_status"
  78. :key="item.value"
  79. :label="item.label"
  80. :value="item.value"
  81. ></el-option>
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item>
  85. <el-date-picker
  86. v-model="search_form.time"
  87. clearable
  88. type="daterange"
  89. value-format="timestamp"
  90. range-separator="-"
  91. start-placeholder="调拨开始日期"
  92. end-placeholder="调拨结束日期"
  93. @change="LocationFrom"
  94. ></el-date-picker>
  95. </el-form-item>
  96. </el-form>
  97. </div>
  98. <!-- 表格 -->
  99. <el-table
  100. border
  101. :data="stock_list"
  102. :span-method="objectSpanMethod"
  103. @row-dblclick="goDetail"
  104. >
  105. <el-table-column
  106. prop="id"
  107. align="left"
  108. label="ID"
  109. min-width="50"
  110. ></el-table-column>
  111. <el-table-column prop="no" align="left" label="单号" min-width="200">
  112. <template slot-scope="scope">
  113. <span
  114. v-if="$accessCheck($Access.AllocationFormGetAllocateInfo)"
  115. class="click-div"
  116. @click="goDetail(scope.row)"
  117. >
  118. {{ scope.row.no }}
  119. </span>
  120. <span v-else>{{ scope.row.no }}</span>
  121. </template>
  122. </el-table-column>
  123. <el-table-column
  124. prop="materielCode"
  125. align="left"
  126. label="商品编码"
  127. min-width="140"
  128. ></el-table-column>
  129. <el-table-column
  130. prop="materielName"
  131. label="商品名称"
  132. align="left"
  133. min-width="160"
  134. ></el-table-column>
  135. <el-table-column
  136. v-if="unitFlag"
  137. prop="unitName"
  138. label="规格"
  139. min-width="80"
  140. >
  141. <template slot-scope="scope">
  142. {{ scope.row.unitName }};{{ scope.row.skuName }}
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. v-if="batchFlag"
  147. align="left"
  148. label="批次"
  149. min-width="160"
  150. >
  151. <template slot-scope="scope">
  152. <el-popover
  153. v-if="scope.row.batch && scope.row.batch.length > 0"
  154. placement="right"
  155. width="500"
  156. trigger="hover"
  157. >
  158. <el-table border :data="scope.row.batch">
  159. <el-table-column
  160. property="batchNo"
  161. label="批次"
  162. ></el-table-column>
  163. <el-table-column
  164. property="num"
  165. label="批次可用库存"
  166. ></el-table-column>
  167. </el-table>
  168. <el-button slot="reference" size="mini">查看</el-button>
  169. </el-popover>
  170. <span v-else>--</span>
  171. </template>
  172. </el-table-column>
  173. <el-table-column
  174. v-if="calloutFlag"
  175. prop="warehouseName"
  176. align="left"
  177. label="调出仓库"
  178. min-width="140"
  179. :show-overflow-tooltip="true"
  180. ></el-table-column>
  181. <el-table-column
  182. v-if="foldFlag"
  183. prop="inWarehouseName"
  184. align="left"
  185. label="调入仓库"
  186. min-width="140"
  187. ></el-table-column>
  188. <el-table-column
  189. v-if="quantityFlag"
  190. prop="num"
  191. align="left"
  192. label="数量"
  193. min-width="80"
  194. >
  195. <template slot-scope="scope">
  196. {{ $_common.formatNub(scope.row.num) }}
  197. </template>
  198. </el-table-column>
  199. <el-table-column
  200. v-if="unitPriceFlag"
  201. prop="costUnitPrice"
  202. align="left"
  203. label="单价"
  204. min-width="80"
  205. >
  206. <template slot-scope="scope">
  207. {{ $_common.formattedNumber(scope.row.costUnitPrice) }}
  208. </template>
  209. </el-table-column>
  210. <el-table-column
  211. v-if="moneyFlag"
  212. prop="costUnitPrice"
  213. align="left"
  214. label="金额"
  215. min-width="100"
  216. >
  217. <template slot-scope="scope">
  218. {{ $NP.times(scope.row.costUnitPrice, scope.row.num) }}
  219. </template>
  220. </el-table-column>
  221. <el-table-column
  222. v-if="operationFlag"
  223. prop="operatorName"
  224. align="left"
  225. label="操作人"
  226. min-width="120"
  227. ></el-table-column>
  228. <el-table-column
  229. v-if="auditStatusFlag"
  230. prop="auditId"
  231. align="left"
  232. label="审核状态"
  233. min-width="100"
  234. >
  235. <template slot-scope="scope">
  236. <span v-if="scope.row.auditStatus === 1" class="info-status">
  237. 待审核
  238. </span>
  239. <span v-if="scope.row.auditStatus === 2" class="success-status">
  240. 已审核
  241. </span>
  242. </template>
  243. </el-table-column>
  244. <el-table-column
  245. header-align="left"
  246. align="left"
  247. fixed="right"
  248. label="操作"
  249. min-width="160"
  250. >
  251. <template slot="header" slot-scope="scope">
  252. <span v-if="false">{{ scope.$index }}</span>
  253. <span class="operation">操作</span>
  254. <el-popover popper-class="custom-table-checkbox" trigger="click">
  255. <el-checkbox-group v-model="checkList">
  256. <el-checkbox
  257. v-for="(item, index) in columns"
  258. :key="index"
  259. :label="item.label"
  260. @change="change"
  261. ></el-checkbox>
  262. </el-checkbox-group>
  263. <el-button
  264. slot="reference"
  265. icon="el-icon-setting"
  266. type="text"
  267. ></el-button>
  268. </el-popover>
  269. </template>
  270. <template slot-scope="scope">
  271. <el-button
  272. v-if="$accessCheck($Access.AllocationFormAuditAllocate)"
  273. :disabled="parseInt(scope.row.auditStatus) === 2"
  274. type="text"
  275. @click="updateAuditStatus(scope.row)"
  276. >
  277. 审核
  278. </el-button>
  279. <el-button
  280. v-if="$accessCheck($Access.AllocationFormUpdateAllocate)"
  281. type="text"
  282. :disabled="parseInt(scope.row.auditStatus) === 2"
  283. @click="
  284. $router.push(
  285. `/stock/WarehouseManagement/EditAllocationForm/${scope.row.id}`
  286. )
  287. "
  288. >
  289. 编辑
  290. </el-button>
  291. <el-button
  292. v-if="$accessCheck($Access.AllocationFormDeleteAllocate)"
  293. :disabled="parseInt(scope.row.auditStatus) === 2"
  294. type="text"
  295. @click="delData(scope.row.id)"
  296. >
  297. 删除
  298. </el-button>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. <FooterPage
  303. :page-size="pre_page"
  304. :total-page.sync="total"
  305. :current-page.sync="page"
  306. @pageChange="pageChange"
  307. @sizeChange="sizeChange"
  308. ></FooterPage>
  309. </ContainerQuery>
  310. </template>
  311. <script>
  312. import {
  313. getAllWarehouse,
  314. getAllAllocate,
  315. searchAllocate,
  316. auditAllocate,
  317. deleteAllocate,
  318. exportgetAllAllocate,
  319. exportgetInventoryByWarehouseId,
  320. getInventoryByWarehouseId,
  321. } from "@/api/Stock";
  322. export default {
  323. name: "AllocationForm",
  324. data() {
  325. return {
  326. spanArr: [],
  327. pos: 0,
  328. outWare: [],
  329. search_form: {
  330. keyword: "",
  331. status: "", // 审核状态
  332. inStatus: "", // 调入仓库
  333. outStatus: "", // 出库
  334. singlestatus: "", // 单据状态
  335. start: "",
  336. end: "",
  337. },
  338. order_status: [
  339. {
  340. value: 1,
  341. label: "待审核",
  342. },
  343. { value: 2, label: "已审核" },
  344. ],
  345. single_status: [
  346. { value: 1, label: "暂存" },
  347. { value: 2, label: "未出库" },
  348. { value: 3, label: "已出库" },
  349. { value: 4, label: "已完成" },
  350. ],
  351. stock_status: "",
  352. search_key: "",
  353. stock_list: [],
  354. page: 1,
  355. pre_page: 10,
  356. total: 0,
  357. checkList: [
  358. "规格",
  359. "调出仓库",
  360. "调入仓库",
  361. "数量",
  362. "单价",
  363. "金额",
  364. "操作人",
  365. "审核状态",
  366. ],
  367. columns: [
  368. {
  369. label: "规格",
  370. },
  371. {
  372. label: "批次",
  373. },
  374. {
  375. label: "调出仓库",
  376. },
  377. {
  378. label: "调入仓库",
  379. },
  380. {
  381. label: "数量",
  382. },
  383. {
  384. label: "单价",
  385. },
  386. {
  387. label: "金额",
  388. },
  389. {
  390. label: "操作人",
  391. },
  392. {
  393. label: "审核状态",
  394. },
  395. ],
  396. unitFlag: true,
  397. batchFlag: false,
  398. calloutFlag: true,
  399. foldFlag: true,
  400. quantityFlag: true,
  401. unitPriceFlag: true,
  402. moneyFlag: true,
  403. operationFlag: true,
  404. auditStatusFlag: true,
  405. amount: "",
  406. count: 1,
  407. };
  408. },
  409. created() {
  410. this.getAllAllocate();
  411. this.getAllWarehouse();
  412. },
  413. activated() {
  414. if (this.$_isInit()) return;
  415. this.getData();
  416. },
  417. methods: {
  418. // 获取时间
  419. LocationFrom(val) {
  420. if (val && val.length) {
  421. this.search_form.start = val[0] / 1000;
  422. this.search_form.end = val[1] / 1000 + 86399;
  423. } else {
  424. this.search_form.start = "";
  425. this.search_form.end = "";
  426. }
  427. this.pageChange(1);
  428. },
  429. // 请求仓库列表
  430. async getAllWarehouse() {
  431. const data = await getAllWarehouse({
  432. page: 1,
  433. pageSize: 999,
  434. });
  435. this.outWare = data.data;
  436. // this.search_form.inStatus = data.data[0].id
  437. // this.search_form.outStatus = data.data[0].id
  438. },
  439. // 仓库调拨列表
  440. async getAllAllocate(exports) {
  441. let params = {
  442. page: this.page,
  443. pageSize: this.pre_page,
  444. };
  445. if (exports) {
  446. params.export = 1;
  447. const target = await exportgetAllAllocate({
  448. ...params,
  449. });
  450. } else {
  451. const res = await getAllAllocate({
  452. ...params,
  453. });
  454. this.stock_list = res.data;
  455. this.total = res.pageTotal;
  456. // this.amount = res.amount;
  457. // this.count = res.count;
  458. }
  459. // 合并单元格
  460. const getSpanArr = this.$_common.getSpanArr(this.stock_list, "no");
  461. this.spanArr = getSpanArr.spanArr;
  462. this.pos = getSpanArr.pos;
  463. },
  464. // 调拨搜索
  465. async searchAllocate() {
  466. const { data, pageTotal } = await searchAllocate({
  467. warehouseId: this.search_form.outStatus,
  468. inWarehouseId: this.search_form.inStatus,
  469. auditStatus: this.search_form.status,
  470. start: this.search_form.start,
  471. end: this.search_form.end,
  472. search: this.search_form.keyword,
  473. page: this.page,
  474. pageSize: this.pre_page,
  475. });
  476. this.stock_list = data;
  477. this.total = pageTotal;
  478. // 合并单元格
  479. const getSpanArr = this.$_common.getSpanArr(this.stock_list, "no");
  480. this.spanArr = getSpanArr.spanArr;
  481. this.pos = getSpanArr.pos;
  482. },
  483. // 判断
  484. getData() {
  485. const isKey = this.$_common.isSerch(this.search_form);
  486. if (isKey) {
  487. this.searchAllocate();
  488. } else {
  489. this.getAllAllocate();
  490. }
  491. },
  492. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  493. if (
  494. [
  495. "ID",
  496. "单号",
  497. "调出仓库",
  498. "调入仓库",
  499. "操作人",
  500. "审核状态",
  501. "操作",
  502. ].includes(column.label)
  503. ) {
  504. const _row = this.spanArr[rowIndex];
  505. const _col = _row > 0 ? 1 : 0;
  506. return {
  507. rowspan: _row,
  508. colspan: _col,
  509. };
  510. }
  511. },
  512. /** 分页切换 */
  513. pageChange(page) {
  514. this.page = page;
  515. this.getData();
  516. },
  517. /** 分页切换 */
  518. sizeChange(size) {
  519. this.pre_page = size;
  520. this.pageChange(1);
  521. },
  522. /** 状态筛选 启用或禁用 */
  523. statusChange() {
  524. this.pageChange(1);
  525. },
  526. // 审核
  527. async updateAuditStatus(row) {
  528. this.$confirm("确定要审核通过该单据吗?", "提示", {
  529. confirmButtonText: "确定",
  530. cancelButtonText: "取消",
  531. type: "warning",
  532. }).then(async () => {
  533. const data = await auditAllocate(row.id, {
  534. auditName: this.userName,
  535. });
  536. this.$message({
  537. type: "success",
  538. message: "审核成功",
  539. });
  540. this.getAllAllocate();
  541. });
  542. },
  543. delData(id) {
  544. this.$confirm("确定要删除该单据吗?", "提示", {
  545. confirmButtonText: "确定",
  546. cancelButtonText: "取消",
  547. type: "warning",
  548. }).then(async () => {
  549. const data = await deleteAllocate(id);
  550. this.$message({
  551. type: "success",
  552. message: "删除成功!",
  553. });
  554. this.getAllAllocate();
  555. });
  556. },
  557. goDetail(row) {
  558. if (!this.$accessCheck(this.$Access.AllocationFormGetAllocateInfo)) {
  559. return;
  560. }
  561. this.$router.push({
  562. path: `/stock/WarehouseManagement/DetailAllocationForm/${row.id}`,
  563. });
  564. },
  565. change() {
  566. this.unitFlag = this.checkList.some((item) => item === "规格");
  567. this.batchFlag = this.checkList.some((item) => item === "批次");
  568. this.calloutFlag = this.checkList.some((item) => item === "调出仓库");
  569. this.foldFlag = this.checkList.some((item) => item === "调入仓库");
  570. this.quantityFlag = this.checkList.some((item) => item === "数量");
  571. this.unitPriceFlag = this.checkList.some((item) => item === "单价");
  572. this.moneyFlag = this.checkList.some((item) => item === "金额");
  573. this.operationFlag = this.checkList.some((item) => item === "操作人");
  574. this.auditStatusFlag = this.checkList.some(
  575. (item) => item === "审核状态"
  576. );
  577. },
  578. },
  579. };
  580. </script>
  581. <style scoped lang="scss">
  582. .goods-img-div {
  583. background-color: #f4f4f4;
  584. width: 60px;
  585. height: 60px;
  586. margin-right: 10px;
  587. }
  588. .goods-img {
  589. width: 100%;
  590. height: 100%;
  591. object-fit: cover;
  592. }
  593. .goods-info {
  594. width: calc(100% - 84px);
  595. }
  596. .custom-table-checkbox {
  597. .el-checkbox {
  598. display: block !important;
  599. margin: 0 0 $base-padding/4 0;
  600. }
  601. }
  602. </style>