index.vue 16 KB

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