暂存工作台模块,初步完成待测试和优化
This commit is contained in:
		| @@ -1,4 +1,11 @@ | ||||
| // pages/workBench/components/approve/index.js | ||||
| import { alertInfo, alertSuccess, loadingFunc } from "../../../../utils/index"; | ||||
| import { getParkMeterList, handleOperateMeterSwitch } from "../../../../service/meter" | ||||
| import { getRechargeApproveList, rechargeApprove } from "../../../../service/recharge" | ||||
| import request from "../../../../utils/request" | ||||
| const { OK } = request | ||||
|  | ||||
| // pages/workBench/components/record/index.js | ||||
| Component({ | ||||
|  | ||||
|   /** | ||||
| @@ -12,13 +19,162 @@ Component({ | ||||
|    * 组件的初始数据 | ||||
|    */ | ||||
|   data: { | ||||
|  | ||||
|     keyword: "", | ||||
|     keywordTemp: "", | ||||
|     page: 1, | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * 组件的方法列表 | ||||
|    */ | ||||
|   methods: { | ||||
|  | ||||
|     onParkFocus(e) { | ||||
|       this.setData({ | ||||
|         show: true, | ||||
|         title: "园区", | ||||
|         type: 'park' | ||||
|       }) | ||||
|     }, | ||||
|     onConfirm(e) { | ||||
|       const { data } = e.detail; | ||||
|       const that = this; | ||||
|       this.setData({ | ||||
|         parkName: data.name, | ||||
|         park: data.id, | ||||
|       }, () => { | ||||
|         loadingFunc(async () => { | ||||
|           await that.init(); | ||||
|         }) | ||||
|       }) | ||||
|       this.onConcal(); | ||||
|     }, | ||||
|     onChangeKeyword(e) { | ||||
|       this.setData({ keywordTemp: e.detail }) | ||||
|     }, | ||||
|     onSearch() { | ||||
|       const that = this; | ||||
|       that.setData({ | ||||
|         keyword: that.data.keywordTemp | ||||
|       }, () => { | ||||
|         loadingFunc(async () => { | ||||
|           await that.init(); | ||||
|         }) | ||||
|       }) | ||||
|     }, | ||||
|     async init() { | ||||
|       const { page, keyword, park } = this.data; | ||||
|       const { code, message, data, total } = await getRechargeApproveList({ park, page, keyword }) | ||||
|       if (code !== OK) { | ||||
|         alertInfo(message); | ||||
|         return; | ||||
|       } | ||||
|       this.setData({ | ||||
|         list: data, | ||||
|         total: total, | ||||
|         totalPage: Math.ceil(total / 20) | ||||
|       }) | ||||
|     }, | ||||
|     onChangeReason(e) { | ||||
|       console.log('e.detail', e.detail) | ||||
|       this.setData({ | ||||
|         reason: e.detail, | ||||
|       }) | ||||
|     }, | ||||
|     onApproveClose() { | ||||
|       this.setData({ | ||||
|         reason: "", | ||||
|         approveShow: false, | ||||
|       }) | ||||
|     }, | ||||
|     onApproveConfirm() { | ||||
|       const { reason, record } = this.data; | ||||
|       const that = this; | ||||
|       if (!reason) { | ||||
|         alertInfo("请输入拒绝理由") | ||||
|         return; | ||||
|       } | ||||
|       console.log('1') | ||||
|       loadingFunc(async () => { | ||||
|         console.log('2') | ||||
|         const { code, message } = await rechargeApprove({ id: record, status: 1, reason }) | ||||
|         console.log('3') | ||||
|         if (code !== OK) { | ||||
|           alertInfo(message) | ||||
|           return; | ||||
|         } | ||||
|         alertSuccess("已拒绝") | ||||
|         that.init(); | ||||
|         that.setData({ | ||||
|           reason: "", | ||||
|           approveShow: false, | ||||
|           record: "", | ||||
|         }) | ||||
|       }) | ||||
|        | ||||
|     }, | ||||
|     handleApprove(e) { | ||||
|       const status = e.currentTarget.dataset.status; | ||||
|       const that = this; | ||||
|       if (status === '1') { | ||||
|         this.setData({ | ||||
|           approveShow: true | ||||
|         }) | ||||
|         return; | ||||
|       } | ||||
|       const { record, list } = this.data; | ||||
|       const item = list.find(ele => ele.id === record) | ||||
|      | ||||
|       wx.showModal({ | ||||
|         title: '提示', | ||||
|         content: `您确认要同意${item?.tenement?.shortName || 当前记录}吗?`, | ||||
|         complete: async (res) => { | ||||
|           if (res.cancel) { | ||||
|              | ||||
|           } | ||||
|        | ||||
|           if (res.confirm) { | ||||
|             loadingFunc(async () => { | ||||
|               const { code, message } = await rechargeApprove({ id: record, status: 0,  }) | ||||
|               if (code !== OK) { | ||||
|                 alertInfo(message) | ||||
|                 return; | ||||
|               } | ||||
|               alertSuccess("已同意") | ||||
|               that.init(); | ||||
|             }) | ||||
|              | ||||
|           } | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     jumpToDetail(e) { | ||||
|       const { id } = e.currentTarget.dataset; | ||||
|       wx.navigateTo({ | ||||
|         url: '/pages/rechargeDetail/index?id=' + id, | ||||
|       }) | ||||
|     }, | ||||
|     async onChangePage(e) { | ||||
|       const page = e.detail.currentIndex; | ||||
|       const that = this; | ||||
|       this.setData({ | ||||
|         page | ||||
|       }, () => { | ||||
|         loadingFunc(async () => { | ||||
|           await that.init(); | ||||
|         }) | ||||
|       }) | ||||
|     }, | ||||
|     onConcal() { | ||||
|       this.setData({ | ||||
|         show: false, | ||||
|         title: "", | ||||
|         type: "", | ||||
|       }) | ||||
|     }, | ||||
|     onChangeSelectRecharge(e) { | ||||
|       this.setData({ | ||||
|         record: e.detail | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| }) | ||||
| @@ -1,4 +1,15 @@ | ||||
| { | ||||
|   "component": true, | ||||
|   "usingComponents": {} | ||||
|   "usingComponents": { | ||||
|     "van-field": "@vant/weapp/field/index", | ||||
|     "van-button": "@vant/weapp/button/index", | ||||
|     "search-select": "/components/searchSelect/index", | ||||
|     "van-empty": "@vant/weapp/empty/index", | ||||
|     "table": "/components/table/table", | ||||
|     "pagination": "/components/pagination/index", | ||||
|     "empty": "/components/empty/index", | ||||
|     "van-radio": "@vant/weapp/radio/index", | ||||
|     "van-radio-group": "@vant/weapp/radio-group/index", | ||||
|     "van-dialog": "@vant/weapp/dialog/index" | ||||
|   } | ||||
| } | ||||
| @@ -1,2 +1,116 @@ | ||||
| <!--pages/workBench/components/approve/index.wxml--> | ||||
| <text>pages/workBench/components/approve/index.wxml</text> | ||||
| <!--pages/workBench/components/record/index.wxml--> | ||||
| <van-field | ||||
|     value="{{ parkName }}" | ||||
|     placeholder="请选择园区" | ||||
|     label="园区" | ||||
|     readonly | ||||
|     border="{{ false }}" | ||||
|     use-button-slot | ||||
|     title-width="100rpx" | ||||
| > | ||||
|     <van-button slot="button" size="small" type="primary" bind:click="onParkFocus"> | ||||
|       选择 | ||||
|     </van-button> | ||||
| </van-field> | ||||
|  | ||||
| <van-empty wx:if="{{!park}}" description="选择园区后查看" /> | ||||
| <view wx:else> | ||||
|     <van-field | ||||
|         value="{{ keyword }}" | ||||
|         placeholder="请输入关键字" | ||||
|         label="关键字" | ||||
|         border="{{ false }}" | ||||
|         use-button-slot | ||||
|         bind:change="onChangeKeyword" | ||||
|         title-width="100rpx" | ||||
|     > | ||||
|         <van-button slot="button" size="small" type="primary" bind:click="onSearch"> | ||||
|         搜索 | ||||
|         </van-button> | ||||
|     </van-field> | ||||
|     <view> | ||||
|         <view wx:if="{{list.length}}"> | ||||
|             <view class="tableWrapper"> | ||||
|                 <view class="table"> | ||||
|                     <view class="thead"> | ||||
|                         <view class="th" style="width: 70rpx">  </view> | ||||
|                         <view class="th" style="width: 250rpx"> 商户名字 </view> | ||||
|                         <view class="th" style="width: 150rpx"> 充值金额 </view> | ||||
|                         <view class="th" style="width: 200rpx"> 操作 </view> | ||||
|                     </view> | ||||
|                     <view class="tbody"> | ||||
|                         <van-radio-group value="{{ record }}" bind:change="onChangeSelectRecharge"> | ||||
|                             <block wx:for="{{list}}" wx:for-index="itemIndex" wx:key="item"> | ||||
|                                 <view class="tr"> | ||||
|                                     <view class="th" style="width: 60rpx"> | ||||
|                                         <van-radio wx:if="{{item.orderStatus !== '已退回'}}" name="{{item.id}}"></van-radio> | ||||
|                                     </view> | ||||
|                                     <view class="th" style="width: 200rpx"> {{ item.tenement.shortName }} </view> | ||||
|                                     <view class="th" style="width: 200rpx"> {{ item.amount }} </view> | ||||
|                                     <view class="th" style="width: 200rpx"> | ||||
|                                         <view class="primaryTextBtn" bind:tap="jumpToDetail" data-id="{{item.id}}"> | ||||
|                                             查看详细 | ||||
|                                         </view> | ||||
|                                     </view> | ||||
|                                 </view> | ||||
|                             </block> | ||||
|                         </van-radio-group> | ||||
|                     </view> | ||||
|                 </view> | ||||
|             </view> | ||||
|              | ||||
|             <pagination  | ||||
|                 currentIndex="{{page}}"  | ||||
|                 totalPage="{{totalPage}}"  | ||||
|                 bind:pagingChange="onChangePage"   | ||||
|             /> | ||||
|              | ||||
|         </view> | ||||
|         <empty bind:refresh="init" wx:else /> | ||||
|         <view class="operate"> | ||||
|             <view style="margin-top: 60rpx; margin-bottom: 60rpx;display: flex; justify-content: center; align-items: center;"> | ||||
|                 <van-button  | ||||
|                     type="info"  | ||||
|                     size="small"  | ||||
|                     style="margin-right: 30rpx;"  | ||||
|                     bind:click="handleApprove" | ||||
|                     data-status="0" | ||||
|                     disabled="{{!record}}" | ||||
|                 > 同意 </van-button> | ||||
|                 <van-button  | ||||
|                     size="small"  | ||||
|                     bind:click="handleClear"   | ||||
|                     disabled="{{!record}}"  | ||||
|                     bind:click="handleApprove" | ||||
|                     data-status="1" | ||||
|                 > 拒绝 </van-button> | ||||
|             </view> | ||||
|         </view> | ||||
|     </view> | ||||
| </view> | ||||
|  | ||||
| <search-select  | ||||
|     show="{{show}}"  | ||||
|     title="{{title}}"  | ||||
|     type="{{type}}"  | ||||
|     park="{{park}}" | ||||
|     bindconfirm="onConfirm" | ||||
|     bindcancel="onConcal" | ||||
| /> | ||||
|  | ||||
| <van-dialog | ||||
|   use-slot | ||||
|   title="审核" | ||||
|   show="{{ approveShow }}" | ||||
|   show-cancel-button | ||||
|   bind:close="onApproveClose" | ||||
|   bind:confirm="onApproveConfirm" | ||||
| > | ||||
|     <van-field | ||||
|         label="拒绝理由" | ||||
|         value="{{ reason }}" | ||||
|         placeholder="请输入拒绝理由" | ||||
|         bind:change="onChangeReason" | ||||
|     /> | ||||
| </van-dialog> | ||||
|   | ||||
| @@ -1 +1,45 @@ | ||||
| /* pages/workBench/components/approve/index.wxss */ | ||||
| /* pages/workBench/components/approve/index.wxss */ | ||||
| .table { | ||||
|     width: 810rpx; | ||||
|  | ||||
| } | ||||
|  | ||||
| .tableWrapper { | ||||
|     width: 100vw; | ||||
|     overflow-x: auto; | ||||
| } | ||||
|  | ||||
| .thead { | ||||
|      | ||||
|     display: flex; | ||||
|     flex-wrap: nowrap; | ||||
|   | ||||
| } | ||||
|  | ||||
| .thead  .th { | ||||
|     padding: 20rpx; | ||||
|     white-space: nowrap; | ||||
|     text-align: center; | ||||
|     box-sizing: border-box; | ||||
| } | ||||
|  | ||||
| .primaryTextBtn { | ||||
|     color: #1989fa; | ||||
|   } | ||||
|  | ||||
| .tbody { | ||||
|     width: 810rpx; | ||||
| } | ||||
|  | ||||
| .tbody .tr { | ||||
|     padding: 20rpx; | ||||
|     border-bottom: 1rpx solid #EEEEEE; | ||||
|     display: flex; | ||||
|     align-items: center; | ||||
|     flex-wrap: nowrap; | ||||
| } | ||||
|  | ||||
| .tbody .tr { | ||||
|     word-break: break-all; | ||||
|     text-align: center; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user