task_detail_fh.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <view class="container">
  3. <view class="detail-desc">
  4. <view class="d-header">
  5. <text>选择车辆</text>
  6. </view>
  7. <scroll-view scroll-y @tap.stop="">
  8. <checkbox-group class="block" @change="CheckboxChange">
  9. <view class="cu-list menu text-left">
  10. <view class="cu-item" v-for="(item,index) in taskInfo" :key="index">
  11. <label v-if="item.fhFlag == 0" class="flex justify-between align-center flex-sub">
  12. <view class="flex-sub">{{item.carNo+" [ "+item.tranNo+" ] "}}(未放货)</view>
  13. <checkbox class="round" :checked="checkedList.includes(String(item.id))"
  14. :value="item.id"></checkbox>
  15. </label>
  16. <label v-else-if="item.fhFlag == 1" class="flex justify-between text-green align-center flex-sub">
  17. <view class="flex-sub">{{item.carNo+" [ "+item.tranNo+" ] "}}(已放货)</view>
  18. <checkbox class="round" :checked="checkedList.includes(String(item.id))"
  19. :value="item.id"></checkbox>
  20. </label>
  21. </view>
  22. </view>
  23. </checkbox-group>
  24. </scroll-view>
  25. <uni-table border stripe emptyText="暂无收款数据" min-width='250px' >
  26. <uni-tr>
  27. <uni-th align="center" width="60">收款方式</uni-th>
  28. <uni-th align="center" width="60">收款金额</uni-th>
  29. <uni-th align="center" width="70">收款日期</uni-th>
  30. <uni-th align="center" width="60">收款截图</uni-th>
  31. <uni-th align="center" width="40">操作</uni-th>
  32. </uni-tr>
  33. <uni-tr v-for="(item, index) in collectInfo" >
  34. <uni-td align="center">{{item.strPaymentMethod}}</uni-td>
  35. <uni-td align="center">{{item.collectMoney}}</uni-td>
  36. <uni-td align="center">{{item.strCollectDate}}</uni-td>
  37. <uni-td align="center">
  38. <view class="bg-img" v-if="item.collectImg != ''" @tap="ViewImage" :data-url="item.collectImg">
  39. <image :src="item.collectImg" mode="aspectFit" style="width: 40px; height: 40px;"></image>
  40. </view>
  41. </uni-td>
  42. <uni-td align="center">
  43. <view v-if="!item.id" style="color: #0081FF;" @click="deleteRow(index)">移除</view>
  44. </uni-td>
  45. </uni-tr>
  46. </uni-table>
  47. <uni-table border stripe emptyText="" min-width='250px' >
  48. <uni-tr>
  49. <uni-th align="center" width="100">应收:{{shouldCollect}}</uni-th>
  50. <uni-th align="center" width="100">已收:{{alreadyCollect}}</uni-th>
  51. <uni-th align="center" width="100">未收:{{shouldCollect-alreadyCollect}}</uni-th>
  52. </uni-tr>
  53. <uni-tr>
  54. </uni-tr>
  55. </uni-table>
  56. <u-modal v-model="collectShow"
  57. ref="collectModal"
  58. title="收款"
  59. show-cancel-button="true"
  60. confirm-text="确定"
  61. cancel-text="取消"
  62. @confirm="confirm"
  63. @cancel="cancel" >
  64. <view class="cu-form-group">
  65. <view class="title">收款方式</view>
  66. <picker @change="CollectTypeChange" :value="collectTypeIndex" :range="collectType">
  67. <view class="picker">
  68. {{collectTypeIndex>-1?collectType[collectTypeIndex]:'请选择'}}
  69. </view>
  70. </picker>
  71. </view>
  72. <view v-if="collectTypeIndex == 0" class="cu-form-group">
  73. <view class="title">收款编号</view>
  74. <picker @change="CollectNoChange" :value="collectNoIndex" :range="collectNo">
  75. <view class="picker">
  76. {{collectNoIndex>-1?collectNo[collectNoIndex]:'请选择'}}
  77. </view>
  78. </picker>
  79. </view>
  80. <view class="cu-form-group">
  81. <view class="title">收款金额</view>
  82. <input placeholder="请填写" name="input" @input="collectMoneyInput"></input>
  83. </view>
  84. <view class="cu-form-group">
  85. <view class="title">收款日期</view>
  86. <picker mode = "date" @change="CollectDateChange" :value="collectDate" >
  87. <view class="picker">
  88. {{collectDate}}
  89. </view>
  90. </picker>
  91. </view>
  92. <view class="cu-form-group">
  93. <view class="title">收款截图</view>
  94. <view class="bg-img" v-if="collectImg != ''" @tap="ViewImage" :data-url="collectImg">
  95. <image :src="collectImg" mode="aspectFit" style="width: 40px; height: 40px;"></image>
  96. </view>
  97. <view class="solids" style="width: 20px; height: 20px;" @tap="ChooseImage" v-if="collectImg == ''">
  98. <text class='cuIcon-cameraadd'></text>
  99. </view>
  100. </view>
  101. </u-modal>
  102. <view class="cu-modal" :class="modalName=='workModal'?'show':''" >
  103. <scroll-view scroll-y class="cu-dialog" :style="userStyle" @tap.stop="">
  104. <view class="cu-list menu text-center" >
  105. <!-- <view >{{请选择单号}}</view> -->
  106. <view class="cu-item" v-for="(item,index) in workList" :key="index" @click="choose(item.workNo)">
  107. <label class="flex justify-between align-center flex-sub">
  108. <view class="flex-sub">{{item.workNo}}</view>
  109. </label>
  110. </view>
  111. </view>
  112. </scroll-view>
  113. </view>
  114. </view>
  115. <view class="page-bottom">
  116. <view class="action-btn-group">
  117. <button type="primary" class=" action-btn no-border add-cart-btn" @click="collect">添加收款</button>
  118. <button type="primary" class=" action-btn no-border add-cart-btn" @click="fanghuo">申请放货</button>
  119. </view>
  120. </view>
  121. </view>
  122. </template>
  123. <script>
  124. import uploadImage from '@/components/ossutil/uploadFile.js';
  125. import {
  126. mapState
  127. } from 'vuex';
  128. export default {
  129. data() {
  130. return {
  131. taskInfo:[],
  132. taskInfoTmp:[],
  133. collectInfo:[],
  134. collectImg:'',
  135. grossWeight:'',
  136. skinWeight:'',
  137. netWeight:'',
  138. taskStatus:'',
  139. userStyle:'',
  140. modalName:'',
  141. workList:[],
  142. taskType:'',
  143. taskId:'',
  144. carNo:'',
  145. checkedList:[],
  146. collectShow:false,
  147. collectType: ['预收款', '网银收款', '现金收款'],
  148. collectTypeIndex: -1,
  149. collectNoData: [],
  150. collectNo: [],
  151. collectNoIndex: -1,
  152. collectMoney:0,
  153. collectDate:"请选择",
  154. workNo:null,
  155. shouldCollect:0,
  156. alreadyCollect:0
  157. };
  158. },
  159. computed: {
  160. ...mapState(['hasLogin','userInfo'])
  161. },
  162. onShow() {
  163. },
  164. onLoad(options) {
  165. const that = this
  166. this.taskId = options.taskId
  167. this.taskStatus = options.taskStatus
  168. this.$api.request('task', 'getFanghuoList', failres => {
  169. that.$api.msg(failres.errmsg)
  170. uni.hideLoading()
  171. }).then(res => {
  172. let data = res.data
  173. if(data.taskInfo){
  174. that.taskInfoTmp = data.taskInfo
  175. }
  176. if(data.collectInfo){
  177. that.collectInfo = data.collectInfo
  178. }
  179. if(data.workInfo){
  180. that.workList = data.workInfo
  181. }
  182. for(var i=0;i<that.collectInfo.length;i++){
  183. that.alreadyCollect += that.collectInfo[i].collectMoney
  184. }
  185. that.shouldCollect = data.shouldCollect
  186. var height = that.workList.length * 100
  187. var width = 500
  188. that.userStyle = "height:"+height+"rpx;width:" + width+"rpx"
  189. that.modalName = 'workModal'
  190. uni.hideLoading()
  191. })
  192. },
  193. methods: {
  194. deleteRow(e){
  195. this.collectInfo.splice(e,1)
  196. },
  197. choose(workNo){
  198. this.workNo = workNo
  199. this.modalName = null
  200. const list = this.taskInfoTmp.filter ( item => item.tranNo == workNo)
  201. this.taskInfo = list
  202. },
  203. collectMoneyInput(e){
  204. this.collectMoney = e.detail.value
  205. },
  206. CollectDateChange(e) {
  207. this.collectDate = e.detail.value
  208. },
  209. CollectTypeChange(e) {
  210. const that = this
  211. this.collectTypeIndex = e.detail.value
  212. if(this.collectTypeIndex == 0){
  213. this.$api.request('task', 'getCollectList', {
  214. collectType: 1
  215. }, failres => {
  216. that.$api.msg(failres.errmsg)
  217. uni.hideLoading()
  218. }).then(res => {
  219. that.collectNoData = res.data
  220. for(var i=0;i<that.collectNoData.length;i++){
  221. that.collectNo.push(that.collectNoData[i].collectNo)
  222. }
  223. uni.hideLoading()
  224. })
  225. }
  226. },
  227. CollectNoChange(e) {
  228. this.collectNoIndex = e.detail.value
  229. },
  230. confirm(){
  231. if(this.collectTypeIndex == -1){
  232. this.$api.msg('请选择收款方式');
  233. this.collectShow = true;
  234. return;
  235. }
  236. if(this.collectTypeIndex == 0 && this.collectNoIndex == -1){
  237. this.$api.msg('请选择预收款编号');
  238. this.collectShow = true;
  239. return;
  240. }
  241. if(!this.collectMoney){
  242. this.$api.msg('请填写收款金额');
  243. this.collectShow = true;
  244. return;
  245. }
  246. if(!this.collectDate){
  247. this.$api.msg('请选择收款日期');
  248. this.collectShow = true;
  249. return;
  250. }
  251. if(!this.collectImg){
  252. this.$api.msg('请上传收款截图');
  253. this.collectShow = true;
  254. return;
  255. }
  256. const that = this
  257. // uni.showLoading()
  258. var paymentMethod;
  259. if(this.collectTypeIndex == 0){
  260. paymentMethod = "预收款"
  261. }
  262. else if(this.collectTypeIndex == 1){
  263. paymentMethod = "网银收款"
  264. }
  265. else if(this.collectTypeIndex == 2){
  266. paymentMethod = "现金收款"
  267. }
  268. var collectNo;
  269. if(this.collectNoIndex == -1){
  270. collectNo = '';
  271. }
  272. else{
  273. collectNo = this.collectNoData[this.collectNoIndex].collectNo
  274. }
  275. var tmp = {
  276. workNo:this.workNo,
  277. strPaymentMethod:paymentMethod,
  278. collectNo:collectNo,
  279. collectMoney:this.collectMoney,
  280. strCollectDate:this.collectDate,
  281. collectImg:this.collectImg
  282. }
  283. this.collectInfo.push(tmp)
  284. this.alreadyCollect += Number(this.collectMoney)
  285. // that.$api.request('task', 'saveCollectKN', {
  286. // workNo:workNo,
  287. // paymentMethod:paymentMethod,
  288. // collectNo:this.collectNoData[this.collectNoIndex].collectNo,
  289. // collectMoney:this.collectMoney,
  290. // collectDate:this.collectDate,
  291. // collectImg:this.collectImg
  292. // }, failres => {
  293. // that.$api.msg(failres.errmsg)
  294. // uni.hideLoading()
  295. // }).then(res => {
  296. // uni.hideLoading()
  297. // that.$api.msg('收款成功')
  298. // })
  299. },
  300. cancel(){
  301. this.collectShow = false
  302. },
  303. collect(e){
  304. // if(this.checkedList.length == 0){
  305. // this.$api.msg('请选择收款车辆');
  306. // return;
  307. // }
  308. // var workNo;
  309. // var tmpList=[];
  310. // for(var i=0;i<this.taskInfo.length;i++){
  311. // for(var j=0;j<this.checkedList.length;j++){
  312. // if(this.taskInfo[i].id == this.checkedList[j]){
  313. // workNo = this.taskInfo[i].tranNo
  314. // tmpList.push(workNo)
  315. // }
  316. // }
  317. // }
  318. // for(var i=0;i<tmpList.length;i++){
  319. // var workNo = tmpList[i]
  320. // for(var j=0;j<tmpList.length;j++){
  321. // if(workNo != tmpList[j]){
  322. // this.$api.msg('请选择同一单号车辆');
  323. // return;
  324. // }
  325. // }
  326. // }
  327. this.collectShow = true
  328. },
  329. CheckboxChange(e){
  330. if(e.detail.value.length == 0){
  331. this.checkedList = e.detail.value;
  332. return;
  333. }
  334. var newList = e.detail.value
  335. var currentTarget;
  336. if(newList.length < this.checkedList.length){
  337. for(var j = 0;j<newList.length;j++){
  338. for(var i=0;i<this.checkedList.length;i++){
  339. if(newList[j] == this.checkedList[i]){
  340. this.checkedList.splice(i,1)
  341. }
  342. }
  343. }
  344. for(var i=0;i<this.taskInfo.length;i++){
  345. if(this.checkedList[0] == this.taskInfo[i].id){
  346. currentTarget = this.taskInfo[i]
  347. }
  348. }
  349. if(currentTarget.fhFlag == 1){
  350. for(var j=0;j<this.taskInfo.length;j++){
  351. if(this.taskInfo[j].batch == currentTarget.batch){
  352. for(var i=0;i<newList.length;i++){
  353. if(this.taskInfo[j].id == newList[i]){
  354. newList.splice(i,1)
  355. }
  356. }
  357. }
  358. }
  359. }
  360. this.checkedList = newList;
  361. }
  362. else{
  363. for(var j = 0;j<newList.length;j++){
  364. for(var i=0;i<this.taskInfo.length;i++){
  365. if(newList[j] == this.taskInfo[i].id){
  366. currentTarget = this.taskInfo[i]
  367. }
  368. }
  369. }
  370. if(currentTarget.fhFlag == 1){
  371. for(var i=0;i<this.taskInfo.length;i++){
  372. if(this.taskInfo[i].batch == currentTarget.batch){
  373. this.checkedList.push(String(this.taskInfo[i].id));
  374. }
  375. }
  376. }
  377. else{
  378. this.checkedList = newList;
  379. }
  380. }
  381. },
  382. ViewImage(e) {
  383. var img = [];
  384. img = e.currentTarget.dataset.url.split(' ')
  385. uni.previewImage({
  386. current:0,
  387. urls: img
  388. });
  389. },
  390. DelImg(e) {
  391. uni.showModal({
  392. title: '提示',
  393. content: '确定要删除该照片吗?',
  394. cancelText: '取消',
  395. confirmText: '确定',
  396. success: res => {
  397. if (res.confirm) {
  398. if(e.currentTarget.dataset.index == 0){
  399. this.collectImg = "";
  400. }
  401. }
  402. }
  403. })
  404. },
  405. ChooseImage() {
  406. uni.chooseImage({
  407. count: 1, //默认9
  408. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  409. sourceType: ['album','camera'], //从相册选择
  410. success: (res) => {
  411. //上传图片
  412. //图片路径可自行修改
  413. uploadImage(res.tempFilePaths[0], 'collectImg/',
  414. result => {
  415. this.collectImg = result
  416. uni.hideLoading();
  417. }
  418. )
  419. }
  420. });
  421. },
  422. fanghuo(){
  423. const that = this
  424. // if(!that.collectImg){
  425. // this.$api.msg('请上传收款截图');
  426. // return;
  427. // }
  428. if(this.shouldCollect < this.alreadyCollect){
  429. this.$api.msg('已收款不能大于应收款');
  430. return;
  431. }
  432. var taskId = "";
  433. for(var i=0;i<that.checkedList.length;i++){
  434. taskId += that.checkedList[i]+","
  435. }
  436. if(taskId == ""){
  437. this.$api.msg('请选择放货车辆');
  438. return;
  439. }
  440. var workDetailDTO = {
  441. workNo:this.workNo,
  442. list:this.collectInfo
  443. }
  444. uni.showLoading({
  445. title: '正在加载',
  446. mask:true
  447. })
  448. that.$api.request('task', 'fanghuoApply', {
  449. taskId: taskId,
  450. collectImg:!that.collectImg?'':that.collectImg,
  451. workDetailDTO:JSON.stringify(workDetailDTO)
  452. }, failres => {
  453. that.$api.msg(failres.errmsg)
  454. uni.hideLoading()
  455. }).then(res => {
  456. uni.hideLoading()
  457. that.$api.msg('申请成功')
  458. setTimeout(()=>{uni.navigateBack()},1000);
  459. })
  460. }
  461. }
  462. }
  463. </script>
  464. <style lang='scss'>
  465. .container{
  466. padding-bottom: 160upx;
  467. }
  468. .detail-desc {
  469. background: #fff;
  470. margin-top: 16upx;
  471. width: 750upx;
  472. .d-header {
  473. display: flex;
  474. justify-content: center;
  475. align-items: center;
  476. height: 80upx;
  477. font-size: $font-base + 2upx;
  478. color: $font-color-dark;
  479. position: relative;
  480. text {
  481. padding: 0 20upx;
  482. background: #fff;
  483. position: relative;
  484. z-index: 1;
  485. }
  486. &:after {
  487. position: absolute;
  488. left: 50%;
  489. top: 50%;
  490. transform: translateX(-50%);
  491. width: 300upx;
  492. height: 0;
  493. content: '';
  494. border-bottom: 1px solid #ccc;
  495. }
  496. }
  497. }
  498. .c-list {
  499. font-size: $font-sm + 2upx;
  500. color: $font-color-base;
  501. background: #fff;
  502. .c-row {
  503. display: flex;
  504. align-items: center;
  505. padding: 20upx 30upx;
  506. position: relative;
  507. }
  508. .tit {
  509. width: 220upx;
  510. }
  511. .con {
  512. flex: 1;
  513. color: $font-color-dark;
  514. .selected-text {
  515. margin-right: 10upx;
  516. }
  517. }
  518. .bz-list {
  519. height: 40upx;
  520. font-size: $font-sm+2upx;
  521. color: $font-color-dark;
  522. text {
  523. display: inline-block;
  524. margin-right: 30upx;
  525. }
  526. }
  527. .con-list {
  528. flex: 1;
  529. display: flex;
  530. flex-direction: column;
  531. color: $font-color-dark;
  532. line-height: 40upx;
  533. text-align: right;
  534. padding-right: 20upx;
  535. }
  536. .red {
  537. color: $uni-color-primary;
  538. }
  539. }
  540. @mixin playcenter {
  541. display: flex;
  542. align-items: center;
  543. justify-content: center;
  544. }
  545. .xsh-start {
  546. width: 105rpx;
  547. height: 105rpx;
  548. background: #FFFFFF;
  549. border-radius: 50%;
  550. font-size: 29rpx;
  551. color: #4135EB;
  552. @include playcenter;
  553. flex-wrap: wrap;
  554. }
  555. .x-modal {
  556. width: 100%;
  557. .x-m-title {
  558. width: 100%;
  559. height: 90rpx;
  560. padding: 0 38rpx 0 31rpx;
  561. box-sizing: border-box;
  562. font-size: 29rpx;
  563. color: #333333;
  564. border-bottom: 1px dashed #999;
  565. @include playcenter;
  566. justify-content: space-between;
  567. .xm-t-clear {
  568. font-size: 25rpx;
  569. color: #341DB7;
  570. @include playcenter;
  571. >image {
  572. width: 28rpx;
  573. height: 28rpx;
  574. display: block;
  575. margin-right: 8rpx;
  576. }
  577. }
  578. }
  579. .x-m-con {
  580. width: 100%;
  581. padding: 0 31rpx 18rpx;
  582. margin-top: 5rpx;
  583. box-sizing: border-box;
  584. }
  585. }
  586. </style>