321 lines
8.9 KiB
Java
321 lines
8.9 KiB
Java
<template>
|
|
<div style="height: 100%">
|
|
<div class="box">
|
|
<a-table
|
|
class="table"
|
|
rowKey="id"
|
|
:row-selection="{ fixed: true, selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
|
:pagination="false"
|
|
:scroll="{x: true}"
|
|
:data-source="dataSource"
|
|
:loading="loading"
|
|
:columns="columns"
|
|
@change="tableOnChange"
|
|
>
|
|
<span slot="showContent" slot-scope="text, record" class="item-solt">
|
|
<!-- <a-tooltip placement="top" class="item-content-tooltip" >-->
|
|
<!-- <template slot="title" class="item-content-title">-->
|
|
<!-- <span class="item-content-show" v-html="record.iterms_conditions"></span>-->
|
|
<!-- </template>-->
|
|
<span class="content-show" href="javascript:;" @click="showContent(text,record)">{{record.iterms_conditions&&record.iterms_conditions!=='null'?record.iterms_conditions.replace(/<.*?>/ig, ' ') : ''}}</span>
|
|
<!-- </a-tooltip>-->
|
|
</span>
|
|
|
|
<span slot="operation" slot-scope="record" class="operate">
|
|
<a v-for="(ol,index) in OperationList"
|
|
@click="OperationClick(ol,record)">
|
|
<span class="text" v-if="ol.text==$t('edit')" v-has="'split:sarFileSplitItems:update'">
|
|
{{ol.text}}
|
|
</span>
|
|
<span class="text" v-if="ol.text==$t('delete')" v-has="'split:sarFileSplitItems:delete'">
|
|
{{ol.text}}
|
|
</span>
|
|
</a>
|
|
</span>
|
|
<span slot="urlClick" slot-scope="text,record">
|
|
<a class="text" :title="text" @click="urlClick(text)">
|
|
{{text && text.length > 18?text.slice(0,17)+'...':text}}
|
|
</a>
|
|
</span>
|
|
<span slot="detailText" slot-scope="text,record">
|
|
<span class="text" :title="text">
|
|
{{text && text.length > 18?text.slice(0,17)+'...':text}}
|
|
</span>
|
|
</span>
|
|
</a-table>
|
|
</div>
|
|
<div class="page" v-if="dataSource.length > 0">
|
|
<a-pagination
|
|
:show-total="total => $t('total')+` ${total} `+$t('strip')"
|
|
show-quick-jumper
|
|
show-size-changer
|
|
:page-size.sync="pageSize"
|
|
:total="total"
|
|
@change="onChange"
|
|
@showSizeChange="SizeChange"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import eventBUs from '../../common/event'
|
|
import { getAction, postAction } from '@/api/manage'
|
|
|
|
export default {
|
|
name: 'SplitDetailTable',
|
|
props: {
|
|
//接口
|
|
url: {
|
|
type: Object,
|
|
default: {}
|
|
},
|
|
// 操作按钮
|
|
OperationList: {
|
|
type: Array,
|
|
default: []
|
|
},
|
|
flag: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
//是否显示操作;默认不显示
|
|
showAction: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
infoId: {
|
|
type:String,
|
|
default:''
|
|
},
|
|
menuId:{
|
|
type:String,
|
|
default:''
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
jsonBody: [],
|
|
checkboxList: [],
|
|
tableAll: false,
|
|
indeterminate: false,
|
|
columns: [],
|
|
selectedRowKeys: [],
|
|
dataSource: [],
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
total: 0,
|
|
searchParmes: {},
|
|
loading: false,
|
|
orderBy: '1',
|
|
orderByField: ''
|
|
}
|
|
},
|
|
watch:{
|
|
menuId(oldValue,newValue){
|
|
// console.log('oldnew',oldValue,newValue)
|
|
|
|
// this.getTableList()
|
|
}
|
|
},
|
|
mounted() {
|
|
eventBUs.$on('searchQuery', search => {
|
|
Object.keys(search).forEach(res => {
|
|
if (search[res] instanceof Array) {
|
|
search[res] = search[res].join(',')
|
|
}
|
|
})
|
|
this.searchParmes = search
|
|
this.getData()
|
|
this.getTableList()
|
|
})
|
|
eventBUs.$on('searchReset', target => {
|
|
this.searchParmes = {}
|
|
this.selectedRowKeys = []
|
|
this.getData()
|
|
this.getTableList()
|
|
})
|
|
this.getData()
|
|
this.getTableList()
|
|
},
|
|
methods: {
|
|
|
|
getTextWith(text, fontStyle) {
|
|
var canvas = document.createElement('canvas')
|
|
var context = canvas.getContext('2d')
|
|
context.font = fontStyle || '14px' // 设置字体样式
|
|
var dimension = context.measureText(text)
|
|
return dimension.width + 40
|
|
},
|
|
getData() {
|
|
let params = {
|
|
flag: this.flag
|
|
}
|
|
getAction(this.url.tableHeader, params).then((res) => {
|
|
if (res.success) {
|
|
var jsonHead = res.result
|
|
this.columns = []
|
|
// res.db_field_txt
|
|
jsonHead.forEach((res, index) => {
|
|
this.columns.push({
|
|
title: res.db_field_txt,
|
|
dataIndex: res.db_field_name,
|
|
align: 'center',
|
|
ellipsis: true,
|
|
sorter: res.sort
|
|
})
|
|
|
|
if (res.urlClick) {
|
|
this.columns[index].scopedSlots = {
|
|
customRender: 'urlClick'
|
|
}
|
|
}else if(res.db_field_name=='iterms_conditions'){
|
|
this.columns[index].width='500'
|
|
this.columns[index].scopedSlots = {
|
|
customRender: 'showContent'
|
|
}
|
|
}else{
|
|
this.columns[index].scopedSlots = {
|
|
customRender: 'detailText'
|
|
}
|
|
}
|
|
})
|
|
// console.log('this.columns',this.columns)
|
|
let width = 0
|
|
if (this.OperationList.length > 0) {
|
|
for (let i = 0; i < this.OperationList.length; i++) {
|
|
width += this.getTextWith(this.OperationList[i].text)
|
|
}
|
|
}
|
|
if (this.showAction) {
|
|
this.columns.push({
|
|
title: this.$t('operation'),
|
|
align: 'center',
|
|
fixed: 'right',
|
|
width: width,
|
|
scopedSlots: { customRender: 'operation' }
|
|
})
|
|
}
|
|
// console.log('columns',this.columns)
|
|
}
|
|
})
|
|
},
|
|
tableOnChange(pagination, filters, sorter) {
|
|
this.orderBy = sorter.order == 'ascend' ? '1' : '2'
|
|
this.orderByField = sorter.columnKey
|
|
this.getTableList()
|
|
},
|
|
getTableList() {
|
|
// console.log('this.searchParmestable',this.searchParmes)
|
|
let pageNo = JSON.parse(JSON.stringify(this.pageNo))
|
|
let pageSize = JSON.parse(JSON.stringify(this.pageSize))
|
|
let params = {
|
|
...this.searchParmes,
|
|
// orderBy: this.orderBy,
|
|
// orderByField: this.orderByField,
|
|
// info_id:this.infoId,
|
|
// menu_id:this.searchParmes.menuId?this.searchParmes.menuId:this.menuId,
|
|
pageNo: pageNo + '',
|
|
pageSize: pageSize + ''
|
|
}
|
|
if(!params.info_id){
|
|
params.info_id=this.infoId
|
|
}
|
|
// console.log('parmsss',params)
|
|
this.loading = true
|
|
postAction(this.url.tableList, params).then((res) => {
|
|
if (res.success) {
|
|
if (res.result.current > 1 && res.result.records.length == 0) {
|
|
this.pageNo = res.result.current - 1
|
|
this.getTableList()
|
|
return
|
|
}
|
|
this.dataSource = res.result.records
|
|
this.total = res.result.total
|
|
this.loading = false
|
|
} else {
|
|
this.loading = false
|
|
}
|
|
})
|
|
},
|
|
onChange(page, pageSize) {
|
|
this.pageNo = page
|
|
this.getTableList()
|
|
},
|
|
SizeChange(page, pageSize) {
|
|
this.pageNo = 1
|
|
this.pageSize = pageSize
|
|
this.getTableList()
|
|
},
|
|
onSelectChange(value,rows) {
|
|
// console.log('rowwww',value,rows)
|
|
this.selectedRowKeys = value
|
|
this.$emit('onSelectChange', value,rows)
|
|
},
|
|
OperationClick(ol, item) {
|
|
this.$emit(ol.ClickEvent, item)
|
|
},
|
|
detailClick(item, index) {
|
|
this.$emit('detailClick', item)
|
|
},
|
|
showContent(item, index) {
|
|
this.$emit('showContent', item)
|
|
},
|
|
urlClick(item) {
|
|
window.open(item)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="less">
|
|
.table .ant-table-column-title {
|
|
font-weight: bold;
|
|
}
|
|
|
|
.ant-table td {
|
|
white-space: nowrap;
|
|
}
|
|
.split-detail-wrap{
|
|
.table{
|
|
.ant-table-row-cell-break-word{
|
|
span{
|
|
display: block;
|
|
width: inherit;
|
|
|
|
}
|
|
.content-show{
|
|
width: 500px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.text{
|
|
display: inline-block;
|
|
}
|
|
}
|
|
}
|
|
.operate{
|
|
display: flex;
|
|
}
|
|
}
|
|
</style>
|
|
<style lang="less" scoped>
|
|
.box {
|
|
width: 100%;
|
|
height: calc(100% - 100px);
|
|
overflow: auto;
|
|
.content-show{
|
|
/*text-align: center;*/
|
|
}
|
|
}
|
|
|
|
.text {
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.page {
|
|
text-align: right;
|
|
margin-top: 20px;
|
|
}
|
|
</style>
|