billHistoryDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <view class="content flex flex_column" v-if="billInfo">
  3. <view class="b_head">
  4. <view class="head_list">
  5. <text>分享时间</text>
  6. <text>{{ billInfo.createDate }}</text>
  7. </view>
  8. <view class="head_list" v-if="billInfo.customer">
  9. <text>客户名称</text>
  10. <text>{{ billInfo.customer.customerName }}</text>
  11. </view>
  12. <!-- <view class="head_list">
  13. <text>对账周期</text>
  14. <text>{{ timeInfo || '--' }}</text>
  15. </view> -->
  16. <view class="head_list">
  17. <text>付款状态</text>
  18. <text>{{ billInfo.billStatus == 'UNSETTLE' ? '未付款' : billInfo.settleStyleSnDictValue ? '已结清(' + billInfo.settleStyleSnDictValue + ')' : '已结清' }}</text>
  19. </view>
  20. </view>
  21. <view class="b_detail" v-if="billInfo.billStatus == 'UNSETTLE'">
  22. <view class="detail_list u-flex">
  23. <view class="detail_box">
  24. <text>总单数:</text>
  25. <text>{{ billInfo.detailNum }}</text>
  26. </view>
  27. <view class="detail_box">
  28. <text>待收:</text>
  29. <text>¥{{dueAmount}}</text>
  30. </view>
  31. </view>
  32. <view class="detail_list u-flex">
  33. <view class="detail_box">
  34. <text>折让:</text>
  35. <text>¥{{ billInfo.discountAmount||billInfo.discountAmount==0? toThousands(billInfo.discountAmount,2):'--'}}</text>
  36. </view>
  37. <view class="detail_box">
  38. <text>折后:</text>
  39. <text>¥{{ billInfo.settleAmount||billInfo.settleAmount ==0? toThousands(billInfo.settleAmount,2):'--' }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="b_detail" v-else>
  44. <view class="detail_list u-flex">
  45. <view class="detail_box">
  46. <text>总单数:</text>
  47. <text>{{ billInfo.detailNum }}</text>
  48. </view>
  49. <view class="detail_box">
  50. <text>折让:</text>
  51. <text>¥{{ billInfo.discountAmount||billInfo.discountAmount==0? toThousands(billInfo.discountAmount,2):'--'}}</text>
  52. </view>
  53. </view>
  54. <view class="detail_list u-flex">
  55. <view class="detail_box">
  56. <text>折后:</text>
  57. <text>¥{{ billInfo.settleAmount||billInfo.settleAmount ==0? toThousands(billInfo.settleAmount,2):'--' }}</text>
  58. </view>
  59. <view class="detail_box">
  60. <text>实收:</text>
  61. <text>¥{{ billInfo.settleRealAmount||billInfo.settleRealAmount ==0? toThousands(billInfo.settleRealAmount,2):'--' }}</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="detail_con"><billList ref="billBox" :showCheck="isShowEdit" :list="billArr" @allChecked="chooseBillList"></billList></view>
  66. <view v-if="!isShowEdit">
  67. <view class="footer u-flex u-col-bottom u-row-right" v-if="billInfo.billStatus == 'UNSETTLE'&& billArr&&billArr.length!=0">
  68. <view class="u-flex u-col-center" >
  69. <u-button type="warning" shape="circle" @click="openPaymentModal">确认收款</u-button>
  70. <u-button type="primary" shape="circle" :loading="btnLoading" @click="submitOrder" style="margin-left:20rpx;" :custom-style="customStyle">再次发送对账单</u-button>
  71. </view>
  72. </view>
  73. <view class="footer" v-else-if="billInfo.billStatus != 'UNSETTLE'&& billArr&&billArr.length!=0">
  74. <u-button type="primary" shape="circle" :loading="btnLoading" @click="submitOrder" :custom-style="customStyle">再次发送对账单</u-button>
  75. </view>
  76. </view>
  77. <view v-else>
  78. <view class="footer flex align_center" v-if="billInfo.billStatus == 'UNSETTLE' && billArr&&billArr.length!=0">
  79. <u-checkbox-group style="flex:1;">
  80. <u-checkbox v-model="checkedAll" shape="circle" @change="chooseAll">{{checkedAll?'取消全选':'全选'}}</u-checkbox>
  81. </u-checkbox-group>
  82. <view class="u-flex u-row-right">
  83. <u-button type="error" shape="circle" :loading="btnLoading" @click="handleEvents('del')" :custom-style="customDelStyle">删除</u-button>
  84. <u-button type="warning" shape="circle" style="margin-left: 30rpx;" @click="handleEvents('update')">一键刷新</u-button>
  85. </view>
  86. </view>
  87. </view>
  88. <u-modal v-model="modalShow" :show-title="false" :content="modalCon" :show-cancel-button="true" @confirm="handleConfirm"></u-modal>
  89. <!-- 确认收款弹窗 -->
  90. <u-popup v-model="showPayment" mode="center" :border-radius="20" width="82%">
  91. <view class="slot-content">
  92. <view style="padding:50rpx 40rpx 20rpx;">
  93. <u-form :model="form" ref="uForm" :label-width="150" :rules="rules" :label-style="{color:'#999'}">
  94. <u-form-item :border-bottom ="false" label="总单数:" prop="num" v-if="billArr">{{billArr.length}}</u-form-item>
  95. <u-form-item :border-bottom ="false" label="结算方式:" prop="settleTypeName">
  96. <u-input type="text" placeholder="请选择结算方式" :disabled="true" :height="60" v-model="form.settleTypeName" @click="settleShow = true"/>
  97. <u-icon :name="settleShow?'arrow-right':'arrow-down'" color="#e0e0e0" size="26"></u-icon>
  98. </u-form-item>
  99. <u-form-item v-if="enableFundAccount" :border-bottom ="false" label="结算账户:" prop="settleAccountName">
  100. <u-input type="text" placeholder="请选择结算账户" :disabled="true" :height="60" v-model="form.settleAccountName" @click="openSettleAccount"/>
  101. <u-icon :name="settleAccount?'arrow-right':'arrow-down'" color="#e0e0e0" size="26"></u-icon>
  102. </u-form-item>
  103. <u-form-item :border-bottom ="false" label="待收金额:" prop="num">¥{{ billInfo.totalAmount ||billInfo.totalAmount == 0 ? toThousands(billInfo.totalAmount,2):'--' }}</u-form-item>
  104. <u-form-item :border-bottom ="false" label="折让金额:" prop="discountAmount"><u-input type="number" placeholder="请输入实际收款金额(最多2位小数)" :border="true" :height="60" v-model="form.discountAmount"/></u-form-item>
  105. </u-form>
  106. </view>
  107. <view class="costText">实收金额</view>
  108. <view class="costText1">¥{{settlement<0?0:settlement}}</view>
  109. <view class="paymentFooter flex algin-center">
  110. <view @click="closePopup">取消</view>
  111. <view @click="handlePay">确定</view>
  112. </view>
  113. </view>
  114. </u-popup>
  115. <!-- 提示弹窗 -->
  116. <u-modal v-model="showModal" confirm-text="知道了" :content="modalContent" :show-title="false"></u-modal>
  117. <u-picker mode="selector" v-model="settleShow" @confirm="confirmSettle" :default-selector="[0]" :range="settleList" range-key="dispName"></u-picker>
  118. <u-picker mode="selector" v-model="settleAccount" @confirm="confirmSettleAccount" :default-selector="[0]" :range="accountList" range-key="name"></u-picker>
  119. <!-- 分享询问弹窗 -->
  120. <u-modal v-model="shareShow" :show-cancel-button="true" :content="shareContent" @confirm="handleShare" @cancel="shareShow = false;btnLoading = false;"></u-modal>
  121. </view>
  122. </template>
  123. <script>
  124. import billList from './billListComponent.vue';
  125. import { findBySn, insert,settleVerify,settle,flushBill,deleteDetails } from '@/api/verify.js';
  126. import getDate from '@/libs/getDate.js';
  127. import { toThousands } from '@/libs/tools.js'
  128. import { getLookUpDatas } from '@/api/data';
  129. import { queryFunctionState,settleAccountList } from '@/api/user';
  130. export default {
  131. components: { billList },
  132. data() {
  133. return {
  134. customStyle: {
  135. backgroundColor: this.$config('primaryColor'),
  136. color: '#fff'
  137. },
  138. customDelStyle: {
  139. width:'200rpx',
  140. color: '#fff'
  141. },
  142. verifySn: '',
  143. billInfo: null,
  144. billArr: [],
  145. timeInfo: '',
  146. btnLoading: false,
  147. shareShow: false,
  148. isShowEdit:false,//编辑
  149. settleShow:false,//结算方式
  150. shareContent: `是否同意发送对账单给微信好友?`,
  151. toThousands,
  152. showPayment:false,
  153. form:{
  154. receiptAmount:0,
  155. discountAmount:undefined,
  156. settleType:'',
  157. settleTypeName:'',
  158. settleAccountSn:'',
  159. settleAccountName:''
  160. },
  161. settleList:[],
  162. rules: {
  163. settleTypeName: [
  164. {
  165. required: true,
  166. message: '请选择结算方式',
  167. trigger: 'change',
  168. }
  169. ],
  170. settleAccountName:[
  171. {
  172. required: true,
  173. message: '请选择结算账户',
  174. trigger: 'change',
  175. }
  176. ]
  177. },
  178. showModal:false,
  179. modalContent:'',
  180. enableFundAccount:false,
  181. accountList:[],//结算账户列表
  182. settleAccount:false,
  183. orderList:[],
  184. modalShow:false,
  185. modalCon:'刷新后,将删除对账单中已收款的订单,更新待收款单据。确定刷新吗?',
  186. eventsType:'' //打开弹窗类型 del删除 update更新
  187. };
  188. },
  189. onReady() {
  190. uni.setNavigationBarColor({
  191. frontColor: '#ffffff',
  192. backgroundColor: this.$config('primaryColor')
  193. });
  194. },
  195. onLoad(options) {
  196. if (options && options.billId) {
  197. this.verifySn = options.billId;
  198. this.loadData({ verifySn: options.billId });
  199. }
  200. },
  201. //编辑事件
  202. onNavigationBarButtonTap(e){
  203. this.isShowEdit = !this.isShowEdit
  204. var pages = getCurrentPages();
  205. var page = pages[pages.length - 1];
  206. var currentWebview = page.$getAppWebview();
  207. var tn = currentWebview.getStyle().titleNView;
  208. let _this = this
  209. if(_this.isShowEdit){
  210. tn.buttons[0].text = '\ue601 取消';
  211. }else{
  212. tn.buttons[0].text = '\ue601 编辑';
  213. }
  214. _this.$nextTick(()=>{
  215. currentWebview.setStyle({
  216. titleNView: tn
  217. });
  218. })
  219. },
  220. computed: {
  221. //经销商信息
  222. userData() {
  223. return this.$store.state.vuex_userData;
  224. },
  225. settlement() {
  226. let totalPrice=this.billInfo.totalAmount?this.billInfo.totalAmount:0;
  227. let discountPrice=this.form.discountAmount?this.form.discountAmount:0
  228. let priceNum=totalPrice - discountPrice;
  229. const ret = priceNum.toFixed(2)
  230. let endPay=Number(totalPrice)>=Number(discountPrice) ? ret : 0
  231. this.form.receiptAmount = endPay
  232. return endPay
  233. },
  234. dueAmount(){
  235. let totalAmount = this.billInfo.totalAmount?this.billInfo.totalAmount:0
  236. let settleRealAmount = this.billInfo.settleRealAmount?this.billInfo.settleRealAmount:0
  237. let duePrice = totalAmount - settleRealAmount // 待收金额
  238. duePrice=Number(duePrice)>0 ? duePrice : 0
  239. const resPrice = duePrice.toFixed(2)
  240. return resPrice
  241. },
  242. //经销商信息
  243. userData() {
  244. return this.$store.state.vuex_userData;
  245. }
  246. },
  247. methods: {
  248. loadData(ajaxData) {
  249. let that = this;
  250. findBySn(ajaxData).then(res => {
  251. if (res.status == 200) {
  252. that.billInfo = res.data;
  253. that.billArr = res.data.detailList;
  254. let timeobj = getDate.editDay(res.data.bizBeginDate, res.data.bizEndDate);
  255. that.timeInfo = timeobj.starttime + '~' + timeobj.endtime;
  256. that.$nextTick(() => {
  257. that.$refs.billBox.setData(res.data.detailList);
  258. });
  259. }
  260. });
  261. },
  262. // 关闭弹窗
  263. closePopup(){
  264. this.form={
  265. receiptAmount:0,
  266. discountAmount:this.billInfo.discountAmount,
  267. settleType:'',
  268. settleTypeName:'',
  269. settleAccountSn:'',
  270. settleAccountName:''
  271. }
  272. this.showPayment = false
  273. },
  274. // 打开确认收款弹窗
  275. openPaymentModal(){
  276. let _this=this
  277. // 校验弹窗是否需要打开
  278. settleVerify({ verifySn: _this.verifySn}).then(res => {
  279. if (res.status == 200) {
  280. if(!res.data.falg){
  281. _this.modalContent = res.data.message
  282. _this.$nextTick(()=>{
  283. _this.showModal = true
  284. })
  285. }else{
  286. // 判断是否显示结算类型
  287. if(this.$hasPermissions('M_fundAccountList')&&this.$hasPermissions('B_fundAccountEnable')){
  288. queryFunctionState().then(res => {
  289. if (res.status == 200) {
  290. _this.enableFundAccount = res.data.functionEnableFlag == 1
  291. }
  292. })
  293. }
  294. _this.getPayType();
  295. _this.showPayment = true
  296. _this.form.discountAmount=_this.billInfo.discountAmount
  297. _this.$nextTick(()=>{
  298. _this.$refs.uForm.setRules(_this.rules);
  299. })
  300. }
  301. }
  302. });
  303. },
  304. //获取结算类型列表
  305. getPayType(){
  306. getLookUpDatas({
  307. lookupCode: 'SETTLE_STYLE',
  308. pageNo: 1,
  309. pageSize: 1000
  310. }).then(result => {
  311. if (result && result.status == 200) {
  312. this.settleList = result.data.list;
  313. }
  314. });
  315. },
  316. //获取结算账户
  317. getPayAccount(typeCode){
  318. settleAccountList({settleStyleSn: typeCode,pageNo:1,pageSize:500,state:'ENABLE'}).then(result => {
  319. if (result && result.status == 200) {
  320. result.data.list.forEach(item=>{
  321. item.name = item.accountName+'-'+item.accountNo
  322. })
  323. this.accountList = result.data.list;
  324. }
  325. });
  326. },
  327. //结算类型 确定
  328. confirmSettle(e){
  329. let pos=e[0]
  330. this.form.settleType = this.settleList[pos].code
  331. this.form.settleTypeName = this.settleList[pos].dispName
  332. if(this.enableFundAccount){
  333. this.form.settleAccountSn=''
  334. this.form.settleAccountName=''
  335. this.getPayAccount(this.settleList[pos].code)
  336. }
  337. },
  338. submitOrder() {
  339. //发送对账单
  340. this.shareShow = true;
  341. },
  342. //结算账户弹窗
  343. openSettleAccount(){
  344. if(!this.form.settleTypeName){
  345. uni.showToast({
  346. title:'请先选择结算类型',
  347. icon:'none'
  348. })
  349. return
  350. }
  351. this.settleAccount = true
  352. },
  353. //结算账户 确定
  354. confirmSettleAccount(e){
  355. let pos=e[0]
  356. this.form.settleAccountSn=this.accountList[pos].settleAccountSn
  357. this.form.settleAccountName=this.accountList[pos].name
  358. },
  359. //确认收款
  360. handlePay(){
  361. let _this=this
  362. _this.$refs.uForm.validate(valid => {
  363. if (valid) {
  364. let totalPrice=this.billInfo.totalAmount?this.billInfo.totalAmount:0;
  365. let discountPrice=this.form.discountAmount?this.form.discountAmount:0
  366. if (discountPrice > totalPrice) {
  367. uni.showToast({
  368. title: '折让金额不能大于待收金额,请重新输入',
  369. icon: 'none'
  370. });
  371. return;
  372. }
  373. let reg = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
  374. if(discountPrice && discountPrice!=0){
  375. if (!reg.test(discountPrice)) {
  376. uni.showToast({
  377. title: '折让金额格式不正确,请重新输入',
  378. icon: 'none'
  379. });
  380. return;
  381. }
  382. }
  383. let ajaxData=JSON.stringify(_this.form)
  384. let newAjaxData = JSON.parse(ajaxData)
  385. newAjaxData.verifySn = _this.verifySn
  386. delete newAjaxData.settleAccountName
  387. settle(newAjaxData).then(result => {
  388. if (result && result.status == 200) {
  389. _this.closePopup()
  390. _this.loadData({ verifySn: _this.verifySn });
  391. }
  392. });
  393. } else {
  394. console.log('验证失败');
  395. }
  396. });
  397. },
  398. // 分享图文
  399. handleShare() {
  400. let jumpUrl = getApp().globalData.baseUrl.replace('qpls-md/','')
  401. let url = jumpUrl+'dzd/index.html?' + this.userData.orgSn + '&' + this.verifySn;
  402. if (uni.getSystemInfoSync().platform == 'ios') {
  403. uni.share({
  404. provider: 'weixin',
  405. scene: 'WXSceneSession',
  406. type: 0,
  407. href: url,
  408. title: this.billInfo.customer.customerName + '的对账单',
  409. summary: '共' + this.billInfo.settleAmount + '元,请您查阅',
  410. imageUrl: '../../static/logo.png',
  411. success: function(res) {
  412. console.log('success:' + JSON.stringify(res));
  413. },
  414. fail: function(err) {
  415. console.log('fail:' + JSON.stringify(err));
  416. }
  417. });
  418. } else {
  419. uni.shareWithSystem({
  420. summary: this.billInfo.customer.customerName + '您好,您有一个对账单共' + this.billInfo.settleAmount + '元,请您查阅',
  421. href: url,
  422. success() {
  423. console.log('调取微信列表成功,分享不一定成功');
  424. },
  425. fail() {
  426. console.log('分享失败');
  427. }
  428. });
  429. }
  430. },
  431. //一键刷新
  432. handleUpdate(){
  433. this.checkedAll = false
  434. this.$refs.billBox.allSelect(false);
  435. flushBill({verifySn:this.verifySn}).then(res => {
  436. if (res.status == 200) {
  437. this.loadData({ verifySn: this.verifySn })
  438. }
  439. });
  440. },
  441. //删除
  442. deleteOrder(){
  443. let that=this
  444. deleteDetails({verifySn:that.verifySn,detailSnList:that.orderList}).then(res => {
  445. if (res.status == 200) {
  446. uni.showToast({
  447. title:res.message,
  448. duration: 2000
  449. })
  450. that.loadData({ verifySn: that.verifySn });
  451. }
  452. });
  453. },
  454. handleEvents(type){
  455. this.eventsType=type
  456. if(type == 'del'){
  457. let allList=this.$refs.billBox.getAllData();
  458. let newChooseList = []
  459. let num = 0
  460. allList.forEach(item=>{
  461. if(item.checked){
  462. newChooseList.push(item.detailSn)
  463. num+=item.unsettleAmount
  464. }
  465. })
  466. if(newChooseList.length == 0){
  467. uni.showToast({
  468. title:'请先选择要删除的销售单',
  469. icon:'none'
  470. })
  471. return
  472. }
  473. this.orderList=newChooseList
  474. let newNum=toThousands(num,2)
  475. this.modalCon = '选中'+newChooseList.length+'项,待收金额¥'+newNum+',确认删除吗?'
  476. }
  477. let that=this
  478. that.$nextTick(()=>{
  479. that.modalShow = true
  480. })
  481. },
  482. //确定提交删除、刷新
  483. handleConfirm(){
  484. if(this.eventsType=='del'){
  485. this.deleteOrder();
  486. }else{
  487. this.handleUpdate();
  488. }
  489. },
  490. chooseBillList(flag){
  491. this.checkedAll = flag
  492. },
  493. chooseAll(){
  494. this.$refs.billBox.allSelect(!this.checkedAll);
  495. }
  496. }
  497. };
  498. </script>
  499. <style lang="scss" scoped>
  500. .content {
  501. height: 100vh;
  502. width: 100%;
  503. box-sizing: border-box;
  504. .b_head {
  505. background-color: #fff;
  506. .head_list {
  507. padding: 14rpx 20rpx;
  508. border-bottom: 1rpx solid #f8f8f8;
  509. text {
  510. &:first-child {
  511. color: $uni-text-color-grey;
  512. display: inline-block;
  513. width: 160rpx;
  514. }
  515. }
  516. }
  517. }
  518. .b_detail {
  519. margin: 6rpx 0;
  520. background-color: #fff;
  521. padding: 20rpx;
  522. box-sizing: border-box;
  523. .detail_list {
  524. margin-bottom: 10rpx;
  525. &:last-child {
  526. margin-bottom: 0rpx;
  527. }
  528. .detail_box::after {
  529. content: ';';
  530. color: $uni-text-color-grey;
  531. }
  532. .detail_box {
  533. text {
  534. &:first-child {
  535. color: $uni-text-color-grey;
  536. }
  537. &:last-child {
  538. color: $uni-color-warning;
  539. font-weight: 600;
  540. }
  541. }
  542. }
  543. }
  544. }
  545. .detail_con {
  546. flex-grow: 1;
  547. overflow: auto;
  548. background-color: #fff;
  549. }
  550. .footer {
  551. width: 100%;
  552. box-sizing: border-box;
  553. padding: 10rpx 20rpx;
  554. background: #fff;
  555. }
  556. }
  557. // 确认收款弹窗
  558. .slot-content{
  559. .u-form-item{
  560. line-height:0 !important;
  561. }
  562. .paymentFooter{
  563. border-top:1rpx solid #eee;
  564. view{
  565. width: 50%;
  566. text-align:center;
  567. padding:26rpx 0;
  568. }
  569. }
  570. .paymentFooter view:last-child{
  571. color:#007aff;
  572. border-left:1rpx solid #eee;
  573. }
  574. .costText {
  575. text-align: center;
  576. color: $uni-text-color-grey;
  577. font-size: 22rpx;
  578. }
  579. .costText1 {
  580. text-align: center;
  581. font-weight: bold;
  582. color: $uni-color-error;
  583. font-size: 36rpx;
  584. line-height: 60rpx;
  585. padding-bottom: 30rpx;
  586. }
  587. }
  588. </style>