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.

714 lines
20 KiB

  1. <template>
  2. <div class="sl">
  3. <div ref="sl_search">
  4. <span @click="favoriteFunction()">
  5. <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
  6. </span>
  7. <el-button @click="searchShowDiv()" type="primary">{{ buttons.search }}</el-button>
  8. <el-button @click="userSetting" type="primary">{{ buttons.settingTable }}</el-button>
  9. <el-button v-if="isAuth('sys:setting')" @click="saveColumnList()" type="primary" v-show="showDefault">{{ buttons.defaultTable }}
  10. </el-button>
  11. <el-form :inline="true" label-position="top" :model="queryData" @keyup.enter.native="searchList()"
  12. v-show="searchShow">
  13. <el-form-item label="箱号">
  14. <el-input style="width: 150px" v-model="queryData.boxNo" clearable>
  15. </el-input>
  16. </el-form-item>
  17. <el-form-item label="销售单号">
  18. <el-input style="width: 150px" v-model="queryData.orderNo" clearable>
  19. </el-input>
  20. </el-form-item>
  21. <el-form-item label="物料编号">
  22. <el-input style="width: 150px" v-model="queryData.itemCode" clearable>
  23. </el-input>
  24. </el-form-item>
  25. <el-form-item label="创建时间">
  26. <el-date-picker style="width: 150px" value-format="yyyy-MM-dd HH:mm:ss" type="date"
  27. v-model="queryData.createdDate">
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item label=" - ">
  31. <el-button @click="searchList()" type="primary">{{ buttons.select }}</el-button>
  32. </el-form-item>
  33. </el-form>
  34. </div>
  35. <el-table
  36. :height="height"
  37. :data="dataList"
  38. border
  39. v-loading="dataListLoading"
  40. style="width: 100%;">
  41. <el-table-column
  42. v-for="(item,index) in columnList" :key="index"
  43. :sortable="item.columnSortable"
  44. :prop="item.columnProp"
  45. :header-align="item.headerAlign"
  46. :show-overflow-tooltip="item.showOverflowTooltip"
  47. :align="item.align"
  48. :fixed="item.fixed"
  49. :min-width="item.columnWidth"
  50. :label="item.columnLabel">
  51. <template slot-scope="scope">
  52. {{ scope.row[item.columnProp] }}
  53. <!-- <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>-->
  54. <!-- <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"-->
  55. <!-- style="width: 100px; height: 80px"/></span>-->
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. fixed="right"
  60. header-align="center"
  61. align="center"
  62. width="150"
  63. :label="buttons.cz">
  64. <template slot-scope="scope">
  65. <a type="text" size="small" @click="openPrintDialog(scope.row)" herf="#">{{ buttons.boxPrint }}</a>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <!-- 模板列表 -->
  70. <el-dialog
  71. v-drag
  72. :title="pageLanguageData.printDialog"
  73. :visible.sync="printVisible"
  74. width="220px"
  75. center>
  76. <dev style="margin: 0 auto">
  77. <el-select style="width: 200px" :placeholder="pageLanguageData.printTemplateMsg" v-model="reportFileVo">
  78. <el-option v-for="(item,index) in printTemplates" :key="index" :label="item.reportFileVo"
  79. :value="item.reportIdVo"></el-option>
  80. </el-select>
  81. </dev>
  82. <span slot="footer" class="dialog-footer">
  83. <el-button type="primary" @click="printBox()">{{ buttons.print }}</el-button>
  84. <el-button @click="printVisible = false">{{ buttons.close }}</el-button>
  85. </span>
  86. </el-dialog>
  87. <!-- 设置列 -->
  88. <column v-if="visible" ref="column" @refreshData="getTableUserColumn"></column>
  89. </div>
  90. </template>
  91. <script>
  92. import {
  93. getSoBoxingList,
  94. getReportFileListByCustomerId,
  95. getCustomerId,
  96. printPacking
  97. } from '@/api/finishedProductWarehouse/soBoxes.js'
  98. import column from "../common/column";
  99. import search from "../common/search";
  100. import {
  101. searchSysLanguageParam,
  102. searchFunctionButtonList,
  103. saveButtonList,
  104. searchPageLanguageData
  105. } from "@/api/sysLanguage.js"
  106. import {
  107. saveTableDefaultList,
  108. getTableDefaultListLanguage,
  109. getTableUserListLanguage
  110. } from "@/api/table.js"
  111. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  112. export default {
  113. data() {
  114. return {
  115. printVisible: false,
  116. searchVisible: false,
  117. searchShow: false,
  118. // table高度
  119. height: 450,
  120. // 是否收藏
  121. favorite: false,
  122. addLanguage: false,
  123. functionId: 1001,
  124. tableId: "1001BoxingPrint",
  125. languageCode: this.$i18n.locale,
  126. visible: false,
  127. showDefault: false,
  128. queryData: {
  129. boxNo: '',
  130. orderNo: '',
  131. itemCode: '',
  132. createdDate: this.dayjs().format('YYYY-MM-DD HH:mm:ss')
  133. },
  134. reportFileVo: '',
  135. boxNumber: 0,
  136. itemCode: '',
  137. orderNo: '',
  138. boxNo:'',
  139. // 打印模板列表
  140. printTemplates: [],
  141. // 语言词典集合
  142. sysLanguageParams: [],
  143. columnList: [
  144. {
  145. userId: this.$store.state.user.name,
  146. functionId: 1001,
  147. tableId: "1001BoxingPrint",
  148. tableName: "so_receive_boxes",
  149. columnProp: "id",
  150. headerAlign: "center",
  151. align: "center",
  152. columnLabel: "主键",
  153. columnHidden: false,
  154. columnImage: false,
  155. columnSortable: false,
  156. sortLv: 0,
  157. status: true,
  158. fixed: false,
  159. serialNumber: '1001BoxingPrintId'
  160. }, {
  161. userId: this.$store.state.user.name,
  162. functionId: 1001,
  163. tableId: "1001BoxingPrint",
  164. tableName: "so_receive_boxes",
  165. columnProp: "site",
  166. headerAlign: "center",
  167. align: "center",
  168. columnLabel: "工厂编号",
  169. columnHidden: false,
  170. columnImage: false,
  171. columnSortable: false,
  172. sortLv: 0,
  173. status: true,
  174. fixed: false,
  175. serialNumber: '1001BoxingPrintSite'
  176. }, {
  177. userId: this.$store.state.user.name,
  178. functionId: 1001,
  179. tableId: "1001BoxingPrint",
  180. tableName: "so_receive_boxes",
  181. columnProp: "boxNo",
  182. headerAlign: "center",
  183. align: "center",
  184. columnLabel: "箱编号",
  185. columnHidden: false,
  186. columnImage: false,
  187. columnSortable: false,
  188. sortLv: 0,
  189. status: true,
  190. fixed: false,
  191. serialNumber: '1001BoxingPrintBoxNo'
  192. }, {
  193. userId: this.$store.state.user.name,
  194. functionId: 1001,
  195. tableId: "1001BoxingPrint",
  196. tableName: "so_receive_boxes",
  197. columnProp: "orderNo",
  198. headerAlign: "center",
  199. align: "center",
  200. columnLabel: "订单编号",
  201. columnHidden: false,
  202. columnImage: false,
  203. columnSortable: false,
  204. sortLv: 0,
  205. status: true,
  206. fixed: false,
  207. serialNumber: '1001BoxingPrintOrderNo'
  208. }, {
  209. userId: this.$store.state.user.name,
  210. functionId: 1001,
  211. tableId: "1001BoxingPrint",
  212. tableName: "so_receive_boxes",
  213. columnProp: "batchCode",
  214. headerAlign: "center",
  215. align: "center",
  216. columnLabel: "批号",
  217. columnHidden: false,
  218. columnImage: false,
  219. columnSortable: false,
  220. sortLv: 0,
  221. status: true,
  222. fixed: false,
  223. serialNumber: '1001BoxingPrintBatchCode'
  224. }, {
  225. userId: this.$store.state.user.name,
  226. functionId: 1001,
  227. tableId: "1001BoxingPrint",
  228. tableName: "so_receive_boxes",
  229. columnProp: "itemCode",
  230. headerAlign: "center",
  231. align: "center",
  232. columnLabel: "物料编码",
  233. columnHidden: false,
  234. columnImage: false,
  235. columnSortable: false,
  236. sortLv: 0,
  237. status: true,
  238. fixed: false,
  239. serialNumber: '1001BoxingPrintItemCode'
  240. }, {
  241. userId: this.$store.state.user.name,
  242. functionId: 1001,
  243. tableId: "1001BoxingPrint",
  244. tableName: "so_receive_boxes",
  245. columnProp: "status",
  246. headerAlign: "center",
  247. align: "center",
  248. columnLabel: "状态",
  249. columnHidden: false,
  250. columnImage: false,
  251. columnSortable: false,
  252. sortLv: 0,
  253. status: true,
  254. fixed: false,
  255. serialNumber: '1001BoxingPrintStatus'
  256. }, {
  257. userId: this.$store.state.user.name,
  258. functionId: 1001,
  259. tableId: "1001BoxingPrint",
  260. tableName: "so_receive_boxes",
  261. columnProp: "status2",
  262. headerAlign: "center",
  263. align: "center",
  264. columnLabel: "状态2",
  265. columnHidden: false,
  266. columnImage: false,
  267. columnSortable: false,
  268. sortLv: 0,
  269. status: true,
  270. fixed: false,
  271. serialNumber: '1001BoxingPrintStatus2'
  272. }, {
  273. userId: this.$store.state.user.name,
  274. functionId: 1001,
  275. tableId: "1001BoxingPrint",
  276. tableName: "so_receive_boxes",
  277. columnProp: "rollsQty",
  278. headerAlign: "center",
  279. align: "center",
  280. columnLabel: "卷数量",
  281. columnHidden: false,
  282. columnImage: false,
  283. columnSortable: false,
  284. sortLv: 0,
  285. status: true,
  286. fixed: false,
  287. serialNumber: '1001BoxingPrintRollsQty'
  288. }, {
  289. userId: this.$store.state.user.name,
  290. functionId: 1001,
  291. tableId: "1001BoxingPrint",
  292. tableName: "so_receive_boxes",
  293. columnProp: "boxType",
  294. headerAlign: "center",
  295. align: "center",
  296. columnLabel: "箱类型",
  297. columnHidden: true,
  298. columnImage: false,
  299. columnSortable: false,
  300. sortLv: 0,
  301. status: true,
  302. fixed: false,
  303. serialNumber: '1001BoxingPrintBoxType'
  304. }, {
  305. userId: this.$store.state.user.name,
  306. functionId: 1001,
  307. tableId: "1001BoxingPrint",
  308. tableName: "so_receive_boxes",
  309. columnProp: "createdDate",
  310. headerAlign: "center",
  311. align: "center",
  312. columnLabel: "创建时间",
  313. columnHidden: true,
  314. columnImage: false,
  315. columnSortable: false,
  316. sortLv: 0,
  317. status: true,
  318. fixed: false,
  319. serialNumber: '1001BoxingPrintCreatedDate'
  320. }, {
  321. userId: this.$store.state.user.name,
  322. functionId: 1001,
  323. tableId: "1001BoxingPrint",
  324. tableName: "so_receive_boxes",
  325. columnProp: "createdBy",
  326. headerAlign: "center",
  327. align: "center",
  328. columnLabel: "创建人",
  329. columnHidden: true,
  330. columnImage: false,
  331. columnSortable: false,
  332. sortLv: 0,
  333. status: true,
  334. fixed: false,
  335. serialNumber: '1001BoxingPrintCreatedBy'
  336. }
  337. ],
  338. dataList: [],
  339. pageLanguageDataList: [
  340. {
  341. functionId: "1001",
  342. languageValue: '操作',
  343. objectId: 'operate',
  344. objectType: "page",
  345. tableId: "boxingPrint"
  346. },
  347. {
  348. functionId: "1001",
  349. languageValue: '销售单号',
  350. objectId: 'shopOrderNo',
  351. objectType: "page",
  352. tableId: "boxingPrint"
  353. },
  354. {
  355. functionId: "1001",
  356. languageValue: '箱号',
  357. objectId: 'boxNo',
  358. objectType: "page",
  359. tableId: "boxingPrint"
  360. },
  361. {
  362. functionId: "1001",
  363. languageValue: '物料编号',
  364. objectId: 'partNo',
  365. objectType: "page",
  366. tableId: "boxingPrint"
  367. },
  368. {
  369. functionId: "1001",
  370. languageValue: '创建时间',
  371. objectId: 'createdDate',
  372. objectType: "page",
  373. tableId: "boxingPrint"
  374. },
  375. {
  376. functionId: "1001",
  377. languageValue: '搜索',
  378. objectId: 'search',
  379. objectType: "page",
  380. tableId: "boxingPrint"
  381. },
  382. {
  383. functionId: "1001",
  384. languageValue: '设置列表',
  385. objectId: 'setting',
  386. objectType: "page",
  387. tableId: "boxingPrint"
  388. },
  389. {
  390. functionId: "1001",
  391. languageValue: '取消',
  392. objectId: 'recall',
  393. objectType: "page",
  394. tableId: "boxingPrint"
  395. },
  396. {
  397. functionId: "1001",
  398. languageValue: '打印',
  399. objectId: 'print',
  400. objectType: "page",
  401. tableId: "boxingPrint"
  402. },
  403. {
  404. functionId: "1001",
  405. languageValue: '请选择模板',
  406. objectId: 'printTemplateMsg',
  407. objectType: "page",
  408. tableId: "boxingPrint"
  409. },
  410. {
  411. functionId: "1001",
  412. languageValue: '打印模板选择',
  413. objectId: 'printDialog',
  414. objectType: "page",
  415. tableId: "boxingPrint"
  416. },
  417. {
  418. functionId: "1001",
  419. languageValue: '标签打印',
  420. objectId: 'labelPrint',
  421. objectType: "page",
  422. tableId: "boxingPrint"
  423. }
  424. ],
  425. queryPageLang: {
  426. functionId: "1001",
  427. objectType: "page",
  428. tableId: "boxingPrint",
  429. languageCode: this.$i18n.locale
  430. },
  431. buttons: {
  432. add: '添加',
  433. edit: '编辑',
  434. delete: '删除',
  435. deleteList: '批量删除',
  436. cz: '操作',
  437. search: '搜索',
  438. select: '查询',
  439. download: '导出',
  440. settingTable: '设置列表',
  441. defaultTable: '设置默认配置',
  442. print: '打印',
  443. close: '取消',
  444. boxPrint: '标签打印'
  445. },
  446. pageLanguageData: {
  447. printDialog: "打印模板选择",
  448. printTemplateMsg: "请选择模板",
  449. },
  450. dataListLoading: false,
  451. dataListSelections: [],
  452. addOrUpdateVisible: false
  453. }
  454. },
  455. components: {
  456. column,
  457. search
  458. },
  459. mounted() {
  460. this.getAutoHeight()
  461. },
  462. activated() {
  463. this.searchList()
  464. },
  465. methods: {
  466. // 打开搜索条件
  467. searchShowDiv() {
  468. if (this.searchShow) {
  469. this.searchShow = false
  470. } else {
  471. this.searchShow = true
  472. }
  473. },
  474. // 打开打印模态框
  475. openPrintDialog(val) {
  476. this.boxNumber = val.rollsQty
  477. this.itemCode = val.itemCode
  478. this.orderNo = val.orderNo
  479. this.boxNo = val.boxNo
  480. this.printVisible = true
  481. this.getReportFileListByCustomerId(val.itemCode)
  482. },
  483. // 打印
  484. printBox() {
  485. this.printVisible = false
  486. let reportFile = this.reportFileVo.split(":");
  487. let reportFileVo = {
  488. reportFile: reportFile[2],
  489. reportId: reportFile[1],
  490. isCustomer: reportFile[0],
  491. pickingNumber: this.boxNumber,
  492. partNo: this.itemCode,
  493. orderNo: this.orderNo,
  494. boxNo: this.boxNo,
  495. }
  496. printPacking(reportFileVo).then(({data}) => {
  497. if (data.code == 0) {
  498. this.$message.success(data.msg)
  499. }
  500. if (data.code == 500) {
  501. this.$message.error(data.msg)
  502. }
  503. })
  504. },
  505. // 获取打印模板数据
  506. getReportFileListByCustomerId(partNo) {
  507. let vo = {
  508. partNo: partNo
  509. }
  510. getCustomerId(vo).then((data) => {
  511. let reportFileVo = {
  512. customerId: data.customerId,
  513. reportFamily: '外箱标签'
  514. }
  515. getReportFileListByCustomerId(reportFileVo).then(({data}) => {
  516. this.printTemplates = data.reportFileVos
  517. this.reportFileVo = data.reportFileVos[0].reportIdVo
  518. })
  519. })
  520. },
  521. // 获取数据
  522. searchList() {
  523. getSoBoxingList(this.queryData).then(({data}) => {
  524. this.dataList = data.data
  525. })
  526. },
  527. // 这个方法用来动态设置 height
  528. getAutoHeight() {
  529. // 一定要使用 nextTick 来改变height 不然不会起作用
  530. this.$nextTick(() => {
  531. this.height = window.innerHeight - 174;
  532. });
  533. },
  534. // 校验用户是否收藏
  535. favoriteIsOk() {
  536. let userFavorite = {
  537. userId: this.$store.state.user.id,
  538. languageCode: this.$i18n.locale
  539. }
  540. userFavoriteList(userFavorite).then(({data}) => {
  541. let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
  542. if (size > 0) {
  543. this.favorite = true
  544. } else {
  545. this.favorite = false
  546. }
  547. })
  548. },
  549. // 收藏 OR 取消收藏
  550. favoriteFunction() {
  551. let userFavorite = {
  552. userId: this.$store.state.user.id,
  553. functionId: this.$route.meta.menuId,
  554. }
  555. if (this.favorite) {
  556. // 取消收藏
  557. this.$confirm(`确定取消收藏`, '提示', {
  558. confirmButtonText: '确定',
  559. cancelButtonText: '取消',
  560. type: 'warning'
  561. }).then(() => {
  562. removeUserFavorite(userFavorite).then(({data}) => {
  563. this.$message.success(data.msg)
  564. this.favorite = false
  565. })
  566. })
  567. } else {
  568. // 收藏
  569. saveUserFavorite(userFavorite).then(({data}) => {
  570. this.$message.success(data.msg)
  571. this.favorite = true
  572. })
  573. }
  574. },
  575. // 获取页面所有语言数据
  576. // 获取页面提示信息
  577. getPageLanguageData() {
  578. searchPageLanguageData(this.queryPageLang).then((data) => {
  579. if (JSON.stringify(data.data) != '{}') {
  580. this.pageLanguageData = data.data
  581. } else {
  582. }
  583. })
  584. },
  585. // 获取button的词典
  586. getFunctionButtonList() {
  587. let queryButton = {
  588. functionId: this.functionId,
  589. tableId: this.tableId,
  590. languageCode: this.languageCode,
  591. objectType: 'button'
  592. }
  593. searchFunctionButtonList(queryButton).then(({data}) => {
  594. if (data.data.length > 0) {
  595. this.buttons = data.data
  596. }
  597. })
  598. },
  599. // 获取语言词典
  600. getSysLanguageParamList() {
  601. let querySysLanguageParam = {
  602. languageCode: this.$i18n.locale
  603. }
  604. searchSysLanguageParam(querySysLanguageParam).then(({data}) => {
  605. this.sysLanguageParams = data.rows
  606. })
  607. },
  608. // 打开页面设置
  609. userSetting() {
  610. this.visible = true;
  611. let queryTable = {
  612. userId: this.userId,
  613. functionId: this.functionId,
  614. tableId: this.tableId,
  615. languageCode: this.languageCode
  616. }
  617. this.$nextTick(() => {
  618. this.$refs.column.init(queryTable);
  619. });
  620. },
  621. // 获取 用户保存的 格式列
  622. getTableUserColumn() {
  623. let queryTableUser = {
  624. userId: this.userId,
  625. functionId: this.functionId,
  626. tableId: this.tableId,
  627. languageCode: this.languageCode,
  628. status: true,
  629. }
  630. getTableUserListLanguage(queryTableUser).then(({data}) => {
  631. if (data.rows.length > 0) {
  632. //this.columnList = []
  633. this.columnList = data.rows
  634. } else {
  635. this.getColumnList()
  636. }
  637. })
  638. },
  639. // 保存 默认配置 列
  640. saveColumnList() {
  641. this.showDefault = false
  642. saveButtonList(this.buttonList).then(({data}) => {
  643. })
  644. saveButtonList(this.buttonList).then(({data}) => {
  645. })
  646. saveTableDefaultList(this.columnList).then(({data}) => {
  647. if (data.code == 0) {
  648. this.$message.success(data.msg)
  649. this.showDefault = false
  650. } else {
  651. this.showDefault = true
  652. this.$message.error(data.msg)
  653. }
  654. })
  655. /* this.getFunctionButtonList();
  656. this.getPageLanguageData()
  657. this.getColumnList()*/
  658. },
  659. // 获取 tableDefault 列
  660. getColumnList() {
  661. let queryTable = {
  662. functionId: this.functionId,
  663. tableId: this.tableId,
  664. languageCode: this.languageCode
  665. }
  666. getTableDefaultListLanguage(queryTable).then(({data}) => {
  667. if (!data.rows.length == 0) {
  668. this.showDefault = false
  669. this.columnList = data.rows
  670. } else {
  671. this.showDefault = true
  672. }
  673. })
  674. },
  675. },
  676. created() {
  677. this.getTableUserColumn()
  678. this.getSysLanguageParamList()
  679. this.getFunctionButtonList()
  680. this.favoriteIsOk()
  681. }
  682. }
  683. </script>
  684. <style>
  685. .sl-svg {
  686. overflow: hidden;
  687. float: right;
  688. }
  689. .el-dialog--center .el-dialog__body {
  690. text-align: center;
  691. padding: 0;
  692. }
  693. </style>