bill.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="header">
  4. <view class="headerList u-flex">
  5. <view class="list_l">
  6. <u-icon name="account" color="#00aaff" size="32"></u-icon>
  7. <text>客户名称</text>
  8. </view>
  9. <view class="list_r u-flex">
  10. <u-input v-model="customerObj.customerName" @click="goChooseCustomer" disabled placeholder="请选择客户名称" />
  11. <u-icon name="arrow-right" color="#999" size="30"></u-icon>
  12. </view>
  13. </view>
  14. <view class="headerList u-flex">
  15. <view class="list_l">
  16. <u-icon name="clock" color="#00aaff" size="32"></u-icon>
  17. <text>对账周期</text>
  18. <u-icon name="question-circle-fill" @click="tipShow = true" :color="wordColor" size="32"></u-icon>
  19. </view>
  20. <view class="list_r u-flex">
  21. <u-input v-model="cycleName" @click="showSearch = true" disabled placeholder="请选择对账日期" />
  22. <u-icon name="arrow-right" color="#999" size="30"></u-icon>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="statistical u-flex">
  27. <view class="statisticalList">
  28. <text>总单数:</text>
  29. <text>{{bill.length}}</text>
  30. </view>
  31. <view class="statisticalList">
  32. <text>待收金额合计:</text>
  33. <text>¥{{totalPayPrice}}</text>
  34. </view>
  35. </view>
  36. <view class="chooseCon"><billList ref="bill" :showCheck="true" :list="bill" @allChecked="allCheckedCallback"></billList></view>
  37. <view class="footer u-flex">
  38. <view class="f-left">
  39. <u-checkbox @change="allCheckeChange" v-model="allChecked" shape="circle">{{ allChecked ? '取消全选' : '全选' }}</u-checkbox>
  40. </view>
  41. <view class="f-mid" @click="isDetailShow = !isDetailShow">
  42. <view>
  43. 待收:
  44. <text>¥{{chooseTotalPayPrice}}</text>
  45. </view>
  46. <view v-if="chooseList.length>0">
  47. 折后:
  48. <text>¥{{settlement}}</text>
  49. </view>
  50. <view class="u-flex" v-if="chooseList.length>0">
  51. <view>
  52. 折让:
  53. <text>¥{{discountVal || 0}}</text>
  54. </view>
  55. <view class="costBtn" @click="costShow = true">打折</view>
  56. </view>
  57. </view>
  58. <view class="f-btns">
  59. <u-button size="medium" @click="submitOrder" :custom-style="customBtnStyle" shape="circle" type="primary" hover-class="none">发送对账单</u-button>
  60. </view>
  61. </view>
  62. <!-- 对账周期弹窗 -->
  63. <u-popup v-model="showSearch" mode="right" width="70%">
  64. <view class="tabBox">
  65. <view class="tabs">
  66. <view class="flex">
  67. <view :class="item.val == curTab ? 'active' : 'all'" v-for="item in placeTab" :key="item.val" @click="tabChange(item)">{{ item.name }}</view>
  68. </view>
  69. </view>
  70. <view class="flex align_center form-item-inp" style="padding: 0 30rpx;" v-if="curTab == 6">
  71. <u-input clearable v-model="dateArray" disabled placeholder="请选择时间段" input-align="center" @click="showDate = true" />
  72. </view>
  73. <view class="form-footer-btn">
  74. <u-button class="handle-btn" shape="circle" size="medium" hover-class="none" @click="handleClean">重置</u-button>
  75. <u-button class="handle-btn" shape="circle" size="medium" hover-class="none" :custom-style="customBtnStyle" @click="handleSearch">查询</u-button>
  76. </view>
  77. </view>
  78. </u-popup>
  79. <!-- 选择日期范围 -->
  80. <u-calendar v-model="showDate" ref="rangeDate" @change="dateChange" mode="range"></u-calendar>
  81. <!-- 打折弹窗 -->
  82. <u-popup v-model="costShow" mode="center" :border-radius="20" closeable width="82%">
  83. <view class="costPopup">
  84. <view class="costPopupTit">东莞市京步车证汽车服务中心</view>
  85. <view class="costPopupCon">
  86. <view class="costList">
  87. <text class="label">待收金额:</text>
  88. <text>¥{{chooseTotalPayPrice}}</text>
  89. </view>
  90. <view class="costList u-flex">
  91. <view class="label">折让金额:</view>
  92. <u-input v-model="discountVal" @input="onKeyInput" :border="true" :height="50"/>
  93. </view>
  94. <view class="tip" v-if="discountVal>chooseTotalPayPrice">折让金额不能大于待收金额,请重新输入</view>
  95. <view class="costText">折让后金额</view>
  96. <view class="costText">¥{{settlement}}</view>
  97. </view>
  98. <u-button type="primary" :custom-style="customStyle" shape="circle" @click="handleDisCount">确定</u-button>
  99. </view>
  100. </u-popup>
  101. <!-- 对账周期弹窗 -->
  102. <u-modal v-model="tipShow" :show-title="false" :content="tipContent" confirm-text="知道了"></u-modal>
  103. </view>
  104. </template>
  105. <script>
  106. import billList from './billListComponent.vue';
  107. import { queryUnsettleSaleList,insert } from '@/api/verify.js';
  108. import getDate from '@/libs/getDate.js';
  109. export default {
  110. components: { billList },
  111. data() {
  112. return {
  113. customBtnStyle: {
  114. // 自定义按钮样式
  115. borderColor: this.$config('primaryColor'),
  116. backgroundColor: this.$config('primaryColor'),
  117. color: '#fff',
  118. width: '180rpx'
  119. },
  120. wordColor: this.$config('infoColor'),
  121. customStyle: {
  122. borderColor: this.$config('primaryColor'),
  123. backgroundColor: this.$config('primaryColor'),
  124. color: '#fff'
  125. },
  126. allChecked: false,
  127. tipShow: false,
  128. discountVal: null,//折让金额
  129. tipContent: `账单周期指销售单的创建时间`,
  130. placeTab: [
  131. {
  132. name: '今日',
  133. val: '0'
  134. },
  135. {
  136. name: '昨日',
  137. val: '1'
  138. },
  139. {
  140. name: '本周',
  141. val: '2'
  142. },
  143. {
  144. name: '上周',
  145. val: '3'
  146. },
  147. {
  148. name: '本月',
  149. val: '4'
  150. },
  151. {
  152. name: '上月',
  153. val: '5'
  154. },
  155. {
  156. name: '自定义',
  157. val: '6'
  158. },
  159. {
  160. name: '全部',
  161. val: '7'
  162. }
  163. ],
  164. curTab: '0',
  165. showSearch: false,
  166. showDate: false,
  167. costShow: false,
  168. customerObj: {
  169. customerName: null
  170. },
  171. cycleName: '',
  172. params: {
  173. targetSn: undefined,
  174. bizBeginDate: undefined,
  175. bizEndDate: undefined
  176. },
  177. bill: [],
  178. dateArray:'',
  179. chooseList:[]
  180. };
  181. },
  182. onReady() {
  183. uni.setNavigationBarColor({
  184. frontColor: '#ffffff',
  185. backgroundColor: this.$config('primaryColor')
  186. });
  187. },
  188. onLoad(options) {
  189. //获取对账周期默认值
  190. if(uni.getStorageSync('curTab')){
  191. this.curTab = uni.getStorageSync('curTab');
  192. }else{
  193. let systemList = this.$store.state.vuex_systemSetList;
  194. let cycleObj = systemList.find(item => {
  195. return item.remarks == 'sales_bill_period';
  196. });
  197. this.curTab = this.placeTab.findIndex(con => con.name == cycleObj.valueShow);
  198. }
  199. this.cycleName = this.changeShowTime();
  200. // 获取选择客户
  201. if (options && options.data) {
  202. this.customerObj = JSON.parse(options.data);
  203. this.params.targetSn = this.customerObj.customerSn;
  204. }
  205. this.changeTime();
  206. },
  207. onNavigationBarButtonTap() {
  208. uni.navigateTo({
  209. url: '/pages/sales/billHistory'
  210. });
  211. },
  212. onBackPress() {
  213. if (this.showSearch) {
  214. this.showSearch = false;
  215. }else{
  216. uni.removeStorageSync('curTab')
  217. }
  218. },
  219. computed: {
  220. totalPayPrice() {
  221. let totalPrice = 0;
  222. for (let i = 0; i < this.bill.length; i++) {
  223. this.bill[i].unsettleAmount = this.bill[i].unsettleAmount ? this.bill[i].unsettleAmount :0
  224. totalPrice += this.bill[i].unsettleAmount;
  225. }
  226. return totalPrice;
  227. },
  228. chooseTotalPayPrice(){
  229. let price=0;
  230. this.chooseList.forEach(item=>{
  231. item.unsettleAmount =item.unsettleAmount? item.unsettleAmount:0;
  232. price += item.unsettleAmount;
  233. })
  234. return price;
  235. },
  236. settlement(){
  237. return this.chooseTotalPayPrice - this.discountVal || 0;
  238. }
  239. },
  240. methods: {
  241. //选择客户
  242. goChooseCustomer(){
  243. uni.setStorageSync('curTab',this.curTab);
  244. this.jumpPage('/pages/sales/chooseCustomerBill');
  245. },
  246. changeTime() {
  247. if (this.curTab != 6 && this.curTab != 7) {
  248. this.params.bizBeginDate = this.getQueryDate().beginDate;
  249. this.params.bizEndDate = this.getQueryDate().endDate;
  250. this.cycleName = this.changeShowTime();
  251. }else if(this.curTab == 7){
  252. this.cycleName = this.placeTab[this.curTab].name;
  253. this.params.bizBeginDate = undefined;
  254. this.params.bizEndDate = undefined;
  255. }else{
  256. this.dateArray = ''
  257. }
  258. this.getList();
  259. },
  260. getList() {
  261. const _this = this;
  262. queryUnsettleSaleList(this.params).then(res => {
  263. if (res.status == 200) {
  264. this.bill = res.data;
  265. this.$refs.bill.setData(res.data);
  266. }
  267. });
  268. },
  269. // 时间 change
  270. dateChange(date) {
  271. this.dateArray = date.startDate + ' ~ ' + date.endDate;
  272. this.params.bizBeginDate = date.startDate + ' 00:00:00';
  273. this.params.bizEndDate = date.endDate + ' 23:59:59';
  274. this.cycleName=date.startDate + '至' + date.endDate;
  275. },
  276. // 更改日期格式显示
  277. changeShowTime(){
  278. const fun = [getDate.getTodayInfo, getDate.getYesterdayInfo, getDate.getCurrWeekDaysInfo, getDate.getLastWeekDaysInfo, getDate.getCurrLastMonthDaysInfo, getDate.getLastMonthDaysInfo];
  279. return fun[this.curTab]();
  280. },
  281. tabChange(data) {
  282. this.curTab = data.val;
  283. },
  284. getQueryDate() {
  285. const fun = [getDate.getToday, getDate.getYesterday, getDate.getCurrWeekDays, getDate.getLastWeekDays, getDate.getCurrLastMonthDays, getDate.getLastMonthDays];
  286. return {
  287. beginDate: fun[this.curTab]().starttime,
  288. endDate: fun[this.curTab]().endtime
  289. };
  290. },
  291. handleSearch() {
  292. this.showSearch = false;
  293. this.changeTime();
  294. },
  295. jumpPage(url) {
  296. uni.navigateTo({
  297. url
  298. });
  299. },
  300. handleDisCount(){
  301. this.costShow = false
  302. },
  303. submitOrder(){//发送对账单
  304. if(this.chooseList.length==0){
  305. uni.showToast({
  306. title:'请选择要发送的对账单',
  307. icon:'none'
  308. })
  309. return;
  310. }
  311. let obj={
  312. detailNum:this.chooseList.length,
  313. totalAmount:this.chooseTotalPayPrice,
  314. discountAmount:this.discountVal,
  315. settleAmount:this.settlement,
  316. detailList:this.chooseList
  317. }
  318. let ajaxData=Object.assign(this.params,obj)
  319. insert(ajaxData).then(res => {
  320. if (res.status == 200) {
  321. this.goShare();
  322. }
  323. });
  324. },
  325. allCheckeChange(e){
  326. this.$refs.bill.allSelect(e.value)
  327. const list = this.$refs.bill.getAllData()
  328. },
  329. // 选中事件
  330. allCheckedCallback(isAllChecked,row){
  331. const has = this.chooseList.findIndex(k => k.bizSn == row.bizSn)
  332. // 在已选列表中
  333. if(has>=0){
  334. // 取消选中
  335. if(!row.checked){
  336. this.chooseList.splice(has,1)
  337. }
  338. }else{
  339. if(row.checked){
  340. this.chooseList.push(row)
  341. }
  342. }
  343. // 是否全选
  344. this.allChecked = isAllChecked
  345. },
  346. // 分享图文
  347. goShare(){
  348. uni.shareWithSystem({
  349. summary: '',
  350. href: '',
  351. success(){
  352. // 分享完成,请注意此时不一定是成功分享
  353. },
  354. fail(){
  355. // 分享失败
  356. }
  357. })
  358. }
  359. }
  360. };
  361. </script>
  362. <style lang="scss" scoped>
  363. .content {
  364. width: 100%;
  365. height: 100vh;
  366. .header {
  367. width: 100%;
  368. .headerList {
  369. width: 100%;
  370. box-sizing: border-box;
  371. padding: 16rpx 20rpx;
  372. background: #fff;
  373. &:last-child {
  374. border-top: 1rpx solid #e4e7ed;
  375. }
  376. .list_l {
  377. width: 208rpx;
  378. text {
  379. font-size: 28rpx;
  380. color: #666666;
  381. margin-left: 10rpx;
  382. margin-right: 10rpx;
  383. }
  384. }
  385. .list_r {
  386. width: calc(100% - 208rpx);
  387. }
  388. }
  389. }
  390. .statistical {
  391. padding: 20rpx;
  392. background: #fff;
  393. margin: 10rpx 0;
  394. .statisticalList {
  395. &:first-child {
  396. width: 210rpx;
  397. }
  398. }
  399. text {
  400. &:last-child {
  401. color: $uni-color-warning;
  402. font-weight: 600;
  403. }
  404. }
  405. }
  406. .chooseCon {
  407. flex-grow: 1;
  408. overflow: auto;
  409. background-color: #fff;
  410. }
  411. .footer {
  412. background-color: #f8f8f8;
  413. padding:10rpx 20rpx;
  414. .f-mid {
  415. flex-grow: 1;
  416. color: #666;
  417. font-size: 0.8rem;
  418. > view {
  419. &:first-child {
  420. text {
  421. color: $uni-color-warning;
  422. vertical-align: middle;
  423. }
  424. }
  425. &:last-child {
  426. text {
  427. color: $uni-color-primary;
  428. vertical-align: middle;
  429. }
  430. }
  431. }
  432. .costBtn {
  433. width: 70rpx;
  434. height: 40rpx;
  435. line-height: 40rpx;
  436. text-align: center;
  437. color: #fff;
  438. font-size: 20rpx;
  439. border-radius: 30rpx;
  440. background: #999;
  441. margin-left: 20rpx;
  442. }
  443. }
  444. }
  445. // 历史对账单弹窗
  446. .tabBox {
  447. height: 100vh;
  448. .tabs {
  449. flex-grow: 1;
  450. overflow: auto;
  451. padding: 20rpx;
  452. > view {
  453. flex-wrap: wrap;
  454. justify-content: space-between;
  455. > view {
  456. width: 45%;
  457. border: 1rpx solid #eee;
  458. padding: 15rpx;
  459. border-radius: 50rpx;
  460. text-align: center;
  461. margin-bottom: 15rpx;
  462. }
  463. .active {
  464. border: 0;
  465. background-color: #0485f6;
  466. color: #fff;
  467. }
  468. }
  469. }
  470. .form-item-inp {
  471. border-bottom: 1rpx solid #eee;
  472. }
  473. .form-footer-btn {
  474. margin: 30upx;
  475. display: flex;
  476. justify-content: space-between;
  477. }
  478. .form-footer-btn {
  479. display: flex;
  480. .handle-btn {
  481. font-size: 28upx;
  482. margin: 0 10upx;
  483. flex: 1;
  484. }
  485. }
  486. }
  487. //打折弹窗
  488. .costPopup {
  489. padding: 26rpx 20rpx 40rpx;
  490. box-sizing: border-box;
  491. .costPopupTit {
  492. text-align: center;
  493. font-weight: bold;
  494. }
  495. .costPopupCon {
  496. margin-top: 40rpx;
  497. .costList {
  498. margin-bottom: 20rpx;
  499. .label {
  500. color: $uni-text-color-grey;
  501. }
  502. }
  503. .tip{
  504. color: $uni-color-error;
  505. font-size: 20rpx;
  506. text-align: right;
  507. }
  508. .costText {
  509. text-align: center;
  510. color: $uni-text-color-grey;
  511. font-size: 22rpx;
  512. margin-top: 40rpx;
  513. &:last-child {
  514. font-weight: bold;
  515. color: $uni-color-error;
  516. font-size: 32rpx;
  517. line-height: 60rpx;
  518. margin-top: 0rpx;
  519. margin-bottom: 50rpx;
  520. }
  521. }
  522. }
  523. }
  524. }
  525. </style>