index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  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.fCorpid"
  38. clearable
  39. filterable
  40. placeholder="请输入客户名称"
  41. >
  42. <el-option
  43. v-for="(item, index) in fMblnoOptions"
  44. :key="index.fId"
  45. :label="item.fName"
  46. :value="item.fId"
  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.fMblno"
  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.fWarehouseid" placeholder="请选择仓库库区" clearable filterable>
  64. <el-option
  65. v-for="(item, index) in warehouseOptions"
  66. :key="index.fId"
  67. :label="item.fName"
  68. :value="item.fId"
  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.fStorekeeper"
  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.fBsdate"
  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 == 'fBsdate'">
  252. {{ scope.row.fBsdate | fBsdateFormat }}
  253. </span>
  254. <span v-else-if="item.label == 'fMblno'">
  255. <el-link :underline="false" type="primary" v-if="activeName == 'outStock'">
  256. <span @click="jumpPage(scope.row)">{{ scope.row.fMblno }}</span>
  257. </el-link>
  258. <span v-else>{{ scope.row.fMblno }}</span>
  259. </span>
  260. <span v-else-if="item.label == 'fBilltype'">
  261. {{ scope.row.fBilltype | billTypeFormat(billTypeList) }}
  262. </span>
  263. <span v-else-if="item.label == 'fCorpid'">
  264. {{ scope.row.fCorpid | fMblnoFormat(fMblnoOptions) }}
  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. fMblnoOptions: [], //客户
  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. align: 'center',
  320. stripe: true,
  321. index: true,
  322. menu: false,
  323. addBtn: false,
  324. editBtn: false,
  325. delBtn: false,
  326. height: "auto",
  327. searchSpan: 8,
  328. searchIcon: true,
  329. searchIndex: 2,
  330. highlightCurrentRow: true,
  331. column:[
  332. {
  333. index: "1",
  334. prop: "billtype",
  335. label: "业务类型",
  336. width: 100,
  337. },
  338. {
  339. index: "2",
  340. prop: "corpid",
  341. label: "客户名称",
  342. width: 120,
  343. search: true,
  344. },
  345. {
  346. index: "2",
  347. prop: "name",
  348. label: "品名",
  349. width: 100,
  350. },
  351. {
  352. index: "3",
  353. prop: "mblno",
  354. label: "提单号",
  355. width: 130,
  356. search: true,
  357. },
  358. {
  359. index: "4",
  360. prop: "qty",
  361. label: "件数",
  362. width: 80,
  363. },
  364. {
  365. index: "5",
  366. prop: "grossweight",
  367. label: "毛重",
  368. width: 120,
  369. },
  370. {
  371. index: "6",
  372. prop: "warehouseInformation",
  373. label: "仓库",
  374. width: 150,
  375. search: true,
  376. },
  377. {
  378. index: "7",
  379. prop: "originalbilldate",
  380. label: "入库日期",
  381. width: 150,
  382. },
  383. {
  384. index: "8",
  385. prop: "bsDate",
  386. label: "出库日期",
  387. width: 150,
  388. search: true,
  389. },
  390. {
  391. index: "9",
  392. prop: "storekeeper",
  393. label: "仓管员",
  394. width: 150,
  395. search: true,
  396. },
  397. {
  398. index: "10",
  399. prop: "createBy",
  400. label: "制单人",
  401. width: 150,
  402. },
  403. {
  404. index: "11",
  405. prop: "createTime",
  406. label: "制单日期",
  407. width: 150,
  408. },
  409. ]
  410. },
  411. tableDate:[
  412. {
  413. surface: "1",
  414. label: "fBilltype",
  415. name: "业务类型",
  416. checked: 0,
  417. width: 100,
  418. show: true,
  419. },
  420. {
  421. surface: "2",
  422. label: "fCorpid",
  423. name: "客户名称",
  424. checked: 0,
  425. width: 120,
  426. show: true,
  427. },
  428. {
  429. surface: "2",
  430. label: "fName",
  431. name: "品名",
  432. checked: 0,
  433. width: 100,
  434. show: true,
  435. },
  436. {
  437. surface: "3",
  438. label: "fMblno",
  439. name: "提单号",
  440. checked: 0,
  441. width: 130,
  442. show: true,
  443. },
  444. {
  445. surface: "4",
  446. label: "fQty",
  447. name: "件数",
  448. checked: 0,
  449. width: 80,
  450. show: true,
  451. },
  452. {
  453. surface: "5",
  454. label: "fGrossweight",
  455. name: "毛重",
  456. checked: 0,
  457. width: 120,
  458. show: true,
  459. },
  460. {
  461. surface: "6",
  462. label: "fWarehouseInformation",
  463. name: "仓库",
  464. checked: 0,
  465. width: 150,
  466. show: true,
  467. },
  468. {
  469. surface: "7",
  470. label: "fOriginalbilldate",
  471. name: "入库日期",
  472. checked: 0,
  473. width: 150,
  474. show: true,
  475. },
  476. {
  477. surface: "8",
  478. label: "fBsdate",
  479. name: "出库日期",
  480. checked: 0,
  481. width: 150,
  482. show: true,
  483. },
  484. {
  485. surface: "9",
  486. label: "fStorekeeper",
  487. name: "仓管员",
  488. checked: 0,
  489. width: 150,
  490. show: true,
  491. },
  492. {
  493. surface: "10",
  494. label: "createBy",
  495. name: "制单人",
  496. checked: 0,
  497. width: 150,
  498. show: true,
  499. },
  500. {
  501. surface: "11",
  502. label: "createTime",
  503. name: "制单日期",
  504. checked: 0,
  505. width: 150,
  506. show: true,
  507. },
  508. ],
  509. }
  510. },
  511. created() {
  512. this.setRowList = this.tableDate;
  513. this.getRowList = this.tableDate;
  514. let i = 0;
  515. this.option.column.forEach(item => {
  516. if (item.search) i++
  517. })
  518. if (i % 3 !== 0) {
  519. const num = 3 - Number(i % 3)
  520. this.option.searchMenuSpan = num * 8;
  521. this.option.searchMenuPosition = "right";
  522. }
  523. this.getDicts("data_billtype_type").then((response) => {
  524. this.billTypeList = response.data;
  525. });
  526. listCorps({ type: 1 }).then((response) => {
  527. this.fMblnoOptions = response.rows;
  528. });
  529. listWarehousesss({fStatus: 0, delFlag: 0}).then((response) => {
  530. this.warehouseOptions = response.rows;
  531. });
  532. queryClerkRoleList().then((response) => {
  533. this.userOptions = response.data;
  534. });
  535. this.getList();
  536. this.getRow();
  537. },
  538. mounted() {
  539. this.$nextTick(() => {
  540. // 监听浏览器高度变化,改变表格高度
  541. window.onresize = () => {
  542. this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 85
  543. }
  544. })
  545. },
  546. filters: {
  547. fBsdateFormat(row) {
  548. if (row) {
  549. const dateMat = new Date(row);
  550. const year = dateMat.getFullYear();
  551. const month = dateMat.getMonth() + 1;
  552. const day = dateMat.getDate();
  553. const timeFormat = year + "-" + month + "-" + day;
  554. return timeFormat;
  555. }
  556. },
  557. billTypeFormat(row, billTypeList) {
  558. let type;
  559. billTypeList.map((e) => {
  560. if (row == e.dictValue) {
  561. type = e.dictLabel;
  562. }
  563. });
  564. return type;
  565. },
  566. fMblnoFormat(row, fMblnoOptions) {
  567. let name;
  568. fMblnoOptions.map((e) => {
  569. if (row == e.fId) {
  570. name = e.fName;
  571. }
  572. });
  573. return name;
  574. },
  575. },
  576. methods: {
  577. getList() {
  578. const data = {
  579. type: 2, // 1入 2出
  580. ...this.queryParams
  581. }
  582. if (this.activeName == 'outStock') {
  583. data.type = 2;
  584. } else {
  585. data.type = 1;
  586. }
  587. this.loading = true
  588. getList(data).then(res => {
  589. this.dataList = res.rows
  590. this.total = res.total;
  591. }).finally(() => {
  592. this.loading = false
  593. })
  594. setTimeout(() => {
  595. this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 85
  596. }, 300)
  597. },
  598. // 搜索
  599. handleQuery() {
  600. this.queryParams.pageNum = 1;
  601. this.queryParams.pageSize = 10;
  602. this.getList();
  603. },
  604. /** 重置按钮操作 */
  605. resetQuery() {
  606. this.queryParams = {
  607. pageNum: 1,
  608. pageSize: 10,
  609. }
  610. this.resetForm("queryForm");
  611. this.handleQuery();
  612. },
  613. //导出
  614. handleExport() {
  615. const type = this.activeName == 'outStock'? 2: 1
  616. const query = {...this.queryParams, type}
  617. this.$confirm(type == 2?"是否确认导出出库数据项?": "是否确认导出在库数据项?", "提示", {
  618. confirmButtonText: "确定",
  619. cancelButtonText: "取消",
  620. type: "warning",
  621. }).then(() => {
  622. return exportData(query)
  623. }).then(res => {
  624. this.download(res.msg);
  625. })
  626. },
  627. //合计
  628. getSum(param) {
  629. const { columns, data } = param;
  630. const sums = [];
  631. var values = [];
  632. columns.forEach((column, index) => {
  633. if (index === 0) {
  634. sums[index] = "合计";
  635. return;
  636. }
  637. if (column.property === "fGrossweight") {
  638. values = data.map((item) => Number(item["fGrossweight"]));
  639. }
  640. if (column.property === "fQty") {
  641. values = data.map((item) => Number(item["fQty"]));
  642. }
  643. if (
  644. column.property === "fGrossweight" ||
  645. column.property === "fQty"
  646. ) {
  647. sums[index] = values.reduce((prev, curr) => {
  648. const value = Number(curr);
  649. if (!isNaN(value)) {
  650. return prev + curr;
  651. } else {
  652. return prev;
  653. }
  654. }, 0);
  655. if (column.property === "fGrossweight") {
  656. sums[index] = (sums[index] / 1000).toFixed(4) + "(吨)";
  657. }
  658. if (column.property === "fQty") {
  659. // sums[index] = sums[index].toFixed(2);
  660. sums[index] = sums[index];
  661. }
  662. }
  663. });
  664. return sums;
  665. },
  666. tabsHandle(data) {
  667. if (this.disabledName == data.name) return
  668. this.disabledName = data.name
  669. if (this.activeName === "inStock"){
  670. this.option.column.forEach(item=>{
  671. if (item.prop === "bsDate"){
  672. item.index = 9999
  673. item.hide = true
  674. item.showColumn = false
  675. }
  676. })
  677. }else {
  678. this.option.column.forEach(item=>{
  679. if (item.prop === "bsDate"){
  680. item.hide = false
  681. item.showColumn = true
  682. item.index = 8
  683. }
  684. })
  685. }
  686. this.tableDate.forEach(item => {
  687. if (this.activeName == 'inStock') {
  688. if (item.label == 'fBsdate') {
  689. item.show = false
  690. }
  691. } else {
  692. item.show = true
  693. }
  694. })
  695. this.getList()
  696. this.$nextTick(() => {
  697. this.$refs.table.doLayout()
  698. })
  699. },
  700. jumpPage(row) {
  701. if (this.activeName == 'outStock') {
  702. this.$router.push({
  703. path: "/business/outStock",
  704. query: { id: row.fId },
  705. });
  706. }
  707. },
  708. //列设置全选
  709. allChecked() {
  710. if (this.allCheck == true) {
  711. this.setRowList.map((e) => {
  712. return (e.checked = 0);
  713. });
  714. } else {
  715. this.setRowList.map((e) => {
  716. return (e.checked = 1);
  717. });
  718. }
  719. },
  720. //开始拖拽事件
  721. onStart() {
  722. this.drag = true;
  723. },
  724. //拖拽结束事件
  725. onEnd() {
  726. this.drag = false;
  727. },
  728. //重置列表
  729. delRow() {
  730. this.data = {
  731. tableName: "仓储分析列表",
  732. userId: Cookies.get("userName"),
  733. };
  734. resetModule(this.data).then((res) => {
  735. if (res.code == 200) {
  736. this.showSetting = false;
  737. this.setRowList = this.tableDate;
  738. console.log(this.setRowList)
  739. this.getRowList = this.tableDate;
  740. }
  741. });
  742. },
  743. //保存列设置
  744. save() {
  745. this.showSetting = false;
  746. this.data = {
  747. tableName: "仓储分析列表",
  748. userId: Cookies.get("userName"),
  749. sysTableSetList: this.setRowList,
  750. };
  751. addSet(this.data).then((res) => {
  752. this.getRowList = this.setRowList.filter((e) => e.checked == 0);
  753. });
  754. },
  755. //查询列数据
  756. getRow() {
  757. let that = this;
  758. this.data = {
  759. tableName: "仓储分析列表",
  760. userId: Cookies.get("userName"),
  761. };
  762. select(this.data).then((res) => {
  763. if (res.data.length != 0) {
  764. this.getRowList = res.data.filter((e) => e.checked == 0);
  765. this.setRowList = res.data;
  766. this.setRowList = this.setRowList.reduce((res, item) => {
  767. res.push({
  768. surface: item.surface,
  769. label: item.label,
  770. name: item.name,
  771. checked: item.checked,
  772. width: item.width,
  773. fixed: item.fixed,
  774. });
  775. return res;
  776. }, []);
  777. }
  778. });
  779. },
  780. },
  781. }
  782. </script>
  783. <style scoped lang="scss">
  784. /deep/ .el-tabs .el-tabs__content {
  785. overflow-x: visible !important;
  786. }
  787. </style>