[update] 修改变更25

This commit is contained in:
lideqin
2023-07-19 11:41:57 +08:00
parent 19d6804975
commit e827592617
2 changed files with 149 additions and 11 deletions
+33
View File
@@ -115,6 +115,37 @@ export default {
this.loadData()
},
methods: {
// 2023-07:解决选中回显问题
loadData(arg) {
this.judgeFreeCount && this.judgeFreeCount()
if(!this.url.list){
this.$message.error('请设置url.list属性!')
return
}
//加载数据 若传入参数1则加载第一页的内容
if (arg === 1) {
this.ipagination.current = 1
}
var params = this.getQueryParams()//查询条件
this.loading = true
this.getAction(this.url.list, params).then((res) => {
if (res.success) {
//update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
this.dataSource = res.result.records||res.result
if(res.result.total)
{
this.ipagination.total = res.result.total
}else{
this.ipagination.total = 0
}
//update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
}
if(res.code===510){
this.$message.warning(res.message)
}
this.loading = false
})
},
handleOk() {
this.$emit('ok', this.selectedCompany)
this.close()
@@ -123,6 +154,8 @@ export default {
this.close()
},
close() {
// 清空列表选中
this.onClearSelected()
this.visible = false
this.selectedCompany = {}
},
+116 -11
View File
@@ -13,11 +13,20 @@
<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'
disabled
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
<!-- 2023-07变更:可以修改企业名称,姓名 -->
<company-select @change="changeCompany" v-decorator="['company',validatorRules.company]"
placeholder="请选择参会企业"
:is-limit="true"
:is-company-disabled="isCompanyDisabled || isCompanyAdmin"
:disabled="isCompanyDisabled || isCompanyAdmin"
:maxLength='50'>
</company-select>
<span class="color-red">若没有您要选择的企业,请您添加企业信息(发票抬头)</span>
<!-- <a-input placeholder="请输入企业名称"-->
<!-- v-decorator="['companyName',validatorRules.companyName]"-->
<!-- :maxLength='50'-->
<!-- disabled-->
<!-- @change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>-->
</a-form-item>
</a-col>
<a-col :xl="12" :sm="24">
@@ -25,7 +34,7 @@
<a-input placeholder="请输入姓名"
v-decorator="['name',validatorRules.name]"
:maxLength='50'
disabled
:disabled="isCompanyAdmin"
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
</a-form-item>
</a-col>
@@ -109,13 +118,31 @@
import pick from 'lodash.pick'
import { isEmail, postcode } from '@/utils/validate'
import { editUserInfo } from '@api/incomePaymentsApi'
import CompanySelect from '@comp/company/CompanySelect'
import { queryContactByName } from '@api/incomePaymentsApi'
import { USER_INFO } from '@/store/mutation-types'
import Vue from 'vue'
export default {
name: 'AccountCenterModel',
components: {CompanySelect},
props: {
// 是否可以选择企业 true--不可选;false--可选
isCompanyDisabled: {
type: Boolean,
required: false,
default: false
}
},
computed: {
isCompanyAdmin() {
return Vue.ls.get(USER_INFO).roleCode === '2'
}
},
data() {
return {
title: '编辑个人信息',
width: 800,
width: 1000,
visible: false,
confirmLoading: false,
form: this.$form.createForm(this),
@@ -137,6 +164,14 @@ export default {
sm: { span: 21 }
},
validatorRules: {
company: {
rules: [{ required: true, validator: this.checkCompany }],
validateTrigger: 'change'
},
name: {
rules: [{ required: true, validator: this.checkName }],
validateTrigger: 'blur'
},
email: {
rules: [{ required: true, validator: this.checkMail }],
validateTrigger: 'blur'
@@ -150,15 +185,22 @@ export default {
validateTrigger: 'blur'
}
},
selectedCompanyId: null // 当前选择企业的id
}
},
methods: {
edit(record) {
console.log(record)
let company = {
id: record.companyId,
companyName: record.companyName
}
record.company = company
this.form.resetFields()
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'companyName', 'name', 'gender', 'post', 'phone', 'email', 'contactAddress', 'postalCode', 'remarks'))
this.form.setFieldsValue(pick(this.model, 'company', 'name', 'gender', 'post', 'phone', 'email', 'contactAddress', 'postalCode', 'remarks'))
})
},
handleOk() {
@@ -172,6 +214,9 @@ export default {
values.gender = null
}
const formData = Object.assign(this.model, values)
formData.company = values.company
formData.companyId = values.company.id
formData.companyName = values.company.companyName
console.log('表单提交数据', formData)
editUserInfo(formData).then((res) => {
if (res.success) {
@@ -193,6 +238,61 @@ export default {
close() {
this.visible = false
},
/**
* 企业必填校验
* @param rules
* @param value
* @param callback
*/
checkCompany(rules, value, callback) {
console.log('---check---', value)
if (value.id && value.companyName) {
callback()
return
}
callback('请选择企业')
},
/**
* 联系人姓名重复校验
* @param rules
* @param value
* @param callback
*/
checkName(rules, value, callback) {
let company = this.form.getFieldValue('company')
if (!value) {
callback('请输入姓名')
return
}
if (!company.id) {
callback('请先选择企业再输入姓名')
return
}
// 是否编辑
if (this.model.id) {
// 编辑前后姓名是否一致,一致则不进行验重
if (value === this.model.name) {
callback()
return
}
this.selectedCompanyId = this.model.company.id
}
if (this.isCompanyDisabled) {
this.selectedCompanyId = this.selectedCompany.id
}
let param = {
companyId: this.selectedCompanyId,
name: value
}
queryContactByName(param).then(res => {
if (res.success) {
callback()
} else {
callback(res.message)
}
})
},
/**
* 邮箱校验
* @param rules
@@ -218,11 +318,16 @@ export default {
} else {
callback('请输入正确格式的邮政编码')
}
}
},
changeCompany(value) {
this.selectedCompanyId = value.id
},
}
}
</script>
<style scoped>
<style scoped lang="less">
.color-red {
color: red;
}
</style>