delivery.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <template>
  2. <!-- 确认送达 -->
  3. <view>
  4. <u-navbar :title="navTitle" autoBack placeholder @leftClick="leftClick"></u-navbar>
  5. <view class="card_order_details">
  6. <view style="display: flex;align-items: center;margin-bottom: 20rpx;" v-if="storeFlag">
  7. <image class="mine_image" src="../../static/portrait.png" mode=""></image>
  8. <view class="card_user_title">
  9. <view class="mine_phone">{{storeData[2]}}
  10. </view>
  11. <view class="mine_phone">{{storeData[4]}}
  12. </view>
  13. </view>
  14. </view>
  15. <view class="details_title">单位内编号 <span class="line_title">*</span></view>
  16. <view style="display: flex;align-items: center;" v-if="selectiveType != 'inspect'">
  17. <u-input border="surround" placeholder="点击输入" v-model="frequencyCoding"></u-input>
  18. <view class="btn_add_card">
  19. <u-button type="primary" text="添加" @click="addCode"></u-button>
  20. </view>
  21. </view>
  22. <view class="card_search" v-else-if="selectiveType == 'inspect'">
  23. <view class="card_sweep" @click="sweep">
  24. <u-icon name="scan" size="36"></u-icon>
  25. <view class="scan_title">扫一扫</view>
  26. </view>
  27. <view class="card_input">
  28. <u-input border="surround" v-model="frequencyCoding" @blur="inputBlur"></u-input>
  29. </view>
  30. <view class="deleteCurrent" @click="removeWaybill(frequencyCoding)">
  31. <u-icon class="icon_current" name="backspace" height="10" size="20"></u-icon>
  32. <view class="title_nape">删除</view>
  33. </view>
  34. </view>
  35. <view class="card_frequency" v-if="selectiveType != 'inspect'">
  36. <view class="scan_card_code">
  37. <view style="display: flex;align-items: center;">
  38. <view style="display: flex;align-items: center;" @click="addLine">
  39. <u-icon name="scan" size="26"></u-icon>
  40. <view class="title_subhead">增加一条</view>
  41. </view>
  42. <view style="display: flex;align-items: center;margin-left: 30rpx;" @click="continuousAddition">
  43. <u-icon name="scan" size="26"></u-icon>
  44. <view class="title_subhead">连续扫码增加</view>
  45. </view>
  46. </view>
  47. <view class="card_bottle">已扫<span>{{list.length}}</span>瓶</view>
  48. </view>
  49. <view style="width: 100%;" v-if="list.length > 0">
  50. <view class="item_coding" v-for="(item,index) in list" :key="index">
  51. <view style="display: flex;align-items: center;">
  52. <view class="item_current">{{index + 1}}</view>
  53. <view class="title_codingewtw">{{item}}</view>
  54. </view>
  55. <view class="item_title1 title_red" @click="removeWaybill(item)">删除</view>
  56. </view>
  57. </view>
  58. <view class="card_empty" v-else>
  59. <u-empty mode="list" text="请先扫描添加单位内编号"></u-empty>
  60. </view>
  61. </view>
  62. <view class="card_examine" v-else>
  63. <view class="card_examine_item space_between" v-for="(item,index) in checkEntry" :key="index">
  64. <view class="title_entry">{{item.label}}</view>
  65. <view style="height: 40rpx;" v-if="item.type == 'radio'">
  66. <u-radio-group v-model="ruleForm[`${item.field}`]" placement="row">
  67. <u-radio shape="circle" :customStyle="{width:'140rpx'}"
  68. v-for="(item, index) in item.options" :key="index" :label="item.label"
  69. :name="item.value"></u-radio>
  70. </u-radio-group>
  71. </view>
  72. <view class="center_row" v-if="item.type == 'input'">
  73. <u-input class="input_item" border="surround" v-model="ruleForm[`${item.field}`]"></u-input>
  74. <view style="margin-left: 15rpx;width: 90rpx;">{{item.unit}}</view>
  75. </view>
  76. <view class="center_row" v-if="item.type == 'numinput'">
  77. <u-input class="input_item" type="digit" border="surround"
  78. v-model="ruleForm[`${item.field}`]"></u-input>
  79. <view style="margin-left: 15rpx;width: 90rpx;">{{item.unit}}</view>
  80. </view>
  81. </view>
  82. </view>
  83. <view style="width: 100%;height: 120rpx;"></view>
  84. <view class="card_btn">
  85. <u-button style="margin-bottom: 20rpx;" type="primary" @click="submit">提交</u-button>
  86. </view>
  87. </view>
  88. <u-popup :show="show" :round="10" :closeOnClickOverlay="false" mode="center" @close="close">
  89. <view class="card_coding_scan">
  90. <view class="title_coding">单位内编号</view>
  91. <view class="coding_title1">{{scanCoding}}</view>
  92. <view style="display: flex;align-items: center;">
  93. <u-icon color="#19be6b" size="30" name="checkmark-circle-fill"></u-icon>
  94. <view class="success_title">扫描成功</view>
  95. </view>
  96. <view class="title_coding">3秒后再次扫描</view>
  97. </view>
  98. </u-popup>
  99. </view>
  100. </template>
  101. <script>
  102. import {
  103. formRules,
  104. } from "./new_file.js";
  105. export default {
  106. data() {
  107. return {
  108. frequencyCoding: '',
  109. navTitle: '',
  110. selectiveType: '',
  111. cmpCode: '',
  112. list: [],
  113. checkEntry: formRules(),
  114. ruleForm: {
  115. deadWeight: '',
  116. color: '',
  117. pipePressure: '',
  118. fillWeight: '',
  119. repeatWeight: '',
  120. corrosion: 0,
  121. crackle: 0,
  122. deform: 0,
  123. damage: 0,
  124. safeAnnex: 0,
  125. gasPressure: 0,
  126. bodyDeform: 0,
  127. fillingLeak: 0,
  128. bodyTemperature: 0,
  129. filledLeak: 0,
  130. warnSign: 0,
  131. fillLabel: 0,
  132. seal: 0,
  133. },
  134. orderId: '',
  135. scanType: 1,
  136. show: false,
  137. scanCoding: '',
  138. storeFlag: false,
  139. storeData: [],
  140. scanFlag: true,
  141. }
  142. },
  143. onUnload() {
  144. console.log('页面销毁了!');
  145. this.$cache.removeCache('storeInformation')
  146. },
  147. onLoad(receive) {
  148. var storeList = this.$cache.getCache('storeInformation')
  149. if (storeList) {
  150. this.storeFlag = true
  151. this.storeData = storeList
  152. }
  153. this.navTitle = receive.title
  154. this.selectiveType = receive.id
  155. this.cmpCode = receive.cmpCode
  156. this.orderId = receive.orderId
  157. },
  158. methods: {
  159. leftClick() {
  160. uni.$emit('refresh');
  161. },
  162. submit() {
  163. // 99订单扫码确定送达、100订单扫码确定取消
  164. if (this.selectiveType == '99' || this.selectiveType == '100') {
  165. // 修改订单状态
  166. if (this.list.length > 0) {
  167. const param = {
  168. id: Number(this.orderId),
  169. state: null,
  170. chipUid: this.list,
  171. }
  172. if (this.selectiveType == '99') {
  173. param.state = 3
  174. } else if (this.selectiveType == '100') {
  175. param.state = 4
  176. }
  177. uni.showLoading({
  178. mask: true,
  179. });
  180. this.$api.put('/api/order/state', param).then(res => {
  181. if (res.code == 200) {
  182. this.frequencyCoding = ''
  183. this.list = []
  184. uni.$u.toast('操作成功')
  185. setTimeout(() => {
  186. uni.$emit('refresh');
  187. uni.navigateBack({
  188. delta: 1
  189. });
  190. }, 1000)
  191. } else {
  192. uni.$u.toast(res.data.msg)
  193. }
  194. uni.hideLoading();
  195. }).catch(() => {
  196. uni.hideLoading();
  197. })
  198. } else {
  199. uni.$u.toast('请先扫单位内编号')
  200. }
  201. } else if (this.selectiveType == 'inspect') {
  202. if (this.frequencyCoding) {
  203. uni.showLoading({
  204. mask: true,
  205. });
  206. let params = JSON.parse(JSON.stringify(this.ruleForm))
  207. params.repeatWeight = Number(this.ruleForm.repeatWeight)
  208. params.fillWeight = Number(this.ruleForm.fillWeight)
  209. params.deadWeight = Number(this.ruleForm.deadWeight)
  210. params.pipePressure = Number(this.ruleForm.pipePressure)
  211. this.$api.post('/api/fill-check', {
  212. innerCode: this.frequencyCoding,
  213. ...params,
  214. }).then(res => {
  215. if (res.code == 200) {
  216. this.frequencyCoding = ''
  217. for (const k in this.ruleForm) {
  218. // 循环赋值
  219. this.ruleForm[k] = 0
  220. if (['deadWeight', 'color', 'pipePressure', 'fillWeight', 'repeatWeight']
  221. .includes(k)) {
  222. this.ruleForm[k] = ''
  223. }
  224. }
  225. uni.$u.toast('操作成功')
  226. }
  227. uni.hideLoading();
  228. }).catch(() => {
  229. uni.hideLoading();
  230. })
  231. } else {
  232. uni.$u.toast('请先扫单位内编号')
  233. }
  234. } else {
  235. if (this.list.length > 0) {
  236. // 操作记录、流转步骤接口
  237. const param = {
  238. chipUidList: this.list,
  239. currentEnterprise: this.cmpCode,
  240. optType: this.selectiveType,
  241. }
  242. if (!param.currentEnterprise) {
  243. delete param.currentEnterprise
  244. }
  245. uni.showLoading({
  246. mask: true,
  247. });
  248. this.$api.post('/api/operation-log', param).then(res => {
  249. if (res.code == 200) {
  250. this.list = []
  251. this.frequencyCoding = ''
  252. uni.$u.toast('操作成功')
  253. } else {
  254. uni.$u.toast(res.data.msg)
  255. }
  256. uni.hideLoading();
  257. }).catch(() => {
  258. uni.hideLoading();
  259. })
  260. } else {
  261. uni.$u.toast('请先扫单位内编号')
  262. }
  263. }
  264. },
  265. // 输入值
  266. inputBlur(value) {
  267. this.list.push(value)
  268. this.list = Array.from(new Set(this.list));
  269. },
  270. // 输入钢瓶编号添加
  271. addCode() {
  272. if (this.frequencyCoding) {
  273. if (['10', '15', '33', '37', '12', '16', '19', '99'].includes(this.selectiveType)) {
  274. let arrNum = ''
  275. if (this.selectiveType == '99') {
  276. arrNum = '26'
  277. } else {
  278. arrNum = this.selectiveType
  279. }
  280. this.$api.post('/api/operation-log/check', {
  281. chipUid: this.frequencyCoding,
  282. optType: arrNum,
  283. }).then(res => {
  284. if (res.code == 200) {
  285. this.list.push(this.frequencyCoding)
  286. this.list = Array.from(new Set(this.list));
  287. this.frequencyCoding = ''
  288. } else {
  289. uni.$u.toast(res.data.msg)
  290. }
  291. })
  292. } else {
  293. this.list.push(this.frequencyCoding)
  294. this.list = Array.from(new Set(this.list));
  295. this.frequencyCoding = ''
  296. }
  297. }
  298. },
  299. // 添加一条
  300. addLine() {
  301. this.scanType = 1
  302. if (this.scanFlag) {
  303. this.scanFlag = false
  304. this.sweep()
  305. }
  306. },
  307. // 连续添加
  308. continuousAddition() {
  309. this.scanType = 2
  310. if (this.scanFlag) {
  311. this.scanFlag = false
  312. this.sweep()
  313. }
  314. },
  315. // 扫一扫
  316. sweep() {
  317. // 允许从相机和相册扫码
  318. uni.scanCode({
  319. scanType: ['qrCode'],
  320. autoZoom: false,
  321. success: (res) => {
  322. console.log(res, '--------');
  323. if (res.result) {
  324. this.scanFlag = true
  325. let url = res.result;
  326. const arrf = url.split('=')
  327. this.unitCoding(arrf[1])
  328. } else {
  329. console.log('请重新扫描');
  330. return false;
  331. }
  332. },
  333. fail: (res) => {
  334. console.log('未识别到二维码1');
  335. }
  336. })
  337. },
  338. // 单位内编码获取
  339. unitCoding(qrid) {
  340. uni.showLoading({
  341. title: '加载中'
  342. });
  343. uni.request({
  344. url: 'http://qr.uinshine.com:9000/CommonAPI/product/getDetails', //仅为示例,并非真实接口地址。
  345. method: 'POST',
  346. header: {
  347. 'content-type': 'application/x-www-form-urlencoded', // 默认值
  348. },
  349. data: {
  350. qr_id: qrid,
  351. },
  352. success: (res) => {
  353. if (res.data.code == 0) {
  354. var arr = res.data.data
  355. if (this.selectiveType != 'inspect') {
  356. if (['10', '15', '33', '37', '12', '16', '19', '99'].includes(this
  357. .selectiveType)) {
  358. let arrNum = ''
  359. if (this.selectiveType == '99') {
  360. arrNum = '26'
  361. } else {
  362. arrNum = this.selectiveType
  363. }
  364. this.$api.post('/api/operation-log/check', {
  365. chipUid: arr.inner_code,
  366. optType: arrNum,
  367. }).then(res => {
  368. if (res.code == 200) {
  369. if (this.scanType == 1) {
  370. this.list.push(arr.inner_code)
  371. this.list = Array.from(new Set(this.list));
  372. } else {
  373. this.show = true
  374. this.list.push(arr.inner_code)
  375. this.list = Array.from(new Set(this.list));
  376. this.scanCoding = arr.inner_code
  377. // 扫码间隔两秒
  378. setTimeout(() => {
  379. this.sweep()
  380. this.show = false
  381. }, 3000)
  382. }
  383. } else {
  384. this.show = false
  385. uni.$u.toast(res.data.msg)
  386. }
  387. })
  388. } else {
  389. if (this.scanType == 1) {
  390. this.list.push(arr.inner_code)
  391. this.list = Array.from(new Set(this.list));
  392. } else {
  393. this.show = true
  394. this.list.push(arr.inner_code)
  395. this.list = Array.from(new Set(this.list));
  396. this.scanCoding = arr.inner_code
  397. // 扫码间隔两秒
  398. setTimeout(() => {
  399. this.sweep()
  400. this.show = false
  401. }, 3000)
  402. }
  403. }
  404. } else {
  405. this.frequencyCoding = arr.inner_code
  406. }
  407. } else {
  408. uni.$u.toast('请扫描单位内编号二维码')
  409. }
  410. uni.hideLoading();
  411. }
  412. });
  413. },
  414. // 移除错误运单号
  415. removeWaybill(value) {
  416. if (this.frequencyCoding == value) {
  417. this.frequencyCoding = ''
  418. }
  419. const arr = deleteElementById(this.list, value)
  420. this.list = arr
  421. function deleteElementById(arr, key) {
  422. return arr.filter((item) => item !== key);
  423. }
  424. },
  425. // 弹窗关闭
  426. close() {
  427. this.show = false
  428. }
  429. }
  430. }
  431. </script>
  432. <style lang="scss" scoped>
  433. .card_order_details {
  434. margin: 0rpx 25rpx 25rpx 25rpx;
  435. }
  436. .mine_image {
  437. width: 100rpx;
  438. height: 100rpx;
  439. border-radius: 50%;
  440. }
  441. .card_user_title {
  442. display: flex;
  443. flex-direction: column;
  444. align-items: flex-start;
  445. }
  446. .mine_phone {
  447. margin-left: 20rpx;
  448. font-size: 30rpx;
  449. }
  450. .details_title {
  451. color: #333;
  452. font-size: 34rpx;
  453. font-weight: 500;
  454. margin-bottom: 10rpx;
  455. }
  456. .btn_add_card {
  457. margin-left: 20rpx;
  458. }
  459. .card_search {
  460. display: flex;
  461. align-items: center;
  462. margin: 20rpx 0rpx;
  463. }
  464. .scan_title {
  465. font-size: 20rpx;
  466. }
  467. .card_sweep {
  468. display: flex;
  469. flex-direction: column;
  470. align-items: center;
  471. flex: none;
  472. }
  473. .card_input {
  474. width: 100%;
  475. margin-left: 30rpx;
  476. }
  477. .deleteCurrent {
  478. display: flex;
  479. align-items: center;
  480. flex-direction: column;
  481. justify-content: center;
  482. border: 1px solid #e5e5e5;
  483. padding: 5rpx 0rpx 5rpx 5rpx;
  484. margin-left: 10rpx;
  485. border-radius: 8rpx;
  486. height: 66rpx;
  487. .icon_current {
  488. height: 15px;
  489. }
  490. .title_nape {
  491. margin: 0rpx 10rpx;
  492. display: flex;
  493. font-size: 20rpx;
  494. width: 40rpx;
  495. }
  496. }
  497. .line_title {
  498. color: red;
  499. }
  500. .card_frequency {
  501. display: flex;
  502. flex-wrap: wrap;
  503. }
  504. .scan_card_code {
  505. width: 100%;
  506. display: flex;
  507. align-items: center;
  508. justify-content: space-between;
  509. margin-top: 30rpx;
  510. padding-bottom: 30rpx;
  511. border-bottom: 1rpx solid #e4e7ed;
  512. }
  513. .card_bottle {
  514. font-size: 30rpx;
  515. span {
  516. margin: 0rpx 5rpx;
  517. color: red;
  518. }
  519. }
  520. .item_coding {
  521. display: flex;
  522. justify-content: space-between;
  523. align-items: center;
  524. width: 100%;
  525. margin-top: 10px;
  526. padding: 25rpx 0rpx;
  527. border-bottom: 2rpx solid #dfdfdf;
  528. }
  529. .item_current {
  530. width: 40rpx;
  531. color: #82848a;
  532. }
  533. .title_codingewtw {
  534. margin-left: 10rpx;
  535. font-size: 30rpx;
  536. }
  537. .item_title1 {
  538. margin-left: 10rpx;
  539. }
  540. .title_red {
  541. color: #fa3534;
  542. }
  543. .card_empty {
  544. width: 100%;
  545. margin-top: 50rpx;
  546. display: flex;
  547. align-items: center;
  548. justify-content: center;
  549. }
  550. .card_btn {
  551. position: fixed;
  552. left: 0;
  553. right: 0;
  554. bottom: 0;
  555. padding-left: 30rpx;
  556. padding-right: 30rpx;
  557. padding-top: 20rpx;
  558. background-color: #fff;
  559. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  560. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  561. }
  562. .card_examine {
  563. margin-top: 50rpx;
  564. }
  565. .card_examine_item {
  566. display: flex;
  567. margin-bottom: 20rpx;
  568. height: 72rpx;
  569. }
  570. .title_entry {
  571. font-size: 26rpx;
  572. }
  573. .center_row {
  574. display: flex;
  575. height: 70rpx;
  576. align-items: center;
  577. }
  578. .input_item {
  579. width: 240rpx;
  580. }
  581. .card_coding_scan {
  582. display: flex;
  583. align-items: center;
  584. flex-direction: column;
  585. width: 400rpx;
  586. padding: 30rpx;
  587. }
  588. .title_coding {
  589. font-size: 32rpx;
  590. margin: 20rpx;
  591. }
  592. .success_title {
  593. font-size: 40rpx;
  594. margin-left: 10rpx;
  595. }
  596. .coding_title1 {
  597. font-size: 60rpx;
  598. margin-bottom: 20rpx;
  599. font-weight: 600;
  600. }
  601. </style>