273 lines
8.4 KiB
Vue
273 lines
8.4 KiB
Vue
<template>
|
|
<j-modal
|
|
:title="title"
|
|
:width="width"
|
|
:visible="visible"
|
|
:confirmLoading="confirmLoading"
|
|
switchFullscreen
|
|
@ok="handleOk"
|
|
@cancel="handleCancel"
|
|
cancelText="关闭">
|
|
<a-spin :spinning="confirmLoading">
|
|
<a-form :form="form">
|
|
<a-row>
|
|
<a-col :xl="12" :sm="24">
|
|
<a-form-item label="企业名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input placeholder="请输入公司名称"
|
|
v-decorator="['companyName',validatorRules.companyName]"
|
|
:maxLength='50'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :xl="12" :sm="24">
|
|
<a-form-item label="公司地址" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input placeholder="请输入公司地址"
|
|
v-decorator="['companyAddress']"
|
|
:maxLength='50'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row>
|
|
<a-col :xl="12" :sm="24">
|
|
<a-form-item label="公司电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input placeholder="请输入公司电话"
|
|
v-decorator="['companyPhone',validatorRules.companyPhone]"
|
|
:maxLength='15'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :xl="12" :sm="24">
|
|
<a-form-item label="邮政编码" :labelCol="labelCol" :wrapperCol="wrapperCol" class="form-item-postcode">
|
|
<a-input placeholder="请输入邮政编码"
|
|
v-decorator="['postalCode',validatorRules.postalCode]"
|
|
:maxLength='50'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
|
<a class="search-postcode" href="https://www.youbianku.com" target="_blank">查询邮编</a>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row>
|
|
<a-col :xl="12" :sm="24">
|
|
<a-form-item label="银行户名" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input placeholder="请输入银行户名"
|
|
v-decorator="['bankAccountName']"
|
|
:maxLength='50'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :xl="12" :sm="24">
|
|
<a-form-item label="开户行" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input placeholder="请输入开户行"
|
|
v-decorator="['openingBank']"
|
|
:maxLength='50'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row>
|
|
<a-col :xl="12" :sm="24">
|
|
<a-form-item label="银行账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input placeholder="请输入银行账号"
|
|
v-decorator="['bankAccount']"
|
|
:maxLength='50'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :xl="12" :sm="24">
|
|
<a-form-item label="税号" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input placeholder="请输入税号"
|
|
v-decorator="['dutyCode']"
|
|
:maxLength='50'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row>
|
|
<a-col>
|
|
<a-form-item label="备注" :labelCol="remarksLabelCol" :wrapperCol="remarksWrapperCol">
|
|
<a-textarea
|
|
placeholder="请输入备注"
|
|
v-decorator="['remarks']"
|
|
:auto-size="{ minRows: 3, maxRows: 6 }"
|
|
:maxLength='300'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"/>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
</a-form>
|
|
</a-spin>
|
|
</j-modal>
|
|
</template>
|
|
|
|
<script>
|
|
import { postcode, phoneReg, isPhone } from '@/utils/validate'
|
|
import pick from 'lodash.pick'
|
|
import { httpAction } from '@api/manage'
|
|
import { duplicateCheck } from '@api/api'
|
|
|
|
export default {
|
|
name: 'BusinessMangementModule',
|
|
data() {
|
|
return {
|
|
title: '操作',
|
|
width: 800,
|
|
visible: false,
|
|
confirmLoading: false,
|
|
form: this.$form.createForm(this),
|
|
model: {},
|
|
labelCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 6 }
|
|
},
|
|
wrapperCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 18 }
|
|
},
|
|
remarksLabelCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 3 }
|
|
},
|
|
remarksWrapperCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 21 }
|
|
},
|
|
validatorRules: {
|
|
companyName: {
|
|
rules: [{ required: true, validator: this.checkCompanyName }],
|
|
validateTrigger: 'blur'
|
|
},
|
|
companyPhone: {
|
|
rules: [{ required: false, validator: this.checkCompanyPhone }]
|
|
},
|
|
postalCode: {
|
|
rules: [{ required: false, validator: this.checkPostcode }]
|
|
}
|
|
},
|
|
url: {
|
|
add: '/company/payCompanyManagement/add',
|
|
edit: '/company/payCompanyManagement/edit'
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
add() {
|
|
this.edit({})
|
|
},
|
|
edit(record) {
|
|
this.form.resetFields()
|
|
this.model = Object.assign({}, record)
|
|
this.visible = true
|
|
this.$nextTick(() => {
|
|
this.form.setFieldsValue(pick(this.model, 'companyName', 'companyAddress', 'companyPhone', 'postalCode', 'bankAccountName', 'openingBank', 'bankAccount', 'dutyCode', 'remarks'))
|
|
})
|
|
},
|
|
close() {
|
|
this.$emit('close')
|
|
this.visible = false
|
|
},
|
|
handleOk() {
|
|
const that = this
|
|
// 触发表单验证
|
|
this.form.validateFields((err, values) => {
|
|
if (!err) {
|
|
let httpurl = ''
|
|
let method = 'post'
|
|
if (!this.model.id) {
|
|
httpurl += this.url.add
|
|
} else {
|
|
httpurl += this.url.edit
|
|
}
|
|
const formData = Object.assign(this.model, values)
|
|
console.log('表单提交数据', formData)
|
|
httpAction(httpurl, formData, method).then((res) => {
|
|
if (res.success) {
|
|
that.$message.success(res.message)
|
|
that.$emit('ok')
|
|
that.close()
|
|
} else {
|
|
that.$message.warning(res.message)
|
|
}
|
|
}).finally(() => {
|
|
that.confirmLoading = false
|
|
})
|
|
}
|
|
})
|
|
},
|
|
handleCancel() {
|
|
this.close()
|
|
},
|
|
/**
|
|
* 电话号码校验
|
|
* @param rules
|
|
* @param value
|
|
* @param callback
|
|
*/
|
|
checkCompanyPhone(rules, value, callback) {
|
|
if (value) {
|
|
if (phoneReg(value) || isPhone(value)) {
|
|
callback()
|
|
} else {
|
|
callback('请填写正确的电话号码')
|
|
}
|
|
return
|
|
}
|
|
callback()
|
|
},
|
|
/**
|
|
* 邮编校验
|
|
* @param rules
|
|
* @param value
|
|
* @param callback
|
|
*/
|
|
checkPostcode(rules, value, callback) {
|
|
if (value) {
|
|
if (postcode(value)) {
|
|
callback()
|
|
} else {
|
|
callback('请输入正确格式的邮编')
|
|
}
|
|
return
|
|
}
|
|
callback()
|
|
},
|
|
/**
|
|
* 企业名称唯一性校验
|
|
* @param rules
|
|
* @param value
|
|
* @param callback
|
|
*/
|
|
checkCompanyName(rules, value, callback) {
|
|
if (value) {
|
|
const params = {
|
|
confusionCode: 'pay_company_management_company_name',
|
|
fieldVal: value
|
|
}
|
|
duplicateCheck(params).then(res => {
|
|
if (res.success) {
|
|
callback()
|
|
} else {
|
|
callback(res.message)
|
|
}
|
|
})
|
|
} else {
|
|
callback('请输入企业名称')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.form-item-postcode {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.search-postcode {
|
|
color: #0090ff;
|
|
|
|
&:hover {
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
</style> |