Browse Source

居民信息新增,编辑

dev
13176889840 4 years ago
parent
commit
518e3960a4
  1. 130
      epmet-oper-web/src/views/components/editResi.vue
  2. 60
      epmet-oper-web/src/views/components/resiForm.vue
  3. 160
      epmet-oper-web/src/views/modules/base/resi.vue

130
epmet-oper-web/src/views/components/editResi.vue

@ -7,8 +7,8 @@
<el-button icon="el-icon-plus" size="small" @click="handleAddRow"></el-button>
</el-col>
</el-row>
<resi-form v-for="(item, index) in addList" :key="index" :ref="'baseForms' + index" :columns="3"
:form-list="item.itemList" :form-id="'baseForms' + item" />
<edit-form v-for="(item, index) in addList" :key="index" :ref="'baseForms' + index" :columns="3"
:form-list="item.itemList || formList" :form-id="'baseForms' + item.row" />
</template>
<template v-else>
<el-row v-if="fixed" class="resi-row">
@ -186,6 +186,7 @@
:props="{ checkStrictly: true }"
clearable
size="small"
@blur="handleChange"
class="resi-cell-select">
</el-cascader>
<template v-else-if="n.itemType === 'radio'">
@ -215,7 +216,7 @@
import { isCard, isMobile } from '@/utils/validate'
export default {
name: 'resiForm',
name: 'editForm',
props: {
fixed: {
type: Boolean,
@ -285,14 +286,15 @@ export default {
// console.log('formInfo', obj)
if (Object.keys(obj).length > 0) {
_form = { ...obj }
return _form
// return _form
}
arr.forEach(item => {
if (item.multiSelect || item.itemType === 'cascader') {
if (item.columnValue && item.columnValue.indexOf(',') > -1) _form[item.columnName] = item.columnValue.split(',')
else _form[item.columnName] = [item.columnValue]
} else _form[item.columnName] = item.columnValue
else _form[item.columnName] = (item.columnValue && [item.columnValue]) || []
} else _form[item.columnName] = item.columnValue || ''
})
// console.log('_from0000---', arr)
return _form
}
let initRules = (arr) => {
@ -320,45 +322,19 @@ export default {
let rules = initRules(this.formList)
let tempFormList = [ ...this.formList ]
let constForm = {
...form,
GRID_ID: '',
VILLAGE_ID: '',
BUILD_ID: '',
HOME_ID: ''
...form
}
return {
openSearch: false,
options: [{
value: '选项1',
label: '黄金糕'
}, {
value: '选项2',
label: '双皮奶'
}, {
value: '选项3',
label: '蚵仔煎'
}, {
value: '选项4',
label: '龙须面'
}, {
value: '选项5',
label: '北京烤鸭'
}],
fixedForm: {
GRID_ID: '',
VILLAGE_ID: '',
BUILD_ID: '',
HOME_ID: ''
},
fixedList: {
AGENCY_ID: this.$store.state.user.agencyId
},
fixedList: {},
form: {
...form,
GRID_ID: '',
VILLAGE_ID: '',
BUILD_ID: '',
HOME_ID: ''
...form
},
constForm,
tempFormList,
@ -370,7 +346,6 @@ export default {
optionsB: [],
optionsH: [],
optionsG: [],
checkList: ['选中且禁用', '复选框 A'],
pickerOptions: {
shortcuts: [{
text: '最近一周',
@ -441,7 +416,7 @@ export default {
watch: {
form: {
handler (val, val2) {
// console.log('valpppp----', val, val2)
console.log('valpppp----', val, val2)
for (let n in val) {
if (this.constForm[n] !== val[n]) {
this.handleChangeForm(n)
@ -455,30 +430,38 @@ export default {
}
},
created () {
// this.initForm()
this.initForm()
// console.log('formInfo---ggg', this.form)
if (this.supportAdd) {
this.addList = [...this.mutiList]
// console.log('addList----111', this.addList)
}
// } this.addList.push(this.addCount++)
this.getOptionsList()
if (this.fixed) this.getOptionsList()
},
methods: {
initForm () {
console.log('formInfo', this.formInfo)
if (Object.keys(this.formInfo).length > 0) {
this.form = { ...this.formInfo }
return
}
this.formList.forEach(item => {
this.$set(this.form, item.columnName, '')
// console.log('formInfo', this.formInfo)
// if (Object.keys(this.formInfo).length > 0) {
// this.form = { ...this.formInfo }
// return
// }
this.formList.forEach(async item => {
if (item.optionSourceType === 'remote') {
await this.getOptionsLists(item.optionSourceValue).then(res => {
item.options = res
})
}
})
},
handleOpenSearch () {
this.openSearch = !this.openSearch
},
handleAddRow () {
this.addList.push(this.addCount++)
this.addList.push({
row: this.addList.length,
itemList: this.formList
})
},
//
handleFiexedForm (val) {
@ -500,31 +483,26 @@ export default {
// form
handleChangeForm (val) {
if (this.fixed) {
// let item = {}
for (let n in this.fixedForm) {
if (n === val) {
// item = {
// [val]: this.form[val]
// }
// this.fixedList.push(item)
this.$set(this.fixedList, val, this.form[val])
}
}
}
console.log('fixedList----999', this.fixedList)
this.tempFormList.forEach(item => {
if (item.columnName === val) item.isChange = true
})
},
handleChange () {
// this.handleForm()
},
handlerMuscForm () {
let arr = []
this.addList.forEach(item => {
// console.log('handlerMuscForm----000', this.$refs['baseForms' + item][0].handleForm())
arr.push([ ...this.$refs['baseForms' + item][0].handleForm() ])
// console.log('handlerMuscForm----000', this.$refs['baseForms' + item.row || item][0].handleForm())
arr.push([ ...this.$refs['baseForms' + item.row][0].handleForm() ])
})
// console.log('handlerMuscForm----111', arr)
let arr2 = arr.reduce(function (a, b) { return a.concat(b) })
// console.log('handlerMuscForm----222', arr2)
let hash = {}
let i = 0
let res = []
@ -533,7 +511,6 @@ export default {
let name = item.tableName
if (hash[name]) {
res[hash[name] - 1].list.push(...item.list)
// console.log('hash[name]---', hash[name], res, res[hash[name] - 1], item)
} else {
hash[name] = ++i
res.push({
@ -541,10 +518,8 @@ export default {
supportAdd: this.supportAdd,
tableName: name
})
// console.log('hash[name]0000---', hash[name], res)
}
})
// console.log('handlerMuscForm----333', res)
return res
},
resetForm () {
@ -561,26 +536,38 @@ export default {
var name = item.tableName
hash[name] ? res[hash[name] - 1].list.push(item) : hash[name] = ++i && res.push({
list: [item],
ID: item.ID,
tableName: name
})
})
// console.log('resssssss', res)
res.forEach(item => {
let _form = {}
// let ID = item.list[0].ID
item.list.filter(n => n.isChange).forEach(r => {
_form[r.columnName] = r.multiSelect || r.itemType === 'cascader' ? this.form[r.columnName].toString() : this.form[r.columnName]
if (r.ID) {
_form.ID = r.ID
}
// return _form
})
if (this.fixed) {
for (let n in this.fixedList) {
_form[n] = this.fixedList[n]
}
if (Object.keys(_form).length > 0) {
_form.AGENCY_ID = this.$store.state.user.agencyId
}
}
// console.log('objeckeyssss', Object.keys(_form), _form, this.form)
newForm.push({
tableName: item.tableName,
supportAdd: this.supportAdd,
list: [{ ..._form }]
ID: item.ID,
list: Object.keys(_form).length > 0 ? [{ ..._form }] : []
})
})
// console.log('newFormhhhhh', newForm)
return newForm
} else {
console.log('error submit!!')
@ -590,6 +577,23 @@ export default {
if (this.supportAdd) newForm = this.handlerMuscForm()
return newForm
},
async getOptionsLists (url) {
let options = []
// console.log('getOptionsList----', url)
await this.$http
.post(url, { formCode: 'resi_base_info' })
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
options = res.data
}
})
.catch(() => {
return this.$message.error('网络错误')
})
return options
},
getOptionsList () {
const { user } = this.$store.state
this.$http
@ -598,7 +602,6 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取查询详情成功', res.data)
this.optionsG = res.data
}
})
@ -611,7 +614,6 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取查询详情成功', res.data)
this.optionsV = res.data
}
})
@ -624,7 +626,6 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取查询详情成功', res.data)
this.optionsB = res.data
}
})
@ -637,7 +638,6 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取查询详情成功', res.data)
this.optionsH = res.data
}
})

60
epmet-oper-web/src/views/components/resiForm.vue

@ -283,6 +283,12 @@ export default {
arr.forEach(item => {
if (item.multiSelect) _form[item.columnName] = []
else _form[item.columnName] = ''
// if (item.optionSourceType === 'remote') {
// this.getOptionsLists(item.optionSourceValue).then(res => {
// item.options = res
// })
// }
})
return _form
}
@ -319,22 +325,6 @@ export default {
}
return {
openSearch: false,
options: [{
value: '选项1',
label: '黄金糕'
}, {
value: '选项2',
label: '双皮奶'
}, {
value: '选项3',
label: '蚵仔煎'
}, {
value: '选项4',
label: '龙须面'
}, {
value: '选项5',
label: '北京烤鸭'
}],
fixedForm: {
GRID_ID: '',
VILLAGE_ID: '',
@ -361,7 +351,6 @@ export default {
optionsB: [],
optionsH: [],
optionsG: [],
checkList: ['选中且禁用', '复选框 A'],
pickerOptions: {
shortcuts: [{
text: '最近一周',
@ -449,17 +438,17 @@ export default {
// this.initForm()
// console.log('formInfo---ggg', this.form)
if (this.supportAdd) this.addList.push(this.addCount++)
this.getOptionsList()
if (this.fixed) this.getOptionsList()
},
methods: {
initForm () {
console.log('formInfo', this.formInfo)
if (Object.keys(this.formInfo).length > 0) {
this.form = { ...this.formInfo }
return
}
this.formList.forEach(item => {
this.$set(this.form, item.columnName, '')
this.formList.forEach(async item => {
console.log('initform---item', item.label, item.optionSourceType)
// if (item.optionSourceType === 'remote') {
// await this.getOptionsLists(item.optionSourceValue).then(res => {
// item.options = res
// })
// }
})
},
handleOpenSearch () {
@ -479,6 +468,7 @@ export default {
//
handleChangeGroup (columnName, value) {
this.tempFormList.forEach(item => {
// console.log('columnName', item.columnName, columnName)
if (item.columnName === columnName && item.itemType === 'radio' && item.childGroup) {
console.log('columnName', item.columnName, columnName)
this.$emit('changegroup', { value, childGroup: item.childGroup })
@ -586,7 +576,6 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取查询详情成功', res.data)
this.optionsG = res.data
}
})
@ -599,7 +588,6 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取查询详情成功', res.data)
this.optionsV = res.data
}
})
@ -612,7 +600,6 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取查询详情成功', res.data)
this.optionsB = res.data
}
})
@ -632,6 +619,23 @@ export default {
.catch(() => {
return this.$message.error('网络错误')
})
},
async getOptionsLists (url) {
let options = []
console.log('getOptionsList----', url)
await this.$http
.post(url, { formCode: 'resi_base_info' })
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
options = res.data
}
})
.catch(() => {
return this.$message.error('网络错误')
})
return options
}
}
}

160
epmet-oper-web/src/views/modules/base/resi.vue

@ -85,8 +85,8 @@
width="80%"
append-to-body
:close-on-click-modal="false"
:before-close="handlerCancle">
<edit-resi v-if="dialogEditVisible" ref="baseForm" :fixed="true" :form-list="formList" @changegroup="handleChangeGroup" />
:before-close="handlerEditCancle">
<edit-resi v-if="dialogEditVisible" ref="baseForm" :form-info="editForm" :fixed="true" :form-list="formList" @changegroup="handleChangeGroup" />
<div v-if="dialogEditVisible" class="resi-other">
<div class="resi-other-title">其他</div>
<div class="tabs-other-info">
@ -100,8 +100,8 @@
</div>
</div>
<div class="resi-btns">
<el-button size="small" @click="handlerCancle">取消</el-button>
<el-button type="primary" size="small" @click="handleSUbmit">提交</el-button>
<el-button size="small" @click="handlerEditCancle">取消</el-button>
<el-button type="primary" size="small" @click="handleEditSUbmit">提交</el-button>
</div>
</el-dialog>
@ -132,6 +132,15 @@ export default {
tableData: [],
searchList: [],
value: '',
editForm: {
GRID_ID: '',
VILLAGE_ID: '',
BUILD_ID: '',
HOME_ID: ''
},
editTableName: {
},
formList: [],
tableHeader: [],
tabsForm: [{
@ -180,7 +189,7 @@ export default {
},
async created () {
await this.getSearchList()
await this.getFormList()
// await this.getFormList()
await this.getTableHeader()
this.getTableData()
this.pageLoading = true
@ -215,10 +224,12 @@ export default {
handleClick (tab, event) {
console.log(tab, event)
},
handleEdit (row) {
async handleEdit (row) {
await this.getFormList()
this.getrowInfo(row.icResiUserId)
},
handleAdd () {
async handleAdd () {
await this.getFormList()
this.dialogVisible = true
},
async handleChangeGroup (val) {
@ -251,6 +262,59 @@ export default {
if (hasT) this.tabsList.splice(i, 1)
}
},
handleEditSUbmit () {
const _baseForm = this.$refs.baseForm.handleForm()
let arr = []
// let arr1 = []
if (_baseForm.length === 0) return false
arr.push([ ..._baseForm ])
this.tabsList.forEach(item => {
// console.log('groupInfo', this.$refs['group' + item.groupId][0].handleForm())
arr.push([ ...this.$refs['group' + item.groupId][0].handleForm() ])
})
let arr2 = arr.reduce(function (a, b) { return a.concat(b) })
// console.log('arrr555-----sub', arr2)
let noChange = true
arr2.forEach(item => {
if (item.list.length !== 0) noChange = false
})
if (noChange) return this.$message.warning('您还没有做任何修改')
// tableName
let hash = {}
let i = 0
let res = []
let finalArr = []
arr2.forEach(function (item) {
// console.log('arrr666-----sub', item)
let name = item.tableName
if (hash[name]) {
res[hash[name] - 1].list.push(...item.list)
// console.log('hash[name]---', hash[name], res, res[hash[name] - 1], item)
} else {
hash[name] = ++i
res.push({
list: [...item.list],
supportAdd: item.supportAdd,
tableName: name
})
// console.log('hash[name]0000---', hash[name], res)
}
})
// listlist
res.forEach(item => {
// console.log('arrr777-----sub', item)
let _form = {}
item.list.forEach(n => {
_form = { ..._form, ...n }
})
finalArr.push({
tableName: item.tableName,
list: item.supportAdd ? [...item.list] : [{ ..._form }]
})
})
// console.log('editInfo---', res, finalArr)
this.submitEdit(finalArr)
},
handleSUbmit () {
console.log('baseform', this.$refs.baseForm.handleForm())
const _baseForm = this.$refs.baseForm.handleForm()
@ -303,6 +367,13 @@ export default {
handleFormatUrl (url) {
return url.includes('?')
},
handlerEditCancle () {
this.$refs.baseForm.resetForm()
this.tabsList.forEach(item => {
this.$refs['group' + item.groupId][0].resetForm()
})
this.dialogEditVisible = false
},
handlerCancle () {
this.$refs.baseForm.resetForm()
this.tabsList.forEach(item => {
@ -322,8 +393,8 @@ export default {
this.$refs.baseForm.resetForm()
this.tabsList.forEach(item => {
this.$refs['group' + item.groupId][0].resetForm()
this.getTableData()
})
this.getTableData()
this.dialogVisible = false
}
})
@ -331,6 +402,27 @@ export default {
return this.$message.error('网络错误')
})
},
submitEdit (arr) {
this.$http
.post('/epmetuser/icresiuser/edit', arr)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
this.$message.success('提交成功')
// this.$refs[formName].resetFields();
this.$refs.baseForm.resetForm()
this.tabsList.forEach(item => {
this.$refs['group' + item.groupId][0].resetForm()
})
this.getTableData()
this.dialogEditVisible = false
}
})
.catch(() => {
return this.$message.error('网络错误')
})
},
getTableHeader () {
this.$http
.post('/oper/customize/icform/tableheaders', { formCode: 'resi_base_info' })
@ -377,9 +469,13 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('getrowInfo----', res.data)
// console.log('getrowInfo----', res.data)
let info = res.data
this.editTableName = { ...info }
let list = info[this.formList[0].tableName][0]
for (let n in list) {
this.editForm[n] = list[n]
}
this.formList.forEach(item => {
if (item.childGroup && info[item.childGroup.tableName]) {
// let _info = info[item.childGroup.tableName]
@ -389,47 +485,53 @@ export default {
this.tabsList.push(item.childGroup)
}
item.columnValue = list[item.columnName]
item.ID = list.ID
})
let mutiList = []
this.tabsList.forEach(item => {
let _info = info[item.tableName]
let _list = [...item.itemList]
if (item.supportAdd) {
// console.log('tabsList---333', item.label)
const _list = [...item.itemList]
let mutiList = []
if (_info) {
_info.forEach((fo, index) => {
// console.log('mutiList----555' + index, mutiList, _list)
mutiList.splice(index, 0, {
row: index,
itemList: _list.map(m => {
// console.log('itemList---item' + index, m)
return {
...m,
ID: fo.ID,
columnValue: fo[m.columnName]
}
})
})
console.log('mutiList----666' + index, mutiList)
// console.log('mutiList----666' + index, mutiList)
})
}
item.mutiList = mutiList
} else {
if (_info) {
item.itemList.forEach(n => {
n.ID = _info[0].ID
n.columnValue = _info[0][n.columnName]
})
}
}
})
console.log('getrowInfo---formname', this.tabsList)
// console.log('getrowInfo---formname', this.tabsList)
this.dialogEditVisible = true
}
})
.catch(() => {
console.log('getrowInfo---formname', 0)
.catch((err) => {
console.log('getrowInfo---formnameerr', err)
return this.$message.error('网络错误')
})
},
async getOptionsList (url) {
let options = []
console.log('getOptionsList----', url)
// console.log('getOptionsList----', url)
await this.$http
.post(url, { formCode: 'resi_base_info' })
.then(({ data: res }) => {
@ -451,10 +553,9 @@ export default {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取查询详情成功', res.data)
// console.log('', res.data)
this.searchList = res.data
res.data.forEach(item => {
console.log('optionSourceType---000', item.optionSourceType, item.optionSourceValue, item.label)
if (item.optionSourceType === 'remote') {
this.getOptionsList(item.optionSourceValue).then(res => {
item.options = res
@ -468,40 +569,35 @@ export default {
return this.$message.error('网络错误')
})
},
getFormList () {
this.$http
async getFormList () {
await this.$http
.post('/oper/customize/icform/getcustomerform', { formCode: 'resi_base_info', dynamic: true })
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
} else {
console.log('获取详情成功')
console.log('获取详情成功getFormList')
let { itemList, groupList } = res.data
// this.details = res.data /oper/customize/icform/conditionlist
this.formList = res.data.itemList
this.tabsList = res.data.groupList
this.activeName = 'group' + res.data.groupList[0].groupId
itemList.forEach(item => {
itemList.forEach(async item => {
if (item.optionSourceType === 'remote') {
console.log('optionSourceType-111', this.handleFormatUrl(item.optionSourceValue), item.optionSourceValue)
this.getOptionsList(item.optionSourceValue).then(res => {
await this.getOptionsList(item.optionSourceValue).then(res => {
item.options = res
})
}
})
groupList.forEach(item => {
item.itemList.forEach(n => {
item.itemList.forEach(async n => {
n.tableName = item.tableName
if (n.optionSourceType === 'remote') {
this.getOptionsList(n.optionSourceValue).then(res => {
await this.getOptionsList(n.optionSourceValue).then(res => {
n.options = res
})
}
})
// if (item.supportAdd) {
// item.itemList = [ item.itemList ]
// }
})
this.formList = itemList
this.tabsList = groupList
}
})
.catch(() => {

Loading…
Cancel
Save