From efe3d3241dfd1d144ca253e93e4e3f674008a883 Mon Sep 17 00:00:00 2001 From: qiaomu <3520484422@qq.com> Date: Wed, 13 Nov 2024 17:31:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98=E5=B7=A5=E4=BD=9C=E5=8F=B0?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=BE=85=E6=B5=8B=E8=AF=95=E5=92=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/searchSelect/index.js | 7 +- pages/workBench/components/approve/index.js | 160 +++++++++++++++++- pages/workBench/components/approve/index.json | 13 +- pages/workBench/components/approve/index.wxml | 116 ++++++++++++- pages/workBench/components/approve/index.wxss | 46 ++++- pages/workBench/components/recharge/index.js | 53 ++++-- .../workBench/components/recharge/index.wxml | 3 +- pages/workBench/components/record/index.js | 131 +++++++++++++- pages/workBench/components/record/index.json | 13 +- pages/workBench/components/record/index.wxml | 103 ++++++++++- pages/workBench/components/record/index.wxss | 42 ++++- service/meter.js | 17 +- service/recharge.js | 10 ++ 13 files changed, 680 insertions(+), 34 deletions(-) diff --git a/components/searchSelect/index.js b/components/searchSelect/index.js index 117d476..8885541 100644 --- a/components/searchSelect/index.js +++ b/components/searchSelect/index.js @@ -1,5 +1,5 @@ import { getParkList } from "../../service/park" -import { getParkMeterList } from "../../service/meter" +import { getParkSimpleMeterList } from "../../service/meter" import { alertInfo } from "../../utils/index"; import request from "../../utils/request" import { payWays } from "../../utils/data"; @@ -80,13 +80,11 @@ Component({ }, onSearch() { const { type } = this.data; - console.log('type', type) switch(type) { case "park": this.onSearchPark(); return; case "meter": - console.log("meter") this.onSearchMeter(); return; } @@ -105,8 +103,7 @@ Component({ }, async onSearchMeter() { const { searchText = "", park } = this.data; - console.log('this.data', this.data) - const { code, message, data: parks = [] } = await getParkMeterList({keyword: searchText, park}); + const { code, message, data: parks = [] } = await getParkSimpleMeterList({keyword: searchText, park}); if (code !== OK) { alertInfo(message) return diff --git a/pages/workBench/components/approve/index.js b/pages/workBench/components/approve/index.js index 04c0e1a..4592da2 100644 --- a/pages/workBench/components/approve/index.js +++ b/pages/workBench/components/approve/index.js @@ -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 + }) + } } }) \ No newline at end of file diff --git a/pages/workBench/components/approve/index.json b/pages/workBench/components/approve/index.json index e8cfaaf..c992ee6 100644 --- a/pages/workBench/components/approve/index.json +++ b/pages/workBench/components/approve/index.json @@ -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" + } } \ No newline at end of file diff --git a/pages/workBench/components/approve/index.wxml b/pages/workBench/components/approve/index.wxml index 80cada9..c9f31e9 100644 --- a/pages/workBench/components/approve/index.wxml +++ b/pages/workBench/components/approve/index.wxml @@ -1,2 +1,116 @@ -pages/workBench/components/approve/index.wxml \ No newline at end of file + + + + 选择 + + + + + + + + 搜索 + + + + + + + + + 商户名字 + 充值金额 + 操作 + + + + + + + + + {{ item.tenement.shortName }} + {{ item.amount }} + + + 查看详细 + + + + + + + + + + + + + + + + 同意 + 拒绝 + + + + + + + + + + diff --git a/pages/workBench/components/approve/index.wxss b/pages/workBench/components/approve/index.wxss index 9543ab5..0c73220 100644 --- a/pages/workBench/components/approve/index.wxss +++ b/pages/workBench/components/approve/index.wxss @@ -1 +1,45 @@ -/* pages/workBench/components/approve/index.wxss */ \ No newline at end of file +/* 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; +} diff --git a/pages/workBench/components/recharge/index.js b/pages/workBench/components/recharge/index.js index 559769d..8cbb125 100644 --- a/pages/workBench/components/recharge/index.js +++ b/pages/workBench/components/recharge/index.js @@ -1,6 +1,6 @@ import { handleRecharge } from "../../../../service/recharge"; -import { alertInfo, alertSuccess } from "../../../../utils/index"; +import { alertInfo, alertSuccess, loadingFunc } from "../../../../utils/index"; import request from '../../../../utils/request' const { OK } = request; @@ -45,9 +45,7 @@ Component({ }) }, onConfirm(e) { - // console.log('e', e) const { data, type, way } = e.detail; - console.log('e.detail', e.detail) switch(type) { case "park": this.setData({ @@ -85,14 +83,28 @@ Component({ }) }, onChangeMoney(e) { - console.log('e', e) this.setData({ money: e.detail }) }, onChangeVoucherNo(e) { - console.log('e', e) this.setData({ voucherNo: e.detail }) }, + handleClear() { + this.setData({ + park: "", + parkName: "", + meter: "", + meterName: "", + way: "", + payName: "", + show: false, + title: "", + type: "", + money: null, + voucherNo: null + }) + }, async handleSubmit() { + const that = this; const { park, meter, money, way, voucherNo } = this.data; if (!park) { alertInfo("请选择园区"); @@ -114,18 +126,27 @@ Component({ alertInfo("请输入凭证号") return } - const { code, message } = await handleRecharge(park, { - amount: `${money || ''}`, - meter, - paymentType: way, - voucherNo, - type: "0" + loadingFunc(async () => { + const { code, message } = await handleRecharge(park, { + amount: `${money || ''}`, + meter, + paymentType: way, + voucherNo, + type: 0 + }) + if (code !== OK) { + alertInfo(message) + return + } + alertSuccess("充值成功") + setTimeout(() => { + that.handleClear() + that.setData({ + + }) + }, 500) }) - if (code !== OK) { - alertInfo(message) - return - } - alertSuccess("充值成功") + } } }) \ No newline at end of file diff --git a/pages/workBench/components/recharge/index.wxml b/pages/workBench/components/recharge/index.wxml index fbf989e..f337f3a 100644 --- a/pages/workBench/components/recharge/index.wxml +++ b/pages/workBench/components/recharge/index.wxml @@ -68,7 +68,7 @@ 确认 - 取消 + 清空 diff --git a/pages/workBench/components/record/index.js b/pages/workBench/components/record/index.js index c76b4f6..855b4de 100644 --- a/pages/workBench/components/record/index.js +++ b/pages/workBench/components/record/index.js @@ -1,3 +1,8 @@ +import { alertInfo, alertSuccess, loadingFunc } from "../../../../utils/index"; +import { getParkMeterList, handleOperateMeterSwitch } from "../../../../service/meter" +import request from "../../../../utils/request" +const { OK } = request + // pages/workBench/components/record/index.js Component({ @@ -12,13 +17,135 @@ 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 getParkMeterList({ park, keyword, page }) + if (code !== OK) { + alertInfo(message); + return; + } + this.setData({ + list: data, + total: total, + totalPage: Math.ceil(total / 20) + }) + }, + 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: "", + }) + }, + onChangeSelectMeter(e) { + this.setData({ + meter: e.detail + }) + }, + async handleMeterSwitchOn() { + const that = this; + const { meter, list } = this.data; + const item = list.find(ele => ele.id === meter) + wx.showModal({ + title: '提示', + content: `您确认要对${item?.address || 当前电表}进行合闸吗?`, + complete: async (res) => { + if (res.cancel) { + + } + + if (res.confirm) { + loadingFunc(async () => { + const { code, message } = await handleOperateMeterSwitch({ ids: [meter], status: 0 }) + if (code !== OK) { + alertInfo(message) + return; + } + alertSuccess("合闸成功") + that.init(); + }) + + } + } + }) + }, + async handleMeterSwitchOff() { + const that = this; + const { meter, list } = this.data; + const item = list.find(ele => ele.id === meter) + wx.showModal({ + title: '提示', + content: `您确认要对${item?.address || 当前电表}进行拉闸吗?`, + complete: async (res) => { + if (res.cancel) { + return; + } + if (res.confirm) { + loadingFunc(async () => { + const { code, message } = await handleOperateMeterSwitch({ ids: [meter], status: 1 }) + if (code !== OK) { + alertInfo(message) + return; + } + alertSuccess("拉闸成功") + that.init(); + }) + } + } + }) + } } }) \ No newline at end of file diff --git a/pages/workBench/components/record/index.json b/pages/workBench/components/record/index.json index e8cfaaf..cd9253e 100644 --- a/pages/workBench/components/record/index.json +++ b/pages/workBench/components/record/index.json @@ -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-tag": "@vant/weapp/tag/index" + } } \ No newline at end of file diff --git a/pages/workBench/components/record/index.wxml b/pages/workBench/components/record/index.wxml index 9200d7d..92b5263 100644 --- a/pages/workBench/components/record/index.wxml +++ b/pages/workBench/components/record/index.wxml @@ -1,2 +1,103 @@ -pages/workBench/components/record/index.wxml \ No newline at end of file + + + 选择 + + + + + + + + 搜索 + + + + + + + + + + 商户名称 + 电表地址 + 电表余额 + 拉合闸 + 是否失联 + + + + + + + + {{ item.tenement.shortName }} + {{ item.address }} + {{ item.amount }} + + 拉闸 + + + 合闸 + + + 在线 + + + 失联 + + + + + + + + + + + + + + + 合闸 + 拉闸 + + + + + + diff --git a/pages/workBench/components/record/index.wxss b/pages/workBench/components/record/index.wxss index f41e371..34f106c 100644 --- a/pages/workBench/components/record/index.wxss +++ b/pages/workBench/components/record/index.wxss @@ -1 +1,41 @@ -/* pages/workBench/components/record/index.wxss */ \ No newline at end of file +/* pages/workBench/components/record/index.wxss */ +.table { + width: 890rpx; + +} + +.classWrapper { + width: 100vw; + overflow-x: auto; +} + +.thead { + display: flex; + flex-wrap: nowrap; + border-bottom: 1rpx solid #EEEEEE; +} + +.thead .th { + padding: 20rpx; + white-space: nowrap; + text-align: center; + box-sizing: border-box; + +} + +.tbody { + width: 890rpx; +} + +.tbody .tr { + padding: 20rpx; + border-bottom: 1rpx solid #EEEEEE; + display: flex; + align-items: center; + flex-wrap: nowrap; +} + +.tbody .th { + word-break: break-all; + text-align: center; +} diff --git a/service/meter.js b/service/meter.js index 2f37d61..91027a6 100644 --- a/service/meter.js +++ b/service/meter.js @@ -17,6 +17,19 @@ export const getTenementMeterList = async function(tid) { } // 获取某一园区下的电表列表 -export const getParkMeterList = async function({park = "", keyword = ""}) { - return await GET(`/equipment/getOperateMeterList?page=1&park=${park}&keyword=${keyword}`); +export const getParkMeterList = async function({park = "", keyword = "", page = 1}) { + return await GET(`/equipment/getOperateMeterList?page=${page}&park=${park}&keyword=${keyword}`); +} + +// 获取某一园区下的简洁电表列表 +export const getParkSimpleMeterList = async function({park = "", keyword = "", page = 1}) { + return await GET(`/work/getWorkMeter?page=${page}&park=${park}&keyword=${keyword}`); +} + + + + +// 拉合闸 +export const handleOperateMeterSwitch = async function({ ids = [], status }) { + return await PUT(`/equipment/batchSwtich`, { ids, status }); } \ No newline at end of file diff --git a/service/recharge.js b/service/recharge.js index 2fd8cbd..5a8ce21 100644 --- a/service/recharge.js +++ b/service/recharge.js @@ -30,4 +30,14 @@ export const createPublicTopUp = async function(data) { // 后台充值 export const handleRecharge = async function(park, data) { return await POST(`/wechatTopup/${park}`, data) +} + +// 获取后台审核列表 +export const getRechargeApproveList = async function({park, page, keyword}) { + return await GET(`/wx/getTopExamineList?park=${park}&page=${page}&keyword=${keyword}`) +} + +// 对公审核 +export const rechargeApprove = async function({ id, status, reason }) { + return await PUT(`/wx/updateTopExamineList/`, { id, status, reason }) } \ No newline at end of file