工作台代码提交

This commit is contained in:
2025-11-09 17:33:32 +08:00
parent 0d38e006e1
commit 639f92540f
27 changed files with 1257 additions and 27 deletions

View File

@@ -0,0 +1,276 @@
// pages/workBenchNew/components/workBenchMeter/index.js
import { alertInfo, alertSuccess, loadingFunc } from "../../../../utils/index";
import { getParkMeterList, handleOperateMeterSwitch } from "../../../../service/meter"
import request from "../../../../utils/request"
const { OK } = request
Page({
/**
* 页面的初始数据
*/
data: {
keyword: "",
keywordTemp: "",
page: 1,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
onParkFocus(e) {
this.setData({
show: true,
title: "园区",
type: 'park'
})
},
onModeFocus(e) {
this.setData({
show: true,
title: "强控类型",
type: 'meterMode'
})
},
onMeterFocus(e) {
const { park } = this.data;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "电表",
type: 'meter'
})
},
onConfirm(e) {
const { data, type, way } = e.detail;
const that = this;
switch(type) {
case "park":
this.setData({
parkName: data.name,
park: data.id,
})
break;
case "meterMode":
this.setData({
modeName: data,
mode: way,
})
break;
case "meter":
this.setData({
meterName: data.address,
meter: data.id,
}, () => {
loadingFunc(async () => {
await that.init();
})
})
break;
}
this.onCancel();
},
onChangeKeyword(e) {
this.setData({ keywordTemp: e.detail })
},
changeDays(e) {
this.setData({
days: e.detail,
})
},
uploadImage() {
const that = this;
wx.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album', 'camera'],
success: async function(res) {
console.log("res", res)
const path = res.tempFiles?.[0]?.tempFilePath.toLowerCase()
if (!/(\.jpg|\.png|\.jpeg)$/.test(path)) {
wx.showToast({
title: '请上传jpg、png或jpeg格式的图片',
icon: 'none',
});
return;
}
var tempFilePaths = path;
loadingFunc(async () => {
const { code, message, url } = await uploadInstallMeter(tempFilePaths)
if (code !== OK) {
alertError(message)
return
}
that.setData({
url: url
})
})
}
})
},
clearImage() {
this.setData({
url: ""
})
},
changeReason(e) {
this.setData({
reason: e.detail,
})
},
onSearch() {
const that = this;
that.setData({
keyword: that.data.keywordTemp
}, () => {
loadingFunc(async () => {
await that.init();
})
})
},
async init() {
const { page, park, meter } = this.data;
if (!park) {
return;
}
const { code, message, data, total } = await getParkMeterList({ park, keyword: meter, 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();
})
})
},
onCancel() {
this.setData({
show: false,
title: "",
type: "",
})
},
onChangeSelectMeter(e) {
this.setData({
meter: e.detail
})
},
async handleMeterSwitchOn() {
const that = this;
const { meter, meterName } = this.data;
wx.showModal({
title: '提示',
content: `您确认要对${meterName || 当前电表}进行合闸吗?`,
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, meterName } = this.data;
wx.showModal({
title: '提示',
content: `您确认要对${meterName || 当前电表}进行拉闸吗?`,
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();
})
}
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@@ -0,0 +1,20 @@
{
"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",
"van-row": "@vant/weapp/row/index",
"van-col": "@vant/weapp/col/index",
"navigator": "/components/navigator/index",
"searchSelectWrapper": "/components/searchSelectWrapper/index",
"van-popup": "@vant/weapp/popup/index"
},
"navigationStyle": "custom"
}

View File

@@ -0,0 +1,163 @@
<!--pages/workBench/components/record/index.wxml-->
<navigator title="电表操作" canBack="{{true}}" />
<searchSelectWrapper
label="园区"
placeholder="请选择园区"
text="{{parkName}}"
bind:search="onParkFocus"
/>
<searchSelectWrapper
label="电表"
placeholder="请选择电表"
text="{{meterName}}"
bind:search="onMeterFocus"
/>
<van-empty wx:if="{{!meter}}" description="选择电表后查看" />
<view wx:else>
<view wx:if="{{list.length}}">
<!-- <view class="operate">
<view style="margin-top: 24rpx; margin-bottom: 24rpx;display: flex; justify-content: center; align-items: center;">
<van-button
type="info"
size="small"
style="margin-right: 30rpx;"
bind:click="handleMeterSwitchOn"
disabled="{{!meter}}"
> 合闸 </van-button>
<van-button size="small" bind:click="handleClear" disabled="{{!meter}}" bind:click="handleMeterSwitchOff"> 拉闸 </van-button>
</view>
</view> -->
<view class="customTable" wx:for="{{list}}" wx:key="id">
<view class="customTableTile">
<van-row>
<van-col span="8">
<view style="text-align: center;"> {{item.tenement.shortName}} </view>
</van-col>
<van-col span="16"><view style="margin-left: 16rpx;">{{item.tenement.name}}</view> </van-col>
</van-row>
</view>
<view class="customTableContent">
<van-row >
<van-col span="24">
<view class="tableRow">
<van-row gutter="5">
<van-col span="8" wx:if="{{item.type === 0}}">
<view style="text-align: center;border-right: 1rpx solid #ccc;"> 商户电表 </view></van-col>
<van-col span="8" wx:elif="{{item.type === 2}}">
<view style="text-align: center;border-right: 1rpx solid #ccc;"> 公摊电表 </view></van-col>
<van-col span="8" wx:else>
<view style="text-align: center;border-right: 1rpx solid #ccc;"> 园区电表 </view></van-col>
<van-col span="16">表号:{{item.meterNo}}</van-col>
</van-row>
</view>
</van-col>
<van-col span="24">
<view class="tableRow">
<van-row gutter="5">
<van-col span="8">
<view style="text-align: center;border-right: 1rpx solid #ccc;"> {{item.address}} </view>
</van-col>
<van-col span="16">SN{{item.meterSn}}</van-col>
</van-row>
</view>
</van-col>
<van-col span="24">
<view class="tableRow">
<van-row gutter="5">
<van-col span="8">
<view style="text-align: center;border-right: 1rpx solid #ccc;"> 表字:{{item.amount}} </view>
</van-col>
<van-col span="16">余额:{{item.money}}</van-col>
</van-row>
</view>
</van-col>
<van-col span="24">
<view class="tableRow">
<van-row gutter="5">
<van-col span="8" wx:if="{{item.onPosition === 0}}">
<view style="text-align: center;border-right: 1rpx solid #ccc;">合闸</view> </van-col>
<van-col span="8" wx:else><view style="text-align: center;border-right: 1rpx solid #ccc;">拉闸</view> </van-col>
<van-col span="8" wx:if="{{item.canConnect}}">
<view style="display: flex;align-items: center;">
<view style="text-align: center; margin-right: 24rpx;">在线</view>
<view wx:if="{{item.mode === 0}}"> 预付费 </view>
<view wx:if="{{item.mode === 1}}"> 强控 </view>
<view wx:if="{{item.mode === 2}}"> 临时强控 </view>
</view>
</van-col>
<van-col span="8" wx:else>
<view style="display: flex;align-items: center; margin-right: 24rpx;">
<view style="text-align: center;">失联</view>
<view wx:if="{{item.mode === 0}}"> 预付费 </view>
<view wx:if="{{item.mode === 1}}"> 强控 </view>
<view wx:if="{{item.mode === 2}}"> 临时强控 </view>
</view>
</van-col>
</van-row>
</view>
</van-col>
</van-row>
</view>
</view>
<view class="wrapper">
<searchSelectWrapper
label="强控类型"
placeholder="请选择强控类型"
text="{{modeName}}"
bind:search="onModeFocus"
required="{{true}}"
/>
<searchSelectWrapper
wx:if="{{mode === 2}}"
label="天数"
placeholder="请输入天数"
text="{{days}}"
type="input"
bind:changeText="changeDays"
/>
<searchSelectWrapper
label="原因"
placeholder="请输入原因"
text="{{reason}}"
type="input"
bind:changeText="changeReason"
/>
<searchSelectWrapper
label="图片"
useSlot="{{true}}"
type=""
hideBorder="{{true}}"
>
<view style="display: flex; align-items: center;">
<view>
<van-button type="info" size="small" bind:click="uploadImage" custom-style="margin-right: 20rpx;"> 上传 </van-button>
<view style="margin-top: 20rpx" wx:if="{{!!url}}">
<van-button type="danger" size="small" bind:click="clearImage" custom-style="margin-right: 20rpx;"> 清除 </van-button>
</view>
</view>
<van-image wx:if="{{!!url}}" width="100" height="100" src="{{url}}" custom-style="margin-left: 20rpx;" />
</view>
</searchSelectWrapper>
<view class="operate">
<view class="submit"> <van-button type="info" block bind:click="handleSubmit"> 提交 </van-button> </view>
<view class="cancel"> <van-button block bind:tap="goback"> 返回 </van-button> </view>
</view>
</view>
</view>
<empty bind:refresh="init" wx:else />
</view>
<search-select
show="{{show}}"
title="{{title}}"
type="{{type}}"
park="{{park}}"
bindconfirm="onConfirm"
bindcancel="onCancel"
wx:if="{{show}}"
/>

View File

@@ -0,0 +1,78 @@
/* 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;
}
.customTable {
margin: 20rpx;
}
.customTableTile {
background-color: var(--light-green);
padding: 16rpx;
box-sizing: border-box;
font-weight: 700;
}
.tableRow {
padding: 16rpx;
border: 1rpx solid #ccc;
border-top: 0rpx;
}
page {
background-color: rgb(228,240,236);
font-size: 32rpx;
}
.operate {
display: flex;
padding-top: 24rpx;
padding-bottom: 36rpx;
}
.submit, .cancel {
flex: 1;
}
.submit {
margin-right: 30rpx;
}