bill.vue 16 KB

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