You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

692 lines
20 KiB

6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
  1. <template>
  2. <div class="mod-config">
  3. <div>
  4. <span @click="favoriteFunction()">
  5. <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
  6. </span>
  7. </div>
  8. <!-- <el-button @click="searchList()" type="primary">{{ buttons.search }}</el-button>-->
  9. <!-- <el-button @click="saveColumnList()" v-show="showDefault" type="primary">{{ buttons.defaultTable }}-->
  10. <!-- </el-button>-->
  11. <!-- <el-button @click="userSetting" type="primary">{{ buttons.settingTable }}</el-button>-->
  12. <el-form label-position="top" style="margin-top: 5px" v-show="searchShow" :inline="true" :model="queryData"
  13. @keyup.enter.native="getDataList()">
  14. <el-form-item label="卷号">
  15. <el-input v-model="queryData.rollno" clearable>
  16. </el-input>
  17. </el-form-item>
  18. <el-form-item label="物料编码">
  19. <el-input v-model="queryData.partno" clearable>
  20. </el-input>
  21. </el-form-item>
  22. <el-form-item style="margin-top: 18px">
  23. <el-button @click="getDataList()" type="primary">{{ buttons.search1 }}</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-table
  27. :height="height"
  28. :data="dataList"
  29. border
  30. v-loading="dataListLoading"
  31. highlight-current-row
  32. style="width: 100%;">
  33. <el-table-column
  34. v-for="(item,index) in columnList" :key="index"
  35. :sortable="item.columnSortable"
  36. :prop="item.columnProp"
  37. :header-align="item.headerAlign"
  38. :show-overflow-tooltip="item.showOverflowTooltip"
  39. :align="item.align"
  40. :fixed="item.fixed==''?false:item.fixed"
  41. :min-width="item.columnWidth"
  42. :label="item.columnLabel">
  43. <template slot-scope="scope">
  44. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  45. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  46. style="width: 100px; height: 80px"/></span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. fixed="right"
  51. header-align="center"
  52. align="center"
  53. width="150"
  54. :label="buttons.cz">
  55. <template slot-scope="scope">
  56. <a type="text" size="small" @click="printRoll(scope.row)" herf="#">{{ buttons.rollPrint }}</a>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. <!-- 设置列 -->
  61. <column v-if="visible" ref="column" @refreshData="getTableUserColumn"></column>
  62. <!-- 弹窗, 新增 / 修改 -->
  63. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  64. </div>
  65. </template>
  66. <script>
  67. import AddOrUpdate from './crollinfo-add-or-update'
  68. import {getCRollInfoList} from '@/api/crollinfo/crollinfo.js'
  69. import {rollPrint} from '@/api/finishedProductWarehouse/rollPrint.js'
  70. import column from "../common/column";
  71. import search from "../common/search";
  72. import {
  73. searchSysLanguageParam,
  74. searchFunctionButtonList,
  75. saveButtonList,
  76. } from "@/api/sysLanguage.js"
  77. import {
  78. saveTableDefaultList,
  79. getTableDefaultListLanguage,
  80. getTableUserListLanguage,
  81. removerDefault,
  82. removerUser
  83. } from "@/api/table.js"
  84. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  85. export default {
  86. data() {
  87. return {
  88. searchVisible: false,
  89. searchShow: false,
  90. // table高度
  91. height: 450,
  92. // 是否收藏
  93. favorite: false,
  94. addLanguage: false,
  95. userId: this.$store.state.user.name,
  96. functionId: this.$route.meta.menuId,
  97. tableId: "105003002RP",
  98. languageCode: this.$i18n.locale,
  99. visible: false,
  100. showDefault: false,
  101. queryData: {
  102. day1: '',
  103. day2: '',
  104. rollno: '',
  105. partno: ''
  106. },
  107. queryTable: {
  108. functionId: this.$route.meta.menuId,
  109. tableId: "105003002RP",
  110. languageCode: this.$i18n.locale
  111. },
  112. // 语言词典集合
  113. sysLanguageParams: [],
  114. columnList: [
  115. {
  116. "userId": this.$store.state.user.name,
  117. "tableId": "105003002RP",
  118. "tableName": "卷标签打印",
  119. "columnProp": "rollno",
  120. "columnLabel": "卷号",
  121. "columnHidden": false,
  122. "columnImage": false,
  123. "columnSortable": false,
  124. "columnWidth": 100,
  125. "format": null,
  126. "sortLv": 10,
  127. "status": true,
  128. "fixed": true,
  129. "serialNumber": null,
  130. "columnType": "string",
  131. "align": null
  132. },
  133. {
  134. "userId": this.$store.state.user.name,
  135. "tableId": "105003002RP",
  136. "tableName": "卷标签打印",
  137. "columnProp": "partno",
  138. "columnLabel": "物料编号",
  139. "columnHidden": false,
  140. "columnImage": false,
  141. "columnSortable": false,
  142. "columnWidth": 100,
  143. "format": null,
  144. "sortLv": 20,
  145. "status": true,
  146. "fixed": false,
  147. "serialNumber": null,
  148. "columnType": "string",
  149. "align": null
  150. },
  151. {
  152. "userId": this.$store.state.user.name,
  153. "tableId": "105003002RP",
  154. "tableName": "卷标签打印",
  155. "columnProp": "partDescription",
  156. "columnLabel": "物料描述",
  157. "columnHidden": false,
  158. "columnImage": false,
  159. "columnSortable": false,
  160. "columnWidth": 250,
  161. "format": null,
  162. "sortLv": 30,
  163. "status": true,
  164. "fixed": false,
  165. "serialNumber": null,
  166. "columnType": "string",
  167. "align": null
  168. },
  169. {
  170. "userId": this.$store.state.user.name,
  171. "tableId": "105003002RP",
  172. "tableName": "卷标签打印",
  173. "columnProp": "site",
  174. "columnLabel": "工厂编号",
  175. "columnHidden": false,
  176. "columnImage": false,
  177. "columnSortable": false,
  178. "columnWidth": 80,
  179. "format": null,
  180. "sortLv": 40,
  181. "status": true,
  182. "fixed": false,
  183. "serialNumber": null,
  184. "columnType": "string",
  185. "align": null
  186. },
  187. {
  188. "userId": this.$store.state.user.name,
  189. "tableId": "105003002RP",
  190. "tableName": "卷标签打印",
  191. "columnProp": "rollqty",
  192. "columnLabel": "卷数量",
  193. "columnHidden": false,
  194. "columnImage": false,
  195. "columnSortable": false,
  196. "columnWidth": 41,
  197. "format": null,
  198. "sortLv": 7,
  199. "status": true,
  200. "fixed": false,
  201. "serialNumber": null,
  202. "columnType": "number",
  203. "align": null
  204. },
  205. {
  206. "userId": this.$store.state.user.name,
  207. "tableId": "105003002RP",
  208. "tableName": "卷标签打印",
  209. "columnProp": "status",
  210. "columnLabel": "状态",
  211. "columnHidden": false,
  212. "columnImage": false,
  213. "columnSortable": false,
  214. "columnWidth": 80,
  215. "format": null,
  216. "sortLv": 50,
  217. "status": true,
  218. "fixed": false,
  219. "serialNumber": null,
  220. "columnType": "number",
  221. "align": null
  222. },
  223. {
  224. "userId": this.$store.state.user.name,
  225. "tableId": "105003002RP",
  226. "tableName": "卷标签打印",
  227. "columnProp": "sourcetype",
  228. "columnLabel": "来源类型",
  229. "columnHidden": false,
  230. "columnImage": false,
  231. "columnSortable": false,
  232. "columnWidth": 80,
  233. "format": null,
  234. "sortLv": 60,
  235. "status": true,
  236. "fixed": false,
  237. "serialNumber": null,
  238. "columnType": "string",
  239. "align": null
  240. },
  241. {
  242. "userId": this.$store.state.user.name,
  243. "tableId": "105003002RP",
  244. "tableName": "卷标签打印",
  245. "columnProp": "warehouseid",
  246. "columnLabel": "仓库编码",
  247. "columnHidden": false,
  248. "columnImage": false,
  249. "columnSortable": false,
  250. "columnWidth": 80,
  251. "format": null,
  252. "sortLv": 70,
  253. "status": false,
  254. "fixed": false,
  255. "serialNumber": null,
  256. "columnType": "string",
  257. "align": null
  258. },
  259. {
  260. "userId": this.$store.state.user.name,
  261. "tableId": "105003002RP",
  262. "tableName": "卷标签打印",
  263. "columnProp": "supplierid",
  264. "columnLabel": "供应商编号",
  265. "columnHidden": false,
  266. "columnImage": false,
  267. "columnSortable": false,
  268. "columnWidth": 80,
  269. "format": null,
  270. "sortLv": 80,
  271. "status": false,
  272. "fixed": false,
  273. "serialNumber": null,
  274. "columnType": "string",
  275. "align": null
  276. },
  277. {
  278. "userId": this.$store.state.user.name,
  279. "tableId": "105003002RP",
  280. "tableName": "卷标签打印",
  281. "columnProp": "suppliername",
  282. "columnLabel": "供应商名称",
  283. "columnHidden": false,
  284. "columnImage": false,
  285. "columnSortable": false,
  286. "columnWidth": 80,
  287. "format": null,
  288. "sortLv": 90,
  289. "status": false,
  290. "fixed": false,
  291. "serialNumber": null,
  292. "columnType": "string",
  293. "align": null
  294. },
  295. {
  296. "userId": this.$store.state.user.name,
  297. "tableId": "105003002RP",
  298. "tableName": "卷标签打印",
  299. "columnProp": "createdby",
  300. "columnLabel": "创建人",
  301. "columnHidden": false,
  302. "columnImage": false,
  303. "columnSortable": false,
  304. "columnWidth": 80,
  305. "format": null,
  306. "sortLv": 100,
  307. "status": true,
  308. "fixed": false,
  309. "serialNumber": null,
  310. "columnType": "string",
  311. "align": null
  312. },
  313. {
  314. "userId": this.$store.state.user.name,
  315. "tableId": "105003002RP",
  316. "tableName": "卷标签打印",
  317. "columnProp": "rolldate",
  318. "columnLabel": "卷创建时间",
  319. "columnHidden": false,
  320. "columnImage": false,
  321. "columnSortable": false,
  322. "columnWidth": 120,
  323. "format": null,
  324. "sortLv": 110,
  325. "status": true,
  326. "fixed": false,
  327. "serialNumber": null,
  328. "columnType": "date",
  329. "align": null
  330. },
  331. {
  332. "userId": this.$store.state.user.name,
  333. "tableId": "105003002RP",
  334. "tableName": "卷标签打印",
  335. "columnProp": "manufacturedate",
  336. "columnLabel": "制造日期",
  337. "columnHidden": false,
  338. "columnImage": false,
  339. "columnSortable": false,
  340. "columnWidth": 120,
  341. "format": null,
  342. "sortLv": 111,
  343. "status": true,
  344. "fixed": false,
  345. "serialNumber": null,
  346. "columnType": "string",
  347. "align": null
  348. },
  349. {
  350. "userId": this.$store.state.user.name,
  351. "tableId": "105003002RP",
  352. "tableName": "卷标签打印",
  353. "columnProp": "createddate",
  354. "columnLabel": "创建时间",
  355. "columnHidden": false,
  356. "columnImage": false,
  357. "columnSortable": false,
  358. "columnWidth": 150,
  359. "format": null,
  360. "sortLv": 112,
  361. "status": true,
  362. "fixed": false,
  363. "serialNumber": null,
  364. "columnType": "date",
  365. "align": null
  366. },
  367. {
  368. "userId": this.$store.state.user.name,
  369. "tableId": "105003002RP",
  370. "tableName": "卷标签打印",
  371. "columnProp": "remark",
  372. "columnLabel": "备注",
  373. "columnHidden": false,
  374. "columnImage": false,
  375. "columnSortable": false,
  376. "columnWidth": 80,
  377. "format": null,
  378. "sortLv": 113,
  379. "status": false,
  380. "fixed": false,
  381. "serialNumber": null,
  382. "columnType": "string",
  383. "align": null
  384. },
  385. ],
  386. dataList: [],
  387. buttons: {
  388. add: '添加',
  389. edit: '编辑',
  390. delete: '删除',
  391. deleteList: '批量删除',
  392. cz: '操作',
  393. search: '搜索',
  394. search1: '查询',
  395. download: '导出',
  396. settingTable: '设置列表',
  397. defaultTable: '设置默认配置',
  398. rollPrint: '卷补打'
  399. },
  400. dataListLoading: false,
  401. dataListSelections: [],
  402. addOrUpdateVisible: false,
  403. pagination: {
  404. page: 1,
  405. pageSize: 200,
  406. total: 0,
  407. },
  408. totalPage: 5,
  409. countTotal: 200,
  410. }
  411. },
  412. components: {
  413. AddOrUpdate,
  414. column,
  415. search
  416. },
  417. mounted() {
  418. this.$nextTick(() => {
  419. this.height = window.innerHeight - 180;
  420. }),
  421. this.lazyLoading();
  422. },
  423. activated() {
  424. // this.getDataList()
  425. },
  426. methods: {
  427. lazyLoading() {
  428. let dom = document.querySelector(".el-table__body-wrapper");
  429. dom.addEventListener("scroll", (v) => {
  430. const scrollDistance = dom.scrollHeight - dom.scrollTop - dom.clientHeight;
  431. // if (scrollDistance <= 0) { //分辨率问题,如果设置 100% ,滑倒最底部,scrollDistance的值 可能为 0.201 到 -0.201
  432. if (scrollDistance <= 1) {
  433. //等于0证明已经到底,可以请求接口
  434. if (this.pagination.page >= this.totalPage) {
  435. //判断是否到达底部
  436. // this.$message.warning("我~是有底线的 (~ ̄▽ ̄)~");
  437. //console.log("我~是有底线的 (~ ̄▽ ̄)~")
  438. }
  439. if (this.pagination.page < this.totalPage) {
  440. //当前页数小于总页数就请求
  441. this.pagination.page++; //当前页数自增
  442. //console.log("页面已经到达底部,可以请求接口,请求第 " + this.pagination.page + " 页数据");
  443. this.pagination.pageSize = this.countTotal;
  444. this.getDataListAdd()
  445. }
  446. }
  447. });
  448. },
  449. // 获取数据列表
  450. getDataList() {
  451. this.dataListLoading = true
  452. let query = {
  453. parttypeFlag: 'F',
  454. sourceType: '其他入库',
  455. rollno: this.queryData.rollno,
  456. partno: this.queryData.partno,
  457. limit: 200,
  458. page: 1
  459. }
  460. getCRollInfoList(query).then(({data}) => {
  461. if (data && data.code === 0) {
  462. this.dataList = data.page.list
  463. this.totalPage = data.page.totalPage
  464. // this.countTotal = data.page.totalCount
  465. this.pagination.page = data.page.currPage
  466. this.pagination.total = data.page.totalCount
  467. }
  468. this.dataListLoading = false
  469. })
  470. // this.searchShow = false
  471. },
  472. // 滚动获取数据
  473. getDataListAdd() {
  474. this.dataListLoading = true
  475. let query = {
  476. parttypeFlag: 'F',
  477. sourceType: '其他入库',
  478. rollno: this.queryData.rollno,
  479. partno: this.queryData.partno,
  480. limit: this.pagination.pageSize,
  481. page: this.pagination.page
  482. }
  483. getCRollInfoList(query).then(({data}) => {
  484. if (data && data.code === 0) {
  485. let voList = data.page.list
  486. this.dataList.push(...voList)
  487. }
  488. this.dataListLoading = false
  489. })
  490. // this.searchShow = false
  491. },
  492. // 打开搜索页面
  493. searchList() {
  494. if (this.searchShow) {
  495. this.searchShow = false
  496. return
  497. } else {
  498. this.searchShow = true
  499. }
  500. },
  501. // 卷标签补打
  502. printRoll(val) {
  503. let rollList = []
  504. rollList.push(val)
  505. rollPrint(rollList).then(({data}) => {
  506. if (data.code == 0) {
  507. this.$message.success(data.msg)
  508. } else {
  509. this.$message.warning(data.msg)
  510. }
  511. })
  512. },
  513. // 校验用户是否收藏
  514. favoriteIsOk() {
  515. let userFavorite = {
  516. userId: this.$store.state.user.id,
  517. languageCode: this.$i18n.locale
  518. }
  519. userFavoriteList(userFavorite).then(({data}) => {
  520. let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
  521. if (size > 0) {
  522. this.favorite = true
  523. } else {
  524. this.favorite = false
  525. }
  526. })
  527. },
  528. // 收藏 OR 取消收藏
  529. favoriteFunction() {
  530. let userFavorite = {
  531. userId: this.$store.state.user.id,
  532. functionId: this.$route.meta.menuId,
  533. }
  534. if (this.favorite) {
  535. // 取消收藏
  536. this.$confirm(`确定取消收藏`, '提示', {
  537. confirmButtonText: '确定',
  538. cancelButtonText: '取消',
  539. type: 'warning'
  540. }).then(() => {
  541. removeUserFavorite(userFavorite).then(({data}) => {
  542. this.$message.success(data.msg)
  543. this.favorite = false
  544. })
  545. })
  546. } else {
  547. // 收藏
  548. saveUserFavorite(userFavorite).then(({data}) => {
  549. this.$message.success(data.msg)
  550. this.favorite = true
  551. })
  552. }
  553. },
  554. // 获取button的词典
  555. getFunctionButtonList() {
  556. let queryButton = {
  557. functionId: this.functionId,
  558. tableId: this.tableId,
  559. languageCode: this.languageCode,
  560. objectType: 'button'
  561. }
  562. searchFunctionButtonList(queryButton).then(({data}) => {
  563. if (data.data.length > 0) {
  564. this.buttons = data.data
  565. }
  566. })
  567. },
  568. // 获取语言词典
  569. getSysLanguageParamList() {
  570. let querySysLanguageParam = {
  571. languageCode: this.$i18n.locale
  572. }
  573. searchSysLanguageParam(querySysLanguageParam).then(({data}) => {
  574. this.sysLanguageParams = data.rows
  575. })
  576. },
  577. // 打开页面设置
  578. userSetting() {
  579. this.visible = true;
  580. let queryTable = {
  581. userId: this.userId,
  582. functionId: this.functionId,
  583. tableId: this.tableId,
  584. languageCode: this.languageCode
  585. }
  586. this.$nextTick(() => {
  587. this.$refs.column.init(queryTable);
  588. });
  589. },
  590. // 获取 用户保存的 格式列
  591. getTableUserColumn() {
  592. let queryTableUser = {
  593. userId: this.userId,
  594. functionId: this.functionId,
  595. tableId: this.tableId,
  596. languageCode: this.languageCode,
  597. objectType: 'table',
  598. status: true,
  599. }
  600. getTableUserListLanguage(queryTableUser).then(({data}) => {
  601. if (data.rows.length > 0) {
  602. this.columnList = data.rows
  603. } else {
  604. this.getColumnList()
  605. }
  606. })
  607. },
  608. // 保存 默认配置 列
  609. async saveColumnList() {
  610. // 删除所有的该页面下保存的数据
  611. //删除 user自定义的数据
  612. await removerUser(this.queryTable)
  613. // 删除默认配置
  614. await removerDefault(this.queryTable)
  615. // 保存页面 table属性
  616. let sumColumnList = this.columnList;
  617. sumColumnList = sumColumnList.map(item => {
  618. return item = {
  619. tableId: item.tableId,
  620. tableName: item.tableName,
  621. columnProp: item.columnProp,
  622. columnLabel: item.columnLabel,
  623. columnHidden: false,
  624. columnImage: false,
  625. columnSortable: item.columnSortable,
  626. columnWidth: item.columnWidth,
  627. format: item.format,
  628. functionId: this.$route.meta.menuId,
  629. sortLv: item.sortLv,
  630. status: true,
  631. fixed: item.fixed,
  632. serialNumber: item.serialNumber,
  633. columnType: item.columnType,
  634. align: item.align
  635. }
  636. })
  637. await saveTableDefaultList(sumColumnList)
  638. // 保存页面 button label title 属性
  639. let buttons = this.buttonList.map(item => {
  640. return item = {
  641. functionId: this.$route.meta.menuId,
  642. languageValue: item.languageValue,
  643. objectId: item.objectId,
  644. objectType: item.objectType,
  645. tableId: item.tableId
  646. }
  647. })
  648. await saveButtonList(buttons)
  649. this.getFunctionButtonList()
  650. this.getColumnList()
  651. },
  652. // 获取 tableDefault 列
  653. getColumnList() {
  654. let queryTable = {
  655. functionId: this.functionId,
  656. tableId: this.tableId,
  657. languageCode: this.languageCode
  658. }
  659. getTableDefaultListLanguage(queryTable).then(({data}) => {
  660. if (!data.rows.length == 0) {
  661. // this.showDefault = false
  662. this.columnList = data.rows
  663. } else {
  664. // this.showDefault = true
  665. }
  666. })
  667. },
  668. },
  669. created() {
  670. // this.getTableUserColumn()
  671. // this.getSysLanguageParamList()
  672. // this.getFunctionButtonList()
  673. // this.favoriteIsOk()
  674. }
  675. }
  676. </script>
  677. <style scoped>
  678. .sl-svg {
  679. overflow: hidden;
  680. float: right;
  681. }
  682. </style>