bill.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  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" :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. isDetailShow:false
  181. };
  182. },
  183. onReady() {
  184. uni.setNavigationBarColor({
  185. frontColor: '#ffffff',
  186. backgroundColor: this.$config('primaryColor')
  187. });
  188. },
  189. onLoad(options) {
  190. //获取对账周期默认值
  191. if (uni.getStorageSync('curTab')) {
  192. this.curTab = uni.getStorageSync('curTab');
  193. } else {
  194. let systemList = this.$store.state.vuex_systemSetList;
  195. let cycleObj = systemList.find(item => {
  196. return item.remarks == 'sales_bill_period';
  197. });
  198. this.curTab = this.placeTab.findIndex(con => con.name == cycleObj.valueShow);
  199. }
  200. this.cycleName = this.changeShowTime();
  201. // 获取选择客户
  202. if (options && options.data) {
  203. this.customerObj = JSON.parse(options.data);
  204. this.params.targetSn = this.customerObj.customerSn;
  205. }
  206. uni.$on('customerInfo', res => {
  207. this.customerObj = res;
  208. this.params.targetSn = res.customerSn;
  209. });
  210. this.changeTime();
  211. },
  212. onNavigationBarButtonTap() {
  213. uni.navigateTo({
  214. url: '/pages/sales/billHistory'
  215. });
  216. },
  217. onBackPress() {
  218. if (this.showSearch) {
  219. this.showSearch = false;
  220. } else {
  221. uni.removeStorageSync('curTab');
  222. }
  223. },
  224. onUnload() {
  225. uni.removeStorageSync('curTab');
  226. },
  227. computed: {
  228. totalPayPrice() {
  229. let totalPrice = 0;
  230. for (let i = 0; i < this.bill.length; i++) {
  231. this.bill[i].unsettleAmount = this.bill[i].unsettleAmount ? this.bill[i].unsettleAmount : 0;
  232. totalPrice += this.bill[i].unsettleAmount;
  233. }
  234. return totalPrice;
  235. },
  236. chooseTotalPayPrice() {
  237. let price = 0;
  238. this.chooseList.forEach(item => {
  239. item.unsettleAmount = item.unsettleAmount ? item.unsettleAmount : 0;
  240. price += item.unsettleAmount;
  241. });
  242. return price;
  243. },
  244. settlement() {
  245. return this.chooseTotalPayPrice - this.discountVal || 0;
  246. }
  247. },
  248. methods: {
  249. handleClean(){
  250. this.showSearch = false;
  251. let systemList = this.$store.state.vuex_systemSetList;
  252. let cycleObj = systemList.find(item => {
  253. return item.remarks == 'sales_bill_period';
  254. });
  255. this.curTab = this.placeTab.findIndex(con => con.name == cycleObj.valueShow);
  256. this.cycleName = this.changeShowTime();
  257. this.changeTime();
  258. },
  259. //选择客户
  260. goChooseCustomer() {
  261. uni.setStorageSync('curTab', this.curTab);
  262. this.jumpPage('/pages/sales/chooseCustomerBill');
  263. },
  264. changeTime() {
  265. if (this.curTab != 6 && this.curTab != 7) {
  266. this.params.bizBeginDate = this.getQueryDate().beginDate;
  267. this.params.bizEndDate = this.getQueryDate().endDate;
  268. this.cycleName = this.changeShowTime();
  269. } else if (this.curTab == 7) {
  270. this.cycleName = this.placeTab[this.curTab].name;
  271. this.params.bizBeginDate = undefined;
  272. this.params.bizEndDate = undefined;
  273. } else {
  274. this.dateArray = '';
  275. }
  276. this.getList();
  277. },
  278. getList() {
  279. const _this = this;
  280. queryUnsettleSaleList(this.params).then(res => {
  281. if (res.status == 200) {
  282. this.bill = res.data;
  283. this.$refs.bill.setData(res.data);
  284. }
  285. });
  286. },
  287. // 时间 change
  288. dateChange(date) {
  289. this.dateArray = date.startDate + ' ~ ' + date.endDate;
  290. this.params.bizBeginDate = date.startDate + ' 00:00:00';
  291. this.params.bizEndDate = date.endDate + ' 23:59:59';
  292. this.cycleName = date.startDate + '至' + date.endDate;
  293. },
  294. // 更改日期格式显示
  295. changeShowTime() {
  296. const fun = [
  297. getDate.getTodayInfo,
  298. getDate.getYesterdayInfo,
  299. getDate.getCurrWeekDaysInfo,
  300. getDate.getLastWeekDaysInfo,
  301. getDate.getCurrLastMonthDaysInfo,
  302. getDate.getLastMonthDaysInfo
  303. ];
  304. return fun[this.curTab]();
  305. },
  306. tabChange(data) {
  307. this.curTab = data.val;
  308. },
  309. getQueryDate() {
  310. const fun = [getDate.getToday, getDate.getYesterday, getDate.getCurrWeekDays, getDate.getLastWeekDays, getDate.getCurrLastMonthDays, getDate.getLastMonthDays];
  311. return {
  312. beginDate: fun[this.curTab]().starttime,
  313. endDate: fun[this.curTab]().endtime
  314. };
  315. },
  316. handleSearch() {
  317. this.showSearch = false;
  318. this.changeTime();
  319. },
  320. jumpPage(url) {
  321. uni.navigateTo({
  322. url
  323. });
  324. },
  325. handleDisCount() {
  326. if(this.discountVal > this.chooseTotalPayPrice){
  327. uni.showToast({
  328. title: '折让金额不能大于待收金额,请重新输入',
  329. icon: 'none'
  330. });
  331. return
  332. }
  333. let reg=/^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
  334. if(!reg.test(this.discountVal)){
  335. uni.showToast({
  336. title: '折让金额格式不正确,请重新输入',
  337. icon: 'none'
  338. });
  339. return
  340. }
  341. this.costShow = false;
  342. },
  343. submitOrder() {
  344. //发送对账单
  345. if (this.chooseList.length == 0) {
  346. uni.showToast({
  347. title: '请选择要发送的对账单',
  348. icon: 'none'
  349. });
  350. return;
  351. }
  352. let obj = {
  353. detailNum: this.chooseList.length,
  354. totalAmount: this.chooseTotalPayPrice,
  355. discountAmount: this.discountVal,
  356. settleAmount: this.settlement,
  357. detailList: this.chooseList
  358. };
  359. let ajaxData = Object.assign(this.params, obj);
  360. insert(ajaxData).then(res => {
  361. if (res.status == 200) {
  362. this.goShare();
  363. }
  364. });
  365. },
  366. allCheckeChange(e) {
  367. this.$refs.bill.allSelect(e.value);
  368. const list = this.$refs.bill.getAllData();
  369. },
  370. // 选中事件
  371. allCheckedCallback(isAllChecked, row) {
  372. const has = this.chooseList.findIndex(k => k.bizSn == row.bizSn);
  373. // 在已选列表中
  374. if (has >= 0) {
  375. // 取消选中
  376. if (!row.checked) {
  377. this.chooseList.splice(has, 1);
  378. }
  379. } else {
  380. if (row.checked) {
  381. this.chooseList.push(row);
  382. }
  383. }
  384. // 是否全选
  385. this.allChecked = isAllChecked;
  386. },
  387. // 分享图文
  388. goShare() {
  389. uni.shareWithSystem({
  390. summary: '',
  391. href: '',
  392. success() {
  393. // 分享完成,请注意此时不一定是成功分享
  394. },
  395. fail() {
  396. // 分享失败
  397. }
  398. });
  399. }
  400. }
  401. };
  402. </script>
  403. <style lang="scss" scoped>
  404. .content {
  405. width: 100%;
  406. height: 100vh;
  407. .header {
  408. width: 100%;
  409. .headerList {
  410. width: 100%;
  411. box-sizing: border-box;
  412. padding: 16rpx 20rpx;
  413. background: #fff;
  414. &:last-child {
  415. border-top: 1rpx solid #e4e7ed;
  416. }
  417. .list_l {
  418. width: 208rpx;
  419. text {
  420. font-size: 28rpx;
  421. color: #666666;
  422. margin-left: 10rpx;
  423. margin-right: 10rpx;
  424. }
  425. }
  426. .list_r {
  427. width: calc(100% - 208rpx);
  428. }
  429. }
  430. }
  431. .statistical {
  432. padding: 20rpx;
  433. background: #fff;
  434. margin: 10rpx 0;
  435. .statisticalList {
  436. &:first-child {
  437. width: 210rpx;
  438. }
  439. }
  440. text {
  441. &:last-child {
  442. color: $uni-color-warning;
  443. font-weight: 600;
  444. }
  445. }
  446. }
  447. .chooseCon {
  448. flex-grow: 1;
  449. overflow: auto;
  450. background-color: #fff;
  451. }
  452. .footer {
  453. background-color: #f8f8f8;
  454. padding: 10rpx 20rpx;
  455. .f-mid {
  456. flex-grow: 1;
  457. color: #666;
  458. font-size: 0.8rem;
  459. > view {
  460. &:first-child {
  461. text {
  462. color: $uni-color-warning;
  463. vertical-align: middle;
  464. }
  465. }
  466. &:last-child {
  467. text {
  468. color: $uni-color-primary;
  469. vertical-align: middle;
  470. }
  471. }
  472. }
  473. .costBtn {
  474. width: 70rpx;
  475. height: 40rpx;
  476. line-height: 40rpx;
  477. text-align: center;
  478. color: #fff;
  479. font-size: 20rpx;
  480. border-radius: 30rpx;
  481. background: #999;
  482. margin-left: 20rpx;
  483. }
  484. }
  485. }
  486. // 历史对账单弹窗
  487. .tabBox {
  488. height: 100vh;
  489. .tabs {
  490. flex-grow: 1;
  491. overflow: auto;
  492. padding: 20rpx;
  493. > view {
  494. flex-wrap: wrap;
  495. justify-content: space-between;
  496. > view {
  497. width: 45%;
  498. border: 1rpx solid #eee;
  499. padding: 15rpx;
  500. border-radius: 50rpx;
  501. text-align: center;
  502. margin-bottom: 15rpx;
  503. }
  504. .active {
  505. border: 0;
  506. background-color: #0485f6;
  507. color: #fff;
  508. }
  509. }
  510. }
  511. .form-item-inp {
  512. border-bottom: 1rpx solid #eee;
  513. }
  514. .form-footer-btn {
  515. margin: 30upx;
  516. display: flex;
  517. justify-content: space-between;
  518. }
  519. .form-footer-btn {
  520. display: flex;
  521. .handle-btn {
  522. font-size: 28upx;
  523. margin: 0 10upx;
  524. flex: 1;
  525. }
  526. }
  527. }
  528. //打折弹窗
  529. .costPopup {
  530. padding: 26rpx 20rpx 40rpx;
  531. box-sizing: border-box;
  532. .costPopupTit {
  533. text-align: center;
  534. font-weight: bold;
  535. }
  536. .costPopupCon {
  537. margin-top: 40rpx;
  538. .costList {
  539. margin-bottom: 20rpx;
  540. .label {
  541. color: $uni-text-color-grey;
  542. }
  543. }
  544. .tip {
  545. color: $uni-color-error;
  546. font-size: 20rpx;
  547. text-align: right;
  548. }
  549. .costText {
  550. text-align: center;
  551. color: $uni-text-color-grey;
  552. font-size: 22rpx;
  553. margin-top: 40rpx;
  554. &:last-child {
  555. font-weight: bold;
  556. color: $uni-color-error;
  557. font-size: 32rpx;
  558. line-height: 60rpx;
  559. margin-top: 0rpx;
  560. margin-bottom: 50rpx;
  561. }
  562. }
  563. }
  564. }
  565. }
  566. </style>