暂存商户信息

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

View File

@ -33,6 +33,7 @@ Component({
columns: [],
searchText: "",
payWays,
feeType,
},
lifetimes: {
attached() {
@ -84,6 +85,17 @@ Component({
})
this.triggerEvent("confirm", { data: item, way: index, type } );
},
onFeeTypeConfirm(event) {
const { index } = event.detail;
const { feeType = [], type } = this.data;
const item = feeType[index];
this.setData({
columns: [],
list: [],
searchText: ""
})
this.triggerEvent("confirm", { data: item, way: index, type } );
},
onSearch() {
const { type } = this.data;
switch(type) {

View File

@ -5,7 +5,27 @@
position="bottom"
z-index="100000"
>
<view wx:if="{{type !== 'pay'}}">
<view wx:if="{{type === 'pay'}}">
<van-picker
custom-style="width: 100%;"
columns="{{ payWays }}"
title="{{title}}"
show-toolbar="{{true}}"
bind:cancel="onCancel"
bind:confirm="onPayConfirm"
/>
</view>
<view wx:elif="{{type === 'feeType'}}">
<van-picker
custom-style="width: 100%;"
columns="{{ feeType }}"
title="{{title}}"
show-toolbar="{{true}}"
bind:cancel="onCancel"
bind:confirm="onFeeTypeConfirm"
/>
</view>
<view wx:elif="{{type !== 'pay'}}">
<van-search
value="{{ value }}"
placeholder="{{type === 'tenement' ? '请输入关键词搜索后选择' : '请输入搜索关键词'}}"
@ -27,26 +47,7 @@
bind:confirm="onConfirm"
/>
</view>
<view wx:elif="{{type === 'pay'}}">
<van-picker
custom-style="width: 100%;"
columns="{{ payWays }}"
title="{{title}}"
show-toolbar="{{true}}"
bind:cancel="onCancel"
bind:confirm="onPayConfirm"
/>
</view>
<view wx:elif="{{type === 'feeType'}}">
<van-picker
custom-style="width: 100%;"
columns="{{ feeType }}"
title="{{title}}"
show-toolbar="{{true}}"
bind:cancel="onCancel"
bind:confirm="onPayConfirm"
/>
</view>
<view wx:else>
<van-picker
custom-style="width: 100%;"

View File

@ -152,9 +152,9 @@ Page({
tenementName: data.name,
})
}
this.onConcal();
this.onCancel();
},
onConcal() {
onCancel() {
this.setData({
show: false,
title: "",

View File

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

View File

@ -15,23 +15,14 @@ Component({
onCancel: Function,
park: String,
tenement: String,
parentPhone:String,
parentName:String,
parentId:String,
},
observers: {
"name": function(newValue) {
const newData = this.data;
newData.name = newValue
this.setData({ data: newData })
"parentName,parentId,parentPhone": function(newName, newId, newPhone) {
this.setData({ data: { name: newName, id: newId, phone: newPhone } })
},
"id": function(newValue) {
const newData = this.data;
newData.id = newValue
this.setData({ data: newData })
},
"phone": function(newValue) {
const newData = this.data;
newData.phone = newValue
this.setData({ data: newData })
}
},
/**
* 组件的初始数据
@ -45,7 +36,7 @@ Component({
*/
methods: {
async onSubmit() {
const { data = {}, tenement, park } = this.data;
const { data = {}, tenement, park, editType } = this.data;
if (!data.phone) {
alertInfo("请输入手机号")
return
@ -54,18 +45,20 @@ Component({
alertInfo("请输入昵称")
return
}
const { code, message } = await createTenementWxUser({ ...data, tenement, park })
if (code !== OK) {
alertInfo(message)
this.triggerEvent("cancel")
if (editType === 'add') {
const { code, message } = await createTenementWxUser({ ...data, tenement, park })
if (code !== OK) {
alertInfo(message)
this.triggerEvent("cancel")
return;
}
alertSuccess("操作成功")
this.triggerEvent("ok")
return;
}
alertSuccess("操作成功")
this.triggerEvent("ok")
},
onChange(e) {
console.log('e', e)
const { name } = e.currentTarget.dataset;
const newData = this.data.data;
newData[name] = e.detail;

View File

@ -69,7 +69,7 @@ Component({
break;
}
},
onConcal() {
onCancel() {
this.setData({
show: false,
})
@ -133,21 +133,22 @@ Component({
},
handleChangeMain() {
const { list = [] } = this.data;
const main = list?.find(item => item.isAdmin)
const main = list?.find(item => item.Permissions)
if (!main) {
alertInfo("没有主账号")
return
}
console.log("main", main)
this.setData({
visible: true,
type: "update",
title: "编辑管理员",
phone: main.phone,
name: main.name,
id: main.id,
phone: main.WechatPhone,
name: main.WechatUserName,
id: main.WechatUserID,
})
},
handleCancel() {
console.log("-------------")
this.setData({
visible: false,
type: "",

View File

@ -11,7 +11,6 @@
"van-radio": "@vant/weapp/radio/index",
"van-radio-group": "@vant/weapp/radio-group/index",
"van-tag": "@vant/weapp/tag/index",
"edit-modal": "./components/editModal/index",
"van-tag": "@vant/weapp/tag/index"
"edit-modal": "./components/editModal/index"
}
}

View File

@ -66,10 +66,10 @@
<block wx:for="{{list}}" wx:for-index="itemIndex" wx:key="item">
<view class="tr">
<view class="th" style="width: 70rpx"> {{ itemIndex + 1 }} </view>
<view class="th" style="width: 200rpx"> {{ item.name }} </view>
<view class="th" style="width: 300rpx"> {{ item.phone }} </view>
<view class="th" style="width: 200rpx"> {{ item.WechatUserName }} </view>
<view class="th" style="width: 300rpx"> {{ item.WechatPhone }} </view>
<view class="th" style="width: 100rpx; display: flex;">
<view class="primaryTextBtn" bind:tap="handleDelete" data-id="{{item.id}}" data-name="{{item.name}}" wx:if="{{!item.isAdmin}}">
<view class="primaryTextBtn" bind:tap="handleDelete" data-id="{{item.WechatUserID}}" data-name="{{item.WechatUserName}}" wx:if="{{!item.Permissions}}">
移除
</view>
<van-tag type="primary" wx:else>管理员</van-tag>
@ -83,7 +83,7 @@
</view>
<empty wx:else bind:refresh="initUserList" />
{{phone}} {{name}}
</view>
<search-select
show="{{show}}"
@ -92,7 +92,7 @@
park="{{park}}"
isBack="{{true}}"
bindconfirm="onConfirm"
bindcancel="onConcal"
bindcancel="onCancel"
/>
<edit-modal
visible="{{visible}}"
@ -100,6 +100,9 @@
title="{{title}}"
tenement="{{tenement}}"
park="{{park}}"
parentPhone="{{phone}}"
parentName="{{name}}"
parentId="{{id}}"
bind:ok="onEditConfirm"
bind:cancel="handleCancel"
/>

View File

@ -49,7 +49,7 @@ Component({
await that.init();
})
})
this.onConcal();
this.onCancel();
},
onChangeKeyword(e) {
this.setData({ keywordTemp: e.detail })
@ -162,7 +162,7 @@ Component({
})
})
},
onConcal() {
onCancel() {
this.setData({
show: false,
title: "",

View File

@ -93,7 +93,7 @@
type="{{type}}"
park="{{park}}"
bindconfirm="onConfirm"
bindcancel="onConcal"
bindcancel="onCancel"
/>
<van-dialog

View File

@ -67,9 +67,9 @@ Component({
});
break;
}
this.onConcal();
this.onCancel();
},
onConcal() {
onCancel() {
this.setData({
show: false,
title: "",

View File

@ -76,6 +76,6 @@
type="{{type}}"
park="{{park}}"
bindconfirm="onConfirm"
bindcancel="onConcal"
bindcancel="onCancel"
wx:if="{{show}}"
/>

View File

@ -66,7 +66,7 @@ Component({
break;
}
this.onConcal();
this.onCancel();
},
onChangeKeyword(e) {
this.setData({ keywordTemp: e.detail })
@ -108,7 +108,7 @@ Component({
})
})
},
onConcal() {
onCancel() {
this.setData({
show: false,
title: "",

View File

@ -146,6 +146,6 @@
type="{{type}}"
park="{{park}}"
bindconfirm="onConfirm"
bindcancel="onConcal"
bindcancel="onCancel"
wx:if="{{show}}"
/>

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 */
.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;
}

View File

@ -27,8 +27,10 @@ export const getParkSimpleMeterList = async function({park = "", keyword = "", p
return await GET(`/work/getWorkMeter?page=${page}&park=${park}&keyword=${replaceSpecialIcon(keyword)}`);
}
// 获取商户下的电表,后台
export const getBackTenementMeters = async function(park, tenement) {
return await GET(`/vx/getWorkMeterDetails?park=${park}&tenement=${tenement}`);
}
// 拉合闸
export const handleOperateMeterSwitch = async function({ ids = [], status }) {

View File

@ -41,7 +41,7 @@ export const updateTenement = async function(pid, data) {
}
// 解绑电表
export const unbindMeter = async function(pid, tid, code) {
return await POST(`/tenement/${pid}/${tid}/binding/${code}/unbind`)
return await PUT(`/tenement/${pid}/${tid}/binding/${code}/unbind`)
}
// 获取b端用户
@ -58,3 +58,12 @@ export const getTenementBackInfo = async (pid, tid) => {
export const createTenementWxUser = async function(data) {
return await POST(`/wx/createUser`, data)
}
// 创建商户
export const createBackTenement = async function(pid, data) {
return await POST(`/vx/tenement/${pid}`, data)
}
// 修改商户信息
export const updateTenementBackInfo = async function(pid, tid, data) {
return await PUT(`/vx/${pid}/${tid}`, data)
}

View File

@ -71,6 +71,6 @@ export const getQuestionList = async function(page) {
}
// 获取扫描二维码的列表
export const getBackApproveList = async function(tenement, status=0) {
return await GET(`/wx/getApproveList?status=${status}&tenement=${tenement}`);
export const getBackApproveList = async function(tenement) {
return await GET(`/wx/getWorkUserList?tenement=${tenement}`);
}