20261008
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<view class="flex justify-end items-center">
|
||||
<el-button type="primary" @click="showAdd" v-if="!isAdd">新增收款账户</el-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="vk.getVuex('$user.userInfo.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="请输入开户行"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="账号名称" required>
|
||||
<el-input v-model="form.accountName" placeholder="请输入账号名称"/>
|
||||
</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"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<view class="mt-30 flex justify-center items-center">
|
||||
<el-button plain @click="isAdd = !isAdd">取消</el-button>
|
||||
<el-button type="primary" @click="addContact">确定</el-button>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="py-20 border-bottom flex justify-between items-center" v-for="(item, index) in list"
|
||||
:key="index">
|
||||
<view class="flex flex-col justify-start items-start">
|
||||
<view class="flex justify-start items-center">
|
||||
<el-tag type="primary" size="small" class="mr-25" v-if="item.isDefault">默认</el-tag>
|
||||
<el-tag type="success" size="small" class="mr-25">{{
|
||||
item.type === 'company' ? '对公' : '个人'
|
||||
}}
|
||||
</el-tag>
|
||||
<text class="font-bold text-40">{{ 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">
|
||||
<el-button type="primary" size="small" @click="edit(item)">编辑</el-button>
|
||||
<view class="mt-20">
|
||||
<el-button type="primary" size="small" @click="del(item._id)" plain>删除</el-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "account",
|
||||
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(vk.getVuex('$user.userInfo.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) {
|
||||
this.$confirm('确认删除该账号吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
showCancelButton: false,
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
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() {
|
||||
const user = vk.getVuex('$user.userInfo')
|
||||
if (vk.getVuex('$user.userInfo.accountType') === 2) {
|
||||
this.form.account = user.company.companyAccount
|
||||
this.form.bankName = user.company.companyBankName
|
||||
this.form.accountName = user.company.companyName
|
||||
}else {
|
||||
this.form.account = user.person.personAccount
|
||||
this.form.bankName = user.person.personBankName
|
||||
this.form.accountName = user.person.accountName
|
||||
console.log(user)
|
||||
}
|
||||
this.isAdd = true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (parseInt(vk.getVuex('$user.userInfo.authStatus')) !== 1) {
|
||||
this.$message.error('请先完成实名认证')
|
||||
this.$emit('done', 'fadada')
|
||||
}
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user