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

577 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
10 months 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
10 months 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. seqNo:this.searchData.seqNo
  170. }
  171. if (!params) {
  172. return
  173. }
  174. getTCPPackagePrintDataList(params).then(({data}) => {
  175. if (data && data.code === 0) {
  176. if(data.rows.length>0){
  177. if(this.flag){
  178. this.weight=data.rows[0].tcpValue
  179. }else {
  180. printTCPPackageLabelNoPreview(data.rows);
  181. }
  182. }
  183. this.searchData.flag = '';
  184. } else {
  185. this.$message.warning(data.msg)
  186. }
  187. }).catch((error) => {
  188. this.$message.error(error)
  189. })
  190. },
  191. stopSchedule() {
  192. if (this.scheduleJob) {
  193. clearInterval(this.scheduleJob); // 使用 clearInterval 来清除定时任务
  194. this.scheduleJob = null; // 将 scheduleJob 置为 null,表示没有活动的定时任务
  195. }
  196. },
  197. cleanAll() {
  198. Object.keys(this.soScheduleRouting).forEach(key => {
  199. this.soScheduleRouting[key] = '';
  200. });
  201. Object.keys(this.picData).forEach(key => {
  202. this.picData[key] = '';
  203. });
  204. this.fileName = null;
  205. this.fileTitle = "文件名 (" + 0 + "/" + 0 + ")";
  206. this.photoUrl = null;
  207. // this.scanTime= '';
  208. // this.closeWeighTPC();
  209. this.nowTime='';
  210. this.stopSchedule()
  211. },
  212. closeWeighTPC(){
  213. this.scanTime= '';
  214. let data={
  215. site:'1'
  216. }
  217. closeWeighTPC(data).then(({data}) => {
  218. })
  219. this.cleanAll()
  220. this.searchData.seqNo=undefined;
  221. },
  222. checkIsPacking() {
  223. let params = {
  224. site: this.soScheduleRouting.site,
  225. workCenterNo: this.soScheduleRouting.sWorkCenterNo,
  226. }
  227. checkIsPacking(params).then(({data}) => {
  228. if (data && data.code === 0) {
  229. this.getData(this.soScheduleRouting.site, this.soScheduleRouting.partNo)
  230. } else {
  231. this.getData('', '')
  232. this.soScheduleRouting = {};
  233. this.$message.warning(data.msg)
  234. this.searchData = {
  235. seqNo: undefined,
  236. flag: '',
  237. }
  238. }
  239. }).catch((error) => {
  240. this.$message.error(error)
  241. this.searchData = {
  242. seqNo: undefined,
  243. flag: '',
  244. }
  245. this.soScheduleRouting = {};
  246. })
  247. },
  248. printLabel() {
  249. if (!this.soScheduleRouting.site) {
  250. this.$message.warning("请先扫描派工单号")
  251. return
  252. }
  253. this.searchData.flag = 'Y'
  254. this.flag = true
  255. },
  256. printPackageLabelNoPreview() {
  257. let params = {
  258. previousSeqNo: this.soScheduleRouting.previousSeqNo,
  259. site: this.soScheduleRouting.site,
  260. orderNo: this.soScheduleRouting.orderNo,
  261. seqNo:this.searchData.seqNo
  262. }
  263. if (!this.number || !this.weight){
  264. this.$message.warning("请先输入数量和重量")
  265. return
  266. }
  267. params.number = this.number;
  268. // 发起请求
  269. getPackagePrintDataList(params).then(({data}) => {
  270. if (data && data.code === 0) {
  271. data.rows[0].tcpValue=this.weight
  272. printTCPPackageLabelNoPreview(data.rows);
  273. this.searchData.flag = '';
  274. this.flag = false
  275. } else {
  276. this.$message.warning(data.msg)
  277. }
  278. }).catch((error) => {
  279. this.$message.error(error)
  280. })
  281. },
  282. getData(site, partNo) {
  283. this.picData.partNo = partNo;
  284. this.picData.site = site;
  285. this.getPhoto();
  286. },
  287. getPhoto() {
  288. getPhotoAddressData(this.picData).then(({data}) => {
  289. this.photoDatas = data.rows;
  290. if (this.photoDatas.length == 0) {
  291. this.fileTitle = "文件名 (" + 0 + "/" + 0 + ")";
  292. this.photoUrl = null;
  293. return false;
  294. }
  295. this.fileName = this.photoDatas[this.num - 1].attaFileNameDb;
  296. this.fileTitle = "文件名 (" + this.num + "/" + this.photoDatas.length + ")";
  297. this.photoUrl = this.$store.state.user.padSopUrl + this.photoDatas[this.num - 1].attaFileNameDb;
  298. // this.photoUrl='http://192.168.1.83:81/upload/'+this.photoDatas[this.num-1].attaFileNameDb;
  299. })
  300. },
  301. nextPicture() {
  302. if (this.photoDatas.length == 0) {
  303. this.fileTitle = "文件名 (" + 0 + "/" + 0 + ")";
  304. this.$alert('该物料没有上传图片!', '错误', {
  305. confirmButtonText: '确定'
  306. })
  307. return false;
  308. }
  309. if (this.num == this.photoDatas.length) {
  310. this.num = 1;
  311. } else {
  312. this.num = this.num + 1;
  313. }
  314. this.fileName = this.photoDatas[this.num - 1].attaFileNameDb;
  315. this.fileTitle = "文件名 (" + this.num + "/" + this.photoDatas.length + ")";
  316. this.photoUrl = this.$store.state.user.padSopUrl + this.photoDatas[this.num - 1].attaFileNameDb;
  317. // this.photoUrl='http://192.168.1.83:81/upload/'+this.photoDatas[this.num-1].attaFileNameDb;
  318. },
  319. lastPicture() {
  320. if (this.photoDatas.length == 0) {
  321. this.fileTitle = "文件名 (" + 0 + "/" + 0 + ")";
  322. this.$alert('该物料没有上传图片!', '错误', {
  323. confirmButtonText: '确定'
  324. })
  325. return false;
  326. }
  327. if (this.num == 1) {
  328. this.num = this.photoDatas.length;
  329. } else {
  330. this.num = this.num - 1;
  331. }
  332. this.fileName = this.photoDatas[this.num - 1].attaFileNameDb;
  333. this.fileTitle = "文件名 (" + this.num + "/" + this.photoDatas.length + ")";
  334. this.photoUrl = this.$store.state.user.padSopUrl + this.photoDatas[this.num - 1].attaFileNameDb;
  335. // this.photoUrl='http://192.168.1.83:81/upload/'+this.photoDatas[this.num-1].attaFileNameDb;
  336. },
  337. },
  338. }
  339. </script>
  340. <template>
  341. <div style="padding: 5px">
  342. <el-form size="medium" class="title" :model="seqNo" label-position="top" :inline="true" @submit.native.prevent>
  343. <el-form-item label="派工单号">
  344. <el-input-number size="medium" style="width: 100%;margin-top: -5px;" :controls="false" ref="focusInput" :min="0"
  345. v-model="searchData.seqNo" @keyup.enter.native="selectBySeqNo"></el-input-number>
  346. </el-form-item>
  347. <!-- <el-form-item label=" ">-->
  348. <!-- <el-select v-model="searchData.flag" clearable>-->
  349. <!-- <el-option value="" label="标准袋数"></el-option>-->
  350. <!-- <el-option value="Y" label="零数袋"></el-option>-->
  351. <!-- </el-select>-->
  352. <!-- </el-form-item>-->
  353. <el-form-item label=" ">
  354. <!-- <el-button type="primary" @click="printLabel">打印标签</el-button>-->
  355. <!-- <el-button type="primary" @click="linkTPC()">重连设备</el-button>-->
  356. <el-button type="primary" @click="closeWeighTPC()">取消连接</el-button>
  357. <el-button type="primary" style="width: 120px" @click="printLabel">手工打印零数标签</el-button>
  358. </el-form-item>
  359. </el-form>
  360. <div class="content">
  361. <el-card style="height: 800px;margin-top: 20px">
  362. <el-form :model="soScheduleRouting" label-position="top">
  363. <el-row :gutter="20">
  364. <el-col :span="6">
  365. <el-form-item label="派工单号">
  366. <el-input v-model="soScheduleRouting.seqNo" readonly></el-input>
  367. </el-form-item>
  368. </el-col>
  369. <el-col :span="6">
  370. <el-form-item label="工厂编码">
  371. <el-input v-model="soScheduleRouting.site" readonly></el-input>
  372. </el-form-item>
  373. </el-col>
  374. <el-col :span="6">
  375. <el-form-item label="生产订单号">
  376. <el-input v-model="soScheduleRouting.orderNo" readonly></el-input>
  377. </el-form-item>
  378. </el-col>
  379. <el-col :span="6">
  380. <el-form-item label=" ">
  381. </el-form-item>
  382. </el-col>
  383. <el-col :span="6">
  384. <el-form-item label="产品编码">
  385. <el-input v-model="soScheduleRouting.partNo" readonly></el-input>
  386. </el-form-item>
  387. </el-col>
  388. <el-col :span="6">
  389. <el-form-item label="产品名称">
  390. <el-input v-model="soScheduleRouting.partDesc" readonly></el-input>
  391. </el-form-item>
  392. </el-col>
  393. <el-col :span="6">
  394. <el-form-item label="派工单类型">
  395. <el-input v-model="soScheduleRouting.scheduleType" readonly></el-input>
  396. </el-form-item>
  397. </el-col>
  398. <el-col :span="6">
  399. <el-form-item label="派工日期">
  400. <el-input v-model="soScheduleRouting.sScheduledDate" readonly></el-input>
  401. </el-form-item>
  402. </el-col>
  403. <el-col :span="6">
  404. <el-form-item label="检验工单号">
  405. <el-input v-model="soScheduleRouting.previousSeqNo" readonly></el-input>
  406. </el-form-item>
  407. </el-col>
  408. <el-col :span="6">
  409. <el-form-item label="检验日期">
  410. <el-input v-model="soScheduleRouting.sScheduledDate2" readonly></el-input>
  411. </el-form-item>
  412. </el-col>
  413. <el-col :span="6">
  414. <el-form-item label="检验员">
  415. <el-input v-model="soScheduleRouting.operatorName2" readonly></el-input>
  416. </el-form-item>
  417. </el-col>
  418. <el-col :span="6">
  419. <el-form-item label="检验合格数量">
  420. <el-input v-model="soScheduleRouting.approveQty2" readonly></el-input>
  421. </el-form-item>
  422. </el-col>
  423. <el-col :span="6">
  424. <el-form-item label="工序号">
  425. <el-input v-model="soScheduleRouting.itemNo" readonly></el-input>
  426. </el-form-item>
  427. </el-col>
  428. <el-col :span="6">
  429. <el-form-item label="工序名称">
  430. <el-input v-model="soScheduleRouting.itemDesc" readonly></el-input>
  431. </el-form-item>
  432. </el-col>
  433. <el-col :span="12">
  434. <el-form-item label=" ">
  435. </el-form-item>
  436. </el-col>
  437. <el-col :span="6">
  438. <el-form-item label="机台ID">
  439. <el-input v-model="soScheduleRouting.sResourceID" readonly></el-input>
  440. </el-form-item>
  441. </el-col>
  442. <el-col :span="6">
  443. <el-form-item label="班次">
  444. <el-input v-model="soScheduleRouting.sShiftNo" readonly></el-input>
  445. </el-form-item>
  446. </el-col>
  447. <el-col :span="6">
  448. <el-form-item label="加工中心编码">
  449. <el-input v-model="soScheduleRouting.sWorkCenterNo" readonly></el-input>
  450. </el-form-item>
  451. </el-col>
  452. <el-col :span="6">
  453. <el-form-item label="操作员姓名">
  454. <el-input v-model="soScheduleRouting.operatorName" readonly></el-input>
  455. </el-form-item>
  456. </el-col>
  457. <el-col :span="6">
  458. <el-form-item label="每袋数量">
  459. <el-input v-model="soScheduleRouting.qtyBag" readonly></el-input>
  460. </el-form-item>
  461. </el-col>
  462. <el-col :span="6">
  463. <el-form-item label="每箱袋装数">
  464. <el-input v-model="soScheduleRouting.bag" readonly></el-input>
  465. </el-form-item>
  466. </el-col>
  467. <el-col :span="6">
  468. <el-form-item label="整箱数量">
  469. <el-input v-model="soScheduleRouting.qty" readonly></el-input>
  470. </el-form-item>
  471. </el-col>
  472. <el-col :span="6">
  473. <el-form-item label="纸箱尺寸">
  474. <el-input v-model="soScheduleRouting.carton" readonly></el-input>
  475. </el-form-item>
  476. </el-col>
  477. </el-row>
  478. </el-form>
  479. <div class="pad" style="float: left;width: 33%;margin-top: 2%">
  480. <h5 style="margin-left: 30px;font-size: 20px">产品图片</h5>
  481. <el-form :inline="true" style="margin-left: 30px" label-position="top">
  482. <el-form-item :label="'产品编码:'" style="margin-left: 0px">
  483. <el-input v-model="picData.partNo" readonly style="width: 220px"></el-input>
  484. </el-form-item>
  485. </el-form>
  486. <el-form :inline="true" style="margin-top: 20px;margin-left: 30px" label-position="top">
  487. <el-form-item :label="fileTitle">
  488. <el-input v-model="fileName" style="width: 374px" readonly></el-input>
  489. </el-form-item>
  490. </el-form>
  491. <el-form :inline="true" style="margin-top: 20px;margin-left: 30px" label-position="top">
  492. <el-form-item :label="' '">
  493. <el-button @click="lastPicture()" style="margin-left: 10px;height: 35px;width: 90px" type="primary">
  494. 上一张
  495. </el-button>
  496. </el-form-item>
  497. <el-form-item :label="' '">
  498. <el-button @click="nextPicture()" style="margin-left: 25px;height: 35px;width: 90px" type="primary">
  499. 下一张
  500. </el-button>
  501. </el-form-item>
  502. </el-form>
  503. </div>
  504. <div id="padPhoto" style="text-align: center;float: left;width: 66%;vertical-align:middle;margin-top: 5px">
  505. <img style="max-width: 100%;max-height: 450px;vertical-align:middle;" :src="photoUrl">
  506. </div>
  507. </el-card>
  508. </div>
  509. <el-dialog title="提示" :visible.sync="flag" :close-on-click-modal="false" @open="()=>{
  510. this.$nextTick(()=>{
  511. this.$refs.dialogInput.focus();
  512. })
  513. }" @close="()=>{
  514. this.number = 1
  515. }" width="15vw" top="30vh">
  516. <el-form label-position="top" class="title">
  517. <el-form-item label="零数量">
  518. <el-input-number size="medium" style="width: 100%;text-align: left" :controls="false" ref="dialogInput"
  519. :min="1" v-model="number" @keyup.enter.native="printPackageLabelNoPreview"></el-input-number>
  520. </el-form-item>
  521. <el-form-item label="重量">
  522. <el-input-number size="medium" style="width: 100%;text-align: left" :controls="false" ref="dialogInput"
  523. :min="1" v-model="weight" @keyup.enter.native="printPackageLabelNoPreview"></el-input-number>
  524. </el-form-item>
  525. </el-form>
  526. <div style="height: 20px;width: 100%"></div>
  527. <div style="text-align: center;margin-bottom: 5px">
  528. <el-button type="primary" @click="printPackageLabelNoPreview">确定</el-button>
  529. </div>
  530. <div style="height: 5px;width: 100%"></div>
  531. </el-dialog>
  532. </div>
  533. </template>
  534. <style scoped>
  535. .title .el-input-number /deep/ .el-input__inner {
  536. text-align: left;
  537. margin-top: 5px;
  538. padding-right: 5px !important;
  539. padding-left: 5px !important;
  540. }
  541. .el-form-item--medium /deep/ .el-form-item__label {
  542. font-size: 16px;
  543. line-height: 30px;
  544. height: 30px;
  545. }
  546. .el-form-item--medium /deep/ .el-form-item__content {
  547. margin-bottom: 5px;
  548. }
  549. .el-form-item--medium /deep/ .el-form-item__content .el-button {
  550. width: 80px;
  551. height: 30px;
  552. }
  553. .el-form-item--medium /deep/ .el-form-item__content .el-input .el-input__inner {
  554. font-size: 16px;
  555. line-height: 30px;
  556. height: 30px !important;
  557. }
  558. </style>