task_detail_kn.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <view class="container">
  3. <view class="detail-desc">
  4. <view class="d-header">
  5. <text>发运数据</text>
  6. </view>
  7. <view class="c-list">
  8. <view class="c-row b-b">
  9. <text class="tit">总任务量</text>
  10. <view class="con-list">
  11. <text>{{taskInfo.count}}</text>
  12. </view>
  13. </view>
  14. <view class="c-row b-b">
  15. <text class="tit">已发运数量</text>
  16. <view class="con-list">
  17. <text>{{taskInfo.outNum}}</text>
  18. </view>
  19. </view>
  20. <view class="c-row b-b">
  21. <text class="tit">车牌号</text>
  22. <view class="con-list">
  23. <input placeholder="请填写车牌号" name="input" v-model="carNo" @input="carNoInput"></input>
  24. </view>
  25. </view>
  26. <view class="c-row b-b">
  27. <text class="tit">毛重(吨)</text>
  28. <view class="con-list">
  29. <input placeholder="请填写毛重" name="input" v-model="grossWeight" @input="grossWeightInput"></input>
  30. </view>
  31. </view>
  32. <view class="c-row b-b">
  33. <text class="tit">皮重(吨)</text>
  34. <view class="con-list">
  35. <input placeholder="请填写皮重" name="input" v-model="skinWeight" @input="skinWeightInput"></input>
  36. </view>
  37. </view>
  38. <view class="c-row b-b">
  39. <text class="tit">净重(自动计算)</text>
  40. <view class="con-list">
  41. <text>{{numFilter(netWeight)}}</text>
  42. </view>
  43. </view>
  44. <view class="cu-bar bg-white">
  45. <view class="action">
  46. 磅单照片
  47. </view>
  48. </view>
  49. <view class="cu-form-group">
  50. <view class="grid col-2 grid-square flex-sub">
  51. <view class="bg-img" v-if="poundImg != ''" @tap="ViewImage" :data-url="poundImg">
  52. <image :src="poundImg" mode="aspectFit"></image>
  53. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="0">
  54. <text class='cuIcon-close'></text>
  55. </view>
  56. </view>
  57. <view class="solids" @tap="ChooseImagePound" v-if="poundImg == ''">
  58. <text class='cuIcon-cameraadd'></text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="cu-modal" :class="modalName=='userModal'?'show':''" @tap="hideModal">
  65. <scroll-view scroll-y class="cu-dialog" :style="userStyle" @tap.stop="">
  66. <view class="cu-list menu text-center">
  67. <view class="cu-item" v-for="(item,index) in userList" :key="index" @click="mygaipai(item.id)">
  68. <label class="flex justify-between align-center flex-sub">
  69. <view class="flex-sub">{{item.userName}}</view>
  70. </label>
  71. </view>
  72. </view>
  73. </scroll-view>
  74. </view>
  75. <view class="cu-modal" :class="modalName=='workModal'?'show':''" @tap="hideModal">
  76. <scroll-view scroll-y class="cu-dialog" :style="userStyle" @tap.stop="">
  77. <view class="cu-list menu text-center">
  78. <view class="cu-item" v-for="(item,index) in userList" :key="index" @click="nextPerson(item.id)">
  79. <label class="flex justify-between align-center flex-sub">
  80. <view class="flex-sub">{{item.userName}}</view>
  81. </label>
  82. </view>
  83. </view>
  84. </scroll-view>
  85. </view>
  86. <view v-if="taskStatus == 1" class="page-bottom">
  87. <view class="action-btn-group">
  88. <button type="primary" class=" action-btn no-border buy-now-btn" @click="save">保存</button>
  89. <button type="primary" class=" action-btn no-border add-cart-btn" @click="finish">完成</button>
  90. <button type="primary" class=" action-btn no-border add-cart-btn" @click="gaipai">改派</button>
  91. </view>
  92. </view>
  93. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  94. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
  95. :showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  96. </view>
  97. </template>
  98. <script>
  99. import uploadImage from '@/components/ossutil/uploadFile.js';
  100. import {
  101. mapState
  102. } from 'vuex';
  103. export default {
  104. data() {
  105. return {
  106. isShowAlert: false,
  107. content: '您尚未登录,是否立即登录?',
  108. taskInfo: [],
  109. poundImg: '',
  110. grossWeight: '',
  111. skinWeight: '',
  112. netWeight: '',
  113. taskStatus: '',
  114. userStyle: '',
  115. modalName: '',
  116. userList: [],
  117. taskType: '',
  118. taskId: '',
  119. carNo: ''
  120. };
  121. },
  122. computed: {
  123. ...mapState(['hasLogin', 'userInfo'])
  124. },
  125. onShow() {},
  126. onLoad(options) {
  127. if (!this.hasLogin) {
  128. this.isShowAlert = true;
  129. // uni.showModal({
  130. // title: '提示',
  131. // content: '您尚未登录,是否立即登录?',
  132. // showCancel: true,
  133. // confirmText: '登录',
  134. // success: (e) => {
  135. // if (e.confirm) {
  136. // uni.navigateTo({
  137. // url: '/pages/public/login'
  138. // })
  139. // }
  140. // },
  141. // fail: () => {},
  142. // complete: () => {}
  143. // })
  144. }
  145. const that = this
  146. this.taskId = options.taskId
  147. this.taskStatus = options.taskStatus
  148. uni.showLoading({
  149. title: '正在加载',
  150. mask: true
  151. })
  152. that.$api.request('task', 'getTaskInfoKN', {
  153. taskId: options.taskId
  154. }, failres => {
  155. that.$api.msg(failres.errmsg)
  156. uni.hideLoading()
  157. }).then(res => {
  158. that.taskInfo = res.data
  159. that.carNo = res.data.carNo
  160. that.grossWeight = res.data.grossWeight
  161. that.skinWeight = res.data.skinWeight
  162. that.netWeight = res.data.netWeight
  163. that.poundImg = res.data.poundImg
  164. uni.hideLoading()
  165. })
  166. },
  167. methods: {
  168. alertBtn() {
  169. uni.navigateTo({
  170. url: '/pages/public/login'
  171. })
  172. },
  173. cancelClick() {
  174. this.isShowAlert = false
  175. },
  176. numFilter(value) {
  177. if (!value) {
  178. return 0
  179. }
  180. // 截取当前数据到小数点后两位
  181. let realVal = parseFloat(value).toFixed(2)
  182. return realVal
  183. },
  184. hideModal(e) {
  185. this.modalName = null
  186. },
  187. ViewImage(e) {
  188. var img = [];
  189. img = e.currentTarget.dataset.url.split(' ')
  190. uni.previewImage({
  191. current: 0,
  192. urls: img
  193. });
  194. },
  195. DelImg(e) {
  196. uni.showModal({
  197. title: '提示',
  198. content: '确定要删除该照片吗?',
  199. cancelText: '取消',
  200. confirmText: '确定',
  201. success: res => {
  202. if (res.confirm) {
  203. if (e.currentTarget.dataset.index == 0) {
  204. this.poundImg = "";
  205. }
  206. }
  207. }
  208. })
  209. },
  210. ChooseImagePound() {
  211. uni.chooseImage({
  212. count: 1, //默认9
  213. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  214. sourceType: ['album', 'camera'], //从相册选择
  215. success: (res) => {
  216. //上传图片
  217. //图片路径可自行修改
  218. uploadImage(res.tempFilePaths[0], 'poundImg/',
  219. result => {
  220. this.poundImg = result
  221. uni.hideLoading();
  222. }
  223. )
  224. }
  225. });
  226. },
  227. grossWeightInput(e) {
  228. this.grossWeight = e.detail.value
  229. if (this.grossWeight && this.skinWeight) {
  230. this.netWeight = this.grossWeight - this.skinWeight
  231. }
  232. },
  233. skinWeightInput(e) {
  234. this.skinWeight = e.detail.value
  235. if (this.grossWeight && this.skinWeight) {
  236. this.netWeight = this.grossWeight - this.skinWeight
  237. }
  238. },
  239. carNoInput(e) {
  240. this.carNo = e.detail.value
  241. },
  242. save() {
  243. const that = this
  244. uni.showLoading({
  245. title: '正在加载',
  246. mask: true
  247. })
  248. that.$api.request('task', 'saveTaskInfoKN', {
  249. taskId: that.taskId,
  250. grossWeight: !that.grossWeight ? '' : that.grossWeight,
  251. skinWeight: !that.skinWeight ? '' : that.skinWeight,
  252. netWeight: !that.netWeight ? '' : that.netWeight,
  253. poundImg: !that.poundImg ? '' : that.poundImg,
  254. carNo: !that.carNo ? '' : that.carNo
  255. }, failres => {
  256. that.$api.msg(failres.errmsg)
  257. uni.hideLoading()
  258. }).then(res => {
  259. that.$api.msg('保存成功')
  260. uni.hideLoading()
  261. })
  262. },
  263. finish() {
  264. const that = this
  265. if (!that.grossWeight) {
  266. this.$api.msg('请填写毛重');
  267. return;
  268. }
  269. if (!that.skinWeight) {
  270. this.$api.msg('请填写皮重');
  271. return;
  272. }
  273. if (!that.poundImg) {
  274. this.$api.msg('请上传磅单照片');
  275. return;
  276. }
  277. uni.showModal({
  278. title: '温馨提示',
  279. content: '是否指派外勤继续完成库内销售发运任务',
  280. confirmText: "是",
  281. cancelText: "否",
  282. success: function(res) {
  283. if (res.confirm) {
  284. uni.showLoading({
  285. title: '正在加载',
  286. mask: true
  287. })
  288. that.$api.request('user', 'getUserList', {
  289. role: '外勤'
  290. }, failres => {
  291. that.$api.msg(failres.errmsg)
  292. uni.hideLoading()
  293. }).then(res => {
  294. that.userList = res.data
  295. if (that.userList.length == 0) {
  296. that.$api.msg('暂无外勤信息')
  297. } else {
  298. var height = that.userList.length * 100
  299. var width = 500
  300. that.userStyle = "height:" + height + "rpx;width:" + width + "rpx"
  301. that.modalName = 'workModal'
  302. }
  303. uni.hideLoading()
  304. })
  305. } else if (res.cancel) {
  306. uni.showLoading({
  307. title: '正在加载',
  308. mask: true
  309. })
  310. that.$api.request('task', 'finishTaskInfoKN', {
  311. taskId: that.taskId,
  312. grossWeight: !that.grossWeight ? '' : that.grossWeight,
  313. skinWeight: !that.skinWeight ? '' : that.skinWeight,
  314. netWeight: !that.netWeight ? '' : that.netWeight,
  315. poundImg: !that.poundImg ? '' : that.poundImg,
  316. carNo: !that.carNo ? '' : that.carNo,
  317. nextUserId: -1
  318. }, failres => {
  319. that.$api.msg(failres.errmsg)
  320. uni.hideLoading()
  321. }).then(res => {
  322. uni.hideLoading()
  323. that.$api.msg('完成成功')
  324. setTimeout(() => {
  325. uni.navigateBack({})
  326. }, 1000);
  327. })
  328. }
  329. }
  330. });
  331. },
  332. gaipai() {
  333. const that = this
  334. uni.showLoading({
  335. title: '正在加载',
  336. mask: true
  337. })
  338. that.$api.request('user', 'getUserList', {
  339. role: '外勤'
  340. }, failres => {
  341. that.$api.msg(failres.errmsg)
  342. uni.hideLoading()
  343. }).then(res => {
  344. that.userList = res.data
  345. if (that.userList.length == 0) {
  346. that.$api.msg('暂无外勤信息')
  347. } else {
  348. var height = that.userList.length * 100
  349. var width = 500
  350. that.userStyle = "height:" + height + "rpx;width:" + width + "rpx"
  351. that.modalName = 'userModal'
  352. }
  353. uni.hideLoading()
  354. })
  355. },
  356. mygaipai(id) {
  357. var that = this
  358. uni.showLoading({
  359. title: '正在加载',
  360. mask: true
  361. })
  362. that.$api.request('task', 'gaipai', {
  363. taskId: that.taskId,
  364. outPersonId: id
  365. }, failres => {
  366. that.$api.msg(failres.errmsg)
  367. that.modalName = null
  368. uni.hideLoading()
  369. }).then(res => {
  370. that.modalName = null
  371. uni.navigateBack({
  372. delta: 2
  373. })
  374. uni.hideLoading()
  375. })
  376. },
  377. nextPerson(id) {
  378. var that = this
  379. uni.showLoading({
  380. title: '正在加载',
  381. mask: true
  382. })
  383. that.$api.request('task', 'finishTaskInfoKN', {
  384. taskId: that.taskId,
  385. grossWeight: !that.grossWeight ? '' : that.grossWeight,
  386. skinWeight: !that.skinWeight ? '' : that.skinWeight,
  387. netWeight: !that.netWeight ? '' : that.netWeight,
  388. poundImg: !that.poundImg ? '' : that.poundImg,
  389. carNo: !that.carNo ? '' : that.carNo,
  390. nextUserId: id
  391. }, failres => {
  392. that.$api.msg(failres.errmsg)
  393. uni.hideLoading()
  394. }).then(res => {
  395. uni.hideLoading()
  396. that.$api.msg('完成成功')
  397. setTimeout(() => {
  398. uni.navigateBack({})
  399. }, 1000);
  400. })
  401. },
  402. },
  403. }
  404. </script>
  405. <style lang='scss'>
  406. .container {
  407. padding-bottom: 160upx;
  408. }
  409. .detail-desc {
  410. background: #fff;
  411. margin-top: 16upx;
  412. width: 750upx;
  413. .d-header {
  414. display: flex;
  415. justify-content: center;
  416. align-items: center;
  417. height: 80upx;
  418. font-size: $font-base + 2upx;
  419. color: $font-color-dark;
  420. position: relative;
  421. text {
  422. padding: 0 20upx;
  423. background: #fff;
  424. position: relative;
  425. z-index: 1;
  426. }
  427. &:after {
  428. position: absolute;
  429. left: 50%;
  430. top: 50%;
  431. transform: translateX(-50%);
  432. width: 300upx;
  433. height: 0;
  434. content: '';
  435. border-bottom: 1px solid #ccc;
  436. }
  437. }
  438. }
  439. .c-list {
  440. font-size: $font-sm + 2upx;
  441. color: $font-color-base;
  442. background: #fff;
  443. .c-row {
  444. display: flex;
  445. align-items: center;
  446. padding: 20upx 30upx;
  447. position: relative;
  448. }
  449. .tit {
  450. width: 220upx;
  451. }
  452. .con {
  453. flex: 1;
  454. color: $font-color-dark;
  455. .selected-text {
  456. margin-right: 10upx;
  457. }
  458. }
  459. .bz-list {
  460. height: 40upx;
  461. font-size: $font-sm+2upx;
  462. color: $font-color-dark;
  463. text {
  464. display: inline-block;
  465. margin-right: 30upx;
  466. }
  467. }
  468. .con-list {
  469. flex: 1;
  470. display: flex;
  471. flex-direction: column;
  472. color: $font-color-dark;
  473. line-height: 40upx;
  474. text-align: right;
  475. padding-right: 20upx;
  476. }
  477. .red {
  478. color: $uni-color-primary;
  479. }
  480. }
  481. /* 底部操作菜单 */
  482. .page-bottom {
  483. .action-btn-group {
  484. .action-btn {
  485. width: 33.3333%;
  486. }
  487. }
  488. }
  489. @mixin playcenter {
  490. display: flex;
  491. align-items: center;
  492. justify-content: center;
  493. }
  494. .xsh-start {
  495. width: 105rpx;
  496. height: 105rpx;
  497. background: #FFFFFF;
  498. border-radius: 50%;
  499. font-size: 29rpx;
  500. color: #4135EB;
  501. @include playcenter;
  502. flex-wrap: wrap;
  503. }
  504. .x-modal {
  505. width: 100%;
  506. .x-m-title {
  507. width: 100%;
  508. height: 90rpx;
  509. padding: 0 38rpx 0 31rpx;
  510. box-sizing: border-box;
  511. font-size: 29rpx;
  512. color: #333333;
  513. border-bottom: 1px dashed #999;
  514. @include playcenter;
  515. justify-content: space-between;
  516. .xm-t-clear {
  517. font-size: 25rpx;
  518. color: #341DB7;
  519. @include playcenter;
  520. >image {
  521. width: 28rpx;
  522. height: 28rpx;
  523. display: block;
  524. margin-right: 8rpx;
  525. }
  526. }
  527. }
  528. .x-m-con {
  529. width: 100%;
  530. padding: 0 31rpx 18rpx;
  531. margin-top: 5rpx;
  532. box-sizing: border-box;
  533. }
  534. }
  535. </style>