delivery.vue 16 KB

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