index.vue 18 KB

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