安虹睿 2 days ago
parent
commit
c018c2361b
  1. 141
      Web/src/components/ediTtablePage/index.vue

141
Web/src/components/ediTtablePage/index.vue

@ -51,14 +51,35 @@
</el-select>
</el-form-item>
<el-form-item>
<el-button
v-for="(btn,btn_key) in props.searchButtons"
:key="btn_key"
:icon="state.searchBtnOptions[btn].icon"
v-auth="state.searchBtnOptions[btn].sAuth || props.apiName + state.searchBtnOptions[btn].auth"
:type="state.searchBtnOptions[btn].type"
@click="searchBtnHandle(btn)"
>{{state.searchBtnOptions[btn].label}}</el-button>
<div style="margin-right:10px" v-for="(btn,btn_key) in props.searchButtons" :key="btn_key">
<!-- 导出 -->
<el-dropdown
v-auth="(props.authName || props.apiName) + state.searchBtnOptions[btn].auth"
:hide-on-click="false"
v-if="state.searchBtnOptions[btn].auth == ':export'"
>
<el-button
:icon="state.searchBtnOptions[btn].icon"
:type="state.searchBtnOptions[btn].type">
{{state.searchBtnOptions[btn].label}}
<el-icon class="el-icon--right"><arrow-down /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="exportHandle()">按条件导出当前页</el-dropdown-item>
<el-dropdown-item divided @click="exportHandle(true)">按条件导出全部</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- 其他按钮 -->
<el-button
v-else
:icon="state.searchBtnOptions[btn].icon"
v-auth="(props.authName || props.apiName) + state.searchBtnOptions[btn].auth"
:type="state.searchBtnOptions[btn].type"
@click="searchBtnHandle(btn)"
>{{state.searchBtnOptions[btn].label}}</el-button>
</div>
</el-form-item>
</el-form>
<!-- 右侧按钮(保存页面) -->
@ -328,7 +349,7 @@
type: Boolean,
default: false
},
// readState=true
// /readState=true
// 使,=
editDisabledConfig:{
type: Object,
@ -494,7 +515,7 @@
}
//
function getPageParams(){
function getPageParams(pageSize){
let _filters = []
if(props.hideSearch){
_filters = props.searchFilter
@ -502,7 +523,7 @@
for(let i in props.searchFilter){
let _item = props.searchOptions.filter(item=>item.prop == i)
let _type = (_item && _item.length > 0) ? _item[0].type : null
if(props.searchFilter[i] || props.searchFilter[i] == 0){
if((props.searchFilter[i] || props.searchFilter[i] == 0) && props.searchFilter[i] != ""){
//
if(_type == 'datetimerange'){
_filters.push(
@ -541,7 +562,7 @@
}
let _pageParams = getPageParamsForFilter({
pageNumber:state.pager.page,
pageSize:state.pager.pageSize,
pageSize:pageSize || state.pager.pageSize,
sortBy:state.sortFilter.sortBy,
isAscending:state.sortFilter.isAscending,
condition:{
@ -552,7 +573,7 @@
}
//
function getTableData(page) {
function getTableData(page,callback) {
state.stage_indexs = []
state.currentDetailId = null
state.headerInfoData = []
@ -567,6 +588,7 @@
state.tableData = resp.data.data
state.stage_tableData = JSON.parse(JSON.stringify(resp.data.data))
state.pager.total = resp.data.totalCount
if(callback)callback(resp)
})
.catch(err=>{ElMessage.error('数据获取失败!')})
.finally(() => (state.loading = false))
@ -580,12 +602,32 @@
state.tableData = resp.data.data
state.stage_tableData = JSON.parse(JSON.stringify(resp.data.data))
state.pager.total = resp.data.totalCount
if(callback)callback(resp)
})
.catch(err=>{ElMessage.error('数据获取失败!')})
.finally(() => (state.loading = false))
}
}
//
function exportHandle(isAll){
state.loading = true
//
getTableData(1,(res=>{
let _params = getPageParams()
if(isAll){_params = getPageParams(res.data.totalCount)}
postCommonExport(props.apiName,_params)
.then((res) => {
let _str = isAll ? '全部' : '当页'
downloadByData(res.data,route.meta.title+`_按条件导出${_str}.xlsx`)
})
.catch(err=>{ElMessage.error('操作失败!')})
.finally(() => (state.loading = false))
}))
}
const importPopRef = ref()
//
function searchBtnHandle(btn){
@ -609,19 +651,10 @@
importPopRef.value.open()
})
}
//
else if (btn == 'export'){
beforClearEdit().then(() => {
state.loading = true
getTableData()//
postCommonExport(props.apiName,getPageParams())
.then((res) => {
downloadByData(res.data,route.meta.title+'.xlsx')
})
.catch(err=>{ElMessage.error('操作失败!')})
.finally(() => (state.loading = false))
})
}
//
// else if (btn == 'export'){
// exportHandle()
// }
//
else if (btn == 'custominvoke'){
beforClearEdit().then(() => {
@ -759,8 +792,29 @@
}
//
function checkDisableByRowRule(row){
function checkDisableByRowRule(row,item){
let hasDisable = false
// editDisabledConfig
for(let i = 0;i<props.editDisabledConfig.length;i++){
if(row[props.editDisabledConfig[i].prop] == props.editDisabledConfig[i].ruleValue){
hasDisable = true
break
}
}
//
//
//
if(!hasDisable && row.feedbackResults == '0' && item.prop != 'feedbackResults'){
hasDisable = true
}
return hasDisable
}
//
function checkDisableCheckByRowRule(row){
// editDisabledConfig
let hasDisable = false
// editDisabledConfig
for(let i = 0;i<props.editDisabledConfig.length;i++){
if(row[props.editDisabledConfig[i].prop] == props.editDisabledConfig[i].ruleValue){
hasDisable = true
@ -782,7 +836,7 @@
return true
}
//
return checkDisableByRowRule(row)
return checkDisableByRowRule(row,item)
}
// table
@ -791,8 +845,8 @@
let _auth = auths.hasPermission(props.apiName+':outputMany')
//
let _idEditData = checkPageEditList()
// ()
let checkRow = checkDisableByRowRule(row)
//
let checkRow = checkDisableCheckByRowRule(row)
return _auth && (!_idEditData || _idEditData.length <= 0) && !checkRow
}
@ -815,7 +869,8 @@
_colums.forEach(item=>{
state.headerInfoData.push({
label:item.title,
value:res.data[item.prop]
value:res.data[item.prop],
prop:item.prop
})
})
})
@ -828,6 +883,30 @@
if(state.stage_indexs.indexOf(scope.$index) < 0){
state.stage_indexs.push(scope.$index)
}
//
//
if(item.prop == "feedbackResults"){
//
if(scope.row.feedbackResults == '0'){
//
scope.row.ventureType = ""
scope.row.ventureSpecific = ""
scope.row.measures = ""
// ()
// prop
let _tableColums = props.tableColumns || apiTableColumns[props.apiName]
for(let prop in scope.row){
let _item = _tableColums.filter(item=>item.prop == prop)
if(_item && _item.length > 0 && _item[0].relevProp){
let _relevProp = _item[0].relevProp
let _list = state.headerInfoData.filter(item=>item.prop == _relevProp)
if(_list && _list.length>0){
scope.row[prop] = _list[0].value
}
}
}
}
}
}
//

Loading…
Cancel
Save