index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. <template>
  2. <div class="app-container">
  3. <basic-container>
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList">
  8. <template slot="menuLeft">
  9. <div style="display:flex;align-items: center;">
  10. <el-tabs v-model="activeName" @tab-click="tabsHandle">
  11. <el-tab-pane label="出库" name="outStock"></el-tab-pane>
  12. <el-tab-pane label="在库" name="inStock"></el-tab-pane>
  13. </el-tabs>
  14. <div style="margin-left: 20px">
  15. <el-button
  16. type="warning"
  17. icon="el-icon-download"
  18. size="mini"
  19. @click="handleExport"
  20. >导出</el-button>
  21. </div>
  22. </div>
  23. </template>
  24. </avue-crud>
  25. </basic-container>
  26. <el-form
  27. :model="queryParams"
  28. ref="queryForm"
  29. v-show="showSearch"
  30. label-width="70px"
  31. size="small"
  32. >
  33. <el-row>
  34. <el-col :xs="12" :sm="6">
  35. <el-form-item label="客户名称">
  36. <el-select
  37. v-model="queryParams.corpid"
  38. clearable
  39. filterable
  40. placeholder="请输入客户名称"
  41. >
  42. <el-option
  43. v-for="(item, index) in mblnoOptions"
  44. :key="index.id"
  45. :label="item.name"
  46. :value="item.id"
  47. ></el-option>
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :xs="12" :sm="6">
  52. <el-form-item label="提单号">
  53. <el-input
  54. v-model="queryParams.mblno"
  55. placeholder="请输入提单号"
  56. clearable
  57. style="width: 200px"
  58. />
  59. </el-form-item>
  60. </el-col>
  61. <el-col :xs="12" :sm="6">
  62. <el-form-item label="仓库">
  63. <el-select v-model="queryParams.warehouseid" placeholder="请选择仓库库区" clearable filterable>
  64. <el-option
  65. v-for="(item, index) in warehouseOptions"
  66. :key="index.id"
  67. :label="item.name"
  68. :value="item.id"
  69. ></el-option>
  70. </el-select>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :xs="12" :sm="6">
  74. <el-form-item label="库管员">
  75. <el-select
  76. v-model="queryParams.storekeeper"
  77. filterable
  78. clearable
  79. placeholder="请选择库管员"
  80. >
  81. <el-option
  82. v-for="(item, index) in userOptions"
  83. :key="index.userName"
  84. :label="item.nickName"
  85. :value="item.userName"
  86. ></el-option>
  87. </el-select>
  88. </el-form-item>
  89. </el-col>
  90. </el-row>
  91. <el-row v-show="show">
  92. <el-col :xs="12" :sm="6">
  93. <el-form-item label="截止日期">
  94. <el-date-picker
  95. v-model="queryParams.bsdate"
  96. type="date"
  97. value-format="yyyy-MM-dd"
  98. clearable
  99. style="width: 200px"
  100. placeholder="选择日期"
  101. ></el-date-picker>
  102. </el-form-item>
  103. </el-col>
  104. </el-row>
  105. <!-- 列设置-->
  106. <el-dialog title="提示" :visible.sync="showSetting" width="700px" v-dialogDrag append-to-body>
  107. <template slot="title">
  108. <div class="avue-crud__dialog__header">
  109. <span class="el-dialog__title">
  110. <span
  111. style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
  112. </span>
  113. </div>
  114. </template>
  115. <div>配置排序列数据(拖动调整顺序)</div>
  116. <div style="margin-left: 17px">
  117. <el-checkbox
  118. v-model="allCheck"
  119. label="全选"
  120. @change="allChecked"
  121. ></el-checkbox>
  122. </div>
  123. <div style="padding: 4px; display: flex; justify-content: center">
  124. <draggable
  125. v-model="setRowList"
  126. group="site"
  127. animation="300"
  128. @start="onStart"
  129. @end="onEnd"
  130. handle=".indraggable"
  131. >
  132. <transition-group>
  133. <div
  134. v-for="item in setRowList"
  135. :key="item.surface"
  136. class="listStyle"
  137. >
  138. <div style="width: 500px" class="indraggable">
  139. <div class="progress" :style="{ width: item.width + 'px' }">
  140. <el-checkbox
  141. :label="item.name"
  142. v-model="item.checked"
  143. :true-label="0"
  144. :false-label="1"
  145. >{{ item.name }}
  146. </el-checkbox>
  147. </div>
  148. </div>
  149. <el-input-number
  150. v-model.number="item.width"
  151. controls-position="right"
  152. :min="1"
  153. :max="500"
  154. size="mini"
  155. ></el-input-number>
  156. </div>
  157. </transition-group>
  158. </draggable>
  159. </div>
  160. <span slot="footer" class="dialog-footer">
  161. <el-button @click="showSetting = false">取 消</el-button>
  162. <el-button @click="delRow" type="danger">重 置</el-button>
  163. <el-button type="primary" @click="save()">确 定</el-button>
  164. </span>
  165. </el-dialog>
  166. <el-row :gutter="10" style="padding-bottom: 10px">
  167. <el-col :span="1.5">
  168. <el-button
  169. type="warning"
  170. icon="el-icon-download"
  171. size="mini"
  172. @click="handleExport"
  173. >导出</el-button>
  174. </el-col>
  175. <div class="tabSetting">
  176. <div style="margin-right: 20px">
  177. <el-button
  178. type="cyan"
  179. icon="el-icon-search"
  180. size="mini"
  181. @click="handleQuery"
  182. >搜索</el-button
  183. >
  184. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  185. >重置</el-button
  186. >
  187. <el-button
  188. v-show="show"
  189. @click="show = !show"
  190. icon="el-icon-arrow-up"
  191. size="mini"
  192. style="border: 1px dashed #dedddd"
  193. >展开</el-button
  194. >
  195. <el-button
  196. v-show="!show"
  197. @click="show = !show"
  198. icon="el-icon-arrow-down"
  199. size="mini"
  200. style="border: 1px dashed #dedddd"
  201. >展开</el-button
  202. >
  203. <right-toolbar
  204. :showSearch.sync="showSearch"
  205. @queryTable="getList"
  206. ></right-toolbar>
  207. <div style="margin: 0 12px;float: right">
  208. <el-button
  209. icon="el-icon-setting"
  210. size="mini"
  211. circle
  212. @click="showSetting = !showSetting"
  213. ></el-button>
  214. </div>
  215. </div>
  216. </div>
  217. </el-row>
  218. </el-form>
  219. <el-tabs v-model="activeName" @tab-click="tabsHandle">
  220. <el-tab-pane label="出库" name="outStock"></el-tab-pane>
  221. <el-tab-pane label="在库" name="inStock"></el-tab-pane>
  222. </el-tabs>
  223. <el-table
  224. ref="table"
  225. v-loading="loading"
  226. :data="dataList"
  227. show-summary
  228. :summary-method="getSum"
  229. :height="tableHeight"
  230. stripe
  231. >
  232. <el-table-column
  233. type="index"
  234. label="行号"
  235. align="center"
  236. fixed
  237. />
  238. <el-table-column
  239. v-for="(item, index) in getRowList"
  240. :key="index"
  241. :label="item.name"
  242. :width="item.width"
  243. :prop="item.label"
  244. align="center"
  245. :fixed="item.fixed"
  246. :show-overflow-tooltip="true"
  247. sortable
  248. v-if="item.show"
  249. >
  250. <template slot-scope="scope">
  251. <span v-if="item.label == 'bsdate'">
  252. {{ scope.row.bsdate | bsdateFormat }}
  253. </span>
  254. <span v-else-if="item.label == 'mblno'">
  255. <el-link :underline="false" type="primary" v-if="activeName == 'outStock'">
  256. <span @click="jumpPage(scope.row)">{{ scope.row.mblno }}</span>
  257. </el-link>
  258. <span v-else>{{ scope.row.mblno }}</span>
  259. </span>
  260. <span v-else-if="item.label == 'billtype'">
  261. {{ scope.row.billtype | billTypeFormat(billTypeList) }}
  262. </span>
  263. <span v-else-if="item.label == 'corpid'">
  264. {{ scope.row.corpid | mblnoFormat(mblnoOptions) }}
  265. </span>
  266. <span v-else>{{ scope.row[item.label] }}</span>
  267. </template>
  268. </el-table-column>
  269. </el-table>
  270. <pagination
  271. v-show="total > 0"
  272. :total="total"
  273. :page.sync="queryParams.pageNum"
  274. :limit.sync="queryParams.pageSize"
  275. @pagination="getList"
  276. />
  277. </div>
  278. </template>
  279. <script>
  280. // import { listCorps } from "@/api/basicdata/corps";
  281. // import { listWarehousesss } from "@/api/basicdata/warehouse";
  282. // import { queryClerkRoleList } from "@/api/warehouseBusiness/warehouseInStock";
  283. // import { getList, exportData } from "@/api/warehouseBusiness/warehouseAnalysis";
  284. import Cookies from "js-cookie";
  285. // import {addSet, resetModule, select} from '@/api/system/set';
  286. import draggable from "vuedraggable";
  287. export default {
  288. name: "index",
  289. components: {
  290. draggable
  291. },
  292. data() {
  293. return {
  294. loading: false,
  295. queryParams: {
  296. pageNum: 1,
  297. pageSize: 10,
  298. },
  299. total: 0,
  300. dataList: [],
  301. tableHeight: '300',
  302. // 显示搜索条件
  303. showSearch: true,
  304. mblnoOptions: [], //客户
  305. warehouseOptions: [], //仓库
  306. userOptions: [],
  307. billTypeList: [],
  308. activeName: 'outStock',
  309. disabledName: 'outStock',
  310. show: false,
  311. // 设置列开关
  312. showSetting: false,
  313. setRowList: [],
  314. getRowList: [],
  315. //自定义列宽
  316. allCheck: false,
  317. drag: false,
  318. option:{
  319. border: true,
  320. align: 'center',
  321. stripe: true,
  322. index: true,
  323. menu: false,
  324. addBtn: false,
  325. editBtn: false,
  326. delBtn: false,
  327. height: "auto",
  328. searchSpan: 8,
  329. searchIcon: true,
  330. searchIndex: 2,
  331. highlightCurrentRow: true,
  332. column:[
  333. {
  334. index: "1",
  335. prop: "billtype",
  336. label: "业务类型",
  337. width: 100,
  338. },
  339. {
  340. index: "2",
  341. prop: "corpid",
  342. label: "客户名称",
  343. width: 120,
  344. search: true,
  345. type:'select',
  346. },
  347. {
  348. index: "2",
  349. prop: "name",
  350. label: "品名",
  351. width: 100,
  352. },
  353. {
  354. index: "3",
  355. prop: "mblno",
  356. label: "提单号",
  357. width: 130,
  358. search: true,
  359. },
  360. {
  361. index: "4",
  362. prop: "qty",
  363. label: "件数",
  364. width: 80,
  365. },
  366. {
  367. index: "5",
  368. prop: "grossweight",
  369. label: "毛重",
  370. width: 120,
  371. },
  372. {
  373. index: "6",
  374. prop: "warehouseInformation",
  375. label: "仓库",
  376. width: 150,
  377. search: true,
  378. type:'select',
  379. },
  380. {
  381. index: "7",
  382. prop: "originalbilldate",
  383. label: "入库日期",
  384. width: 150,
  385. },
  386. {
  387. index: "8",
  388. prop: "bsDate",
  389. label: "出库日期",
  390. width: 150,
  391. search: true,
  392. type: "date",
  393. format:'yyyy-MM-dd',
  394. valueFormat:'yyyy-MM-dd',
  395. },
  396. {
  397. index: "9",
  398. prop: "storekeeper",
  399. label: "仓管员",
  400. width: 150,
  401. search: true,
  402. type:'select',
  403. },
  404. {
  405. index: "10",
  406. prop: "createBy",
  407. label: "制单人",
  408. width: 150,
  409. },
  410. {
  411. index: "11",
  412. prop: "createTime",
  413. label: "制单日期",
  414. width: 150,
  415. },
  416. ]
  417. },
  418. tableDate:[
  419. {
  420. surface: "1",
  421. label: "billtype",
  422. name: "业务类型",
  423. checked: 0,
  424. width: 100,
  425. show: true,
  426. },
  427. {
  428. surface: "2",
  429. label: "corpid",
  430. name: "客户名称",
  431. checked: 0,
  432. width: 120,
  433. show: true,
  434. },
  435. {
  436. surface: "2",
  437. label: "name",
  438. name: "品名",
  439. checked: 0,
  440. width: 100,
  441. show: true,
  442. },
  443. {
  444. surface: "3",
  445. label: "mblno",
  446. name: "提单号",
  447. checked: 0,
  448. width: 130,
  449. show: true,
  450. },
  451. {
  452. surface: "4",
  453. label: "qty",
  454. name: "件数",
  455. checked: 0,
  456. width: 80,
  457. show: true,
  458. },
  459. {
  460. surface: "5",
  461. label: "grossweight",
  462. name: "毛重",
  463. checked: 0,
  464. width: 120,
  465. show: true,
  466. },
  467. {
  468. surface: "6",
  469. label: "warehouseInformation",
  470. name: "仓库",
  471. checked: 0,
  472. width: 150,
  473. show: true,
  474. },
  475. {
  476. surface: "7",
  477. label: "originalbilldate",
  478. name: "入库日期",
  479. checked: 0,
  480. width: 150,
  481. show: true,
  482. },
  483. {
  484. surface: "8",
  485. label: "bsdate",
  486. name: "出库日期",
  487. checked: 0,
  488. width: 150,
  489. show: true,
  490. },
  491. {
  492. surface: "9",
  493. label: "storekeeper",
  494. name: "仓管员",
  495. checked: 0,
  496. width: 150,
  497. show: true,
  498. },
  499. {
  500. surface: "10",
  501. label: "createBy",
  502. name: "制单人",
  503. checked: 0,
  504. width: 150,
  505. show: true,
  506. },
  507. {
  508. surface: "11",
  509. label: "createTime",
  510. name: "制单日期",
  511. checked: 0,
  512. width: 150,
  513. show: true,
  514. },
  515. ],
  516. }
  517. },
  518. created() {
  519. this.setRowList = this.tableDate;
  520. this.getRowList = this.tableDate;
  521. let i = 0;
  522. this.option.column.forEach(item => {
  523. if (item.search) i++
  524. })
  525. if (i % 3 !== 0) {
  526. const num = 3 - Number(i % 3)
  527. this.option.searchMenuSpan = num * 8;
  528. this.option.searchMenuPosition = "right";
  529. }
  530. this.getDicts("data_billtype_type").then((response) => {
  531. this.billTypeList = response.data;
  532. });
  533. listCorps({ type: 1 }).then((response) => {
  534. this.mblnoOptions = response.rows;
  535. });
  536. listWarehousesss({status: 0, delFlag: 0}).then((response) => {
  537. this.warehouseOptions = response.rows;
  538. });
  539. queryClerkRoleList().then((response) => {
  540. this.userOptions = response.data;
  541. });
  542. this.getList();
  543. this.getRow();
  544. },
  545. mounted() {
  546. this.$nextTick(() => {
  547. // 监听浏览器高度变化,改变表格高度
  548. window.onresize = () => {
  549. this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 85
  550. }
  551. })
  552. },
  553. filters: {
  554. bsdateFormat(row) {
  555. if (row) {
  556. const dateMat = new Date(row);
  557. const year = dateMat.getFullYear();
  558. const month = dateMat.getMonth() + 1;
  559. const day = dateMat.getDate();
  560. const timeFormat = year + "-" + month + "-" + day;
  561. return timeFormat;
  562. }
  563. },
  564. billTypeFormat(row, billTypeList) {
  565. let type;
  566. billTypeList.map((e) => {
  567. if (row == e.dictValue) {
  568. type = e.dictLabel;
  569. }
  570. });
  571. return type;
  572. },
  573. mblnoFormat(row, mblnoOptions) {
  574. let name;
  575. mblnoOptions.map((e) => {
  576. if (row == e.id) {
  577. name = e.name;
  578. }
  579. });
  580. return name;
  581. },
  582. },
  583. methods: {
  584. getList() {
  585. const data = {
  586. type: 2, // 1入 2出
  587. ...this.queryParams
  588. }
  589. if (this.activeName == 'outStock') {
  590. data.type = 2;
  591. } else {
  592. data.type = 1;
  593. }
  594. this.loading = true
  595. getList(data).then(res => {
  596. this.dataList = res.rows
  597. this.total = res.total;
  598. }).finally(() => {
  599. this.loading = false
  600. })
  601. setTimeout(() => {
  602. this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 85
  603. }, 300)
  604. },
  605. // 搜索
  606. handleQuery() {
  607. this.queryParams.pageNum = 1;
  608. this.queryParams.pageSize = 10;
  609. this.getList();
  610. },
  611. /** 重置按钮操作 */
  612. resetQuery() {
  613. this.queryParams = {
  614. pageNum: 1,
  615. pageSize: 10,
  616. }
  617. this.resetForm("queryForm");
  618. this.handleQuery();
  619. },
  620. //导出
  621. handleExport() {
  622. const type = this.activeName == 'outStock'? 2: 1
  623. const query = {...this.queryParams, type}
  624. this.$confirm(type == 2?"是否确认导出出库数据项?": "是否确认导出在库数据项?", "提示", {
  625. confirmButtonText: "确定",
  626. cancelButtonText: "取消",
  627. type: "warning",
  628. }).then(() => {
  629. return exportData(query)
  630. }).then(res => {
  631. this.download(res.msg);
  632. })
  633. },
  634. //合计
  635. getSum(param) {
  636. const { columns, data } = param;
  637. const sums = [];
  638. var values = [];
  639. columns.forEach((column, index) => {
  640. if (index === 0) {
  641. sums[index] = "合计";
  642. return;
  643. }
  644. if (column.property === "grossweight") {
  645. values = data.map((item) => Number(item["grossweight"]));
  646. }
  647. if (column.property === "qty") {
  648. values = data.map((item) => Number(item["qty"]));
  649. }
  650. if (
  651. column.property === "grossweight" ||
  652. column.property === "qty"
  653. ) {
  654. sums[index] = values.reduce((prev, curr) => {
  655. const value = Number(curr);
  656. if (!isNaN(value)) {
  657. return prev + curr;
  658. } else {
  659. return prev;
  660. }
  661. }, 0);
  662. if (column.property === "grossweight") {
  663. sums[index] = (sums[index] / 1000).toFixed(4) + "(吨)";
  664. }
  665. if (column.property === "qty") {
  666. // sums[index] = sums[index].toFixed(2);
  667. sums[index] = sums[index];
  668. }
  669. }
  670. });
  671. return sums;
  672. },
  673. tabsHandle(data) {
  674. if (this.disabledName == data.name) return
  675. this.disabledName = data.name
  676. if (this.activeName === "inStock"){
  677. this.option.column.forEach(item=>{
  678. if (item.prop === "bsDate"){
  679. item.index = 9999
  680. item.hide = true
  681. item.showColumn = false
  682. }
  683. })
  684. }else {
  685. this.option.column.forEach(item=>{
  686. if (item.prop === "bsDate"){
  687. item.hide = false
  688. item.showColumn = true
  689. item.index = 8
  690. }
  691. })
  692. }
  693. this.tableDate.forEach(item => {
  694. if (this.activeName == 'inStock') {
  695. if (item.label == 'bsdate') {
  696. item.show = false
  697. }
  698. } else {
  699. item.show = true
  700. }
  701. })
  702. this.getList()
  703. this.$nextTick(() => {
  704. this.$refs.table.doLayout()
  705. })
  706. },
  707. jumpPage(row) {
  708. if (this.activeName == 'outStock') {
  709. this.$router.push({
  710. path: "/business/outStock",
  711. query: { id: row.id },
  712. });
  713. }
  714. },
  715. //列设置全选
  716. allChecked() {
  717. if (this.allCheck == true) {
  718. this.setRowList.map((e) => {
  719. return (e.checked = 0);
  720. });
  721. } else {
  722. this.setRowList.map((e) => {
  723. return (e.checked = 1);
  724. });
  725. }
  726. },
  727. //开始拖拽事件
  728. onStart() {
  729. this.drag = true;
  730. },
  731. //拖拽结束事件
  732. onEnd() {
  733. this.drag = false;
  734. },
  735. //重置列表
  736. delRow() {
  737. this.data = {
  738. tableName: "仓储分析列表",
  739. userId: Cookies.get("userName"),
  740. };
  741. resetModule(this.data).then((res) => {
  742. if (res.code == 200) {
  743. this.showSetting = false;
  744. this.setRowList = this.tableDate;
  745. console.log(this.setRowList)
  746. this.getRowList = this.tableDate;
  747. }
  748. });
  749. },
  750. //保存列设置
  751. save() {
  752. this.showSetting = false;
  753. this.data = {
  754. tableName: "仓储分析列表",
  755. userId: Cookies.get("userName"),
  756. sysTableSetList: this.setRowList,
  757. };
  758. addSet(this.data).then((res) => {
  759. this.getRowList = this.setRowList.filter((e) => e.checked == 0);
  760. });
  761. },
  762. //查询列数据
  763. getRow() {
  764. let that = this;
  765. this.data = {
  766. tableName: "仓储分析列表",
  767. userId: Cookies.get("userName"),
  768. };
  769. select(this.data).then((res) => {
  770. if (res.data.length != 0) {
  771. this.getRowList = res.data.filter((e) => e.checked == 0);
  772. this.setRowList = res.data;
  773. this.setRowList = this.setRowList.reduce((res, item) => {
  774. res.push({
  775. surface: item.surface,
  776. label: item.label,
  777. name: item.name,
  778. checked: item.checked,
  779. width: item.width,
  780. fixed: item.fixed,
  781. });
  782. return res;
  783. }, []);
  784. }
  785. });
  786. },
  787. },
  788. }
  789. </script>
  790. <style scoped lang="scss">
  791. /deep/ .el-tabs .el-tabs__content {
  792. overflow-x: visible !important;
  793. }
  794. </style>