weightCheck.vue 31 KB

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