weightCheck.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. <template>
  2. <div class="center">
  3. <el-row>
  4. <el-col :span="12">
  5. <h2 class="bg-left titleup">{{ information }}检斤信息</h2>
  6. </el-col>
  7. <el-col :span="12" class="bg-right">
  8. <el-button class="bg-bottom" type="primary" size="small" @click="cancel"><img width="6" height="10"
  9. style="vertical-align: bottom; margin-right: 3px" src="../../../public/img/lujing.png" alt="" />返回
  10. </el-button>
  11. </el-col>
  12. </el-row>
  13. <div class="substance">
  14. <div class="left">
  15. <div class="top">
  16. <div class="car-type">{{carWeightInfo.type}}</div>
  17. <div v-if="index==0" class="weight">{{weighingList.grossWeight}} <span class="kg-style">kg</span></div>
  18. <div v-else class="weight">{{weighingList.tare}} <span class="kg-style">kg</span></div>
  19. <div class="car-no">{{carWeightInfo.carNumber}}</div>
  20. </div>
  21. <h2 class="bg-left titleup">实时监控</h2>
  22. <div class="bottom">
  23. <div v-if="!monitorUrl1" class="video1">
  24. <img src="../../../public/img/quesheng@2x.png" alt="" class="img1">
  25. <div>监控视频未连接</div>
  26. </div>
  27. <div v-else class="video1">
  28. <iframe :src="monitorUrl1" width="440" height="360" allowfullscreen="true" webkitallowfullscreen="true"
  29. mozallowfullscreen="true" allow="autoplay; fullscreen; microphone;"></iframe>
  30. </div>
  31. <div v-if="!monitorUrl2" class="video1">
  32. <img src="../../../public/img/quesheng@2x.png" alt="" class="img1">
  33. <div>监控视频未连接</div>
  34. </div>
  35. <div v-else class="video2">
  36. <iframe :src="monitorUrl2" width="440" height="360" allowfullscreen="true" webkitallowfullscreen="true"
  37. mozallowfullscreen="true" allow="autoplay; fullscreen; microphone;"></iframe>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="right">
  42. <ws-form class='right-content'>
  43. <div class="left">
  44. <div class="tab">
  45. <div class="tab-item" :class="index==0?'active':''" @click="tabClick(0)"> 待称毛重({{mListTop.length}})</div>
  46. <div class="tab-item" :class="index==1?'active':''" @click="tabClick(1)">待称皮重({{pListTop.length}})</div>
  47. </div>
  48. <div class="title">基本信息</div>
  49. <ws-info-table>
  50. <ws-form-item label="编号" span="1" prop="number">
  51. <ws-input v-model="weighingList.number" placeholder="请输入编号" maxlength="100" disabled size="small" />
  52. </ws-form-item>
  53. <ws-form-item label="仓位号" span="1" prop="binNumber">
  54. <ws-input v-model="weighingList.binNumber" placeholder="请输入仓位号" maxlength="100" disabled size="small" />
  55. </ws-form-item>
  56. <ws-form-item label="客户" span="1" prop="customer">
  57. <ws-input v-model="weighingList.customer" placeholder="请输入客户" maxlength="100" disabled size="small" />
  58. </ws-form-item>
  59. <ws-form-item label="囤位号" span="1" prop="storageNumber">
  60. <ws-input v-model="weighingList.storageNumber" placeholder="请输入囤位号" maxlength="100" size="small"
  61. disabled />
  62. </ws-form-item>
  63. <ws-form-item label="车牌号" span="1" prop="carNumber">
  64. <ws-input v-model="weighingList.carNumber" placeholder="请输入车牌号" maxlength="100" size="small" disabled />
  65. </ws-form-item>
  66. <ws-form-item label="箱号-1" span="1" prop="boxNo">
  67. <ws-input disabled v-model="inspect.boxNo" placeholder="请输入箱号" maxlength="20" size="small" />
  68. </ws-form-item>
  69. <ws-form-item label="箱号-2" span="1" prop="boxNoOther">
  70. <ws-input disabled v-model="inspect.boxNoOther" placeholder="请输入箱号" maxlength="20" size="small" />
  71. </ws-form-item>
  72. <ws-form-item label="封号-1" span="1" prop="titleNo">
  73. <ws-input disabled v-model="inspect.titleNo" placeholder="请输入封号" maxlength="20" size="small" />
  74. </ws-form-item>
  75. <ws-form-item label="封号-2" span="1" prop="titleNoOther">
  76. <ws-input disabled v-model="inspect.titleNoOther" placeholder="请输入封号" maxlength="20" size="small" />
  77. </ws-form-item>
  78. <ws-form-item label="货名" span="1" prop="goodsName">
  79. <ws-input v-model="weighingList.goodsName" placeholder="请输入货名" maxlength="100" size="small" disabled />
  80. </ws-form-item>
  81. <ws-form-item label="毛重(公斤)" span="1" prop="grossWeight">
  82. <ws-input type="number" @mousewheel.native.prevent v-if="this.index == 0"
  83. v-model="weighingList.grossWeight" @input="calculation" placeholder="未获取到毛重" maxlength="100"
  84. size="small" :disabled="disabled" />
  85. <ws-input type="number" @mousewheel.native.prevent v-else v-model="weighingList.grossWeight"
  86. @input="calculation" placeholder="未获取到毛重" maxlength="100" size="small" disabled />
  87. <el-button type="primary" :class="index ==0 ? '' : 'butCss'" @click="openPort">重新获取</el-button>
  88. </ws-form-item>
  89. <ws-form-item label="皮重(公斤)" span="1" prop="tare" v-if="information == '皮重'">
  90. <ws-input type="number" @mousewheel.native.prevent v-model="weighingList.tare" @input="calculation"
  91. placeholder="未获取到皮重" maxlength="100" size="small" :disabled="disabled" />
  92. <el-button type="primary" v-if="index != 0" @click="openPort">重新获取</el-button>
  93. </ws-form-item>
  94. <div class="formItem">
  95. <ws-form-item label="扣重(公斤)" span="1" prop="buckleWeightRatio"
  96. v-if="information == '皮重' && paramType == '2'">
  97. <ws-input type="number" @mousewheel.native.prevent v-model="weighingList.buckleMiscellaneous"
  98. @input="calculation" placeholder="请输入扣重" maxlength="100" size="small" />
  99. </ws-form-item>
  100. <ws-form-item label="净重(公斤)" span="1" prop="netWeight" v-if="information == '皮重'">
  101. <ws-input type="number" @mousewheel.native.prevent v-model="weighingList.netWeight"
  102. placeholder="请输入净重" maxlength="100" size="small" disabled />
  103. </ws-form-item>
  104. </div>
  105. </ws-info-table>
  106. <div class="but">
  107. <el-button @click="cancel" type="primary">关闭</el-button>
  108. <el-button @click="print" v-if="this.information == '毛重'" type="primary">保存</el-button>
  109. <el-button @click="print" v-if="this.information == '皮重'" type="primary">保存并打印</el-button>
  110. </div>
  111. </div>
  112. <div class="car-right">
  113. <el-button @click="cutstatus(1)" :type="status==1?'primary':''">已称重</el-button>
  114. <el-button @click="cutstatus(2)" :type="status==2?'primary':''">未称重</el-button>
  115. <el-table ref="singleTable" :data="carList" highlight-current-row @current-change="handleCurrentChange"
  116. style="width: 100%;overflow:auto;height:680px">
  117. <el-table-column property="number" label="编号">
  118. </el-table-column>
  119. <el-table-column property="carNumber" label="车牌号">
  120. </el-table-column>
  121. <el-table-column property="status" label="状态">
  122. </el-table-column>
  123. </el-table>
  124. <div style="text-align: center">
  125. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  126. :current-page="currentPage" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
  127. :total="deptBudgetTotal">
  128. </el-pagination>
  129. </div>
  130. <!-- <div class="table-title">
  131. <div class="top">
  132. <div class="top-item first"></div>
  133. <div class="top-item">编号</div>
  134. <div class="top-item">车牌号</div>
  135. </div>
  136. <div class="top">
  137. <div></div>
  138. <div class="top-item"></div>
  139. <div class="top-item">编号</div>
  140. <div class="top-item">车牌号</div>
  141. </div>
  142. </div>
  143. <div class="table">
  144. <div class="table-content" v-for="(item,index) in 30" :key="index">
  145. <div class="table-content-item"><input type="radio"></div>
  146. <div class="table-content-item">xxxxxxxxxxxxx</div>
  147. <div class="table-content-item">辽A11111</div>
  148. </div>
  149. </div> -->
  150. </div>
  151. </ws-form>
  152. </div>
  153. </div>
  154. <el-dialog width="70%" class="table-content" center :visible.sync="isShowPrint" title="粮食检斤单" @close="closeDialog"
  155. :close-on-click-modal="false">
  156. <weightCheckPrint :tableData="inspect" ref="saveImg"></weightCheckPrint>
  157. <div style="text-align:center">
  158. <el-button type="primary" @click="closePrint">关闭</el-button>
  159. <el-button type="primary" @click="printSmall">打印小票</el-button>
  160. <el-button type="primary" @click="printBig">打印单据</el-button>
  161. </div>
  162. </el-dialog>
  163. </div>
  164. </template>
  165. <script>
  166. import {
  167. tare,
  168. grossWeight,
  169. getamount,
  170. getPrint,
  171. getweighingList,
  172. getinspectLookGoods
  173. } from '@/model/houseSelfCollect/index'
  174. import weightCheckPrint from './component/weightCheckPrint.vue'
  175. import html2canvas from 'html2canvas'
  176. import axios from 'axios'
  177. export default {
  178. components: {
  179. weightCheckPrint,
  180. },
  181. watch: {
  182. weighingList: { //深度监听,可监听到对象、数组的变化
  183. handler(val, oldVal) {
  184. if (val.tare) {
  185. if (this.weighingList.buckleMiscellaneous) {
  186. this.weighingList.netWeight = this.weighingList.grossWeight - val.tare - this.weighingList
  187. .buckleMiscellaneous
  188. } else {
  189. this.weighingList.netWeight = this.weighingList.grossWeight - val.tare
  190. }
  191. }
  192. },
  193. deep: true //true 深度监听
  194. }
  195. },
  196. data() {
  197. return {
  198. currentPage: 1,
  199. pageSize: 100,
  200. deptCircularPage: {},
  201. deptBudgetTotal: 0,
  202. pList: [],
  203. mList: [],
  204. index: 0,
  205. status:1,
  206. carList: [],
  207. carWeightInfo: {
  208. carNumber: '',
  209. type: '',
  210. weight: ''
  211. },
  212. currentRow: null,
  213. inspect: {},
  214. types: 1,
  215. information: '',
  216. weighingList: {
  217. grossWeight: 0,
  218. tare: 0,
  219. buckleMiscellaneous: 0,
  220. netWeight: 0
  221. },
  222. tpyeNo: 1,
  223. disabled: true,
  224. relationId: '',
  225. warehouseId: '',
  226. purchasePriceList: [],
  227. isShowPrint: false,
  228. tableData: {},
  229. reader: null,
  230. param: 9600,
  231. monitorUrl1: '',
  232. monitorUrl2: '',
  233. cangid: '',
  234. paramType: '1',
  235. warehouseName: '',
  236. result1: '00',
  237. allowEdit: 0,
  238. mListTop: [],
  239. mListBottom: [],
  240. pListTop: [],
  241. carList1:[],
  242. pListBottom: []
  243. }
  244. },
  245. mounted() {
  246. },
  247. activated() {
  248. console.log(this.common.name)
  249. this.cangid = this.$route.query.cangid
  250. this.paramType = this.$route.query.paramType
  251. this.getList()
  252. this.tpyeNo = this.$route.query.tpyeNo
  253. this.warehouseName = this.$route.query.warehouseName
  254. this.weighingList.number = this.$route.query.number
  255. this.weighingList.binNumber = this.$route.query.binNumber
  256. this.weighingList.customerNumberCard = this.$route.query.customerNumberCard
  257. this.weighingList.customer = this.$route.query.customer
  258. this.weighingList.storageNumber = this.$route.query.storageNumber
  259. this.weighingList.carNumber = this.$route.query.carNumber
  260. this.weighingList.goodsName = this.$route.query.goodsName
  261. this.weighingList.id = this.$route.query.id
  262. // this.relationId = this.$route.query.relationId
  263. this.monitorUrl1 = this.$route.query.monitorUrl1
  264. this.monitorUrl2 = this.$route.query.monitorUrl2
  265. this.warehouseId = this.$route.query.warehouseId
  266. if (!this.$route.query.grossWeight) {
  267. this.$route.query.grossWeight = 0
  268. } else {
  269. this.weighingList.grossWeight = this.$route.query.grossWeight
  270. }
  271. // this.purchasePriceList = this.$route.query.purchasePriceList
  272. // console.log(this.purchasePriceList, '上限')
  273. this.allowEdit = this.$route.query.allowEdit
  274. if (this.allowEdit == 0) {
  275. this.disabled = true
  276. } else if (this.allowEdit == 1) {
  277. this.disabled = false
  278. }
  279. if (this.tpyeNo == 1) {
  280. this.information = '毛重'
  281. this.weighingList.tare = 0
  282. } else if (this.tpyeNo == 2) {
  283. this.information = '皮重'
  284. }
  285. if(this.$route.query.automaticWeightAcquisition == '1'){
  286. this.openPort()
  287. }
  288. },
  289. deactivated() {
  290. // this.closePort()
  291. },
  292. methods: {
  293. cutstatus(status){
  294. this.status=status
  295. if(status==1){
  296. this.carList=this.carList1.filter(function (item) {
  297. return item.status=='已质检'
  298. })
  299. }else{
  300. this.carList=this.carList1.filter(function (item) {
  301. return item.status=='已称毛重'
  302. })
  303. }
  304. },
  305. handleSizeChange(val) {
  306. console.log(`每页 ${val} 条`)
  307. this.pageSize = val
  308. this.getList()
  309. },
  310. getList() {
  311. // 货名
  312. getinspectLookGoods({
  313. warehouseId: this.cangid
  314. })
  315. .toPromise()
  316. .then((response) => {
  317. this.purchasePriceList = response
  318. })
  319. getweighingList({
  320. compId: localStorage.getItem('ws-pf_compId'),
  321. currentPage: this.currentPage,
  322. pageSize: this.pageSize,
  323. searchKeyWord: '',
  324. warehouseName: localStorage.getItem('ck'),
  325. managementType: 1,
  326. // viewFlag:'1'
  327. })
  328. .toPromise()
  329. .then((response) => {
  330. // for (let i = 0; i < response.records.length; i++) {
  331. // if (response.records[i].paymentManagement) {
  332. // if (response.records[i].paymentManagement.status == '待结算' && !response.records[i].paymentManagement
  333. // .approveStatus) {
  334. // response.records[i].allow = 1
  335. // } else {
  336. // response.records[i].allow = 2
  337. // }
  338. // } else {
  339. // response.records[i].allow = 1
  340. // }
  341. // }
  342. this.weighingList = response.records
  343. this.common.commonWeighingList = response.records
  344. this.makeData();
  345. })
  346. .catch((response) => {
  347. // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
  348. })
  349. },
  350. makeData() {
  351. this.mList = [];
  352. this.pList = [];
  353. this.mListTop=[]
  354. this.mListBottom=[]
  355. this.pListTop=[]
  356. this.pListBottom=[]
  357. this.carWeightInfo.carNumber = ''
  358. this.weighingList = []
  359. let that = this
  360. console.log(this.common.commonWeighingList, 'commonWeighingList')
  361. let _list = this.common.commonWeighingList
  362. for (let i = 0; i < _list.length; i++) {
  363. if (_list[i].paymentManagement) {
  364. if (_list[i].paymentManagement.status != '待结算' || _list[i].paymentManagement
  365. .approveStatus) {
  366. continue
  367. }
  368. }
  369. if (_list[i].status == '已质检') {
  370. this.mListTop.push(_list[i])
  371. }
  372. if (_list[i].status == '已称毛重') {
  373. this.mListBottom.push(_list[i])
  374. }
  375. if (_list[i].status == '已称皮重') {
  376. this.pListBottom.push(_list[i])
  377. }
  378. if (_list[i].status == '已称毛重') {
  379. this.pListTop.push(_list[i])
  380. }
  381. }
  382. this.mList = this.mListTop.concat(this.mListBottom)
  383. this.pList = this.pListTop.concat(this.pListBottom)
  384. if (this.information == '毛重') {
  385. this.index = 0
  386. this.carList = this.mList
  387. this.carList1 = this.mList
  388. if (this.mList.length != 0) {
  389. let _item = this.mList.filter(function(val) {
  390. console.log(that.$route.query.id)
  391. if (val.id == that.$route.query.id) {
  392. return val
  393. }
  394. })
  395. if (_item.length != 0) {
  396. this.setCurrent(_item[0])
  397. this.weighingList = _item[0]
  398. this.carWeightInfo = {
  399. carNumber: _item[0].carNumber,
  400. type: this.information,
  401. weight: this.weighingList.grossWeight
  402. }
  403. this.weighingList = _item[0]
  404. } else {
  405. this.setCurrent(this.mList[0])
  406. this.weighingList = this.mList[0]
  407. this.carWeightInfo = {
  408. carNumber: this.mList[0].carNumber,
  409. type: this.information,
  410. weight: this.weighingList.grossWeight
  411. }
  412. }
  413. this.deptBudgetTotal = this.mList.length
  414. }
  415. } else {
  416. this.index = 1
  417. this.carList = this.pList
  418. if (this.pList.length != 0) {
  419. let _item = this.pList.filter(function(val1) {
  420. if (val1.id == that.$route.query.id) {
  421. return val1
  422. }
  423. })
  424. if (_item.length != 0) {
  425. this.setCurrent(_item[0])
  426. this.weighingList = _item[0]
  427. this.carWeightInfo = {
  428. carNumber: _item[0].carNumber,
  429. type: this.information,
  430. weight: this.weighingList.tare
  431. }
  432. } else {
  433. this.setCurrent(this.pList[0])
  434. this.weighingList = this.pList[0]
  435. this.carWeightInfo = {
  436. carNumber: this.pList[0].carNumber,
  437. type: this.information,
  438. weight: this.weighingList.tare
  439. }
  440. }
  441. this.deptBudgetTotal = this.pList.length
  442. }
  443. }
  444. },
  445. tabClick(val) {
  446. this.mListTop = []
  447. this.mListBottom = []
  448. this.pListTop = []
  449. this.pListBottom = []
  450. this.carWeightInfo.carNumber = ''
  451. this.weighingList = []
  452. this.index = val
  453. if (this.information == '皮重') {
  454. this.information = '毛重'
  455. this.tpyeNo = 1
  456. } else {
  457. this.tpyeNo = 2
  458. this.information = '皮重'
  459. }
  460. this.getList()
  461. },
  462. setCurrent(row) {
  463. this.$refs.singleTable.setCurrentRow(row);
  464. },
  465. handleCurrentChange(val) {
  466. this.currentRow = val;
  467. this.carWeightInfo = {
  468. carNumber: val.carNumber,
  469. type: this.information,
  470. weight: val.grossWeight
  471. }
  472. this.weighingList = val;
  473. this.paramType = val.qualityInspectionManagement.paramType
  474. },
  475. async closePort() {
  476. console.log('closePort');
  477. if (this.reader) {
  478. this.reader.cancel()
  479. }
  480. },
  481. async openPort() {
  482. console.log('openPort', navigator)
  483. if ('serial' in navigator) {
  484. // if (!this.$store.state.app.reader) {
  485. // The Web Serial API is supported.
  486. console.log('the Web Serial API is supported.')
  487. console.log(this.param)
  488. const port = await navigator.serial.requestPort()
  489. await port.open({
  490. baudRate: this.param,
  491. }) // set baud rate
  492. this.reader = port.readable.getReader()
  493. console.log('beforeReader', port)
  494. console.log('beforeReader', this.reader)
  495. this.$store.dispatch('app/setReader', this.reader)
  496. // } else {
  497. // console.log('afterport', this.$store.state.app.reader)
  498. // this.reader = this.$store.state.app.reader
  499. // }
  500. // 监听来自串行设备的数据
  501. while (true) {
  502. const {
  503. value,
  504. done
  505. } = await this.reader.read();
  506. // console.log("value",value);
  507. if (done) {
  508. // 允许稍后关闭串口。
  509. this.reader.releaseLock();
  510. break;
  511. }
  512. var result = '';
  513. //2。获取16进制字符串
  514. // var receData = HexConvert.ByteToString(value);
  515. // console.log("receData",receData);
  516. var flag = false;
  517. var flag1 = false;
  518. if (this.warehouseName && (this.warehouseName == '山东诸城迈饶库' || this.warehouseName == '克东千红库' || this
  519. .warehouseName == '鲅鱼圈祥腾库' || this.warehouseName == '哈尔滨依兰库'|| this.warehouseName == '龙江金信库')) {
  520. for (var i = 0; i < value.length; i++) {
  521. var tmp = String.fromCharCode(value[i])
  522. if (tmp == '+') {
  523. flag = true
  524. }
  525. if (flag && result.length < 6 && tmp != '+') {
  526. result += tmp
  527. }
  528. }
  529. if (this.tpyeNo != 2) {
  530. if (parseInt(result) || parseInt(result) == 0) {
  531. this.weighingList.grossWeight = parseInt(result)
  532. }
  533. } else {
  534. if (parseInt(result) || parseInt(result) == 0) {
  535. this.weighingList.tare = parseInt(result)
  536. }
  537. }
  538. } else if (this.warehouseName && (this.warehouseName == '顺诚粮库' || this.warehouseName == '鲅鱼圈金信库')) {
  539. for (var i = value.length - 1; i >= 0; i--) {
  540. var tmp = String.fromCharCode(value[i])
  541. console.log(tmp)
  542. if (String.fromCharCode(value[0]) == '.') {
  543. flag = true
  544. }
  545. if (flag && result.length < 9 && tmp != '=' && tmp != '.') {
  546. result += tmp
  547. }
  548. }
  549. console.log(parseInt(result))
  550. if (this.tpyeNo != 2) {
  551. if (parseInt(result) || parseInt(result) == 0) {
  552. this.weighingList.grossWeight = parseInt(result)
  553. }
  554. } else {
  555. if (parseInt(result) || parseInt(result) == 0) {
  556. this.weighingList.tare = parseInt(result)
  557. }
  558. }
  559. } else {
  560. // console.log(value)
  561. for (var i = 0; i < value.length; i++) {
  562. var tmp = String.fromCharCode(value[i])
  563. if ((value[0] != 49 && value[0] != 2)) {
  564. if ((value[value.length - 1] == 48 && value[value.length - 2] == 48)) {
  565. flag1 = true
  566. } else {
  567. break
  568. }
  569. }
  570. if (tmp == String.fromCharCode(32)) {
  571. flag = true
  572. }
  573. if (flag && result.length < 7 && tmp != String.fromCharCode(32) && !(value[value.length - 1] == 48 &&
  574. value[value.length - 2] == 48)) {
  575. result += tmp
  576. }
  577. if (flag1 && tmp != String.fromCharCode(32)) {
  578. if ((value[value.length - 1] == 48 && value[value.length - 2] == 48)) {
  579. if (i == 0) {
  580. this.result1 = tmp + '0'
  581. }
  582. }
  583. }
  584. }
  585. if (this.tpyeNo != 2) {
  586. console.log(parseInt(result) + '' + parseInt(this.result1))
  587. if (parseInt(result) || parseInt(result) == 0) {
  588. this.weighingList.grossWeight = parseInt(result + this.result1)
  589. }
  590. if (parseInt(result) == 0 && parseInt(this.result1) == 0) {
  591. this.weighingList.grossWeight = 0
  592. }
  593. } else {
  594. if (parseInt(result) || parseInt(result) == 0) {
  595. this.weighingList.tare = parseInt(result + this.result1)
  596. }
  597. if (parseInt(result) == 0 && parseInt(this.result1) == 0) {
  598. this.weighingList.tare = 0
  599. }
  600. }
  601. }
  602. // setTimeout(1000)
  603. // value 是一个 Uint8Array
  604. }
  605. await port.close();
  606. } else {
  607. console.log('the Web Serial API is not supported.', navigator);
  608. }
  609. },
  610. cancel() {
  611. if (this.reader) {
  612. this.reader.cancel()
  613. }
  614. this.$router.push({
  615. path: 'weighingManagement'
  616. })
  617. },
  618. calculation() {
  619. // if (this.weighingList.grossWeight && this.weighingList.tare) {
  620. // this.weighingList.netWeight = this.weighingList.grossWeight - this.weighingList.tare - parseInt(this.weighingList.buckleMiscellaneous)
  621. // this.weighingList.netWeight = this.weighingList.netWeight.toFixed(2)
  622. // }
  623. },
  624. printSmall() {
  625. window.open('../../../../static/weightCheck.html?type=1&tableData=' + JSON.stringify(this.inspect))
  626. },
  627. printBig() {
  628. window.open('../../../../static/weightCheck.html?type=2&tableData=' + JSON.stringify(this.inspect))
  629. },
  630. closeDialog() {
  631. html2canvas(this.$refs.saveImg.$el).then((canvas) => {
  632. let dataURL = canvas.toDataURL('image/png')
  633. this.imgUrl = dataURL
  634. if (this.imgUrl !== '') {
  635. let b = this.dataURLtoFile(this.imgUrl, 'printImage')
  636. let formdata = new FormData()
  637. formdata.append('file', b)
  638. axios({
  639. method: 'post',
  640. url: 'https://www.zthymaoyi.com/upload/admin',
  641. data: formdata,
  642. }).then((response) => {
  643. //编辑接口
  644. this.weighingList.pictureAddress = response.data.url
  645. tare(this.weighingList)
  646. .toPromise()
  647. .then((response) => {})
  648. })
  649. this.dialogTableVisible = true
  650. }
  651. })
  652. this.isShowPrint = false
  653. // this.$router.push({
  654. // path: 'weighingManagement'
  655. // })
  656. },
  657. closePrint() {
  658. this.isShowPrint = false
  659. // this.$router.push({
  660. // path: 'weighingManagement'
  661. // })
  662. },
  663. print() {
  664. if (this.reader) {
  665. this.reader.cancel()
  666. }
  667. if (!this.weighingList.grossWeight) {
  668. this.$message({
  669. message: '毛重不能为空',
  670. type: 'warning',
  671. })
  672. return
  673. }
  674. if (
  675. this.weighingList.grossWeight < 1 ||
  676. this.weighingList.grossWeight > 200000
  677. ) {
  678. this.$message({
  679. message: '毛重输入错误',
  680. type: 'warning',
  681. })
  682. return
  683. }
  684. if (
  685. String(this.weighingList.grossWeight).indexOf('.') != -1 &&
  686. String(this.weighingList.grossWeight).length -
  687. (String(this.weighingList.grossWeight).indexOf('.') + 1) >
  688. 1
  689. ) {
  690. this.$message({
  691. message: '毛重输入错误',
  692. type: 'warning',
  693. })
  694. return
  695. }
  696. if (this.tpyeNo == 2) {
  697. if (!this.weighingList.tare) {
  698. this.$message({
  699. message: '皮重不能为空',
  700. type: 'warning',
  701. })
  702. return
  703. }
  704. if (!this.weighingList.tare) {
  705. this.$message({
  706. message: '皮重不能为空',
  707. type: 'warning',
  708. })
  709. return
  710. }
  711. if (this.weighingList.tare > this.weighingList.grossWeight) {
  712. this.$message({
  713. message: '皮重不能大于毛重',
  714. type: 'warning',
  715. })
  716. return
  717. }
  718. if (this.weighingList.tare < 1 || this.weighingList.tare > 100000) {
  719. this.$message({
  720. message: '皮重输入错误',
  721. type: 'warning',
  722. })
  723. return
  724. }
  725. if (
  726. String(this.weighingList.tare).indexOf('.') != -1 &&
  727. String(this.weighingList.tare).length -
  728. (String(this.weighingList.tare).indexOf('.') + 1) >
  729. 1
  730. ) {
  731. this.$message({
  732. message: '皮重输入错误',
  733. type: 'warning',
  734. })
  735. return
  736. }
  737. if (this.weighingList.netWeight < 0) {
  738. this.$message({
  739. message: '净重不能小于0',
  740. type: 'warning',
  741. })
  742. return
  743. }
  744. }
  745. this.$confirm('确定保存检斤信息?', '提示', {
  746. confirmButtonText: '确定',
  747. cancelButtonText: '取消',
  748. type: 'warning',
  749. })
  750. .then(() => {
  751. if (this.tpyeNo == 1) {
  752. //毛检保存前进行校验
  753. getamount({
  754. compId: localStorage.getItem('ws-pf_compId'),
  755. customerNumberCard: this.weighingList.customerNumberCard,
  756. goodsName: this.weighingList.goodsName,
  757. })
  758. .toPromise()
  759. .then((response) => {
  760. for (let i = 0; i < this.purchasePriceList.length; i++) {
  761. if (
  762. this.weighingList.goodsName == this.purchasePriceList[i].goodsName
  763. ) {
  764. //累计售粮超上限不能完成毛检保存
  765. let count = (this.purchasePriceList[i].saleLimit - response / 1000).toFixed(2)
  766. // console.log(this.weighingList.grossWeight / 1000, '毛重转吨')
  767. // this.weighingList.grossWeight/=1000
  768. if (count - this.weighingList.grossWeight / 1000 < 0) {
  769. this.$alert(
  770. '该客户累计销售' +
  771. this.weighingList.goodsName +
  772. (response / 1000).toFixed(2) +
  773. '吨,还可售粮' +
  774. count +
  775. '吨',
  776. '提示', {
  777. confirmButtonText: '确定',
  778. callback: (action) => {
  779. this.$message({
  780. type: 'info',
  781. message: `累计售粮已超出上限`,
  782. })
  783. },
  784. }
  785. )
  786. } else {
  787. //累计售粮没有超上限完成毛检保存
  788. // this.weighingList.relationId = this.relationId;
  789. this.weighingList.secretaryWeigher = localStorage.getItem('ws-pf_staffName'),
  790. grossWeight(this.weighingList)
  791. .toPromise()
  792. .then((response) => {
  793. if (this.reader) {
  794. this.reader.cancel()
  795. }
  796. this.$notify.success({
  797. title: '成功',
  798. message: '保存成功',
  799. })
  800. // this.$router.go(-1)
  801. })
  802. .catch((response) => {
  803. // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
  804. })
  805. }
  806. }
  807. }
  808. })
  809. } else if (this.tpyeNo == 2) {
  810. // this.weighingList.grossWeight/=1000
  811. // this.weighingList.tare/=1000
  812. // if(this.weighingList.buckleMiscellaneous){
  813. // this.weighingList.buckleMiscellaneous/=1000
  814. // }
  815. // this.weighingList.netWeight/=1000
  816. this.weighingList.warehouseId = this.warehouseId;
  817. (this.weighingList.skinInspector =
  818. localStorage.getItem('ws-pf_staffName')),
  819. tare(this.weighingList)
  820. .toPromise()
  821. .then((response) => {
  822. if (this.reader) {
  823. this.reader.cancel()
  824. }
  825. this.$notify.success({
  826. title: '成功',
  827. message: '保存成功',
  828. })
  829. getPrint({
  830. id: response,
  831. })
  832. .toPromise()
  833. .then((response) => {
  834. this.inspect = response
  835. if (response.compName == '黑龙江秋收有限公司') {
  836. this.inspect.compName = '黑龙江中天昊元贸易有限公司'
  837. }
  838. this.inspect.a = '中天'
  839. // this.tableData = response
  840. this.isShowPrint = true
  841. })
  842. .catch((response) => {
  843. // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
  844. })
  845. })
  846. .catch((response) => {
  847. // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
  848. })
  849. }
  850. })
  851. .catch(() => {
  852. return false
  853. })
  854. },
  855. },
  856. }
  857. </script>
  858. <style lang="scss" scoped>
  859. /deep/.el-pagination {
  860. margin-bottom: 0;
  861. }
  862. .center {
  863. background: #f6f7fc;
  864. }
  865. .ws-info-table {
  866. border: none;
  867. height: 610px;
  868. }
  869. .ws-info-table .el-form-item {
  870. width: 100%;
  871. border: none;
  872. }
  873. .formItem {
  874. width: 100%;
  875. display: inline;
  876. }
  877. /deep/.ws-info-table .el-form-item .el-form-item__label {
  878. width: 30%;
  879. text-align: center;
  880. background: #ffffff;
  881. font-size: 14px;
  882. color: #8890b1;
  883. }
  884. /deep/.ws-info-table .el-form-item .el-form-item__content {
  885. border: none;
  886. }
  887. .title {
  888. font-size: 16px;
  889. font-weight: 600;
  890. margin: 10px;
  891. }
  892. .titleup {
  893. position: relative;
  894. }
  895. .title::before {
  896. content: '';
  897. display: inline-block;
  898. width: 5px;
  899. height: 15px;
  900. background: #8890b1;
  901. margin-right: 5px;
  902. }
  903. .substance {
  904. padding-bottom: 20px;
  905. overflow-y: scroll;
  906. .active {
  907. background: #5878e8;
  908. color: white;
  909. }
  910. // background: #ffffff;
  911. width: 100%;
  912. height: calc(100vh - 125px);
  913. border-radius: 4px;
  914. margin: 0 auto;
  915. display: flex;
  916. .left {
  917. width: 30%;
  918. // padding:0 20px 20px 20px;
  919. .top {
  920. background: black;
  921. color: #2AFF7C;
  922. font-size: 32px;
  923. text-align: right;
  924. padding: 20px;
  925. border-radius: 10px;
  926. margin: 0 20px 20px 20px;
  927. .car-type {
  928. text-align: left;
  929. }
  930. .kg-style {
  931. font-size: 30px;
  932. }
  933. }
  934. .bottom {
  935. text-align: center;
  936. background: white;
  937. margin: 20px 20px 0 20px;
  938. border-radius: 10px;
  939. padding-bottom: 20px;
  940. .img1,
  941. .img2 {
  942. width: 200px;
  943. padding: 20px;
  944. }
  945. .video-content {
  946. width: 100%;
  947. }
  948. }
  949. }
  950. .right {
  951. width: 70%;
  952. padding: 20px;
  953. height: 750px;
  954. background: white;
  955. border-radius: 10px;
  956. .tab {
  957. display: flex;
  958. .tab-item {
  959. padding: 5px 10px;
  960. margin-right: 20px;
  961. border-radius: 10px;
  962. }
  963. }
  964. .table-title {
  965. background: red;
  966. .top {
  967. display: inline-block;
  968. width: 48%;
  969. .top-item {
  970. display: inline-block;
  971. }
  972. }
  973. }
  974. .table {
  975. background: red;
  976. .table-content {
  977. background: green;
  978. display: inline-block;
  979. width: 50%;
  980. .table-content-item {
  981. display: inline-block;
  982. }
  983. }
  984. }
  985. }
  986. }
  987. /deep/.el-table .el-table__header .cell,
  988. /deep/.el-table .el-table__body .cell {
  989. text-align: center;
  990. font-size: 16px;
  991. // background: #f6f7fc;
  992. }
  993. /deep/.el-table td {
  994. background: #e7e8ef;
  995. }
  996. /deep/.el-table--enable-row-transition .el-table__body td {
  997. text-align: center;
  998. }
  999. .bg-left {
  1000. padding-left: 30px;
  1001. }
  1002. .bg-right {
  1003. padding-right: 10px;
  1004. text-align: right;
  1005. }
  1006. .bg-bottom {
  1007. margin: 15px 0px;
  1008. }
  1009. .titleup {
  1010. position: relative;
  1011. }
  1012. .titleup::before {
  1013. content: '';
  1014. display: inline-block;
  1015. width: 5px;
  1016. height: 30px;
  1017. background: #5473e8;
  1018. position: absolute;
  1019. left: 0;
  1020. }
  1021. .but {
  1022. text-align: center;
  1023. margin: 20px auto;
  1024. }
  1025. .butCss {
  1026. opacity: 0;
  1027. }
  1028. /deep/.el-dialog__title {
  1029. font-size: 24px !important;
  1030. }
  1031. /deep/.el-dialog__header {
  1032. text-align: center !important;
  1033. padding: 10px 0 !important;
  1034. height: auto !important;
  1035. }
  1036. .weight {
  1037. font-size: 68px;
  1038. }
  1039. .right-content {
  1040. display: flex;
  1041. .left {
  1042. position: relative;
  1043. .but {
  1044. position: absolute;
  1045. left: 0;
  1046. right: 0;
  1047. margin: auto;
  1048. }
  1049. }
  1050. .left,
  1051. .right {
  1052. width: 50%;
  1053. }
  1054. }
  1055. .car-right {
  1056. width: 50%;
  1057. }
  1058. </style>