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.

618 lines
19 KiB

6 months ago
  1. <template>
  2. <div class="sl-el">
  3. <el-dialog ref="printLoading" :close-on-click-modal="false" :show-close="false" :close-on-press-escape="false"
  4. title="标签打印"
  5. :visible.sync="visible"
  6. width="800px" v-drag>
  7. <el-container>
  8. <el-main style="width: 75%;margin-top: -20px">
  9. <el-row>
  10. <el-col :span="18">
  11. <el-form @submit.native.prevent label-position="top">
  12. <el-form-item style="width: 60%" :label="'请输入卷号:'">
  13. <el-input readonly v-model="rollNos" class="input-with-select"
  14. @keyup.enter.native="getBoxSoAndReportFile()">
  15. <el-button @click="getBoxSoAndReportFile()" slot="append" icon="el-icon-search"></el-button>
  16. </el-input>
  17. </el-form-item>
  18. </el-form>
  19. </el-col>
  20. <el-col :span="6"></el-col>
  21. </el-row>
  22. <el-row>
  23. <el-col :span="24">
  24. <span style="font-size: 12px;">请选择标签:</span>
  25. <el-table
  26. :data="reportFileList"
  27. border
  28. ref="reportFileTable"
  29. highlight-current-row
  30. @current-change="handleCurrentChange"
  31. height="150px">
  32. <el-table-column
  33. v-for="(item,index) in reportColumnList" :key="index"
  34. :sortable="item.columnSortable"
  35. :prop="item.columnProp"
  36. :header-align="item.headerAlign"
  37. :show-overflow-tooltip="item.showOverflowTooltip"
  38. :align="item.align"
  39. :fixed="item.fixed==''?false:item.fixed"
  40. :min-width="item.columnWidth"
  41. :label="item.columnLabel">
  42. <template slot-scope="scope">
  43. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  44. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  45. style="width: 100px; height: 80px"/></span>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. </el-col>
  50. </el-row>
  51. <el-row>
  52. <el-col :span="24">
  53. <span style="font-size: 12px;">打印格式名称:</span>
  54. <el-input type="textarea" v-model="selectReportString" readonly :rows="3"></el-input>
  55. </el-col>
  56. </el-row>
  57. <el-row>
  58. <el-col :span="24">
  59. <el-tabs style="font-size: 14px" v-model="activeName" type="border-card" @tab-click="handleClick"
  60. class="customer-tab">
  61. <el-tab-pane label="打印参数" name="first">
  62. <el-table
  63. :data="reportParamList"
  64. :cell-style="customerCellStyle" :cell-class-name="customerCellClassName"
  65. border
  66. :height="height"
  67. >
  68. <el-table-column
  69. v-for="(item,index) in printParamColumnList" :key="index"
  70. :sortable="item.columnSortable"
  71. :prop="item.columnProp"
  72. :header-align="item.headerAlign"
  73. :show-overflow-tooltip="item.showOverflowTooltip"
  74. :align="item.align"
  75. :fixed="item.fixed==''?false:item.fixed"
  76. :min-width="item.columnWidth"
  77. :label="item.columnLabel">
  78. <template slot-scope="scope">
  79. <span v-if="item.columnHidden">
  80. <span v-if="scope.row.valuetypeDb === 'T'">
  81. <el-input v-model='scope.row[item.columnProp]'> </el-input>
  82. </span>
  83. <span v-if="scope.row.valuetypeDb === 'D'">
  84. <el-date-picker style="width: 100%;"
  85. v-model='scope.row[item.columnProp]'> </el-date-picker>
  86. </span>
  87. <span v-if="scope.row.valuetypeDb === 'I'">
  88. <el-input type="number" v-model='scope.row[item.columnProp]' min="1"> </el-input>
  89. </span>
  90. </span>
  91. <span v-else>{{ scope.row[item.columnProp] }}</span>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. </el-tab-pane>
  96. </el-tabs>
  97. </el-col>
  98. </el-row>
  99. </el-main>
  100. </el-container>
  101. <span slot="footer" class="dialog-footer">
  102. <el-button type="primary" @click="bartenderPrint()">打印</el-button>
  103. <el-button type="primary" @click="closeDialog()">取消</el-button>
  104. </span>
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script>
  109. import {
  110. checkRollCustomer,
  111. getRollCustomer,
  112. getReportFileByCustomer,
  113. getReportSubFileList,
  114. getReportParameters,
  115. printLabel
  116. } from '@/api/print/rollPrint.js';
  117. export default {
  118. components: {},
  119. data() {
  120. return {
  121. visible: false,
  122. rollNos: '',
  123. activeName: 'first',
  124. height: 200,
  125. // 模板
  126. reportColumnList: [
  127. {
  128. tableId: "common1001",
  129. tableName: "common",
  130. columnProp: "reportid",
  131. columnLabel: "报告编号",
  132. columnHidden: false,
  133. columnImage: false,
  134. columnSortable: false,
  135. columnWidth: null,
  136. format: null,
  137. functionId: "this.$route.meta.menuId",
  138. sortLv: 0,
  139. status: true,
  140. fixed: '',
  141. serialNumber: null,
  142. columnType: null,
  143. align: null
  144. }, {
  145. tableId: "common1001",
  146. tableName: "common",
  147. columnProp: "Reportfile",
  148. columnLabel: "报告文件名",
  149. columnHidden: false,
  150. columnImage: false,
  151. columnSortable: false,
  152. columnWidth: null,
  153. format: null,
  154. functionId: "this.$route.meta.menuId",
  155. sortLv: 0,
  156. status: true,
  157. fixed: '',
  158. serialNumber: null,
  159. columnType: null,
  160. align: null
  161. }, {
  162. tableId: "common1001",
  163. tableName: "common",
  164. columnProp: "Remark",
  165. columnLabel: "备注",
  166. columnHidden: false,
  167. columnImage: false,
  168. columnSortable: false,
  169. columnWidth: null,
  170. format: null,
  171. functionId: "this.$route.meta.menuId",
  172. sortLv: 0,
  173. status: true,
  174. fixed: '',
  175. serialNumber: null,
  176. columnType: null,
  177. align: null
  178. }, {
  179. tableId: "common1001",
  180. tableName: "common",
  181. columnProp: "DefaultFlag",
  182. columnLabel: "默认格式",
  183. columnHidden: false,
  184. columnImage: false,
  185. columnSortable: false,
  186. columnWidth: null,
  187. format: null,
  188. functionId: "this.$route.meta.menuId",
  189. sortLv: 0,
  190. status: true,
  191. fixed: '',
  192. serialNumber: null,
  193. columnType: null,
  194. align: null
  195. },
  196. ],
  197. // 打印参数
  198. printParamColumnList: [
  199. {
  200. tableId: "common1001",
  201. tableName: "common",
  202. columnProp: "parametername",
  203. columnLabel: "参数名",
  204. columnHidden: false,
  205. columnImage: false,
  206. columnSortable: false,
  207. columnWidth: null,
  208. format: null,
  209. functionId: "this.$route.meta.menuId",
  210. sortLv: 0,
  211. status: true,
  212. fixed: '',
  213. serialNumber: null,
  214. columnType: null,
  215. align: null
  216. }, {
  217. tableId: "common1001",
  218. tableName: "common",
  219. columnProp: "parameterdesc",
  220. columnLabel: "参数标题",
  221. columnHidden: false,
  222. columnImage: false,
  223. columnSortable: false,
  224. columnWidth: null,
  225. format: null,
  226. functionId: "this.$route.meta.menuId",
  227. sortLv: 0,
  228. status: true,
  229. fixed: '',
  230. serialNumber: null,
  231. columnType: null,
  232. align: null
  233. }, {
  234. tableId: "common1001",
  235. tableName: "common",
  236. columnProp: "optionvalue",
  237. columnLabel: "参数值",
  238. columnHidden: true,
  239. columnImage: false,
  240. columnSortable: false,
  241. columnWidth: null,
  242. format: null,
  243. functionId: "this.$route.meta.menuId",
  244. sortLv: 0,
  245. status: true,
  246. fixed: '',
  247. serialNumber: null,
  248. columnType: null,
  249. align: null
  250. }, {
  251. tableId: "common1001",
  252. tableName: "common",
  253. columnProp: "valuetype",
  254. columnLabel: "参数类型",
  255. columnHidden: false,
  256. columnImage: false,
  257. columnSortable: false,
  258. columnWidth: null,
  259. format: null,
  260. functionId: "this.$route.meta.menuId",
  261. sortLv: 0,
  262. status: true,
  263. fixed: '',
  264. serialNumber: null,
  265. columnType: null,
  266. align: null
  267. },
  268. ],
  269. // 数据
  270. // 可用模板列表
  271. reportFileList: [],
  272. // 选中模板列表
  273. selectReportFileList: [],
  274. selectReportString: '',
  275. // 数量
  276. orderInfo: {
  277. userName: this.$store.state.user.name,
  278. rollNo: '',
  279. customerId: '',
  280. totalQty: 0,
  281. perBoxQty: 0,
  282. boxQty: 0,
  283. lastBoxQty: 0,
  284. rollNos: [],
  285. // 选中模板列表
  286. reportFileList: [],
  287. // 手工参数
  288. param: []
  289. },
  290. // 记录打印参数
  291. printParamList: [],
  292. // 模板参数列表
  293. reportParamList: [],
  294. buttons: {
  295. settingLanguageList: '按语言设置',
  296. edit: '编辑',
  297. delete: '删除',
  298. deleteList: '批量删除',
  299. cz: '操作',
  300. search: '查询',
  301. download: '导出',
  302. settingTable: '设置列表',
  303. defaultTable: '设置默认配置',
  304. list: "列表",
  305. addList: '批量添加',
  306. settingLanguage: "按控件设置"
  307. },
  308. // 导出 end
  309. buttonList: [
  310. {
  311. functionId: "this.$route.meta.menuId",
  312. languageValue: '按语言设置',
  313. objectId: 'settingLanguageList',
  314. objectType: "button",
  315. tableId: "common1001"
  316. },
  317. {
  318. functionId: "this.$route.meta.menuId",
  319. languageValue: '编辑',
  320. objectId: 'edit',
  321. objectType: "button",
  322. tableId: "common1001"
  323. },
  324. {
  325. functionId: "this.$route.meta.menuId",
  326. languageValue: '删除',
  327. objectId: 'delete',
  328. objectType: "button",
  329. tableId: "common1001"
  330. },
  331. {
  332. functionId: "this.$route.meta.menuId",
  333. languageValue: '批量删除',
  334. objectId: 'deleteList',
  335. objectType: "button",
  336. tableId: "common1001"
  337. },
  338. {
  339. functionId: "this.$route.meta.menuId",
  340. languageValue: '操作',
  341. objectId: 'cz',
  342. objectType: "button",
  343. tableId: "common1001"
  344. },
  345. {
  346. functionId: "this.$route.meta.menuId",
  347. languageValue: '查询',
  348. objectId: 'search',
  349. objectType: "button",
  350. tableId: "common1001"
  351. },
  352. {
  353. functionId: "this.$route.meta.menuId",
  354. languageValue: '导出',
  355. objectId: 'download',
  356. objectType: "button",
  357. tableId: "common1001"
  358. },
  359. {
  360. functionId: "this.$route.meta.menuId",
  361. languageValue: '设置列表',
  362. objectId: 'settingTable',
  363. objectType: "button",
  364. tableId: "common1001"
  365. },
  366. {
  367. functionId: "this.$route.meta.menuId",
  368. languageValue: '设置默认配置',
  369. objectId: 'defaultTable',
  370. objectType: "button",
  371. tableId: "common1001"
  372. },
  373. {
  374. functionId: "this.$route.meta.menuId",
  375. languageValue: '列表',
  376. objectId: 'list',
  377. objectType: "button",
  378. tableId: "common1001"
  379. },
  380. {
  381. functionId: "this.$route.meta.menuId",
  382. languageValue: '按控件设置',
  383. objectId: 'settingLanguage',
  384. objectType: "button",
  385. tableId: "common1001"
  386. }
  387. ],
  388. }
  389. },
  390. watch: {
  391. orderInfo: {
  392. handler: function (val, oldVal) {
  393. if (this.orderInfo.totalQty > 0 && this.orderInfo.perBoxQty > 0) {
  394. this.orderInfo.lastBoxQty = this.decimalUtil.mod(this.orderInfo.totalQty, this.orderInfo.perBoxQty)
  395. if (this.decimalUtil.div(this.orderInfo.totalQty, this.orderInfo.perBoxQty) < 1) {
  396. this.orderInfo.boxQty = 1
  397. } else {
  398. this.orderInfo.boxQty = this.decimalUtil.formatDown(this.decimalUtil.div(this.orderInfo.totalQty, this.orderInfo.perBoxQty), 0)
  399. }
  400. }
  401. },
  402. // 深度观察监听
  403. deep: true
  404. },
  405. updateData: {
  406. deep: true,
  407. handler: function (newV, oldV) {
  408. this.updateData.projectID = this.updateData.projectID.toUpperCase();
  409. this.updateData.oriSOOrderNo = this.updateData.oriSOOrderNo.toUpperCase();
  410. this.updateData.orderType = this.updateData.orderType.toUpperCase();
  411. }
  412. }
  413. },
  414. mounted() {
  415. this.$nextTick(() => {
  416. this.height = window.innerHeight - 800;
  417. })
  418. },
  419. methods: {
  420. closeDialog() {
  421. this.visible = false
  422. this.selectReportString = ''
  423. this.reportParamList = []
  424. },
  425. init(val) {
  426. this.visible = true
  427. this.rollNos = val
  428. this.searchBoxLabelSO()
  429. },
  430. // 调用bartender打印
  431. bartenderPrint() {
  432. if (!this.rollNos) {
  433. this.$message.warning('请输入卷号')
  434. return
  435. }
  436. if (this.selectReportFileList.length === 0) {
  437. this.$message.warning('选择模板进行打印')
  438. return
  439. }
  440. // const loading = this.$loading({
  441. // lock: true,
  442. // text: '正在打印',
  443. // spinner: 'el-icon-loading',
  444. // background: 'rgba(0, 0, 0, 0.7)'
  445. // });
  446. let rollNoList = this.rollNos.split(";")
  447. this.orderInfo.reportFileList = this.selectReportFileList
  448. this.orderInfo.param = this.reportParamList
  449. this.orderInfo.rollNos = rollNoList
  450. this.printParamList = JSON.parse(JSON.stringify(this.reportParamList))
  451. printLabel(this.orderInfo).then(({data}) => {
  452. if (data.code === 0) {
  453. this.$message.success(data.msg)
  454. this.visible = false
  455. } else {
  456. this.$message.warning(data.msg)
  457. }
  458. // loading.close();
  459. })
  460. this.visible = false
  461. },
  462. // 获取订单信息
  463. searchBoxLabelSO() {
  464. if (!this.rollNos) {
  465. this.$message.warning('请输入卷号')
  466. return
  467. }
  468. let rollNoList = this.rollNos.split(";")
  469. this.reportFileList = []
  470. checkRollCustomer(rollNoList).then(({data}) => {
  471. if (data.code === 0) {
  472. getRollCustomer(rollNoList[0]).then(({data}) => {
  473. if (data.code === 0) {
  474. this.orderInfo.customerId = data.data.customerId ? data.data.customerId : '*'
  475. let query = {
  476. customerId: data.data.customerId ? data.data.customerId : '*',
  477. reportFamily: '卷标签'
  478. }
  479. getReportFileByCustomer(query).then(({data}) => {
  480. if (data.code === 0) {
  481. this.reportFileList = data.dataList
  482. this.$refs.reportFileTable.setCurrentRow(this.reportFileList[0]);
  483. } else {
  484. this.$message.warning(data.msg)
  485. Object.assign(this.$data, this.$options.data.call(this.orderInfo));
  486. Object.assign(this.$data, this.$options.data.call(this.selectReportString));
  487. Object.assign(this.$data, this.$options.data.call(this.reportParamList));
  488. }
  489. })
  490. } else {
  491. this.$message.warning(data.msg)
  492. }
  493. })
  494. } else {
  495. this.$message.warning(data.msg)
  496. }
  497. })
  498. },
  499. // 获取订单数数据 和 打印 模板数据
  500. getBoxSoAndReportFile() {
  501. this.searchBoxLabelSO()
  502. },
  503. handleClick() {
  504. },
  505. // 选择模板
  506. handleCurrentChange(val) {
  507. if (!val) return
  508. this.selectReportFileList = []
  509. let query = {
  510. reportId: val.reportid,
  511. defaultFlag: val.DefaultFlag,
  512. reportFile: val.Reportfile,
  513. reportFamily: '卷标签',
  514. customerId: this.orderInfo.customerId,
  515. }
  516. this.selectReportFileList.push(query)
  517. this.searchReportSubFileList(query)
  518. this.searchReportParameters(query)
  519. },
  520. // 获取子模版
  521. searchReportSubFileList(val) {
  522. let str = ''
  523. str += val.reportId + ' | ' + val.reportFile + '\n'
  524. this.selectReportString = str
  525. getReportSubFileList(val).then(({data}) => {
  526. if (data.code === 0) {
  527. for (let item of data.data) {
  528. str += item.reportid + ' | ' + item.Reportfile + '\n'
  529. let reportFile = {
  530. reportId: item.reportid,
  531. defaultFlag: 'Y',
  532. reportFile: item.Reportfile,
  533. reportFamily: '外箱标签',
  534. customerId: this.orderInfo.customerId,
  535. }
  536. this.selectReportFileList.push(reportFile)
  537. }
  538. this.selectReportString = str
  539. }
  540. })
  541. },
  542. // 获取柱模版打印参数
  543. searchReportParameters(val) {
  544. let printParamList = JSON.parse(JSON.stringify(this.printParamList))
  545. getReportParameters(val.reportId).then(({data}) => {
  546. if (data.code === 0) {
  547. this.reportParamList = data.data
  548. if (printParamList) {
  549. for (let item1 of printParamList) {
  550. for (let item2 of this.reportParamList) {
  551. if (item1.parametername === item2.parametername) {
  552. item2.optionvalue = item1.optionvalue
  553. }
  554. }
  555. }
  556. }
  557. }
  558. })
  559. },
  560. /*添加定制的css类*/
  561. customerCellClassName({row, column, rowIndex, columnIndex}) {
  562. if (columnIndex === 2) {
  563. return 'customer-text-cell';
  564. }
  565. },
  566. /*添加定制的cess样式*/
  567. customerCellStyle({row, column, rowIndex, columnIndex}) {
  568. if (columnIndex === 2) {
  569. return 'padding: 0px 0px;';
  570. }
  571. },
  572. },
  573. created() {
  574. }
  575. }
  576. </script>
  577. <style scoped>
  578. /deep/ .customer-tab .el-tabs__content {
  579. padding: 0px !important;
  580. }
  581. /deep/ .sl-el .el-tabs__item {
  582. padding: 0 13px;
  583. height: 26px;
  584. line-height: 26px;
  585. font-size: 12px;
  586. font-weight: 500;
  587. }
  588. /deep/ div.table-input {
  589. padding: 0px 0px;
  590. height: 25px !important;
  591. }
  592. /*table中input*/
  593. div.table-input /deep/ input.el-input__inner {
  594. padding: 0px 0px;
  595. height: 23px !important;
  596. text-align: right;
  597. }
  598. </style>