task_detail_kn.vue 13 KB

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