343 lines
9.7 KiB
Java
343 lines
9.7 KiB
Java
<template>
|
|
<div style="height: 100%">
|
|
<div class="box" v-if="isTrue">
|
|
<a-table
|
|
class="table"
|
|
rowKey="id"
|
|
:components="drag(columns,'columns')"
|
|
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
|
:pagination="false"
|
|
:scroll="{x: '100%'}"
|
|
:data-source="dataSource"
|
|
:loading="loading"
|
|
:columns="columns"
|
|
@change="tableOnChange"
|
|
>
|
|
<span slot="operation" slot-scope="text,record">
|
|
<a v-for="(ol,index) in OperationList"
|
|
@click="OperationClick(ol,record)">
|
|
<!-- <span class="text">-->
|
|
<!-- {{ol.text}}-->
|
|
<!-- </span>-->
|
|
<span v-if="ol.text==$t('backDocument') && record.flag==0 && (record.createBy == userData.username || administrators)"
|
|
class="text"
|
|
v-has="'split:sarFileSplitInfo:bind'">
|
|
{{ol.text}}
|
|
</span>
|
|
<span v-if="ol.text==$t('view')" class="text"
|
|
v-has="'split:sarFileSplitItems:page'">
|
|
{{ol.text}}
|
|
</span>
|
|
<span v-if="ol.text==$t('delete') && (record.createBy == userData.username || administrators)"
|
|
v-has="'split:sarFileSplitInfo:delete'">
|
|
{{ol.text}}
|
|
</span>
|
|
</a>
|
|
</span>
|
|
<span slot="detailText" slot-scope="text,record">
|
|
<span class="text" :title="text">
|
|
{{text && text.length > 25?text.slice(0,24)+'...':text}}
|
|
</span>
|
|
</span>
|
|
<span slot="detail" slot-scope="text,record">
|
|
<a class="textName" :title="text" @click="urlClick(text,record)">
|
|
{{text}}
|
|
</a>
|
|
</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"
|
|
:current="pageNo"
|
|
@change="onChange"
|
|
@showSizeChange="SizeChange"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import eventBUs from '../../common/event'
|
|
import { getAction, postAction } from '@/api/manage'
|
|
import { mapGetters } from 'vuex'
|
|
import { ResizeHeader, ResizeColumnProvide } from '@/mixins/header'
|
|
|
|
export default {
|
|
name: 'SplitTable',
|
|
props: {
|
|
//接口
|
|
url: {
|
|
type: Object,
|
|
default: {}
|
|
},
|
|
// 操作按钮
|
|
OperationList: {
|
|
type: Array,
|
|
default: []
|
|
},
|
|
flag: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
//是否显示操作;默认不显示
|
|
showAction: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
infoId: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
mixins:[ResizeHeader, ResizeColumnProvide],
|
|
data() {
|
|
return {
|
|
jsonBody: [],
|
|
checkboxList: [],
|
|
tableAll: false,
|
|
indeterminate: false,
|
|
columns: [],
|
|
selectedRowKeys: [],
|
|
dataSource: [],
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
isTrue: false,
|
|
total: 0,
|
|
searchParmes: {},
|
|
loading: false,
|
|
orderBy: '1',
|
|
userData: {},
|
|
orderByField: '',
|
|
administrators:false,
|
|
}
|
|
},
|
|
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()
|
|
})
|
|
eventBUs.$on('searchGetData', target => {
|
|
this.selectedRowKeys = []
|
|
this.getData()
|
|
this.getTableList()
|
|
})
|
|
if (this.$route.query.serial_number) {
|
|
this.searchParmes.serialNumber = this.$route.query.serial_number
|
|
this.searchParmes = { ...this.searchParmes }
|
|
}
|
|
this.getData()
|
|
this.getTableList()
|
|
this.userData = this.userInfo()
|
|
this.administrators = false
|
|
if (this.userInfo().userRoleList && this.userInfo().userRoleList.length > 0) {
|
|
this.userInfo().userRoleList.forEach(res => {
|
|
if (res.roleCode == 'admin') {
|
|
this.administrators = true
|
|
}
|
|
})
|
|
}
|
|
},
|
|
beforeDestroy() {
|
|
eventBUs.$off('searchQuery')
|
|
eventBUs.$off('searchReset')
|
|
eventBUs.$off('searchGetData')
|
|
},
|
|
methods: {
|
|
...mapGetters(['userInfo']),
|
|
urlClick(text, record) {
|
|
if (record.documentId === null) {
|
|
this.$message.warning(this.$t('Correspondingstandarddeleted'))
|
|
} else {
|
|
let newUrl = this.$router.resolve({
|
|
path: '/docManage/library/detail',
|
|
query: record
|
|
})
|
|
window.open(newUrl.href, '_blank')
|
|
}
|
|
},
|
|
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: 'left',
|
|
ellipsis: true,
|
|
sorter: res.sort,
|
|
width: 224,
|
|
})
|
|
if (res.db_field_name == '') {
|
|
// scope.row.itermsConditions ? scope.row.itermsConditions.replace(/<.*?>/ig, ' ') : ''
|
|
}
|
|
|
|
this.columns[index].scopedSlots = {
|
|
customRender: 'detailText'
|
|
}
|
|
if (res.db_field_txt == 'number' || res.db_field_txt == 'Title' || res.db_field_txt == '编号' || res.db_field_txt == '标题') {
|
|
this.columns[index].scopedSlots = {
|
|
customRender: 'detail'
|
|
}
|
|
this.columns[index].ellipsis = false
|
|
}
|
|
})
|
|
|
|
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: 'left',
|
|
fixed: 'right',
|
|
width: width,
|
|
scopedSlots: { customRender: 'operation' }
|
|
})
|
|
}
|
|
this.isTrue = false
|
|
this.$nextTick(()=>{
|
|
this.isTrue = true
|
|
})
|
|
}
|
|
})
|
|
},
|
|
getDataAdmin(){
|
|
this.isTrue = false
|
|
setTimeout(()=>{
|
|
this.isTrue = true
|
|
},100)
|
|
},
|
|
tableOnChange(pagination, filters, sorter) {
|
|
this.orderBy = sorter.order == 'ascend' ? '1' : '2'
|
|
this.orderByField = sorter.columnKey
|
|
this.getTableList()
|
|
},
|
|
getTableList() {
|
|
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,
|
|
infoId: this.infoId,
|
|
pageNo: pageNo + '',
|
|
pageSize: pageSize + ''
|
|
}
|
|
// console.log('parmsss',params)
|
|
this.loading = true
|
|
getAction(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) {
|
|
this.selectedRowKeys = value
|
|
this.$emit('onSelectChange', value)
|
|
},
|
|
OperationClick(ol, item) {
|
|
this.$emit(ol.ClickEvent, item)
|
|
},
|
|
detailClick(item, index) {
|
|
this.$emit('detailClick', item)
|
|
},
|
|
showContent(item, index) {
|
|
this.$emit('showContent', item)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
.table .ant-table-column-title {
|
|
font-weight: bold;
|
|
}
|
|
</style>
|
|
<style scoped>
|
|
@import '~@assets/less/common.less';
|
|
|
|
|
|
.box {
|
|
width: 100%;
|
|
height: calc(100% - 100px);
|
|
overflow: auto;
|
|
}
|
|
|
|
.text {
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.page {
|
|
text-align: right;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.textName {
|
|
width: 100%;
|
|
overflow: hidden;
|
|
display: -webkit-box;
|
|
text-overflow: ellipsis;
|
|
/*! autoprefixer: off */
|
|
-webkit-box-orient: vertical;
|
|
-webkit-line-clamp: 1;
|
|
/*! autoprefixer: on;*/
|
|
text-justify: inter-ideograph;
|
|
word-break: break-all
|
|
}
|
|
|
|
/*/deep/.table .ant-table-tbody > tr > td {*/
|
|
/* color: #040B29 ;*/
|
|
/*}*/
|
|
</style>
|