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.

630 lines
21 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <script>
  2. import ExternalPart from '../part/external.vue'
  3. import CustomerInfo from '../customer/info.vue'
  4. import {getPrintLabelRecordList, getPrintLabelRecordPage} from '../../../api/label/printLabelRecord'
  5. import { printAlphaHardTagLabel} from '../../../printFormat/alphaHardTagPrintFormat'
  6. import SelectionTable from '../../common/selectionTable.vue'
  7. import {getExternalPartPicturePartList} from '../../../api/part/externalPartPicture'
  8. import {printAntennaLabel} from '../../../printFormat/antenna'
  9. import {printRF_RFIDLabel} from '../../../printFormat/RF_RFID'
  10. import {
  11. getRollPrinterNameList,
  12. selectLabelFormatUserDefaultPrintListByUserId
  13. } from '../../../api/label/labelFormatUserDefault'
  14. import getLodop from '@/utils/LodopFuncs.js'
  15. import {getTableDefaultListLanguage, getTableUserListLanguage} from '../../../api/table'
  16. import {getPrintRollLabelRecord, getPrintRollLabelRecordPage} from '../../../api/label/printRollLabelRecord'
  17. import QrCode from './QrCode.vue'
  18. import {print_roll_label} from '../../../printFormat/roll_label'
  19. const printRecord = {
  20. customerNo: '',
  21. customerName: '',
  22. partNo: '',
  23. partDesc: '',
  24. startDate: '',
  25. endDate: ''
  26. }
  27. export default {
  28. name: 'roll',
  29. components: {QrCode, SelectionTable, CustomerInfo, ExternalPart},
  30. props: {
  31. height: {
  32. type: Number,
  33. default: 700
  34. }
  35. },
  36. data () {
  37. return {
  38. printerSetupList:[],
  39. customerVisible: false,
  40. partVisible: false,
  41. printRecord: {
  42. ...printRecord
  43. },
  44. no:1,
  45. size: 50,
  46. total: 0,
  47. printLabelRecordList: [],
  48. selectionPrintLabelRecordList: [],
  49. columnList: [
  50. {
  51. userId: this.$store.state.user.name,
  52. functionId: 30005,
  53. serialNumber: '30005TableRollNo',
  54. tableId: '30005Table',
  55. tableName: '发货标签记录表',
  56. columnProp: 'rollNo',
  57. headerAlign: 'center',
  58. align: 'left',
  59. columnLabel: 'Roll No',
  60. columnHidden: false,
  61. columnImage: false,
  62. columnSortable: false,
  63. sortLv: 10,
  64. status: true,
  65. fixed: '',
  66. columnWidth: 120
  67. }, {
  68. userId: this.$store.state.user.name,
  69. functionId: 30005,
  70. serialNumber: '30005TableCustomerNo',
  71. tableId: '30005Table',
  72. tableName: '发货标签记录表',
  73. columnProp: 'customerNo',
  74. headerAlign: 'center',
  75. align: 'left',
  76. columnLabel: 'Customer No',
  77. columnHidden: false,
  78. columnImage: false,
  79. columnSortable: false,
  80. sortLv: 10,
  81. status: true,
  82. fixed: '',
  83. columnWidth: 100
  84. }, {
  85. userId: this.$store.state.user.name,
  86. functionId: 30005,
  87. serialNumber: '30005TableCustomerName',
  88. tableId: '30005Table',
  89. tableName: '发货标签记录表',
  90. columnProp: 'customerName',
  91. headerAlign: 'center',
  92. align: 'left',
  93. columnLabel: 'Customer Name',
  94. columnHidden: false,
  95. columnImage: false,
  96. columnSortable: false,
  97. sortLv: 10,
  98. status: true,
  99. fixed: '',
  100. columnWidth: 120
  101. }, {
  102. userId: this.$store.state.user.name,
  103. functionId: 30005,
  104. serialNumber: '30005TablePartNo',
  105. tableId: '30005Table',
  106. tableName: '发货标签记录表',
  107. columnProp: 'partNo',
  108. headerAlign: 'center',
  109. align: 'left',
  110. columnLabel: 'Part No',
  111. columnHidden: false,
  112. columnImage: false,
  113. columnSortable: false,
  114. sortLv: 10,
  115. status: true,
  116. fixed: '',
  117. columnWidth: 120
  118. }, {
  119. userId: this.$store.state.user.name,
  120. functionId: 30005,
  121. serialNumber: '30005TablePartDesc',
  122. tableId: '30005Table',
  123. tableName: '发货标签记录表',
  124. columnProp: 'partDesc',
  125. headerAlign: 'center',
  126. align: 'left',
  127. columnLabel: 'Part Description',
  128. columnHidden: false,
  129. columnImage: false,
  130. columnSortable: false,
  131. sortLv: 10,
  132. status: true,
  133. fixed: '',
  134. columnWidth: 120
  135. }, {
  136. userId: this.$store.state.user.name,
  137. functionId: 30005,
  138. serialNumber: '30005TableQtyPerRoll',
  139. tableId: '30005Table',
  140. tableName: '发货标签记录表',
  141. columnProp: 'qtyPerRoll',
  142. headerAlign: 'center',
  143. align: 'right',
  144. columnLabel: 'Qty Per Roll',
  145. columnHidden: false,
  146. columnImage: false,
  147. columnSortable: false,
  148. sortLv: 10,
  149. status: true,
  150. fixed: '',
  151. columnWidth: 120
  152. }, {
  153. userId: this.$store.state.user.name,
  154. functionId: 30005,
  155. serialNumber: '30005TableTotalShipQty',
  156. tableId: '30005Table',
  157. tableName: '发货标签记录表',
  158. columnProp: 'totalShipQty',
  159. headerAlign: 'center',
  160. align: 'right',
  161. columnLabel: 'Total Ship Qty',
  162. columnHidden: false,
  163. columnImage: false,
  164. columnSortable: false,
  165. sortLv: 10,
  166. status: true,
  167. fixed: '',
  168. columnWidth: 120
  169. }, {
  170. userId: this.$store.state.user.name,
  171. functionId: 30005,
  172. serialNumber: '30005TableCartonCount',
  173. tableId: '30005Table',
  174. tableName: '发货标签记录表',
  175. columnProp: 'cartonCount',
  176. headerAlign: 'center',
  177. align: 'right',
  178. columnLabel: 'Roll Count',
  179. columnHidden: false,
  180. columnImage: false,
  181. columnSortable: false,
  182. sortLv: 10,
  183. status: true,
  184. fixed: '',
  185. columnWidth: 120
  186. }, {
  187. userId: this.$store.state.user.name,
  188. functionId: 30005,
  189. serialNumber: '30005TableSerialNumber',
  190. tableId: '30005Table',
  191. tableName: '发货标签记录表',
  192. columnProp: 'serialNumber',
  193. headerAlign: 'center',
  194. align: 'left',
  195. columnLabel: 'Serial Number',
  196. columnHidden: false,
  197. columnImage: false,
  198. columnSortable: false,
  199. sortLv: 10,
  200. status: true,
  201. fixed: '',
  202. columnWidth: 120
  203. }, {
  204. userId: this.$store.state.user.name,
  205. functionId: 30005,
  206. serialNumber: '30005TableManufacturerNo',
  207. tableId: '30005Table',
  208. tableName: '发货标签记录表',
  209. columnProp: 'manufacturerNo',
  210. headerAlign: 'center',
  211. align: 'left',
  212. columnLabel: 'Manufacturer',
  213. columnHidden: false,
  214. columnImage: false,
  215. columnSortable: false,
  216. sortLv: 10,
  217. status: true,
  218. fixed: '',
  219. columnWidth: 120
  220. }, {
  221. userId: this.$store.state.user.name,
  222. functionId: 30005,
  223. serialNumber: '30005TableMoldCode',
  224. tableId: '30005Table',
  225. tableName: '发货标签记录表',
  226. columnProp: 'moldCode',
  227. headerAlign: 'center',
  228. align: 'left',
  229. columnLabel: 'Mold Code',
  230. columnHidden: false,
  231. columnImage: false,
  232. columnSortable: false,
  233. sortLv: 10,
  234. status: true,
  235. fixed: '',
  236. columnWidth: 120
  237. }, {
  238. userId: this.$store.state.user.name,
  239. functionId: 30005,
  240. serialNumber: '30005TableManufacturerDate',
  241. tableId: '30005Table',
  242. tableName: '发货标签记录表',
  243. columnProp: 'manufacturerDate',
  244. headerAlign: 'center',
  245. align: 'left',
  246. columnLabel: 'Manufacturer Date',
  247. columnHidden: false,
  248. columnImage: false,
  249. columnSortable: false,
  250. sortLv: 10,
  251. status: true,
  252. fixed: '',
  253. columnWidth: 120
  254. }, {
  255. userId: this.$store.state.user.name,
  256. functionId: 30005,
  257. serialNumber: '30005TableCreateBy',
  258. tableId: '30005Table',
  259. tableName: '发货标签记录表',
  260. columnProp: 'createBy',
  261. headerAlign: 'center',
  262. align: 'left',
  263. columnLabel: 'Created By',
  264. columnHidden: false,
  265. columnImage: false,
  266. columnSortable: false,
  267. sortLv: 10,
  268. status: true,
  269. fixed: '',
  270. columnWidth: 120
  271. }, {
  272. userId: this.$store.state.user.name,
  273. functionId: 30005,
  274. serialNumber: '30005TableCreateTime',
  275. tableId: '30005Table',
  276. tableName: '发货标签记录表',
  277. columnProp: 'createTime',
  278. headerAlign: 'center',
  279. align: 'left',
  280. columnLabel: 'CreateTime',
  281. columnHidden: false,
  282. columnImage: false,
  283. columnSortable: false,
  284. sortLv: 10,
  285. status: true,
  286. fixed: '',
  287. columnWidth: 140
  288. }
  289. ],
  290. }
  291. },
  292. watch:{
  293. "printRecord.customerNo"(newVal, oldVal){
  294. this.printRecord.customerNo = newVal.toUpperCase();
  295. },
  296. "printRecord.partNo"(newVal, oldVal){
  297. this.printRecord.partNo = newVal.toUpperCase();
  298. }
  299. },
  300. methods: {
  301. handlePartRowClick (row) {
  302. this.printRecord.partNo = row.partNo
  303. this.partVisible = false
  304. },
  305. handleCustomerRowClick (row) {
  306. this.printRecord.customerNo = row.customerNo
  307. this.customerVisible = false
  308. },
  309. getPrintLabelRecordList () {
  310. let params = {
  311. ...this.printRecord,
  312. site: this.$store.state.user.site,
  313. }
  314. getPrintRollLabelRecordPage(params,this.no,this.size).then(({data}) => {
  315. if (data && data.code === 0) {
  316. this.printLabelRecordList = data.rows
  317. this.total = data.total
  318. } else {
  319. this.$message.warning(data.message)
  320. }
  321. }).catch((error) => {
  322. this.$message.error(error.message)
  323. })
  324. },
  325. handleSelectionChange (val) {
  326. this.selectionPrintLabelRecordList = val
  327. },
  328. async handlePrintLabel () {
  329. if (this.selectionPrintLabelRecordList.length === 0) {
  330. this.$message.warning('please select record')
  331. return
  332. }
  333. let ids = this.selectionPrintLabelRecordList.map((item) => {
  334. return item.id
  335. })
  336. getPrintRollLabelRecord(ids).then(({data})=>{
  337. if (data && data.code === 0){
  338. this.handlePrint(data.rows)
  339. }else {
  340. this.$message.warning(data.msg)
  341. }
  342. }).catch((error)=>{
  343. this.$message.error(error.message)
  344. })
  345. },
  346. handlePrint(list){
  347. let params = list.map((item) => {
  348. return {
  349. site:item.site,
  350. partNo:item.partNo,
  351. customerNo:item.customerNo,
  352. username:this.$store.state.user.name,
  353. rollNo:item.rollNo,
  354. category:item.category,
  355. }
  356. })
  357. getRollPrinterNameList(params).then(({data})=>{
  358. if (data && data.code === 0){
  359. for (let i = 0; i < this.selectionPrintLabelRecordList.length; i++) {
  360. let record = this.selectionPrintLabelRecordList[i]
  361. let printerNameList = data.rows[i].filter((item)=> item.labelType === 'Roll Label')
  362. let arr = []
  363. arr.push(record)
  364. for (let j = 0; j < printerNameList.length; j++) {
  365. arr = arr.map((item)=>{
  366. return {
  367. qrCode: `(00)${item.partNo}(01)${item.qtyPerRoll}(02)${item.umName}(03)${item.manufacturerDate}(04)${item.serialNumber? item.serialNumber : ''}(05)${item.manufacturerNo? item.manufacturerNo : ''}(06)${item.moldCode? item.moldCode : ''}(07)(08)${item.rollNo}`,
  368. ref: item.partNo,
  369. rev: item.rev,
  370. qty: item.qtyPerRoll,
  371. uom: item.umName,
  372. desc: item.partDesc,
  373. date: item.manufacturerDate,
  374. manufacturer: item.manufacturerNo,
  375. moldCode: item.moldCode,
  376. rollNo: item.rollNo,
  377. sn: item.serialNumber,
  378. rollLabelRequired: item.rollLabelRequired,
  379. serialNumberRequired: item.serialNumberRequired,
  380. serialNumber: item.serialNumber,
  381. }
  382. })
  383. let qrCodeList = this.$refs.qrCode.init(arr.map((item)=>{
  384. return item.qrCode
  385. }))
  386. for (let i = 0; i < qrCodeList.length; i++) {
  387. arr[i].qrCode = qrCodeList[i]
  388. }
  389. print_roll_label(arr,printerNameList[j].defaultPrinterName)
  390. }
  391. this.$message.success(data.msg)
  392. }
  393. }else {
  394. this.$message.warning(data.msg)
  395. }
  396. }).catch((error)=>{
  397. this.$message.error(error.message)
  398. })
  399. },
  400. printLabel(pictureList,formatList){
  401. let prints = this.selectionPrintLabelRecordList.map((item) => {
  402. return {
  403. qrCode: `(00)${item.partNo}(01)${item.qtyPerCarton}(02)${item.umName}(03)${item.manufacturerDate}(04)${item.serialNumber}(05)${item.manufacturerNo}(06)${item.moldCode}(07)${item.boxNo}(08)`,
  404. ref: item.partNo,
  405. qty: item.qtyPerCarton,
  406. productRev: item.rev,
  407. uom: item.umName,
  408. desc: item.partDesc,
  409. rollCount: item.qtyPerRoll,
  410. date: item.manufacturerDate,
  411. manufacturer: item.manufacturerNo,
  412. moldCode: item.moldCode,
  413. sn: item.serialNumber,
  414. }
  415. })
  416. let notFound = [];
  417. for (let i = 0; i < prints.length; i++) {
  418. let print = prints[i]
  419. let dataList = []
  420. dataList.push(print);
  421. // 获取模板数量
  422. let format = formatList[i]
  423. let base64List = pictureList[i].map((item)=>{return {icon:item}})
  424. for (let formatElement of format) {
  425. let str = formatElement.split('(type)')
  426. if (!this.printerSetupList.includes(str[0])) {
  427. if (notFound.includes(str[0])){
  428. continue
  429. }
  430. notFound.push(str[0])
  431. continue
  432. }
  433. if (str[1] === 'Alpha/Hard Tag'){
  434. printAlphaHardTagLabel(dataList,base64List,str[0])
  435. }else if (str[1] === 'Hardware(Antenna)'){
  436. printAntennaLabel(dataList,base64List,str[0])
  437. }else if (str[1] === 'RF' || str[1] === 'RFID'){
  438. printRF_RFIDLabel(dataList,base64List,str[0])
  439. }
  440. }
  441. }
  442. this.$refs.table.clearSelection()
  443. if (notFound.length > 0){
  444. this.$message.warning(`The printer ${notFound.join(',')} is not found`)
  445. }else {
  446. this.$message.success("Print label success")
  447. }
  448. },
  449. handleSizeChange(val){
  450. this.size = val
  451. this.getPrintLabelRecordList()
  452. },
  453. handleCurrentChange(val){
  454. this.no = val
  455. this.getPrintLabelRecordList()
  456. },
  457. async getTableUserColumn (tableId, columnId) {
  458. let queryTableUser = {
  459. userId: this.$store.state.user.name,
  460. functionId: this.$route.meta.menuId,
  461. tableId: tableId,
  462. status: true,
  463. languageCode: this.$i18n.locale
  464. }
  465. await getTableUserListLanguage(queryTableUser).then(({data}) => {
  466. if (data.rows.length > 0) {
  467. this.caseTable(data.rows,columnId)
  468. } else {
  469. this.getColumnList(tableId, columnId)
  470. }
  471. })
  472. },
  473. // 获取 tableDefault 列
  474. async getColumnList (tableId, columnId) {
  475. let queryTable = {
  476. functionId: this.$route.meta.menuId,
  477. tableId: tableId,
  478. languageCode: this.$i18n.locale
  479. }
  480. await getTableDefaultListLanguage(queryTable).then(({data}) => {
  481. if (!data.rows.length === 0) {
  482. this.caseTable(data.rows,columnId)
  483. } else {
  484. }
  485. })
  486. },
  487. caseTable(list,columnId){
  488. if (list.length > 0){
  489. switch (columnId) {
  490. case 1:
  491. this.columnList = list
  492. break;
  493. }
  494. }
  495. },
  496. },
  497. mounted () {
  498. const lodop = getLodop()
  499. for (let i = 0; i < lodop.GET_PRINTER_COUNT(); i++) {
  500. this.printerSetupList.push(lodop.GET_PRINTER_NAME(i))
  501. }
  502. },
  503. created () {
  504. // this.getPrintLabelRecordList()
  505. this.getTableUserColumn('30006Table',1)
  506. },
  507. }
  508. </script>
  509. <template>
  510. <div>
  511. <div style="min-width: 600px;max-width: 1000px">
  512. <el-form :model="printRecord" label-position="top">
  513. <el-row :gutter="20">
  514. <el-col :span="4">
  515. <el-form-item label="Customer No">
  516. <span slot="label" style="cursor:pointer;" @click="customerVisible=true"><a
  517. herf="#">Customer No</a></span>
  518. <el-input v-model="printRecord.customerNo" clearable></el-input>
  519. </el-form-item>
  520. </el-col>
  521. <el-col :span="7">
  522. <el-form-item label="Customer Name">
  523. <el-input v-model="printRecord.customerName" clearable></el-input>
  524. </el-form-item>
  525. </el-col>
  526. <el-col :span="8">
  527. <el-row>
  528. <el-col :span="11">
  529. <el-form-item label="Created Time">
  530. <el-date-picker
  531. v-model="printRecord.startDate"
  532. style="width: 100%;"
  533. type="date"
  534. placeholder=" ">
  535. </el-date-picker>
  536. </el-form-item>
  537. </el-col>
  538. <el-col :span="2">
  539. <el-form-item label=" ">
  540. <div style="text-align: center"><i class="el-icon-right"></i></div>
  541. </el-form-item>
  542. </el-col>
  543. <el-col :span="11">
  544. <el-form-item label=" ">
  545. <el-date-picker
  546. v-model="printRecord.endDate"
  547. style="width: 100%;"
  548. type="date"
  549. placeholder=" ">
  550. </el-date-picker>
  551. </el-form-item>
  552. </el-col>
  553. </el-row>
  554. </el-col>
  555. </el-row>
  556. <el-row :gutter="20">
  557. <el-col :span="4">
  558. <el-form-item label="Part No">
  559. <span slot="label" style="cursor:pointer;" @click="partVisible=true"><a herf="#">Part No</a></span>
  560. <el-input v-model="printRecord.partNo" clearable></el-input>
  561. </el-form-item>
  562. </el-col>
  563. <el-col :span="7">
  564. <el-form-item label="Part Description">
  565. <el-input v-model="printRecord.partDesc" clearable></el-input>
  566. </el-form-item>
  567. </el-col>
  568. <el-col :span="6">
  569. <el-form-item label=" ">
  570. <el-button type="primary" style="width: 60px" @click="getPrintLabelRecordList">Query</el-button>
  571. <el-button type="primary" style="width: 60px" @click="handlePrintLabel">Print</el-button>
  572. </el-form-item>
  573. </el-col>
  574. </el-row>
  575. </el-form>
  576. </div>
  577. <el-table :data="printLabelRecordList" ref="table" @selection-change="handleSelectionChange"
  578. style="width: 100%;margin-top: 10px" border :height="height">
  579. <el-table-column type="selection" width="55" fixed="left" align="center"></el-table-column>
  580. <el-table-column
  581. v-for="(item,index) in columnList" :key="index"
  582. :sortable="item.columnSortable"
  583. :prop="item.columnProp"
  584. :header-align="item.headerAlign"
  585. :show-overflow-tooltip="item.showOverflowTooltip"
  586. :align="item.align"
  587. :fixed="item.fixed===''?false:item.fixed"
  588. :min-width="item.columnWidth"
  589. :label="item.columnLabel">
  590. <template slot-scope="scope">
  591. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  592. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  593. style="width: 100px; height: 80px"/></span>
  594. </template>
  595. </el-table-column>
  596. </el-table>
  597. <div>
  598. <selection-table :size="selectionPrintLabelRecordList.length" :total="total"></selection-table>
  599. <el-pagination
  600. @size-change="handleSizeChange"
  601. @current-change="handleCurrentChange"
  602. :current-page.sync="no"
  603. :page-sizes="[50,100, 200, 300, 400]"
  604. :page-size="size"
  605. layout="sizes, prev, pager, next"
  606. :total="total">
  607. </el-pagination>
  608. </div>
  609. <qr-code ref="qrCode"></qr-code>
  610. <el-dialog v-drag title="Select Part" :close-on-click-modal="false" :visible.sync="partVisible">
  611. <external-part :height="450" :of-components="true" @rowClick="handlePartRowClick"></external-part>
  612. <div slot="footer" style="text-align: center; margin-top: 10px"></div>
  613. </el-dialog>
  614. <el-dialog v-drag title="Select Customer" :close-on-click-modal="false" :visible.sync="customerVisible">
  615. <customer-info :height="450" :of-components="true" @rowClick="handleCustomerRowClick"></customer-info>
  616. <div slot="footer" style="text-align: center; margin-top: 10px"></div>
  617. </el-dialog>
  618. </div>
  619. </template>
  620. <style scoped>
  621. </style>