weightCheck.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  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. // let printString = localStorage.getItem('ws-pf_compId') + "," + row.qualityNo + "," + this.cangid
  835. // getQRcode({printString}).toPromise().then((res) => {
  836. this.isShowPrint = true
  837. this.inspect = response
  838. // this.inspect.qrCodeUrl = res
  839. if (response.compName == '黑龙江秋收有限公司') {
  840. this.inspect.compName = '黑龙江中天昊元贸易有限公司'
  841. }
  842. this.inspect.a = '中天'
  843. // })
  844. })
  845. .catch((response) => {
  846. // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
  847. })
  848. })
  849. .catch((response) => {
  850. // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
  851. })
  852. }
  853. })
  854. .catch(() => {
  855. return false
  856. })
  857. },
  858. },
  859. }
  860. </script>
  861. <style lang="scss" scoped>
  862. /deep/.el-pagination {
  863. margin-bottom: 0;
  864. }
  865. .center {
  866. background: #f6f7fc;
  867. }
  868. .ws-info-table {
  869. border: none;
  870. height: 610px;
  871. }
  872. .ws-info-table .el-form-item {
  873. width: 100%;
  874. border: none;
  875. }
  876. .formItem {
  877. width: 100%;
  878. display: inline;
  879. }
  880. /deep/.ws-info-table .el-form-item .el-form-item__label {
  881. width: 30%;
  882. text-align: center;
  883. background: #ffffff;
  884. font-size: 14px;
  885. color: #8890b1;
  886. }
  887. /deep/.ws-info-table .el-form-item .el-form-item__content {
  888. border: none;
  889. }
  890. .title {
  891. font-size: 16px;
  892. font-weight: 600;
  893. margin: 10px;
  894. }
  895. .titleup {
  896. position: relative;
  897. }
  898. .title::before {
  899. content: '';
  900. display: inline-block;
  901. width: 5px;
  902. height: 15px;
  903. background: #8890b1;
  904. margin-right: 5px;
  905. }
  906. .substance {
  907. padding-bottom: 20px;
  908. overflow-y: scroll;
  909. .active {
  910. background: #5878e8;
  911. color: white;
  912. }
  913. // background: #ffffff;
  914. width: 100%;
  915. height: calc(100vh - 125px);
  916. border-radius: 4px;
  917. margin: 0 auto;
  918. display: flex;
  919. .left {
  920. width: 30%;
  921. // padding:0 20px 20px 20px;
  922. .top {
  923. background: black;
  924. color: #2AFF7C;
  925. font-size: 32px;
  926. text-align: right;
  927. padding: 20px;
  928. border-radius: 10px;
  929. margin: 0 20px 20px 20px;
  930. .car-type {
  931. text-align: left;
  932. }
  933. .kg-style {
  934. font-size: 30px;
  935. }
  936. }
  937. .bottom {
  938. text-align: center;
  939. background: white;
  940. margin: 20px 20px 0 20px;
  941. border-radius: 10px;
  942. padding-bottom: 20px;
  943. .img1,
  944. .img2 {
  945. width: 200px;
  946. padding: 20px;
  947. }
  948. .video-content {
  949. width: 100%;
  950. }
  951. }
  952. }
  953. .right {
  954. width: 70%;
  955. padding: 20px;
  956. height: 750px;
  957. background: white;
  958. border-radius: 10px;
  959. .tab {
  960. display: flex;
  961. .tab-item {
  962. padding: 5px 10px;
  963. margin-right: 20px;
  964. border-radius: 10px;
  965. }
  966. }
  967. .table-title {
  968. background: red;
  969. .top {
  970. display: inline-block;
  971. width: 48%;
  972. .top-item {
  973. display: inline-block;
  974. }
  975. }
  976. }
  977. .table {
  978. background: red;
  979. .table-content {
  980. background: green;
  981. display: inline-block;
  982. width: 50%;
  983. .table-content-item {
  984. display: inline-block;
  985. }
  986. }
  987. }
  988. }
  989. }
  990. /deep/.el-table .el-table__header .cell,
  991. /deep/.el-table .el-table__body .cell {
  992. text-align: center;
  993. font-size: 16px;
  994. // background: #f6f7fc;
  995. }
  996. /deep/.el-table td {
  997. background: #e7e8ef;
  998. }
  999. /deep/.el-table--enable-row-transition .el-table__body td {
  1000. text-align: center;
  1001. }
  1002. .bg-left {
  1003. padding-left: 30px;
  1004. }
  1005. .bg-right {
  1006. padding-right: 10px;
  1007. text-align: right;
  1008. }
  1009. .bg-bottom {
  1010. margin: 15px 0px;
  1011. }
  1012. .titleup {
  1013. position: relative;
  1014. }
  1015. .titleup::before {
  1016. content: '';
  1017. display: inline-block;
  1018. width: 5px;
  1019. height: 30px;
  1020. background: #5473e8;
  1021. position: absolute;
  1022. left: 0;
  1023. }
  1024. .but {
  1025. text-align: center;
  1026. margin: 20px auto;
  1027. }
  1028. .butCss {
  1029. opacity: 0;
  1030. }
  1031. /deep/.el-dialog__title {
  1032. font-size: 24px !important;
  1033. }
  1034. /deep/.el-dialog__header {
  1035. text-align: center !important;
  1036. padding: 10px 0 !important;
  1037. height: auto !important;
  1038. }
  1039. .weight {
  1040. font-size: 68px;
  1041. }
  1042. .right-content {
  1043. display: flex;
  1044. .left {
  1045. position: relative;
  1046. .but {
  1047. position: absolute;
  1048. left: 0;
  1049. right: 0;
  1050. margin: auto;
  1051. }
  1052. }
  1053. .left,
  1054. .right {
  1055. width: 50%;
  1056. }
  1057. }
  1058. .car-right {
  1059. width: 50%;
  1060. }
  1061. </style>