Browse Source

门类管理 字段管理对话框修改

master
z_yu 3 years ago
parent
commit
8556da944c
  1. 10
      src/api/category/fieldManage.js
  2. 4
      src/views/category/descriptionPreview/index.vue
  3. 22
      src/views/category/fieldManage/index.vue
  4. 14
      src/views/category/fieldManage/module/form.vue
  5. 57
      src/views/components/category/SettingForm.vue

10
src/api/category/fieldManage.js

@ -2,18 +2,18 @@ import request from '@/utils/request'
export function add(data) { export function add(data) {
return request({ return request({
url: 'api/archives-type/createDic',
url: 'api/archives-type/create-dic',
method: 'post', method: 'post',
data data
}) })
} }
export function del(ids) { export function del(ids) {
const data = ids ? ids.join() : ''
const params = ids[0]
return request({ return request({
url: 'api/dictrionary/delete',
method: 'post',
data
url: 'api/archives-type/delete-dic',
method: 'delete',
id: params
}) })
} }

4
src/views/category/descriptionPreview/index.vue

@ -42,7 +42,7 @@
<span class="dialog-right-top" /> <span class="dialog-right-top" />
<span class="dialog-left-bottom" /> <span class="dialog-left-bottom" />
<div class="setting-dialog"> <div class="setting-dialog">
<SettingForm ref="editForm" :is-disabled="false" :is-add="false" :this-fields="thisFields" />
<SettingForm ref="editForm" :is-disabled="true" :is-add="false" :this-fields="thisFields" />
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="editSubmit">保存</el-button> <el-button type="primary" @click="editSubmit">保存</el-button>
</div> </div>
@ -102,6 +102,8 @@ export default {
FetchArchivesTypeManage({ categoryId: this.selectedCategory.id }).then(res => { FetchArchivesTypeManage({ categoryId: this.selectedCategory.id }).then(res => {
this.allFieldsData = res this.allFieldsData = res
this.allFieldsData.forEach((item, index) => { this.allFieldsData.forEach((item, index) => {
// null
item.dictionaryConfigId = item.dictionaryConfigId || { name: null }
if (item.isInput) { if (item.isInput) {
console.log(item) console.log(item)
// this.fieldsActive = index // this.fieldsActive = index

22
src/views/category/fieldManage/index.vue

@ -98,7 +98,6 @@ export default {
url: 'api/archives-type/manage', url: 'api/archives-type/manage',
crudMethod: { add, edit }, crudMethod: { add, edit },
title: '字段', title: '字段',
// delete
optShow: { optShow: {
add: true, add: true,
edit: true, edit: true,
@ -156,8 +155,23 @@ export default {
[CRUD.HOOK.beforeRefresh]() { [CRUD.HOOK.beforeRefresh]() {
this.crud.query.categoryId = this.selectedCategory.id 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) { clickRowHandler(row) {
this.$refs.fieldTable.clearSelection() this.$refs.fieldTable.clearSelection()
@ -189,7 +203,7 @@ export default {
this.deleteData = {} this.deleteData = {}
done() done()
}, },
digitFormatter(row, column, cellValue, index) {
digitFormatter(row, column, cellValue) {
return cellValue || '-' return cellValue || '-'
} }
} }

14
src/views/category/fieldManage/module/form.vue

@ -30,14 +30,14 @@ const defaultForm = {
isSequence: null, isSequence: null,
isType: null, isType: null,
isSystem: true, isSystem: true,
isLine: null,
isInput: null,
isRequired: null,
isAutomatic: null,
isLine: false,
isInput: false,
isRequired: false,
isAutomatic: false,
isAdd: null, isAdd: null,
isSearch: null, isSearch: null,
isInherit: null, isInherit: null,
isFilling: null,
isFilling: false,
fillingDigit: null, fillingDigit: null,
isRepeat: null, isRepeat: null,
isDisplay: false, isDisplay: false,
@ -46,7 +46,9 @@ const defaultForm = {
displayformatType: null, displayformatType: null,
editLength: null, editLength: null,
displayLength: null, displayLength: null,
dictionaryConfigId: {}
dictionaryConfigId: {
id: null
}
} }
export default { export default {
components: { SettingForm }, components: { SettingForm },

57
src/views/components/category/SettingForm.vue

@ -13,7 +13,7 @@
</el-form-item> </el-form-item>
<el-form-item label="字段类型" prop="isDataType"> <el-form-item label="字段类型" prop="isDataType">
<el-input v-if="isDisabled" v-model="form.isDataType" readonly />
<el-input v-if="isDisabled" v-model="form.isDataTypeTxt" readonly />
<el-select v-else v-model="form.isDataType" placeholder="" :disabled="!isAdd"> <el-select v-else v-model="form.isDataType" placeholder="" :disabled="!isAdd">
<el-option v-for="item in dataTypeOptions" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in dataTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
@ -21,7 +21,7 @@
<el-form-item label="字段长度" prop="isColumnLength"> <el-form-item label="字段长度" prop="isColumnLength">
<el-input v-if="isDisabled" v-model="form.isColumnLength" type="number" placeholder="" readonly /> <el-input v-if="isDisabled" v-model="form.isColumnLength" type="number" placeholder="" readonly />
<el-input v-else v-model="form.isColumnLength" type="number" placeholder="" :disabled="!isAdd" />
<el-input v-else v-model.number="form.isColumnLength" type="number" placeholder="" :disabled="!isAdd" />
</el-form-item> </el-form-item>
<el-form-item label="著录形式" prop="isInputClass"> <el-form-item label="著录形式" prop="isInputClass">
@ -123,25 +123,8 @@ export default {
callback(new Error('字段标识只能由字母、字符“_”组成,并且必须以字母开头和结尾')) 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: [ fieldCnName: [
{ required: true, message: '请输入中文名称', trigger: 'blur' } { required: true, message: '请输入中文名称', trigger: 'blur' }
], ],
@ -155,7 +138,19 @@ export default {
isColumnLength: [ isColumnLength: [
{ validator: checkMaxLength, trigger: 'blur' } { validator: checkMaxLength, trigger: 'blur' }
] ]
}
if (this.isDisabled) {
delete rules.isDataType
}
return rules
}
return {
form: {
dictionaryConfigId: {
id: null
}
}, },
rules: getRules(),
// //
dataTypeOptions: [ dataTypeOptions: [
{ value: 1, label: '字符' }, { value: 1, label: '字符' },
@ -201,9 +196,9 @@ export default {
this.form.isAutomatic = !!this.form.isAutomatic this.form.isAutomatic = !!this.form.isAutomatic
// //
if (this.form.isDataType === 1) { if (this.form.isDataType === 1) {
this.form.isDataType = '字符'
this.form.isDataTypeTxt = '字符'
} else if (this.form.isDataType === 2) { } else if (this.form.isDataType === 2) {
this.form.isDataType = '数字'
this.form.isDataTypeTxt = '数字'
} }
// - // -
switch (this.form.isInputClass) { switch (this.form.isInputClass) {
@ -226,11 +221,13 @@ export default {
this.form.isInputClassTxt = '文本域' this.form.isInputClassTxt = '文本域'
break 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 // list
@ -248,7 +245,7 @@ export default {
this.getDictrionaryList() this.getDictrionaryList()
} else { } else {
this.dictionaryData = [] this.dictionaryData = []
this.form.sysDictionaryId = null
this.form.dictionaryConfigId.id = null
} }
// //
if (this.form.isDataType === 2) { if (this.form.isDataType === 2) {
@ -305,7 +302,7 @@ export default {
submitForm(formName) { submitForm(formName) {
// //
if (this.form.isInputClass === 'select' || this.form.isInputClass === 'popover') { if (this.form.isInputClass === 'select' || this.form.isInputClass === 'popover') {
if (!this.form.sysDictionaryId) {
if (!this.form.dictionaryConfigId.id) {
this.$message.error('对应字典项不可为空!') this.$message.error('对应字典项不可为空!')
return return
} }

Loading…
Cancel
Save