修改数据字典的验证
This commit is contained in:
@@ -9,11 +9,9 @@
|
||||
<a-tooltip placement="topLeft">
|
||||
<template slot="title">
|
||||
<span
|
||||
v-html="titleHeader"></span>
|
||||
v-html="serial_number"></span>
|
||||
</template>
|
||||
<span v-html="$route.query.serial_number"></span>
|
||||
<span v-html="this.$route.query.title == undefined || this.$route.query.title == null
|
||||
|| !this.$route.query.title ?'《'+ ''+'》':'《'+ this.$route.query.title+'》'"></span>
|
||||
<span v-html="serial_number"></span>
|
||||
<span> {{$t('StandardDetails')}}</span>
|
||||
</a-tooltip>
|
||||
|
||||
@@ -258,6 +256,7 @@
|
||||
</span>
|
||||
</a-table>
|
||||
</a-modal>
|
||||
<JLoading :loading="loading">{{$t('dataLoading')}}</JLoading>
|
||||
<uploadFile ref="uploadFile" :isUploadFile="true" :disabled="true"></uploadFile>
|
||||
</div>
|
||||
</template>
|
||||
@@ -275,10 +274,12 @@
|
||||
return {
|
||||
url: {
|
||||
getInfo: 'document/bussDocumentLibraryEO/getInfoById',
|
||||
list: 'log/bussLogEO/page'
|
||||
list: 'log/bussLogEO/page',
|
||||
getTitle: '/document/bussDocumentLibraryEO/getTitle'
|
||||
},
|
||||
titleHeader: '',
|
||||
visibleFile: false,
|
||||
loading: false,
|
||||
columnsRelated: [
|
||||
{
|
||||
title: this.$t('standardName'),
|
||||
@@ -306,6 +307,7 @@
|
||||
dataSourceRelated: [],
|
||||
detailList: [],
|
||||
visible: false,
|
||||
serial_number: '',
|
||||
confirmLoading: false,
|
||||
downLoadFileUrl: window._CONFIG['domianPreviewURL'] + '/sys/common/download',
|
||||
loading: false,
|
||||
@@ -341,24 +343,30 @@
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getInfoById()
|
||||
if (this.$route.query.serial_number && this.$route.query.title) {
|
||||
this.titleHeader = this.$route.query.serial_number + ' 《' + this.$route.query.title + ' 》' + this.$t('StandardDetails')
|
||||
} else if (!this.$route.query.serial_number && this.$route.query.title) {
|
||||
this.titleHeader = '《' + this.$route.query.title + '》' + this.$t('StandardDetails')
|
||||
} else if (this.$route.query.serial_number && !this.$route.query.title) {
|
||||
this.titleHeader = this.$route.query.serial_number + ' 《' + ' 》' + this.$t('StandardDetails')
|
||||
} else {
|
||||
this.titleHeader = ' 《' + ' 》' + this.$t('StandardDetails')
|
||||
}
|
||||
let _this = this
|
||||
this.loading = true
|
||||
this.getTitle(function() {
|
||||
_this.getInfoById()
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
getTitle(callback) {
|
||||
let _id = this.$route.query.documentId === undefined ? this.$route.query.id : this.$route.query.documentId
|
||||
getAction(this.url.getTitle, { id: _id }).then((res) => {
|
||||
if (res.success) {
|
||||
this.serial_number = res.result
|
||||
callback && callback()
|
||||
} else {
|
||||
this.serial_number = ''
|
||||
}
|
||||
})
|
||||
},
|
||||
getInfoById() {
|
||||
let _id = this.$route.query.documentId === undefined ? this.$route.query.id : this.$route.query.documentId
|
||||
console.log(_id)
|
||||
getAction(this.url.getInfo, { id: _id }).then((res) => {
|
||||
if (res.success) {
|
||||
this.detailList = res.result
|
||||
this.loading = false
|
||||
} else {
|
||||
this.detailList = []
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
ref="table"
|
||||
rowKey="id"
|
||||
size="middle"
|
||||
:scroll="{x: 900}"
|
||||
:scroll="{x: '100%'}"
|
||||
:columns="columns"
|
||||
:dataSource="dataSource"
|
||||
:pagination="ipagination"
|
||||
@@ -94,22 +94,29 @@
|
||||
{
|
||||
title: this.$t('name'),
|
||||
align: "center",
|
||||
width:100,
|
||||
ellipsis: true,
|
||||
dataIndex: 'itemText',
|
||||
},
|
||||
{
|
||||
title: this.$t('enName'),
|
||||
align: "center",
|
||||
width:100,
|
||||
ellipsis: true,
|
||||
dataIndex: 'enName',
|
||||
},
|
||||
{
|
||||
title: this.$t('DataValue'),
|
||||
align: "center",
|
||||
width:100,
|
||||
ellipsis: true,
|
||||
dataIndex: 'itemValue',
|
||||
},
|
||||
{
|
||||
title: this.$t('operation'),
|
||||
dataIndex: 'action',
|
||||
align: "center",
|
||||
width:80,
|
||||
scopedSlots: {customRender: 'action'},
|
||||
}
|
||||
],
|
||||
@@ -122,7 +129,7 @@
|
||||
},
|
||||
title: this.$t('operation'),
|
||||
visible: false,
|
||||
screenWidth: 800,
|
||||
screenWidth: 900,
|
||||
model: {},
|
||||
dictId: "",
|
||||
status: 1,
|
||||
|
||||
@@ -129,10 +129,17 @@
|
||||
align: 'center',
|
||||
dataIndex: 'dictName',
|
||||
width: '25%',
|
||||
ellipsis: true,
|
||||
ellipsis: true
|
||||
},
|
||||
// {
|
||||
// title: this.$t('DictionaryEnName'),
|
||||
// align: 'center',
|
||||
// dataIndex: 'dictEnName',
|
||||
// width: '180',
|
||||
// ellipsis: true
|
||||
// },
|
||||
// {
|
||||
// title: this.$t('DictionaryEnName'),
|
||||
// align: "left",
|
||||
// width: 180,
|
||||
// dataIndex: 'dictEnName',
|
||||
@@ -142,14 +149,14 @@
|
||||
align: 'center',
|
||||
dataIndex: 'dictCode',
|
||||
width: '25%',
|
||||
ellipsis: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: this.$t('describe'),
|
||||
align: 'center',
|
||||
dataIndex: 'description',
|
||||
width: '25%',
|
||||
ellipsis: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: this.$t('operation'),
|
||||
|
||||
@@ -14,39 +14,44 @@
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="名称">
|
||||
<a-input placeholder="请输入名称" v-decorator.trim="['itemText', validatorRules.itemText]"/>
|
||||
:label="$t('name')">
|
||||
<a-input :placeholder="$t('PleaseEnter')+$t('name')" v-decorator.trim="['itemText', validatorRules.itemText]"/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
:label="$t('enName')">
|
||||
<a-input :placeholder="$t('PleaseEnter')+$t('enName')" v-decorator.trim="['enName', validatorRules.enName]"/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
:label="$t('DataValue')">
|
||||
<a-input :placeholder="$t('PleaseEnter')+$t('DataValue')" v-decorator.trim="['itemValue', validatorRules.itemValue]"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="数据值">
|
||||
<a-input placeholder="请输入数据值" v-decorator.trim="['itemValue', validatorRules.itemValue]"/>
|
||||
:label="$t('describe')">
|
||||
<a-input :placeholder="$t('PleaseEnter')+$t('describe')" v-decorator.trim="['description', validatorRules.description]"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="描述">
|
||||
<a-input v-decorator="['description']"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="排序值">
|
||||
:label="$t('sort')">
|
||||
<a-input-number :min="1" v-decorator="['sortOrder',{'initialValue':1}]"/>
|
||||
值越小越靠前,支持小数
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="是否启用"
|
||||
hasFeedback>
|
||||
<a-switch checkedChildren="启用" unCheckedChildren="禁用" @change="onChose" v-model="visibleCheck"/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item-->
|
||||
<!-- :labelCol="labelCol"-->
|
||||
<!-- :wrapperCol="wrapperCol"-->
|
||||
<!-- label="是否启用"-->
|
||||
<!-- hasFeedback>-->
|
||||
<!-- <a-switch checkedChildren="启用" unCheckedChildren="禁用" @change="onChose" v-model="visibleCheck"/>-->
|
||||
<!-- </a-form-item>-->
|
||||
|
||||
</a-form>
|
||||
</a-spin>
|
||||
@@ -55,130 +60,168 @@
|
||||
|
||||
<script>
|
||||
import pick from 'lodash.pick'
|
||||
import {addDictItem, editDictItem} from '@/api/api'
|
||||
import { addDictItem, editDictItem } from '@/api/api'
|
||||
import { getAction } from '@api/manage'
|
||||
|
||||
export default {
|
||||
name: "DictItemModal",
|
||||
name: 'DictItemModal',
|
||||
data() {
|
||||
return {
|
||||
title: "操作",
|
||||
title: '操作',
|
||||
visible: false,
|
||||
visibleCheck: true,
|
||||
model: {},
|
||||
dictId: "",
|
||||
dictId: '',
|
||||
status: 1,
|
||||
labelCol: {
|
||||
xs: {span: 24},
|
||||
sm: {span: 5},
|
||||
xs: { span: 24 },
|
||||
sm: { span: 5 }
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: {span: 24},
|
||||
sm: {span: 16},
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 }
|
||||
},
|
||||
confirmLoading: false,
|
||||
form: this.$form.createForm(this),
|
||||
validatorRules: {
|
||||
itemText: {rules: [{required: true, message: '请输入名称!'}]},
|
||||
itemValue: {rules: [{required: true, message: '请输入数据值!'},{validator: this.validateItemValue}]},
|
||||
},
|
||||
itemText: {
|
||||
rules: [
|
||||
{ required: true, message: this.$t('name') + this.$t('cannotEmpty') },
|
||||
{
|
||||
max: 100,
|
||||
message: this.$t('name') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
},
|
||||
itemValue: {
|
||||
rules: [
|
||||
{ required: true, message: this.$t('DataValue') + this.$t('cannotEmpty') },
|
||||
{
|
||||
max: 100,
|
||||
message: this.$t('DataValue') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{ validator: this.validateItemValue }
|
||||
]
|
||||
},
|
||||
enName: {
|
||||
rules: [
|
||||
{ required: true, message: this.$t('enName') + this.$t('cannotEmpty') },
|
||||
{
|
||||
max: 100,
|
||||
message: this.$t('enName') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
},
|
||||
description: {
|
||||
rules: [
|
||||
{
|
||||
max: 300,
|
||||
message: this.$t('describe') + this.$t('cannotExceed') + 300 + this.$t('Characters'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
add(dictId) {
|
||||
this.dictId = dictId;
|
||||
this.edit({});
|
||||
this.dictId = dictId
|
||||
this.edit({})
|
||||
},
|
||||
edit(record) {
|
||||
if (record.id) {
|
||||
this.dictId = record.dictId;
|
||||
this.status = record.status;
|
||||
this.visibleCheck = (record.status == 1) ? true : false;
|
||||
this.dictId = record.dictId
|
||||
this.status = record.status
|
||||
this.visibleCheck = (record.status == 1) ? true : false
|
||||
}
|
||||
this.form.resetFields();
|
||||
this.model = Object.assign({}, record);
|
||||
this.model.dictId = this.dictId;
|
||||
this.model.status = this.status;
|
||||
this.visible = true;
|
||||
this.form.resetFields()
|
||||
this.model = Object.assign({}, record)
|
||||
this.model.dictId = this.dictId
|
||||
this.model.status = this.status
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model, 'itemText', 'itemValue', 'description', 'sortOrder'))
|
||||
});
|
||||
})
|
||||
},
|
||||
onChose(checked) {
|
||||
if (checked) {
|
||||
this.status = 1;
|
||||
this.visibleCheck = true;
|
||||
this.status = 1
|
||||
this.visibleCheck = true
|
||||
} else {
|
||||
this.status = 0;
|
||||
this.visibleCheck = false;
|
||||
this.status = 0
|
||||
this.visibleCheck = false
|
||||
}
|
||||
},
|
||||
// 确定
|
||||
handleOk() {
|
||||
const that = this;
|
||||
const that = this
|
||||
// 触发表单验证
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
that.confirmLoading = true;
|
||||
that.confirmLoading = true
|
||||
values.itemText = (values.itemText || '').trim()
|
||||
values.itemValue = (values.itemValue || '').trim()
|
||||
values.description = (values.description || '').trim()
|
||||
let formData = Object.assign(this.model, values);
|
||||
formData.status = this.status;
|
||||
let obj;
|
||||
let formData = Object.assign(this.model, values)
|
||||
formData.status = this.status
|
||||
let obj
|
||||
if (!this.model.id) {
|
||||
obj = addDictItem(formData);
|
||||
obj = addDictItem(formData)
|
||||
} else {
|
||||
obj = editDictItem(formData);
|
||||
obj = editDictItem(formData)
|
||||
}
|
||||
obj.then((res) => {
|
||||
if (res.success) {
|
||||
that.$message.success(res.message);
|
||||
that.$emit('ok');
|
||||
that.$message.success(res.message)
|
||||
that.$emit('ok')
|
||||
} else {
|
||||
that.$message.warning(res.message);
|
||||
that.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false;
|
||||
that.close();
|
||||
that.confirmLoading = false
|
||||
that.close()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 关闭
|
||||
handleCancel() {
|
||||
this.close();
|
||||
this.close()
|
||||
},
|
||||
close() {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
this.$emit('close')
|
||||
this.visible = false
|
||||
},
|
||||
validateItemValue(rule, value, callback){
|
||||
validateItemValue(rule, value, callback) {
|
||||
let param = {
|
||||
itemValue:value,
|
||||
dictId:this.dictId,
|
||||
itemValue: value,
|
||||
dictId: this.dictId
|
||||
}
|
||||
if(this.model.id){
|
||||
if (this.model.id) {
|
||||
param.id = this.model.id
|
||||
}
|
||||
if(value){
|
||||
let reg=new RegExp("[`_~!@#$^&*()=|{}'.<>《》/?!¥()—【】‘;:”“。,、?]")
|
||||
if(reg.test(value)){
|
||||
callback("数据值不能包含特殊字符!")
|
||||
}else{
|
||||
if (value) {
|
||||
let reg = new RegExp('[`_~!@#$^&*()=|{}\'.<>《》/?!¥()—【】‘;:”“。,、?]')
|
||||
if (reg.test(value)) {
|
||||
callback('数据值不能包含特殊字符!')
|
||||
} else {
|
||||
//update--begin--autor:lvdandan-----date:20201203------for:JT-27【数据字典】字典 - 数据值可重复
|
||||
getAction("/sys/dictItem/dictItemCheck",param).then((res)=>{
|
||||
if(res.success){
|
||||
getAction('/sys/dictItem/dictItemCheck', param).then((res) => {
|
||||
if (res.success) {
|
||||
callback()
|
||||
}else{
|
||||
callback(res.message);
|
||||
} else {
|
||||
callback(res.message)
|
||||
}
|
||||
});
|
||||
})
|
||||
//update--end--autor:lvdandan-----date:20201203------for:JT-27【数据字典】字典 - 数据值可重复
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user