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

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