task_detail_kn.vue 13 KB

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