diff --git a/epmet-oper-web/src/views/components/editResi.vue b/epmet-oper-web/src/views/components/editResi.vue index ef20416..6b7d007 100644 --- a/epmet-oper-web/src/views/components/editResi.vue +++ b/epmet-oper-web/src/views/components/editResi.vue @@ -7,8 +7,8 @@ - + @@ -18,7 +18,7 @@ - --> - --> - --> - - {{ ns.label }} @@ -197,7 +206,7 @@ - {{ns.label}} + {{ns.label}} @@ -215,7 +224,7 @@ import { isCard, isMobile } from '@/utils/validate' export default { - name: 'resiForm', + name: 'editForm', props: { fixed: { type: Boolean, @@ -255,6 +264,10 @@ export default { supportAdd: { // 单表多条数据 type: Boolean, default: false + }, + disabled: { // 单表多条数据 + type: Boolean, + default: false } }, data () { @@ -285,14 +298,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 +334,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 +358,6 @@ export default { optionsB: [], optionsH: [], optionsG: [], - checkList: ['选中且禁用', '复选框 A'], pickerOptions: { shortcuts: [{ text: '最近一周', @@ -441,7 +428,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 +442,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 +495,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 +523,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 +530,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 +548,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 +589,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 +614,6 @@ export default { if (res.code !== 0) { return this.$message.error(res.msg) } else { - console.log('获取查询详情成功', res.data) this.optionsG = res.data } }) @@ -611,7 +626,6 @@ export default { if (res.code !== 0) { return this.$message.error(res.msg) } else { - console.log('获取查询详情成功', res.data) this.optionsV = res.data } }) @@ -624,7 +638,6 @@ export default { if (res.code !== 0) { return this.$message.error(res.msg) } else { - console.log('获取查询详情成功', res.data) this.optionsB = res.data } }) @@ -637,7 +650,6 @@ export default { if (res.code !== 0) { return this.$message.error(res.msg) } else { - console.log('获取查询详情成功', res.data) this.optionsH = res.data } }) diff --git a/epmet-oper-web/src/views/components/resiForm.vue b/epmet-oper-web/src/views/components/resiForm.vue index ac51888..1eaaa33 100644 --- a/epmet-oper-web/src/views/components/resiForm.vue +++ b/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 } @@ -309,6 +315,7 @@ export default { } let form = initForm(this.formInfo, this.formList) let rules = initRules(this.formList) + console.log('rulessss', rules) let tempFormList = [ ...this.formList ] let constForm = { ...form, @@ -319,22 +326,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 +352,6 @@ export default { optionsB: [], optionsH: [], optionsG: [], - checkList: ['选中且禁用', '复选框 A'], pickerOptions: { shortcuts: [{ text: '最近一周', @@ -449,17 +439,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 +469,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 }) @@ -566,7 +557,7 @@ export default { newForm.push({ tableName: item.tableName, supportAdd: this.supportAdd, - list: [{ ..._form }] + list: Object.keys(_form).length > 0 ? [{ ..._form }] : [] }) }) return newForm @@ -586,7 +577,6 @@ export default { if (res.code !== 0) { return this.$message.error(res.msg) } else { - console.log('获取查询详情成功', res.data) this.optionsG = res.data } }) @@ -599,7 +589,6 @@ export default { if (res.code !== 0) { return this.$message.error(res.msg) } else { - console.log('获取查询详情成功', res.data) this.optionsV = res.data } }) @@ -612,7 +601,6 @@ export default { if (res.code !== 0) { return this.$message.error(res.msg) } else { - console.log('获取查询详情成功', res.data) this.optionsB = res.data } }) @@ -632,6 +620,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 } } } diff --git a/epmet-oper-web/src/views/modules/base/resi.vue b/epmet-oper-web/src/views/modules/base/resi.vue index df8c371..95a85d4 100644 --- a/epmet-oper-web/src/views/modules/base/resi.vue +++ b/epmet-oper-web/src/views/modules/base/resi.vue @@ -34,9 +34,14 @@ align="center" width="120"> - 查看 + 查看 编辑 - 删除 + + 删除 + @@ -85,8 +90,8 @@ width="80%" append-to-body :close-on-click-modal="false" - :before-close="handlerCancle"> - + :before-close="handlerEditCancle"> + 其他 @@ -94,14 +99,14 @@ + :form-id="item.columnName" :muti-list="item.mutiList" :form-list=" item.itemList" :disabled="disabled" /> - 取消 - 提交 + 取消 + 提交 @@ -120,6 +125,7 @@ export default { }, data () { return { + disabled: false, pageLoading: false, dialogEditVisible: false, dialogVisible: false, @@ -132,6 +138,15 @@ export default { tableData: [], searchList: [], value: '', + editForm: { + GRID_ID: '', + VILLAGE_ID: '', + BUILD_ID: '', + HOME_ID: '' + }, + editTableName: { + + }, formList: [], tableHeader: [], tabsForm: [{ @@ -180,7 +195,7 @@ export default { }, async created () { await this.getSearchList() - await this.getFormList() + // await this.getFormList() await this.getTableHeader() this.getTableData() this.pageLoading = true @@ -215,10 +230,18 @@ export default { handleClick (tab, event) { console.log(tab, event) }, - handleEdit (row) { + async handleLook (row) { + this.disabled = true + await this.getFormList() this.getrowInfo(row.icResiUserId) }, - handleAdd () { + async handleEdit (row) { + this.disabled = false + await this.getFormList() + this.getrowInfo(row.icResiUserId) + }, + async handleAdd () { + await this.getFormList() this.dialogVisible = true }, async handleChangeGroup (val) { @@ -251,30 +274,29 @@ export default { if (hasT) this.tabsList.splice(i, 1) } }, - handleSUbmit () { - console.log('baseform', this.$refs.baseForm.handleForm()) + formetForm () { 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({ @@ -282,12 +304,10 @@ export default { supportAdd: item.supportAdd, tableName: name }) - // console.log('hash[name]0000---', hash[name], res) } }) // 多个list合并成一个list子集 res.forEach(item => { - // console.log('arrr777-----sub', item) let _form = {} item.list.forEach(n => { _form = { ..._form, ...n } @@ -297,12 +317,45 @@ export default { list: item.supportAdd ? [...item.list] : [{ ..._form }] }) }) - // console.log('arrr999-----sub', finalArr) - this.submitAdd(finalArr) + return finalArr + }, + async handleEditSUbmit () { + const arr = await this.formetForm() + this.submitEdit(arr) + }, + async handleSUbmit () { + const arr = await this.formetForm() + this.submitAdd(arr) + }, + handleDel (row) { + let params = { + formCode: 'resi_base_info', + icResiUserId: row.icResiUserId + } + this.$http + .post('/epmetuser/icresiuser/delete', params) + .then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg) + } else { + this.$message.success('删除成功') + this.getTableData() + } + }) + .catch(() => { + return this.$message.error('网络错误') + }) }, 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 +375,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 +384,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' }) @@ -353,7 +427,7 @@ export default { conditions: this.conditions } this.$http - .post('/data/aggregator/icresiuser/listresi', params) + .post('/epmetuser/icresiuser/listresi', params) .then(({ data: res }) => { if (res.code !== 0) { return this.$message.error(res.msg) @@ -372,14 +446,18 @@ export default { icResiUserId: id } this.$http - .post('/data/aggregator/icresiuser/detail', params) + .post('/epmetuser/icresiuser/detail', params) .then(({ data: res }) => { 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 +467,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 +535,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 +551,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(() => { @@ -537,6 +615,7 @@ export default { } .resi-card-table { .btn-color-del { + margin-left: 10px; color: rgba(213, 16, 16, 1); } .btn-color-edit {