bill.vue 16 KB

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