diff --git a/src/views/components/resiSearch.vue b/src/views/components/resiSearch.vue index 41c00cf2..925367a1 100644 --- a/src/views/components/resiSearch.vue +++ b/src/views/components/resiSearch.vue @@ -134,7 +134,7 @@ range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" - class="resi-cell-input" + class="resi-cell--daterange" size="small" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @@ -588,6 +588,7 @@ export default { display: flex; align-items: center; .resi-cell-label { + flex-shrink: 0; width: 70px; box-sizing: border-box; margin-right: 15px; @@ -602,6 +603,9 @@ export default { .resi-cell-input { width: 180px; } + .resi-cell--daterange { + width: 100%; + } .resi-cell-select { width: 180px; box-sizing: border-box; diff --git a/src/views/modules/base/resi.vue b/src/views/modules/base/resi.vue index c5251801..fcd7ed4f 100644 --- a/src/views/modules/base/resi.vue +++ b/src/views/modules/base/resi.vue @@ -1,11 +1,19 @@ @@ -129,7 +198,7 @@ export default { resiForm, editResi }, - data () { + data() { return { tableLoading: false, btnLoading: false, @@ -150,15 +219,14 @@ export default { BUILD_ID: '', HOME_ID: '' }, - editTableName: { - - }, + editTableName: {}, + formName: '', formList: [], tableHeader: [], tabsList: [] } }, - async created () { + async created() { await this.getSearchList() // await this.getFormList() await this.getTableHeader() @@ -167,38 +235,38 @@ export default { console.log('storeoooo----0000', this.$store) }, methods: { - filterEdit (id) { + filterEdit(id) { const { user } = this.$store.state return id === user.agencyId }, - handleSizeChange (val) { + handleSizeChange(val) { console.log(`每页 ${val} 条`) this.pageSize = val this.getTableData() }, - handleCurrentChange (val) { + handleCurrentChange(val) { console.log(`当前页: ${val}`) this.currentPage = val this.getTableData() }, - handleFilterSpan (row, item) { + handleFilterSpan(row, item) { let _val = '' if (item.itemType === 'radio' && item.options.length > 0) { - item.options.forEach(n => { + item.options.forEach((n) => { if (n.value === row[item.columnName]) _val = n.label }) } return _val || row[item.columnName] }, - handleSearch (val) { + handleSearch(val) { console.log('searchhh--', val) this.currentPage = 1 this.conditions = val this.getTableData() }, // 下载文件 - download (data, fileName) { - console.log('data',data) + download(data, fileName) { + console.log('data', data) if (!data) { return } @@ -206,29 +274,28 @@ export default { var csvData = new Blob([data]) if (window.navigator && window.navigator.msSaveOrOpenBlob) { - window.navigator.msSaveOrOpenBlob(csvData, fileName); + window.navigator.msSaveOrOpenBlob(csvData, fileName) } // for Non-IE (chrome, firefox etc.) else { - var a = document.createElement('a'); - document.body.appendChild(a); - a.style = 'display: none'; - var url = window.URL.createObjectURL(csvData); - a.href = url; - a.download = fileName; - a.click(); - a.remove(); - window.URL.revokeObjectURL(url); + var a = document.createElement('a') + document.body.appendChild(a) + a.style = 'display: none' + var url = window.URL.createObjectURL(csvData) + a.href = url + a.download = fileName + a.click() + a.remove() + window.URL.revokeObjectURL(url) } - }, - handleExport () { + handleExport() { let params = { formCode: 'resi_base_info', conditions: this.conditions } - // .post('epmetuser/icresiuser/exportExcel', params) + // .post('epmetuser/icresiuser/exportExcel', params) this.$http({ url: 'epmetuser/icresiuser/exportExcel', method: 'post', @@ -237,46 +304,47 @@ export default { headers: { 'Content-Type': 'application/x-download' } }, responseType: 'blob' - }).then(({ data: res }) => { + }) + .then(({ data: res }) => { // var headerData = res.headers // this.download(res, '人员数据.xlsx') - console.log('res',res) + console.log('res', res) const fileName = '人员数据.xlsx' - let blob = new Blob([res], {type: 'application/vnd.ms-excel'}) - var url = window.URL.createObjectURL(blob); - var aLink = document.createElement("a"); - aLink.style.display = "none"; - aLink.href = url; - aLink.setAttribute("download", fileName); - document.body.appendChild(aLink); - aLink.click(); - document.body.removeChild(aLink); //下载完成移除元素 - window.URL.revokeObjectURL(url); //释放掉blob对象 + let blob = new Blob([res], { type: 'application/vnd.ms-excel' }) + var url = window.URL.createObjectURL(blob) + var aLink = document.createElement('a') + aLink.style.display = 'none' + aLink.href = url + aLink.setAttribute('download', fileName) + document.body.appendChild(aLink) + aLink.click() + document.body.removeChild(aLink) //下载完成移除元素 + window.URL.revokeObjectURL(url) //释放掉blob对象 // window.location.href = res.data }) - .catch(err => { + .catch((err) => { console.log('获取导出情失败', err) return this.$message.error('网络错误') }) }, - handleClick (tab, event) { + handleClick(tab, event) { console.log(tab, event) }, - async handleLook (row) { + async handleLook(row) { this.disabled = true await this.getFormList() this.getrowInfo(row.icResiUserId) }, - async handleEdit (row) { + async handleEdit(row) { this.disabled = false await this.getFormList('edit') await this.getrowInfo(row.icResiUserId) }, - async handleAdd () { + async handleAdd() { await this.getFormList() this.dialogVisible = true }, - async handleChangeGroup (val) { + async handleChangeGroup(val) { console.log('changeguoprrrrr----', val) let { childGroup, value } = val let hasT = false @@ -291,9 +359,9 @@ export default { if (value === 1 || value === '1') { // console.log('changegroup----999', value) if (!hasT) { - childGroup.itemList.forEach(async item => { + childGroup.itemList.forEach(async (item) => { if (item.optionSourceType === 'remote') { - await this.getOptionsList(item.optionSourceValue).then(res => { + await this.getOptionsList(item.optionSourceValue).then((res) => { item.options = res }) // console.log('') @@ -306,17 +374,19 @@ export default { if (hasT) this.tabsList.splice(i, 1) } }, - formetForm () { + formetForm() { const _baseForm = this.$refs.baseForm.handleForm() let arr = [] if (_baseForm.length === 0) return false - arr.push([ ..._baseForm ]) - this.tabsList.forEach(item => { - arr.push([ ...this.$refs['group' + item.groupId][0].handleForm() ]) + arr.push([..._baseForm]) + this.tabsList.forEach((item) => { + arr.push([...this.$refs['group' + item.groupId][0].handleForm()]) + }) + let arr2 = arr.reduce(function (a, b) { + return a.concat(b) }) - let arr2 = arr.reduce(function (a, b) { return a.concat(b) }) let noChange = true - arr2.forEach(item => { + arr2.forEach((item) => { if (item.list.length !== 0) noChange = false }) console.log('arr2', arr2) @@ -344,11 +414,12 @@ export default { }) console.log('res', res) // 多个list合并成一个list子集 - res.forEach(item => { + res.forEach((item) => { let _form = {} - item.list.length > 0 && item.list.forEach(n => { - _form = { ..._form, ...n } - }) + item.list.length > 0 && + item.list.forEach((n) => { + _form = { ..._form, ...n } + }) if (item.list.length > 0) { finalArr.push({ tableName: item.tableName, @@ -359,15 +430,15 @@ export default { console.log('finalArr', finalArr) return finalArr }, - async handleEditSUbmit () { + async handleEditSUbmit() { const arr = await this.formetForm() if (arr) this.submitEdit(arr) }, - async handleSUbmit () { + async handleSUbmit() { const arr = await this.formetForm() if (arr) this.submitAdd(arr) }, - handleDel (row) { + handleDel(row) { let params = { formCode: 'resi_base_info', icResiUserId: row.icResiUserId @@ -386,24 +457,24 @@ export default { return this.$message.error('网络错误') }) }, - handleFormatUrl (url) { + handleFormatUrl(url) { return url.includes('?') }, - handlerEditCancle () { + handlerEditCancle() { this.$refs.baseForm.resetForm() - this.tabsList.forEach(item => { + this.tabsList.forEach((item) => { this.$refs['group' + item.groupId][0].resetForm() }) this.dialogEditVisible = false }, - handlerCancle () { + handlerCancle() { this.$refs.baseForm.resetForm() - this.tabsList.forEach(item => { + this.tabsList.forEach((item) => { this.$refs['group' + item.groupId][0].resetForm() }) this.dialogVisible = false }, - async submitAdd (arr) { + async submitAdd(arr) { this.btnLoading = true await this.$http .post('/epmetuser/icresiuser/add', arr) @@ -414,7 +485,7 @@ export default { this.$message.success('提交成功') // this.$refs[formName].resetFields(); this.$refs.baseForm.resetForm() - this.tabsList.forEach(item => { + this.tabsList.forEach((item) => { this.$refs['group' + item.groupId][0].resetForm() }) this.getTableData() @@ -424,21 +495,20 @@ export default { .catch(() => { return this.$message.error('网络错误') }) - this.btnLoading = false + this.btnLoading = false }, - async submitEdit (arr) { + async submitEdit(arr) { this.btnLoading = true await 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.tabsList.forEach((item) => { this.$refs['group' + item.groupId][0].resetForm() }) this.getTableData() @@ -448,11 +518,13 @@ export default { .catch(() => { return this.$message.error('网络错误') }) - this.btnLoading = false + this.btnLoading = false }, - getTableHeader () { + getTableHeader() { this.$http - .post('/oper/customize/icform/tableheaders', { formCode: 'resi_base_info' }) + .post('/oper/customize/icform/tableheaders', { + formCode: 'resi_base_info' + }) .then(({ data: res }) => { if (res.code !== 0) { return this.$message.error(res.msg) @@ -464,7 +536,7 @@ export default { return this.$message.error('网络错误') }) }, - async getTableData () { + async getTableData() { this.tableLoading = true let params = { formCode: 'resi_base_info', @@ -485,9 +557,9 @@ export default { .catch(() => { return this.$message.error('网络错误') }) - this.tableLoading = false + this.tableLoading = false }, - getrowInfo (id) { + getrowInfo(id) { let params = { formCode: 'resi_base_info', icResiUserId: id @@ -505,7 +577,7 @@ export default { for (let n in list) { this.editForm[n] = list[n] } - this.formList.forEach(item => { + this.formList.forEach((item) => { if (item.childGroup && info[item.childGroup.tableName]) { // let _info = info[item.childGroup.tableName] // item.childGroup.itemList.forEach(n => { @@ -516,7 +588,7 @@ export default { item.columnValue = list[item.columnName] item.ID = list.ID }) - this.tabsList.forEach(item => { + this.tabsList.forEach((item) => { let _info = info[item.tableName] if (item.supportAdd) { // console.log('tabsList---333', item.label) @@ -527,7 +599,7 @@ export default { // console.log('mutiList----555' + index, mutiList, _list) mutiList.splice(index, 0, { row: index, - itemList: _list.map(m => { + itemList: _list.map((m) => { // console.log('itemList---item' + index, m) return { ...m, @@ -542,7 +614,7 @@ export default { item.mutiList = mutiList } else { if (_info) { - item.itemList.forEach(n => { + item.itemList.forEach((n) => { n.ID = _info[0].ID n.columnValue = _info[0][n.columnName] }) @@ -558,7 +630,7 @@ export default { return this.$message.error('网络错误') }) }, - async getOptionsList (url) { + async getOptionsList(url) { let options = [] // console.log('getOptionsList----', url) await this.$http @@ -575,18 +647,21 @@ export default { }) return options }, - getSearchList () { + getSearchList() { this.$http - .post('/oper/customize/icform/conditionlist', { formCode: 'resi_base_info', dynamic: true }) + .post('/oper/customize/icform/conditionlist', { + formCode: 'resi_base_info', + dynamic: true + }) .then(({ data: res }) => { if (res.code !== 0) { return this.$message.error(res.msg) } else { // console.log('获取查询详情成功', res.data) this.searchList = res.data - res.data.forEach(item => { + res.data.forEach((item) => { if (item.optionSourceType === 'remote') { - this.getOptionsList(item.optionSourceValue).then(res => { + this.getOptionsList(item.optionSourceValue).then((res) => { item.options = res }) // console.log('') @@ -598,30 +673,36 @@ export default { return this.$message.error('网络错误') }) }, - async getFormList (type) { + async getFormList(type) { await this.$http - .post('/oper/customize/icform/getcustomerform', { formCode: 'resi_base_info', dynamic: true }) + .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('获取详情成功getFormList') - let { itemList, groupList } = res.data + let { itemList, groupList, formName } = res.data + this.formName = formName this.activeName = 'group' + res.data.groupList[0].groupId if (type !== 'edit') { - itemList.forEach(async item => { + itemList.forEach(async (item) => { if (item.optionSourceType === 'remote') { - await this.getOptionsList(item.optionSourceValue).then(res => { - item.options = res - }) + await this.getOptionsList(item.optionSourceValue).then( + (res) => { + item.options = res + } + ) } }) } - groupList.forEach(item => { - item.itemList.forEach(async n => { + groupList.forEach((item) => { + item.itemList.forEach(async (n) => { n.tableName = item.tableName if (n.optionSourceType === 'remote' && type !== 'edit') { - await this.getOptionsList(n.optionSourceValue).then(res => { + await this.getOptionsList(n.optionSourceValue).then((res) => { n.options = res }) } @@ -652,20 +733,21 @@ export default { font-weight: 500; color: #666666; line-height: 20px; - background: #EBECF1; + background: #ebecf1; border-radius: 2px; } - .el-tabs__nav-wrap::after, .el-tabs__active-bar { + .el-tabs__nav-wrap::after, + .el-tabs__active-bar { display: none; } - .el-tabs__nav-next, .el-tabs__nav-prev { + .el-tabs__nav-next, + .el-tabs__nav-prev { line-height: 20px; } - } .resi-table { .el-button--text { - text-decoration: underline; + text-decoration: underline; } .btn-color-del { margin-left: 10px; @@ -711,5 +793,4 @@ export default { margin-top: 20px; text-align: center; } -