初步联调装表

This commit is contained in:
2025-11-03 16:26:30 +08:00
parent fe590353df
commit 1539304999
35 changed files with 1495 additions and 100 deletions

View File

@@ -0,0 +1,379 @@
// pages/workBenchNew/components/createMeter/index.js
import dayjs from "../../../../utils/dayjs"
import { alertInfo, alertSuccess, loadingFunc } from "../../../../utils/index"
import { uploadInstallMeter } from "../../../../service/public"
import request from "../../../../utils/request"
import { installMeter } from "../../../../service/meter"
const { OK } = request
Page({
/**
* 页面的初始数据
*/
data: {
time: "",
area: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.setData({
time: dayjs().format("YYYY-MM-DD HH:mm:ss")
})
},
onParkFocus(e) {
this.setData({
show: true,
title: "园区",
type: 'park'
})
},
onMeterFocus(e) {
const { park } = this.data;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "电表",
type: 'inventoryMeter'
})
},
onBuildingFocus() {
const { park } = this.data;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "建筑",
type: 'building'
})
},
clearImage() {
this.setData({
url: ""
})
},
onMeterBoxFocus() {
const { park } = this.data;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "电表箱",
type: 'meterBox'
})
},
onMeterTypeFocus() {
this.setData({
show: true,
title: "电表类型",
type: 'meterType'
})
},
onBindCard() {
const { park } = this.data;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "卡",
type: 'card'
})
},
onBindCollectionA() {
const { park } = this.data;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "采集器A",
type: 'collection',
collection: "A"
})
},
onBindCollectionB() {
const { park } = this.data;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "采集器B",
type: 'collection',
collection: "B"
})
},
onBindCollectionC() {
const { park } = this.data;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "采集器C",
type: 'collection',
collection: "C"
})
},
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
})
})
}
})
},
onConfirm(e) {
const { type, data = {} } = e.detail;
const {collection} = this.data;
switch(type) {
case "park":
this.setData({
park: data.id,
parkName: data.name,
})
break;
case "tenement":
this.setData({
tenement: data.id,
tenementName: data.name,
})
break;
case "inventoryMeter":
this.setData({
meter: data.id,
meterName: data?.sn,
})
break;
case "building":
this.setData({
building: data.id,
buildingName: data.name,
});
break;
case "meterBox":
this.setData({
meterBox: data.id,
meterBoxName: data.address,
});
break;
case "tenement":
this.setData({
tenement: data.id,
tenementName: data.name,
})
break;
case "meterType":
this.setData({
meterType: data.way,
meterTypeName: data,
});
break;
case "meter":
this.setData({
meter: data.id,
meterName: data.address,
});
break;
case "card":
this.setData({
card: data.id,
cardName: data.sim_number,
});
break;
case "collection":
let newData = {}
if (collection === "A") {
newData = {
collectionA: data.id,
collectionAName: data.name,
}
}
if (collection === "B") {
newData = {
collectionB: data.id,
collectionBName: data.name,
}
}
if (collection === "C") {
newData = {
collectionC: data.id,
collectionCName: data.name,
}
}
this.setData(newData);
break;
}
this.onCancel();
},
changeAddress(e) {
this.setData({
address: e.detail
})
},
changeArea(e) {
this.setData({
area: e.detail
})
},
changeOverall(e) {
this.setData({
overall: e.detail
})
},
changeSharp(e) {
this.setData({
sharp: e.detail
})
},
changePeak(e) {
this.setData({
sharp: e.detail
})
},
changeFlat(e) {
this.setData({
flat: e.detail
})
},
changeValley(e) {
this.setData({
valley: e.detail
})
},
changeRatio(e) {
this.setData({
ratio: e.detail,
})
},
onCancel() {
this.setData({
show: false,
title: "",
type: "",
})
},
onTenementFocus(e) {
const { park } = this.data;
const that = this;
if (!park) {
alertInfo("请先选择园区")
return;
}
this.setData({
show: true,
title: "商户",
type: 'tenement'
})
},
async handleSubmit() {
const {
park, meter, address, building, meterBox, meterType,
ratio, area, card, collectionA, collectionB, collectionC,
tenement, sharp, peak, flat, valley, overall, url
} = this.data;
if (!park || !meter || !address) {
alertInfo("请填写必填项后保存")
return;
}
console.log("data", this.data)
const { code, data, message } = await installMeter({
park, meter, address, building, meterBox, meterType,
ratio, area, card, collectionA, collectionB, collectionC,
tenement, sharp, peak, flat, valley, overall, url
})
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("新增成功")
},
goback() {
wx.navigateBack()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@@ -0,0 +1,12 @@
{
"usingComponents": {
"navigator": "/components/navigator/index",
"van-popup": "@vant/weapp/popup/index",
"search-select": "/components/searchSelect/index",
"van-field": "@vant/weapp/field/index",
"van-button": "@vant/weapp/button/index",
"van-image": "@vant/weapp/image/index",
"searchSelectWrapper": "/components/searchSelectWrapper/index"
},
"navigationStyle": "custom"
}

View File

@@ -0,0 +1,181 @@
<!--pages/workBenchNew/components/createMeter/index.wxml-->
<navigator canBack="{{true}}" title="新装电表" />
<view class="wrapper">
<searchSelectWrapper
label="当前时间"
placeholder="请选择园区"
useSlot
type=""
hideBorder="{{true}}"
>
<view> {{time}} </view>
</searchSelectWrapper>
<searchSelectWrapper
label="选择园区"
placeholder="请选择园区"
text="{{parkName}}"
bind:search="onParkFocus"
required="{{true}}"
/>
<searchSelectWrapper
label="选择电表"
placeholder="请选择电表"
text="{{meterName}}"
bind:search="onMeterFocus"
required="{{true}}"
/>
<searchSelectWrapper
label="选择建筑"
placeholder="请选择建筑"
text="{{buildingName}}"
bind:search="onBuildingFocus"
/>
<searchSelectWrapper
label="电表箱"
placeholder="请选择电表箱"
text="{{meterBoxName}}"
bind:search="onMeterBoxFocus"
/>
<searchSelectWrapper
label="电表类型"
placeholder="请选择电表类型"
text="{{meterTypeName}}"
bind:search="onMeterTypeFocus"
required="{{true}}"
/>
<searchSelectWrapper
label="倍率"
placeholder="请输入倍率"
type="input"
text="ratio"
bind:changeText="changeRatio"
/>
<searchSelectWrapper
label="电表地址"
placeholder="请输入电表地址"
text="area"
type="input"
required="{{true}}"
bind:changeText="changeAddress"
/>
<searchSelectWrapper
label="所辖面积"
placeholder="请输入所辖面积"
text="area"
type="input"
bind:changeText="changeArea"
/>
<searchSelectWrapper
label="绑定卡"
placeholder="请选择卡绑定(选填)"
text="{{cardName}}"
bind:search="onBindCard"
/>
<searchSelectWrapper
label="采集器A"
placeholder="请选择采集器绑定(选填)"
text="{{collectionA}}"
bind:search="onBindCollectionA"
/>
<searchSelectWrapper
label="采集器B"
placeholder="请选择采集器绑定(选填)"
text="{{collectionB}}"
bind:search="onBindCollectionB"
/>
<searchSelectWrapper
label="采集器C"
placeholder="请选择采集器绑定(选填)"
text="{{collectionC}}"
bind:search="onBindCollectionC"
/>
<searchSelectWrapper
label="商户"
placeholder="请选择商户"
text="{{ tenementName }}"
bind:search="onTenementFocus"
/>
<searchSelectWrapper
label="总"
placeholder="请输入总"
type="input"
bind:changeText="changeOverall"
/>
<searchSelectWrapper
label="尖"
placeholder="请输入尖"
type="input"
bind:changeText="changeSharp"
/>
<searchSelectWrapper
label="峰"
placeholder="请输入峰"
type="input"
bind:changeText="changePeak"
/>
<searchSelectWrapper
label="平"
placeholder="请输入平"
type="input"
bind:changeText="changeFlat"
/>
<searchSelectWrapper
label="谷"
placeholder="请输入谷"
type="input"
bind:changeText="changeValley"
/>
<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>
<search-select
show="{{show}}"
title="{{title}}"
type="{{type}}"
park="{{park}}"
bindconfirm="onConfirm"
bindcancel="onCancel"
wx:if="{{show}}"
/>
<van-popup
show="{{ imageShow }}"
bind:close="onClose"
z-index="99999"
>
<van-image
width="100vw"
height="99.1vh"
fit="contain"
src="{{url}}"
bind:click="onClose"
/>
</van-popup>

View File

@@ -0,0 +1,15 @@
/* pages/workBenchNew/components/createMeter/index.wxss */
.operate {
display: flex;
padding-top: 24rpx;
padding-bottom: 36rpx;
}
.submit, .cancel {
flex: 1;
}
.submit {
margin-right: 30rpx;
}