Files
2026-10-08 18:34:09 +08:00

163 lines
5.3 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="p-30">
<view class="flex justify-end items-center">
<u-button size="small" color="#A92924" text="新增收款账户"
@click="showAdd" v-if="!isAdd"></u-button>
</view>
<view class="mt-20" v-if="isAdd">
<el-form ref="form" :model="form" label-width="120px">
<el-form-item label="类型" required v-if="userData.accountType === 2">
<el-select v-model="form.type" placeholder="请选择账号类型">
<el-option label="对公账号" value="company"/>
<el-option label="个人账号" value="person"/>
</el-select>
</el-form-item>
<el-form-item label="开户行" required>
<el-input v-model="form.bankName" placeholder="请输入开户行"
:readonly="userData.accountType === 2 && form.type === 'company' "/>
</el-form-item>
<el-form-item label="账号名称" required>
<el-input v-model="form.accountName" placeholder="请输入账号名称"
:readonly="userData.accountType === 2 && form.type === 'company'"/>
</el-form-item>
<el-form-item label="账号" required>
<el-input v-model="form.account" placeholder="请输入邮箱"/>
</el-form-item>
<el-form-item label="默认账号">
<el-switch v-model="form.isDefault" active-color="#a92924"/>
</el-form-item>
</el-form>
<view class="mt-30 flex justify-center items-center">
<view class="flex-1 px-20">
<u-button plain @click="isAdd = !isAdd">取消</u-button>
</view>
<view class="flex-1 px-20">
<u-button type="primary" @click="addContact">确定</u-button>
</view>
</view>
<view class="mt-30 text-main text-25">温馨提示:请详细、慎重核查账户信息的正确性,以免给您造成不必要损失。账户信息错误平台不承担付款错误责任。</view>
</view>
<view v-else>
<view class="p-20 shadow flex justify-between items-center my-20 rounded" v-for="(item, index) in list"
:key="index">
<view class="flex flex-col justify-start items-start">
<view class="flex justify-start items-center">
<u-tag type="primary" size="mini" class="mr-25" text="默认" v-if="item.isDefault"></u-tag>
<u-tag type="success" size="mini" class="mr-25"
:text="item.type === 'company' ? '对公' : '个人'"></u-tag>
<text class="font-bold text-25">{{ item.account }}</text>
</view>
<view class="my-20">{{ item.accountName }}</view>
<view class="my-20">{{ item.bankName }}</view>
</view>
<view class="flex flex-col justify-end">
<u-button type="primary" size="small" @click="edit(item)">编辑</u-button>
<view class="mt-20">
<u-button type="primary" size="small" @click="del(item._id)" plain>删除</u-button>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: "payeeAccount",
props: {
userData: {
type: Object
}
},
data() {
return {
isAdd: false,
form: {
_id: null,
bankName: '',
accountName: '',
account: '',
type: '',
isDefault: false,
},
list: []
}
},
methods: {
async addContact() {
if (!this.form.bankName) {
this.$message.error('请输入开户行')
return
}
if (!this.form.accountName) {
this.$message.error('请输入账号名称')
return
}
if (!this.form.account) {
this.$message.error('请输入账号')
return
}
if (!this.form.type && parseInt(this.userData.accountType) === 2) {
this.$message.error('请选择类型')
return
}
await vk.callFunction({
url: 'client/account/kh/action',
data: this.form
})
this.$message.success(this.form._id ? '修改成功' : '新增成功')
await this.getList()
this.isAdd = false
this.form = {
_id: null,
bankName: '',
accountName: '',
account: '',
type: '',
isDefault: false,
}
},
async getList() {
const {rows} = await vk.callFunction({
url: 'client/account/kh/getList',
})
this.list = rows
},
del(_id) {
uni.showModal({
title: '提示',
content: '确认删除该账号吗?',
success: async res => {
if (res.confirm) {
await vk.callFunction({
url: 'client/account/kh/delete',
data: {_id}
})
await this.getList()
}
}
})
},
edit(item) {
for (let key in this.form) this.form[key] = item[key]
this.isAdd = true
},
showAdd() {
if (this.userData.accountType === 2) {
this.form.account = this.userData.company.companyAccount
this.form.bankName = this.userData.company.companyBankName
this.form.accountName = this.userData.company.companyName
}
this.isAdd = true
}
},
mounted() {
if (parseInt(this.userData.authStatus) !== 1) {
this.$message.error('请先完成实名认证')
uni.navigateBack()
return
}
this.getList()
}
}
</script>