Browse Source

111

shibei_master
13176889840 4 years ago
parent
commit
1915fd7d08
  1. 6
      src/views/components/resiSearch.vue
  2. 365
      src/views/modules/base/resi.vue

6
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;

365
src/views/modules/base/resi.vue

@ -1,11 +1,19 @@
<template>
<div v-if="pageLoading">
<resi-search v-if="searchList.length > 0" ref="resiSearch" :form-list="searchList" @search="handleSearch" />
<resi-search
v-if="searchList.length > 0"
ref="resiSearch"
:form-list="searchList"
@search="handleSearch"
/>
<el-card class="resi-card-table">
<div class="resi-row-btn">
<el-button type="success" size="small" @click="handleAdd">新增</el-button>
<el-button type="warning" size="small" @click="handleExport">导出</el-button>
<el-button type="success" size="small" @click="handleAdd"
>新增</el-button
>
<el-button type="warning" size="small" @click="handleExport"
>导出</el-button
>
<!-- <el-button type="primary" size="small">下载人口模板</el-button> -->
<!-- <el-button type="danger" size="small">导入人口数据</el-button> -->
</div>
@ -14,11 +22,9 @@
v-loading="tableLoading"
border
style="width: 100%"
class="resi-table">
<el-table-column
type="index"
align="center"
width="50">
class="resi-table"
>
<el-table-column type="index" align="center" width="50">
</el-table-column>
<el-table-column
v-for="item in tableHeader"
@ -26,28 +32,42 @@
:prop="item.columnName"
:label="item.label"
align="center"
:width="item.itemType === 'radio' ? 80 : 180">
:width="item.itemType === 'radio' ? 80 : 180"
>
<template slot-scope="scope">
<span>{{ handleFilterSpan(scope.row, item)}}</span>
<span>{{ handleFilterSpan(scope.row, item) }}</span>
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
align="center"
width="120">
<el-table-column fixed="right" label="操作" align="center" width="120">
<template slot-scope="scope">
<el-button @click="handleLook(scope.row)" type="text" size="small" class="btn-color-look">查看</el-button>
<el-button
@click="handleLook(scope.row)"
type="text"
size="small"
class="btn-color-look"
>查看</el-button
>
<template v-if="filterEdit(scope.row.ORG_ID)">
<el-button @click="handleEdit(scope.row)" type="text" size="small" class="btn-color-edit">编辑</el-button>
<el-button
@click="handleEdit(scope.row)"
type="text"
size="small"
class="btn-color-edit"
>编辑</el-button
>
<el-popconfirm
title="删除之后无法回复,确认删除?"
@onConfirm="handleDel(scope.row)"
>
<el-button slot="reference" type="text" size="small" class="btn-color-del">删除</el-button>
<el-button
slot="reference"
type="text"
size="small"
class="btn-color-del"
>删除</el-button
>
</el-popconfirm>
</template>
</template>
</el-table-column>
</el-table>
@ -59,63 +79,112 @@
:page-sizes="[20, 50, 100, 200]"
:page-size="pageSize"
layout="sizes, prev, pager, next"
:total="total">
:total="total"
>
</el-pagination>
</div>
</el-card>
<el-dialog
title="新增"
:title="formName"
:visible.sync="dialogVisible"
width="80%"
append-to-body
:close-on-click-modal="false"
:before-close="handlerCancle">
<resi-form v-if="dialogVisible" ref="baseForm" :fixed="true" :form-list="formList" @changegroup="handleChangeGroup" />
<div v-if="dialogVisible" class="resi-other">
:before-close="handlerCancle"
>
<resi-form
v-if="dialogVisible"
ref="baseForm"
:fixed="true"
:form-list="formList"
@changegroup="handleChangeGroup"
/>
<div v-if="dialogVisible" class="resi-other">
<div class="resi-other-title">其他</div>
<div class="tabs-other-info">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane v-for="item in tabsList" :key="item.columnName"
:label="item.label" :name="'group' + item.groupId">
<resi-form :ref="'group' + item.groupId" :columns="3" :support-add="item.supportAdd"
:form-id="item.columnName" :form-list=" item.itemList" />
<el-tab-pane
v-for="item in tabsList"
:key="item.columnName"
:label="item.label"
:name="'group' + item.groupId"
>
<resi-form
:ref="'group' + item.groupId"
:columns="3"
:support-add="item.supportAdd"
:form-id="item.columnName"
:form-list="item.itemList"
/>
</el-tab-pane>
</el-tabs>
</div>
</div>
<div class="resi-btns">
<el-button size="small" @click="handlerCancle">取消</el-button>
<el-button type="primary" size="small" :loading="btnLoading" @click="handleSUbmit">提交</el-button>
<el-button
type="primary"
size="small"
:loading="btnLoading"
@click="handleSUbmit"
>提交</el-button
>
</div>
</el-dialog>
<el-dialog
title="编辑"
<el-dialog
:title="formName"
:visible.sync="dialogEditVisible"
width="80%"
append-to-body
:close-on-click-modal="false"
:before-close="handlerEditCancle">
<edit-resi v-if="dialogEditVisible" ref="baseForm" :disabled="disabled" :form-info="editForm" :fixed="true" :form-list="formList" @changegroup="handleChangeGroup" />
<div v-if="dialogEditVisible" class="resi-other">
:before-close="handlerEditCancle"
>
<edit-resi
v-if="dialogEditVisible"
ref="baseForm"
:disabled="disabled"
: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">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane v-for="item in tabsList" :key="item.columnName"
:label="item.label" :name="'group' + item.groupId">
<edit-resi :ref="'group' + item.groupId" :columns="3" :support-add="item.supportAdd"
:form-id="item.columnName" :muti-list="item.mutiList" :form-list=" item.itemList" :disabled="disabled" />
<el-tab-pane
v-for="item in tabsList"
:key="item.columnName"
:label="item.label"
:name="'group' + item.groupId"
>
<edit-resi
:ref="'group' + item.groupId"
:columns="3"
:support-add="item.supportAdd"
:form-id="item.columnName"
:muti-list="item.mutiList"
:form-list="item.itemList"
:disabled="disabled"
/>
</el-tab-pane>
</el-tabs>
</div>
</div>
<div class="resi-btns">
<el-button size="small" @click="handlerEditCancle">取消</el-button>
<el-button v-if="!disabled" type="primary" size="small" :loading="btnLoading" @click="handleEditSUbmit">提交</el-button>
<el-button
v-if="!disabled"
type="primary"
size="small"
:loading="btnLoading"
@click="handleEditSUbmit"
>提交</el-button
>
</div>
</el-dialog>
</div>
</template>
@ -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)
// listlist
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;
}
</style>

Loading…
Cancel
Save