暂存商户信息

This commit is contained in:
2025-02-21 15:47:36 +08:00
parent b078bbf26a
commit 93ee759092
26 changed files with 339 additions and 118 deletions

View File

@@ -31,5 +31,8 @@ Component({
type: 'meter'
})
},
onClose() {
this.triggerEvent("close")
}
}
})

View File

@@ -5,6 +5,7 @@
show="{{ show }}"
show-cancel-button
bind:confirm="onSubmit"
bind:close="onClose"
>
<view class="modalContentWrapper">
<van-field

View File

@@ -70,5 +70,5 @@
type="{{type}}"
park="{{park}}"
bindconfirm="onConfirm"
bindcancel="onConcal"
bindcancel="onCancel"
/>

View File

@@ -1,6 +1,9 @@
// pages/workBench/components/tenement/components/kaihu/index.js
import { alertInfo } from "../../../../../../utils/index"
import { alertInfo, alertSuccess } from "../../../../../../utils/index"
import { createBackTenement, updateTenementBackInfo } from "../../../../../../service/tenement"
import request from "../../../../../../utils/request"
import { payWays, feeType as feeTypeList } from "../../../../../../utils/data";
const { OK } = request;
Component({
/**
@@ -9,14 +12,21 @@ Component({
properties: {
park: String,
visible: Boolean,
defaultValue: Object,
editType: String,
title: String,
},
observers: {
'defaultValue': function(defaultValue) {
const { fullName, shortName, phone, id, feeType, address, building, buildingName, contact,} = defaultValue;
this.setData({
name: fullName,
shortName,
phone, id, feeType, address, building, buildingName, contact,
feeTypeName: feeTypeList[feeType]
})
}
},
// observers: {
// 'visible': function(newVisible) {
// this.setData({
// show: newVisible
// })
// }
// },
/**
* 组件的初始数据
*/
@@ -48,10 +58,67 @@ Component({
}
this.setData({
show: true,
title: "建筑",
type: 'building'
title: "收费类型",
type: 'feeType'
})
},
onConfirm(e) {
const { type, data, way } = e.detail;
switch(type) {
case "building":
this.setData({
building: data.id,
buildingName: data.name,
show: false,
})
return;
case "feeType":
this.setData({
feeTypeName: data,
feeType: way,
show: false,
})
}
},
onCancel() {
this.setData({ show: false })
},
onClose() {
this.triggerEvent("close")
},
onChange(e) {
const { name } = e.currentTarget.dataset;
this.setData({
[name]: e.detail
})
},
clear() {
this.setData({
name: "", shortName: "", address: "", contact: "", phone: "",
building: "", feeType: "", buildingName: "", feeTypeName: "", id,
})
},
async onSubmit() {
const { name, shortName, address, contact, phone, building, feeType, park, editType, id } = this.data;
if (editType === "add") {
const { code, message } = await createBackTenement(park, { name, shortName, address, contact, phone, building, feeType })
if (code !== OK) {
alertInfo(message)
return
}
alertSuccess("开户成功")
this.triggerEvent("ok")
return;
}
const { code, message } = await updateTenementBackInfo(park, id, { name, shortName, address, contact, phone, building, feeType })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("编辑成功")
this.triggerEvent("ok")
}
},
})

View File

@@ -1,56 +1,73 @@
<!--pages/workBench/components/tenement/components/kaihu/index.wxml-->
<van-dialog
use-slot
title="开户"
title="{{title}}"
show="{{ visible }}"
show-cancel-button
bind:close="onClose"
bind:confirm="onSubmit"
>
<view class="modalContentWrapper">
<van-field
value=""
value="{{name}}"
data-name="name"
bind:change="onChange"
label="商户全称"
type="textarea"
placeholder="请输入商户全称"
autosize="{{true}}"
title-width="132rpx"
required
/>
<van-field
value=""
value="{{shortName}}"
data-name="shortName"
bind:change="onChange"
label="商户简称"
placeholder="请输入商户简称"
type="textarea"
autosize="{{true}}"
title-width="132rpx"
/>
<van-field
value=""
value="{{address}}"
data-name="address"
bind:change="onChange"
label="联系地址"
placeholder="请输入联系地址"
type="textarea"
autosize="{{true}}"
title-width="132rpx"
required
/>
<van-field
value=""
value="{{contact}}"
data-name="contact"
bind:change="onChange"
label="联系人"
placeholder="请输入联系人"
type="textarea"
autosize="{{true}}"
title-width="132rpx"
required
/>
<van-field
value=""
value="{{phone}}"
data-name="phone"
bind:change="onChange"
label="联系电话"
placeholder="请输入联系电话"
type="textarea"
autosize="{{true}}"
title-width="132rpx"
required
/>
<van-field
value="{{ meterName }}"
value="{{ buildingName }}"
placeholder="请选择建筑"
label="建筑"
use-button-slot
readonly
title-width="120rpx"
>
<van-button slot="button" size="small" type="primary" bind:click="onBuildingFocus">
@@ -58,9 +75,10 @@
</van-button>
</van-field>
<van-field
value="{{ meterName }}"
value="{{ feeTypeName }}"
placeholder="请选择收费类型"
label="收费类型"
readonly
use-button-slot
title-width="120rpx"
>
@@ -77,5 +95,5 @@
type="{{type}}"
park="{{park}}"
bindconfirm="onConfirm"
bindcancel="onConcal"
bindcancel="onCancel"
/>

View File

@@ -1,5 +1,6 @@
import { alertInfo } from "../../../../utils/index";
import { getTenementBackInfo, } from "../../../../service/tenement"
import { alertInfo, alertSuccess } from "../../../../utils/index";
import { getTenementBackInfo, unbindMeter, } from "../../../../service/tenement"
import { getBackTenementMeters, } from "../../../../service/meter"
import request from "../../../../utils/request"
const { OK } = request
// pages/workBench/components/tenement/index.js
@@ -16,12 +17,10 @@ Component({
* 组件的初始数据
*/
data: {
},
lifetimes: {
ready() {
console.log("this.data", this.data)
}
defaultValue: {},
editType: "",
meterList: [],
// bindMeter
},
/**
* 组件的方法列表
@@ -79,18 +78,76 @@ Component({
show: false,
} , () => {
that.getTenementInfo();
that.getTenementMeters();
})
break;
}
},
onCancel() {
this.setData({
show: false,
})
},
startKh() {
this.setData({
kaihuVisible: true
kaihuVisible: true,
editType: "add",
title: "开户"
})
},
startUpdateInfo() {
const { tenementInfo } = this.data;
this.setData({
kaihuVisible: true,
defaultValue: tenementInfo,
editType: "update",
title: "开户"
})
},
async getTenementMeters() {
const { park, tenement } = this.data;
const { code, message, data } = await getBackTenementMeters(park, tenement)
if (code !== OK) {
alertInfo(message)
return
}
this.setData({ meterList: data });
},
onKaihuClose() {
this.setData({
kaihuVisible: false,
defaultValue: {},
title: "编辑"
})
},
onKaihuConfirm() {
this.getTenementInfo();
this.onKaihuClose();
},
unbind(e) {
const that = this;
const { park, tenement } = this.data;
const { address, id } = e.currentTarget.dataset;
wx.showModal({
title: '提示',
content: `确认要解绑${address}吗?`,
complete: async (res) => {
if (res.cancel) {
}
if (res.confirm) {
const { code, message, } = await unbindMeter(park, tenement, id);
if (code !== OK) {
alertInfo(message)
return
}
alertSuccess("解绑成功")
that.getTenementMeters();
return
}
}
})
// const { park = '', parkName = '', tenement = '', tenementName = '' } = this.data;
// wx.navigateTo({
// url: `/pages/workBench/components/tenement/components/createTenement/index?park=${park}&tenement=${tenement}&parkName=${parkName}&${tenementName}=${tenementName}`,
// })
}
}
})

View File

@@ -5,6 +5,7 @@
"van-button": "@vant/weapp/button/index",
"search-select": "/components/searchSelect/index",
"van-empty": "@vant/weapp/empty/index",
"kaihu": "./components/kaihu/index"
"kaihu": "./components/kaihu/index",
"bindMeter": "./components/bindMeter/index"
}
}

View File

@@ -55,22 +55,22 @@
readonly
title-width="140rpx"
/>
<view wx:if="{{list.length}}">
<view wx:if="{{meterList.length}}">
<view class="tableWrapper">
<view class="table">
<view class="thead">
<view class="th" style="width: 250rpx"> 电表地址 </view>
<view class="th" style="width: 150rpx"> SN </view>
<view class="th" style="width: 250rpx"> SN </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">
<block wx:for="{{meterList}}" wx:for-index="itemIndex" wx:key="item">
<view class="tr">
<view class="th" style="width: 200rpx"> {{ item.tenement.shortName }} </view>
<view class="th" style="width: 200rpx"> {{ item.money }} </view>
<view class="th" style="width: 250rpx"> {{ item.address }} </view>
<view class="th" style="width: 250rpx"> {{ item.meterSn }} </view>
<view class="th" style="width: 200rpx">
<view class="primaryTextBtn" bind:tap="jumpToDetail" data-id="{{item.id}}">
<view class="primaryTextBtn" bind:tap="unbind" data-id="{{item.meterId}}" data-address="{{item.address}}">
解绑
</view>
</view>
@@ -89,6 +89,16 @@
type="{{type}}"
park="{{park}}"
bindconfirm="onConfirm"
bindcancel="onConcal"
bindcancel="onCancel"
/>
<kaihu park="{{park}}" visible="{{kaihuVisible}}" />
<kaihu
park="{{park}}"
visible="{{kaihuVisible}}"
defaultValue="{{defaultValue}}"
bind:close="onKaihuClose"
bind:ok="onKaihuConfirm"
editType="{{editType}}"
title="{{title}}"
/>
<bindMeter />

View File

@@ -1 +1,45 @@
/* pages/workBench/components/tenement/index.wxss */
/* pages/workBench/components/tenement/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;
}
.primaryTextBtn {
color: #1989fa;
}