赫艾前端
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.

575 lines
20 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <script>
  2. import {
  3. checkIsPacking,
  4. getPackagePrintDataList,
  5. getSOScheduleRoutingDataPrint,
  6. linkWeighTPC,
  7. closeWeighTPC,
  8. reLinkWeighTPC,
  9. getTCPPackagePrintDataList,
  10. } from "../../../api/production/generateReport";
  11. import {
  12. getPhotoAddressData
  13. } from '@/api/pad.js'
  14. import {printTCPPackageLabelNoPreview} from "../print/print_package_TCPlabel-NOOREVIEW";
  15. import {printPackageLabelNoPreview} from '../print/print_package_label-NOOREVIEW'
  16. export default {
  17. data() {
  18. return {
  19. searchData: {
  20. seqNo: undefined,
  21. flag: '',
  22. },
  23. number: 1,
  24. flag: false,
  25. soScheduleRouting: {},
  26. picData: {
  27. site: '',
  28. partNo: '',
  29. },
  30. fileTitle: "文件名 (" + 0 + "/" + 0 + ")",
  31. fileName: '',
  32. num: 1,
  33. currentData: '',
  34. photoDatas: [],
  35. uploadImg: [],
  36. showviewer: false,
  37. url: '',
  38. photoUrl: '',
  39. scanTime:'',
  40. scheduleJob:'',
  41. nowTime:'',
  42. weight:undefined,
  43. }
  44. },
  45. mounted() {
  46. this.$refs.focusInput.focus()
  47. window.addEventListener('beforeunload', this.handleBeforeUnload);
  48. },
  49. activated() {
  50. this.$refs.focusInput.focus()
  51. },
  52. beforeDestroy(){
  53. this.closeWeighTPC();
  54. window.removeEventListener('beforeunload', this.handleBeforeUnload);
  55. this.stopSchedule();
  56. },
  57. computed: {
  58. seqNo: function () {
  59. return this.searchData.seqNo;
  60. }
  61. },
  62. watch: {
  63. flag(newVal,oldVal){
  64. if (newVal === false){
  65. this.number = undefined
  66. this.weight = undefined
  67. }
  68. }
  69. },
  70. methods: {
  71. handleBeforeUnload() {
  72. this.closeWeighTPC();
  73. },
  74. selectBySeqNo() {
  75. // 查询数据
  76. this.getSOScheduleRoutingData();
  77. },
  78. getSOScheduleRoutingData() {
  79. if (!this.searchData.seqNo) {
  80. this.$message.warning("派工单号为空")
  81. return
  82. }
  83. let params = {
  84. seqNo: this.searchData.seqNo,
  85. userId: this.$store.state.user.name
  86. };
  87. getSOScheduleRoutingDataPrint(params).then(({data}) => {
  88. if (data && data.code === 0) {
  89. if (data.total === 0) {
  90. this.$message.warning("派工单不存在")
  91. return;
  92. } else if (data.total === 1) {
  93. this.soScheduleRouting = data.rows[0];
  94. this.checkIsPacking()
  95. } else {
  96. this.soScheduleRouting = data.rows.find((item) => item.site === this.$store.state.user.site && item.seqNo === this.searchData.seqNo)
  97. this.checkIsPacking()
  98. }
  99. // console.log(data.rows[0].nowTime)
  100. this.nowTime= data.rows[0].nowTime
  101. if (data.row) {
  102. this.soScheduleRouting.qtyBag = data.row[0].qtyBag
  103. this.soScheduleRouting.bag = data.row[0].bag
  104. this.soScheduleRouting.qty = data.row[0].qty
  105. this.soScheduleRouting.carton = data.row[0].carton
  106. }
  107. if (data.data) {
  108. this.soScheduleRouting.sScheduledDate2 = data.data.sScheduledDate;
  109. this.soScheduleRouting.operatorName2 = data.data.operatorName;
  110. this.soScheduleRouting.approveQty2 = data.data.qtyApprove;
  111. }
  112. linkWeighTPC(params).then(({data}) => {
  113. if (data && data.code === 0) {
  114. } else {
  115. this.$message.error(data.msg)
  116. // this.cleanAll()
  117. }
  118. }).catch((error) => {
  119. this.$message.error(error)
  120. // this.cleanAll()
  121. })
  122. this.scheduleJob = setInterval(() => {
  123. this.printTCPLabel();
  124. }, 2000);
  125. } else {
  126. this.$message.warning(data.msg)
  127. this.cleanAll()
  128. }
  129. }).catch((error) => {
  130. this.cleanAll()
  131. this.$message.error(error);
  132. })
  133. },
  134. linkTPC(){
  135. let params = {
  136. nowTime:this.nowTime,
  137. previousSeqNo: this.soScheduleRouting.previousSeqNo,
  138. site: this.soScheduleRouting.site,
  139. orderNo: this.soScheduleRouting.orderNo,
  140. }
  141. linkWeighTPC(params).then(({data}) => {
  142. if (data && data.code === 0) {
  143. this.$message.success("称重器连接成功!")
  144. } else {
  145. this.$message.error(data.msg)
  146. // this.cleanAll()
  147. }
  148. }).catch((error) => {
  149. this.$message.error(error)
  150. // this.cleanAll()
  151. })
  152. },
  153. printTCPLabel(){
  154. if (!this.soScheduleRouting.site) {
  155. return false
  156. }
  157. if (this.nowTime==''||this.nowTime==null) {
  158. return false
  159. }
  160. console.log(this.soScheduleRouting.qtyBag)
  161. if (this.soScheduleRouting.qtyBag === null || this.soScheduleRouting.qtyBag === undefined) {
  162. return false
  163. }
  164. let params = {
  165. nowTime:this.nowTime,
  166. previousSeqNo: this.soScheduleRouting.previousSeqNo,
  167. site: this.soScheduleRouting.site,
  168. orderNo: this.soScheduleRouting.orderNo,
  169. }
  170. if (!params) {
  171. return
  172. }
  173. getTCPPackagePrintDataList(params).then(({data}) => {
  174. if (data && data.code === 0) {
  175. if(data.rows.length>0){
  176. if(this.flag){
  177. this.weight=data.rows[0].tcpValue
  178. }else {
  179. printTCPPackageLabelNoPreview(data.rows);
  180. }
  181. }
  182. this.searchData.flag = '';
  183. } else {
  184. this.$message.warning(data.msg)
  185. }
  186. }).catch((error) => {
  187. this.$message.error(error)
  188. })
  189. },
  190. stopSchedule() {
  191. if (this.scheduleJob) {
  192. clearInterval(this.scheduleJob); // 使用 clearInterval 来清除定时任务
  193. this.scheduleJob = null; // 将 scheduleJob 置为 null,表示没有活动的定时任务
  194. }
  195. },
  196. cleanAll() {
  197. Object.keys(this.soScheduleRouting).forEach(key => {
  198. this.soScheduleRouting[key] = '';
  199. });
  200. Object.keys(this.picData).forEach(key => {
  201. this.picData[key] = '';
  202. });
  203. this.fileName = null;
  204. this.fileTitle = "文件名 (" + 0 + "/" + 0 + ")";
  205. this.photoUrl = null;
  206. // this.scanTime= '';
  207. // this.closeWeighTPC();
  208. this.nowTime='';
  209. this.stopSchedule()
  210. },
  211. closeWeighTPC(){
  212. this.scanTime= '';
  213. let data={
  214. site:'1'
  215. }
  216. closeWeighTPC(data).then(({data}) => {
  217. })
  218. this.cleanAll()
  219. this.searchData.seqNo=undefined;
  220. },
  221. checkIsPacking() {
  222. let params = {
  223. site: this.soScheduleRouting.site,
  224. workCenterNo: this.soScheduleRouting.sWorkCenterNo,
  225. }
  226. checkIsPacking(params).then(({data}) => {
  227. if (data && data.code === 0) {
  228. this.getData(this.soScheduleRouting.site, this.soScheduleRouting.partNo)
  229. } else {
  230. this.getData('', '')
  231. this.soScheduleRouting = {};
  232. this.$message.warning(data.msg)
  233. this.searchData = {
  234. seqNo: undefined,
  235. flag: '',
  236. }
  237. }
  238. }).catch((error) => {
  239. this.$message.error(error)
  240. this.searchData = {
  241. seqNo: undefined,
  242. flag: '',
  243. }
  244. this.soScheduleRouting = {};
  245. })
  246. },
  247. printLabel() {
  248. if (!this.soScheduleRouting.site) {
  249. this.$message.warning("请先扫描派工单号")
  250. return
  251. }
  252. this.searchData.flag = 'Y'
  253. this.flag = true
  254. },
  255. printPackageLabelNoPreview() {
  256. let params = {
  257. previousSeqNo: this.soScheduleRouting.previousSeqNo,
  258. site: this.soScheduleRouting.site,
  259. orderNo: this.soScheduleRouting.orderNo
  260. }
  261. if (!this.number || !this.weight){
  262. this.$message.warning("请先输入数量和重量")
  263. return
  264. }
  265. params.number = this.number;
  266. // 发起请求
  267. getPackagePrintDataList(params).then(({data}) => {
  268. if (data && data.code === 0) {
  269. data.rows[0].tcpValue=this.weight
  270. printTCPPackageLabelNoPreview(data.rows);
  271. this.searchData.flag = '';
  272. this.flag = false
  273. } else {
  274. this.$message.warning(data.msg)
  275. }
  276. }).catch((error) => {
  277. this.$message.error(error)
  278. })
  279. },
  280. getData(site, partNo) {
  281. this.picData.partNo = partNo;
  282. this.picData.site = site;
  283. this.getPhoto();
  284. },
  285. getPhoto() {
  286. getPhotoAddressData(this.picData).then(({data}) => {
  287. this.photoDatas = data.rows;
  288. if (this.photoDatas.length == 0) {
  289. this.fileTitle = "文件名 (" + 0 + "/" + 0 + ")";
  290. this.photoUrl = null;
  291. return false;
  292. }
  293. this.fileName = this.photoDatas[this.num - 1].attaFileNameDb;
  294. this.fileTitle = "文件名 (" + this.num + "/" + this.photoDatas.length + ")";
  295. this.photoUrl = this.$store.state.user.padSopUrl + this.photoDatas[this.num - 1].attaFileNameDb;
  296. // this.photoUrl='http://192.168.1.83:81/upload/'+this.photoDatas[this.num-1].attaFileNameDb;
  297. })
  298. },
  299. nextPicture() {
  300. if (this.photoDatas.length == 0) {
  301. this.fileTitle = "文件名 (" + 0 + "/" + 0 + ")";
  302. this.$alert('该物料没有上传图片!', '错误', {
  303. confirmButtonText: '确定'
  304. })
  305. return false;
  306. }
  307. if (this.num == this.photoDatas.length) {
  308. this.num = 1;
  309. } else {
  310. this.num = this.num + 1;
  311. }
  312. this.fileName = this.photoDatas[this.num - 1].attaFileNameDb;
  313. this.fileTitle = "文件名 (" + this.num + "/" + this.photoDatas.length + ")";
  314. this.photoUrl = this.$store.state.user.padSopUrl + this.photoDatas[this.num - 1].attaFileNameDb;
  315. // this.photoUrl='http://192.168.1.83:81/upload/'+this.photoDatas[this.num-1].attaFileNameDb;
  316. },
  317. lastPicture() {
  318. if (this.photoDatas.length == 0) {
  319. this.fileTitle = "文件名 (" + 0 + "/" + 0 + ")";
  320. this.$alert('该物料没有上传图片!', '错误', {
  321. confirmButtonText: '确定'
  322. })
  323. return false;
  324. }
  325. if (this.num == 1) {
  326. this.num = this.photoDatas.length;
  327. } else {
  328. this.num = this.num - 1;
  329. }
  330. this.fileName = this.photoDatas[this.num - 1].attaFileNameDb;
  331. this.fileTitle = "文件名 (" + this.num + "/" + this.photoDatas.length + ")";
  332. this.photoUrl = this.$store.state.user.padSopUrl + this.photoDatas[this.num - 1].attaFileNameDb;
  333. // this.photoUrl='http://192.168.1.83:81/upload/'+this.photoDatas[this.num-1].attaFileNameDb;
  334. },
  335. },
  336. }
  337. </script>
  338. <template>
  339. <div style="padding: 5px">
  340. <el-form size="medium" class="title" :model="seqNo" label-position="top" :inline="true" @submit.native.prevent>
  341. <el-form-item label="派工单号">
  342. <el-input-number size="medium" style="width: 100%;margin-top: -5px;" :controls="false" ref="focusInput" :min="0"
  343. v-model="searchData.seqNo" @keyup.enter.native="selectBySeqNo"></el-input-number>
  344. </el-form-item>
  345. <!-- <el-form-item label=" ">-->
  346. <!-- <el-select v-model="searchData.flag" clearable>-->
  347. <!-- <el-option value="" label="标准袋数"></el-option>-->
  348. <!-- <el-option value="Y" label="零数袋"></el-option>-->
  349. <!-- </el-select>-->
  350. <!-- </el-form-item>-->
  351. <el-form-item label=" ">
  352. <!-- <el-button type="primary" @click="printLabel">打印标签</el-button>-->
  353. <!-- <el-button type="primary" @click="linkTPC()">重连设备</el-button>-->
  354. <el-button type="primary" @click="closeWeighTPC()">取消连接</el-button>
  355. <el-button type="primary" style="width: 120px" @click="printLabel">手工打印零数标签</el-button>
  356. </el-form-item>
  357. </el-form>
  358. <div class="content">
  359. <el-card style="height: 800px;margin-top: 20px">
  360. <el-form :model="soScheduleRouting" label-position="top">
  361. <el-row :gutter="20">
  362. <el-col :span="6">
  363. <el-form-item label="派工单号">
  364. <el-input v-model="soScheduleRouting.seqNo" readonly></el-input>
  365. </el-form-item>
  366. </el-col>
  367. <el-col :span="6">
  368. <el-form-item label="工厂编码">
  369. <el-input v-model="soScheduleRouting.site" readonly></el-input>
  370. </el-form-item>
  371. </el-col>
  372. <el-col :span="6">
  373. <el-form-item label="生产订单号">
  374. <el-input v-model="soScheduleRouting.orderNo" readonly></el-input>
  375. </el-form-item>
  376. </el-col>
  377. <el-col :span="6">
  378. <el-form-item label=" ">
  379. </el-form-item>
  380. </el-col>
  381. <el-col :span="6">
  382. <el-form-item label="产品编码">
  383. <el-input v-model="soScheduleRouting.partNo" readonly></el-input>
  384. </el-form-item>
  385. </el-col>
  386. <el-col :span="6">
  387. <el-form-item label="产品名称">
  388. <el-input v-model="soScheduleRouting.partDesc" readonly></el-input>
  389. </el-form-item>
  390. </el-col>
  391. <el-col :span="6">
  392. <el-form-item label="派工单类型">
  393. <el-input v-model="soScheduleRouting.scheduleType" readonly></el-input>
  394. </el-form-item>
  395. </el-col>
  396. <el-col :span="6">
  397. <el-form-item label="派工日期">
  398. <el-input v-model="soScheduleRouting.sScheduledDate" readonly></el-input>
  399. </el-form-item>
  400. </el-col>
  401. <el-col :span="6">
  402. <el-form-item label="检验工单号">
  403. <el-input v-model="soScheduleRouting.previousSeqNo" readonly></el-input>
  404. </el-form-item>
  405. </el-col>
  406. <el-col :span="6">
  407. <el-form-item label="检验日期">
  408. <el-input v-model="soScheduleRouting.sScheduledDate2" readonly></el-input>
  409. </el-form-item>
  410. </el-col>
  411. <el-col :span="6">
  412. <el-form-item label="检验员">
  413. <el-input v-model="soScheduleRouting.operatorName2" readonly></el-input>
  414. </el-form-item>
  415. </el-col>
  416. <el-col :span="6">
  417. <el-form-item label="检验合格数量">
  418. <el-input v-model="soScheduleRouting.approveQty2" readonly></el-input>
  419. </el-form-item>
  420. </el-col>
  421. <el-col :span="6">
  422. <el-form-item label="工序号">
  423. <el-input v-model="soScheduleRouting.itemNo" readonly></el-input>
  424. </el-form-item>
  425. </el-col>
  426. <el-col :span="6">
  427. <el-form-item label="工序名称">
  428. <el-input v-model="soScheduleRouting.itemDesc" readonly></el-input>
  429. </el-form-item>
  430. </el-col>
  431. <el-col :span="12">
  432. <el-form-item label=" ">
  433. </el-form-item>
  434. </el-col>
  435. <el-col :span="6">
  436. <el-form-item label="机台ID">
  437. <el-input v-model="soScheduleRouting.sResourceID" readonly></el-input>
  438. </el-form-item>
  439. </el-col>
  440. <el-col :span="6">
  441. <el-form-item label="班次">
  442. <el-input v-model="soScheduleRouting.sShiftNo" readonly></el-input>
  443. </el-form-item>
  444. </el-col>
  445. <el-col :span="6">
  446. <el-form-item label="加工中心编码">
  447. <el-input v-model="soScheduleRouting.sWorkCenterNo" readonly></el-input>
  448. </el-form-item>
  449. </el-col>
  450. <el-col :span="6">
  451. <el-form-item label="操作员姓名">
  452. <el-input v-model="soScheduleRouting.operatorName" readonly></el-input>
  453. </el-form-item>
  454. </el-col>
  455. <el-col :span="6">
  456. <el-form-item label="每袋数量">
  457. <el-input v-model="soScheduleRouting.qtyBag" readonly></el-input>
  458. </el-form-item>
  459. </el-col>
  460. <el-col :span="6">
  461. <el-form-item label="每箱袋装数">
  462. <el-input v-model="soScheduleRouting.bag" readonly></el-input>
  463. </el-form-item>
  464. </el-col>
  465. <el-col :span="6">
  466. <el-form-item label="整箱数量">
  467. <el-input v-model="soScheduleRouting.qty" readonly></el-input>
  468. </el-form-item>
  469. </el-col>
  470. <el-col :span="6">
  471. <el-form-item label="纸箱尺寸">
  472. <el-input v-model="soScheduleRouting.carton" readonly></el-input>
  473. </el-form-item>
  474. </el-col>
  475. </el-row>
  476. </el-form>
  477. <div class="pad" style="float: left;width: 33%;margin-top: 2%">
  478. <h5 style="margin-left: 30px;font-size: 20px">产品图片</h5>
  479. <el-form :inline="true" style="margin-left: 30px" label-position="top">
  480. <el-form-item :label="'产品编码:'" style="margin-left: 0px">
  481. <el-input v-model="picData.partNo" readonly style="width: 220px"></el-input>
  482. </el-form-item>
  483. </el-form>
  484. <el-form :inline="true" style="margin-top: 20px;margin-left: 30px" label-position="top">
  485. <el-form-item :label="fileTitle">
  486. <el-input v-model="fileName" style="width: 374px" readonly></el-input>
  487. </el-form-item>
  488. </el-form>
  489. <el-form :inline="true" style="margin-top: 20px;margin-left: 30px" label-position="top">
  490. <el-form-item :label="' '">
  491. <el-button @click="lastPicture()" style="margin-left: 10px;height: 35px;width: 90px" type="primary">
  492. 上一张
  493. </el-button>
  494. </el-form-item>
  495. <el-form-item :label="' '">
  496. <el-button @click="nextPicture()" style="margin-left: 25px;height: 35px;width: 90px" type="primary">
  497. 下一张
  498. </el-button>
  499. </el-form-item>
  500. </el-form>
  501. </div>
  502. <div id="padPhoto" style="text-align: center;float: left;width: 66%;vertical-align:middle;margin-top: 5px">
  503. <img style="max-width: 100%;max-height: 450px;vertical-align:middle;" :src="photoUrl">
  504. </div>
  505. </el-card>
  506. </div>
  507. <el-dialog title="提示" :visible.sync="flag" :close-on-click-modal="false" @open="()=>{
  508. this.$nextTick(()=>{
  509. this.$refs.dialogInput.focus();
  510. })
  511. }" @close="()=>{
  512. this.number = 1
  513. }" width="15vw" top="30vh">
  514. <el-form label-position="top" class="title">
  515. <el-form-item label="零数量">
  516. <el-input-number size="medium" style="width: 100%;text-align: left" :controls="false" ref="dialogInput"
  517. :min="1" v-model="number" @keyup.enter.native="printPackageLabelNoPreview"></el-input-number>
  518. </el-form-item>
  519. <el-form-item label="重量">
  520. <el-input-number size="medium" style="width: 100%;text-align: left" :controls="false" ref="dialogInput"
  521. :min="1" v-model="weight" @keyup.enter.native="printPackageLabelNoPreview"></el-input-number>
  522. </el-form-item>
  523. </el-form>
  524. <div style="height: 20px;width: 100%"></div>
  525. <div style="text-align: center;margin-bottom: 5px">
  526. <el-button type="primary" @click="printPackageLabelNoPreview">确定</el-button>
  527. </div>
  528. <div style="height: 5px;width: 100%"></div>
  529. </el-dialog>
  530. </div>
  531. </template>
  532. <style scoped>
  533. .title .el-input-number /deep/ .el-input__inner {
  534. text-align: left;
  535. margin-top: 5px;
  536. padding-right: 5px !important;
  537. padding-left: 5px !important;
  538. }
  539. .el-form-item--medium /deep/ .el-form-item__label {
  540. font-size: 16px;
  541. line-height: 30px;
  542. height: 30px;
  543. }
  544. .el-form-item--medium /deep/ .el-form-item__content {
  545. margin-bottom: 5px;
  546. }
  547. .el-form-item--medium /deep/ .el-form-item__content .el-button {
  548. width: 80px;
  549. height: 30px;
  550. }
  551. .el-form-item--medium /deep/ .el-form-item__content .el-input .el-input__inner {
  552. font-size: 16px;
  553. line-height: 30px;
  554. height: 30px !important;
  555. }
  556. </style>