diff --git a/src/api/category/fieldManage.js b/src/api/category/fieldManage.js index d895df5..cf1f7c7 100644 --- a/src/api/category/fieldManage.js +++ b/src/api/category/fieldManage.js @@ -2,18 +2,18 @@ import request from '@/utils/request' export function add(data) { return request({ - url: 'api/archives-type/createDic', + url: 'api/archives-type/create-dic', method: 'post', data }) } export function del(ids) { - const data = ids ? ids.join() : '' + const params = ids[0] return request({ - url: 'api/dictrionary/delete', - method: 'post', - data + url: 'api/archives-type/delete-dic', + method: 'delete', + id: params }) } diff --git a/src/views/category/descriptionPreview/index.vue b/src/views/category/descriptionPreview/index.vue index 1c18646..b3f63ed 100644 --- a/src/views/category/descriptionPreview/index.vue +++ b/src/views/category/descriptionPreview/index.vue @@ -42,7 +42,7 @@
- + @@ -102,6 +102,8 @@ export default { FetchArchivesTypeManage({ categoryId: this.selectedCategory.id }).then(res => { this.allFieldsData = res this.allFieldsData.forEach((item, index) => { + // 防止对应字典是null时报错 + item.dictionaryConfigId = item.dictionaryConfigId || { name: null } if (item.isInput) { console.log(item) // this.fieldsActive = index diff --git a/src/views/category/fieldManage/index.vue b/src/views/category/fieldManage/index.vue index 48a2751..d668188 100644 --- a/src/views/category/fieldManage/index.vue +++ b/src/views/category/fieldManage/index.vue @@ -98,7 +98,6 @@ export default { url: 'api/archives-type/manage', crudMethod: { add, edit }, title: '字段', - // delete optShow: { add: true, edit: true, @@ -156,8 +155,23 @@ export default { [CRUD.HOOK.beforeRefresh]() { this.crud.query.categoryId = this.selectedCategory.id }, - [CRUD.HOOK.beforeToEdit](crud) { - crud.selections[0].dictionaryConfigId = crud.selections[0].dictionaryConfigId || {} + [CRUD.HOOK.afterRefresh](crud) { + crud.data.forEach(function(item, index) { + item.dictionaryConfigId = item.dictionaryConfigId || { id: null } + }) + }, + [CRUD.HOOK.beforeValidateCU](crud) { + crud.findVM('form').$refs['editForm'].$refs['form'].validate(valid => { + if (!valid) { + return + } + if (crud.status.add === CRUD.STATUS.PREPARED) { + crud.doAdd() + } else if (crud.status.edit === CRUD.STATUS.PREPARED) { + crud.doEdit() + } + }) + return false }, clickRowHandler(row) { this.$refs.fieldTable.clearSelection() @@ -189,7 +203,7 @@ export default { this.deleteData = {} done() }, - digitFormatter(row, column, cellValue, index) { + digitFormatter(row, column, cellValue) { return cellValue || '-' } } diff --git a/src/views/category/fieldManage/module/form.vue b/src/views/category/fieldManage/module/form.vue index 3ddd744..9ad5dc7 100644 --- a/src/views/category/fieldManage/module/form.vue +++ b/src/views/category/fieldManage/module/form.vue @@ -30,14 +30,14 @@ const defaultForm = { isSequence: null, isType: null, isSystem: true, - isLine: null, - isInput: null, - isRequired: null, - isAutomatic: null, + isLine: false, + isInput: false, + isRequired: false, + isAutomatic: false, isAdd: null, isSearch: null, isInherit: null, - isFilling: null, + isFilling: false, fillingDigit: null, isRepeat: null, isDisplay: false, @@ -46,7 +46,9 @@ const defaultForm = { displayformatType: null, editLength: null, displayLength: null, - dictionaryConfigId: {} + dictionaryConfigId: { + id: null + } } export default { components: { SettingForm }, diff --git a/src/views/components/category/SettingForm.vue b/src/views/components/category/SettingForm.vue index c7f41f5..733d796 100644 --- a/src/views/components/category/SettingForm.vue +++ b/src/views/components/category/SettingForm.vue @@ -13,7 +13,7 @@ - + @@ -21,7 +21,7 @@ - + @@ -123,25 +123,8 @@ export default { callback(new Error('字段标识只能由字母、字符“_”组成,并且必须以字母开头和结尾')) } } - return { - form: { - // fieldCnName: '', - // fieldName: '', - // isDataType: '', - // isColumnLength: '', - // isInputClass: '', - // sysDictionaryId: '', - // isInputLength: '', - // isDefaultValue: '', - // isFilling: '', - // isLine: '', - // isInput: '', - // isRequired: '', - // isAutomatic: '', - // isRepeat: '', - // fillingDigit: '' - }, - rules: { + var getRules = () => { + const rules = { fieldCnName: [ { required: true, message: '请输入中文名称', trigger: 'blur' } ], @@ -155,7 +138,19 @@ export default { isColumnLength: [ { validator: checkMaxLength, trigger: 'blur' } ] + } + if (this.isDisabled) { + delete rules.isDataType + } + return rules + } + return { + form: { + dictionaryConfigId: { + id: null + } }, + rules: getRules(), // 字段类型 dataTypeOptions: [ { value: 1, label: '字符' }, @@ -201,9 +196,9 @@ export default { this.form.isAutomatic = !!this.form.isAutomatic // 字段类型 if (this.form.isDataType === 1) { - this.form.isDataType = '字符' + this.form.isDataTypeTxt = '字符' } else if (this.form.isDataType === 2) { - this.form.isDataType = '数字' + this.form.isDataTypeTxt = '数字' } // 初始化 - 著录形式 switch (this.form.isInputClass) { @@ -226,11 +221,13 @@ export default { this.form.isInputClassTxt = '文本域' break } - // 初始化 - 著录形式 - 对应字典 - if (this.form.isInputClass === 'select' || this.form.isInputClass === 'popover') { - this.getDictrionaryList() - } else { - this.dictionaryData = [] + if (!this.isDisabled) { + // 初始化 - 著录形式 - 对应字典 + if (this.form.isInputClass === 'select' || this.form.isInputClass === 'popover') { + this.getDictrionaryList() + } else { + this.dictionaryData = [] + } } }, // 获取对应字典list @@ -248,7 +245,7 @@ export default { this.getDictrionaryList() } else { this.dictionaryData = [] - this.form.sysDictionaryId = null + this.form.dictionaryConfigId.id = null } // 字段类型为数字型,且默认著录类型为数字框不可更改 if (this.form.isDataType === 2) { @@ -305,7 +302,7 @@ export default { submitForm(formName) { // 对应字典必填判断 if (this.form.isInputClass === 'select' || this.form.isInputClass === 'popover') { - if (!this.form.sysDictionaryId) { + if (!this.form.dictionaryConfigId.id) { this.$message.error('对应字典项不可为空!') return }