Files
foton-laws-system-front/src/pages/svpps/index.vue
T
2021-05-25 18:06:45 +08:00

326 lines
8.4 KiB
Vue

<template>
<div style="height: 100%;background-color: #fff;position: relative;">
<div style="height: 100%;padding-bottom: 20px;" class="SVPPS">
<!--<table-tools-bar>-->
<!-- <div slot="left">-->
<!-- <div class="search-area">-->
<!-- <el-form :model="searchForm" inline class="label-input-form">-->
<!-- <el-form-item :label="$t('m.standardNumAndName')" prop="standardKey" class="search-item">-->
<!-- <el-input-->
<!-- v-model="searchForm.standardKey"-->
<!-- :placeholder="$t('m.standardNumAndNameTips')"-->
<!-- clearable-->
<!-- :maxlength="100"/>-->
<!-- </el-form-item>-->
<!-- <el-form-item class="search-item btn-box">-->
<!-- <el-button-->
<!-- icon="el-icon-search"-->
<!-- type="primary"-->
<!-- class="common-button-primary"-->
<!-- round-->
<!-- @click="searchBtn"-->
<!-- ></el-button>-->
<!-- </el-form-item>-->
<!-- <el-form-item class="search-item btn-box">-->
<!-- <el-button-->
<!-- class="common-button-default"-->
<!-- icon="el-icon-refresh-left"-->
<!-- round-->
<!-- @click="resetSearchForm">{{$t('m.clearQuery')}}</el-button>-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<!-- </div>-->
<!-- </div>-->
<!--</table-tools-bar>-->
<div class="content">
<loading :loading="tableDataLoading">{{$t('m.dataProcessing')}}</loading>
<el-table
border
ref="selection"
:data="tableList"
tooltip-effect="dark"
style="width: 100%;"
:header-cell-style="{background: '#e8e8e8', color: '#333333', fontSize: '16px',
fontWeight: 'bold', height: '48px'}"
row-key="id"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
:load="loadTableChildren"
lazy
>
<!--<el-table-column-->
<!-- type="index"-->
<!-- width="55"-->
<!-- label="序号"-->
<!-- align="center">-->
<!--</el-table-column>-->
<el-table-column
prop="fnum"
label="一级编码"
>
</el-table-column>
<el-table-column
prop="snum"
label="二级编码">
</el-table-column>
<el-table-column
prop="tnum"
label="三级编码">
</el-table-column>
<el-table-column
prop="svppsCode"
label="SVPPS编码">
</el-table-column>
<el-table-column
prop="svppsEnName"
label="SVPPS英文名称">
</el-table-column>
<el-table-column
prop="svppsCnName"
label="SVPPS中文名称">
</el-table-column>
</el-table>
</div>
<!--<pagination :total="total" @pageChange="pageChange" @pageSizeChange="pageSizeChange"></pagination>-->
<!--<div class="btn-group">-->
<!-- <el-button-->
<!-- round-->
<!-- class="common-button-primary"-->
<!-- type="primary"-->
<!-- icon="el-icon-check"-->
<!-- @click="handleSubmit"-->
<!-- >确定</el-button>-->
<!-- <el-button-->
<!-- round-->
<!-- class="common-button-default"-->
<!-- icon="el-icon-close"-->
<!-- @click="handleCancel">取消</el-button>-->
<!--</div>-->
</div>
</div>
</template>
<script>
export default {
name: 'StandardSelect',
props: ['listId'],
data () {
return {
tableDataLoading: false,
total: 0,
selectRoleId: '',
searchForm: {
standardKey: '',
},
pageNo: 1,
pageSize: 10,
tableList: [],
}
},
methods: {
// 根据条件查询信息
searchBtn () {
this.resetPageNo()
this.queryTablePage()
},
/**
* 重置搜索表单并重新加载表格数据
*/
resetSearchForm () {
this.searchForm.standardKey = ''
// this.resetSearchForm()
this.queryTablePage()
},
pageChange (page) {
this.pageNo = page
this.queryTablePage()
},
pageSizeChange () {
this.queryTablePage()
},
resetPageNo() {
this.pageNo = 1
},
// 查询、加载表格
queryTablePage (pId = '') {
const formData = {
pid: pId,
level: 1,
// standNumber: this.searchForm.standardKey
}
this.$http.get('lawss/otSvpps/selectTree',
formData,
{
_this: this,
loading: 'tableDataLoading'
},
res => {
Promise.all(res.data.map(async item => {
const children = await this.queryTableChildrenPage(item.id)
// console.log(children)
return {
...item,
children,
hasChildren: children.length > 0
}
})).then(values => {
this.tableList = [...values]
})
// this.tableList = res.data.map(async item => {
// const children = await this.queryTableChildrenPage(item.id)
// console.log(children)
// return {
// ...item,
// children
// }
// })
// this.total = res.data.count
}, e => {})
},
loadTableChildren(tree, treeNode, resolve) {
console.log(tree, treeNode, resolve)
Promise.all(tree.children.map(async item => {
const children = await this.queryTableChildrenPage(item.id)
// console.log(children)
return {
...item,
children,
hasChildren: children.length > 0
}
})).then(values => {
resolve(values)
})
// this.queryTableChildrenPage(tree.id, tree)
},
// 查询、加载表格
queryTableChildrenPage (pId = 'c443d9eede8d442da6d7', parent) {
const formData = {
pid: pId,
level: 1,
// standNumber: this.searchForm.standardKey
}
return new Promise((resolve, reject) => {
this.$http.get('lawss/otSvpps/selectTree',
formData,
{
_this: this,
},
res => {
resolve(res.data)
// this.total = res.data.count
}, e => {
reject(e)
})
})
},
// 点击查看
handlePreview (item) {
console.log('item', item)
let routeUrl = this.$router.resolve({
name: 'OtherStandardDetails',
params: {
id: item.id,
pageType: 'INLAND_STAND'
}
})
window.open(routeUrl.href, '_blank')
},
handleSubmit() {
const selection = this.$refs['selection'].selection
console.log(selection)
this.postListToServer(selection).then(res => {
// 关闭当前区域
this.handleCancel()
})
},
handleCancel() {
this.$emit('close')
},
postListToServer(selection) {
const list = selection.map(item => {
let standNum = ''
if (item.standYear) {
standNum = `${item.standSortShow} ${item.standNumber}-${item.standYear}`
} else {
standNum = `${item.standSortShow} ${item.standNumber}`
}
return {
country: item.countryShow,
standNum: standNum,
standName: item.standName,
standId: item.id,
standType: item.standType
}
})
const formData = {
compareBaseId: this.listId,
list: list
}
return new Promise((resolve, reject) => {
this.$http.postData('lawss/SarStandCompareList/save', formData, {
_this: this
}, res => {
if (res.ok) {
resolve(res)
} else {
reject(res)
}
}, err => {
reject(err)
})
})
}
},
created() {
this.queryTablePage()
}
}
</script>
<style lang="less" scoped>
.SVPPS{
height: 100%;
display: flex;
flex-direction: column;
.content {
padding: 0 10px;
flex: auto;
//height: calc(~'100% - 55px - 50px');
}
}
.el-divider-low {
margin: 15px 0;
}
.search-area {
padding: 0;
}
.btn-group {
position: absolute;
bottom: 20px;
right: 20px;
background: #ffffff;
z-index: 999;
}
</style>