资料目录维护文件夹名称唯一性校验

This commit is contained in:
zhaoxiao
2021-09-03 10:07:03 +08:00
parent 3bcaacb4b6
commit f7df178fea
2 changed files with 32 additions and 3 deletions
@@ -44,6 +44,7 @@
<script>
import pick from 'lodash.pick'
import { httpAction } from '../../../../api/manage'
import { duplicateCheck } from '../../../../api/api'
export default {
name: 'DataDirectoryModule',
@@ -62,7 +63,7 @@ export default {
},
validatorRules: {
name: {
rules: [{ required: true, message: '请输入文件夹名称' }],
rules: [{ required: true, validator: this.checkDirectoryName }],
validateTrigger: 'blur'
},
parentId: {
@@ -134,6 +135,32 @@ export default {
},
handleCancle() {
this.model = {}
},
/**
* 文件夹名称唯一性校验
* @param rules
* @param value
* @param callback
*/
checkDirectoryName(rules, value, callback) {
if (value) {
if (!this.model.id) {
const params = {
confusionCode: 'pay_data_directory',
fieldVal: value
}
duplicateCheck(params).then(res => {
if (res.success) {
callback(res.message)
} else {
callback('文件夹名称已存在')
}
})
return
}
callback()
}
callback('请输入文件夹名称')
}
}
}
@@ -389,10 +389,12 @@ export default {
*/
companyChange(value) {
this.selectedCompany = value
this.model.contactsId = undefined
this.model.contactsIdOne = undefined
this.model.contactsIdTwo = undefined
this.model.contactsIdThree = undefined
this.model.mailContactsId = undefined
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'contactsId', 'mailContactsId'))
this.form.setFieldsValue(pick(this.model, 'contactsIdOne', 'contactsIdTwo', 'contactsIdThree', 'mailContactsId'))
})
},
/**