Files
laws-sinotruk-client/src/components/StandardResolutionSheet.vue
T

468 lines
12 KiB
Vue

<template>
<a-spin :spinning="loading">
<div class="sheet-box">
<!--标准目录-->
<div class="standard-catalogue part-common"
:class="isCatalogueExpand ? 'expand-catalogue' : 'no-expand-catalogue'">
<div class="control-standard-catalogue-expand" @click="expandCatalogue">
<a-icon :type="isCatalogueExpand ? 'left' : 'right'" />
</div>
<div class="part-title" v-show="isCatalogueExpand">{{ $t('standardRegulationLibrary.standardCatalogue') }}</div>
<div class="has-title-part-content" v-show="isCatalogueExpand">
<a-tree :tree-data="treeData"
:selected-keys="selectedTreeKeys"
@select="handleTreeSelected"
:replaceFields="{children: 'children', key: 'id'}">
<a-icon slot="switcherIcon" type="down" :style="{ fontSize: '12px', color: '#103770' }" />
<template slot="title" slot-scope="{name, itemName}">
<span :style="name && name.indexOf('.')===-1?'font-weight: 600;':''">{{ `${name} ${itemName || ''}` }}</span>
</template>
</a-tree>
</div>
</div>
<!--标准内容-->
<div class="sheet-container part-ml">
<!--标准名称-->
<div class="standard-name">
<a-tooltip placement="topLeft">
<template #title>
{{ spiltInfo.serialNumber }}
</template>
<span> {{ spiltInfo.serialNumber }}{{ spiltInfo.fileName }}</span>
</a-tooltip>
<a-button type="link" :icon="isContainerExpand ? 'fullscreen-exit' : 'fullscreen'" @click="handleContainerExpand">
{{ isContainerExpand ? $t('putAway') : $t('open') }}
</a-button>
</div>
<!--条文内容-->
<div class="standard-content">
<div class="clause-content-item"
v-for="clause in clauseContentList"
:key="clause.id"
@click="handleClickClauseContentItem(clause)">
<div class="clause-content-item-title">{{ clause.item_num }} {{ clause.item_title }}</div>
<div class="clause-content-item-content"
:class="{'clause-content-item-content-hight': clause.menu_id === hightMenuId}"
v-html="clause.item_content"></div>
</div>
</div>
</div>
<!--条文标签-->
<div class="clause-label part-ml part-common" :class="{'hide-clause-label': !showClauseLabel || isContainerExpand}">
<div class="part-title">{{ $t('standardRegulationLibrary.clauseLabel') }}</div>
<div class="has-title-part-content">
<template v-for="clause in clauseField">
<div class="clause-item" v-if="!clauseLabelHideField.includes(clause.dbFieldName)" :key="clause.id">
<label>{{ clause.dbFieldTxt }}</label>
<div class="clause-item-content"
v-html="clauseLabelInfo[needDictField.includes(clause.fieldShowType) ? clause.dbFieldName + '_dictText' : clause.dbFieldName]"></div>
</div>
</template>
</div>
</div>
<!--条文条文标签切换-->
<div class="clause-label-change part-ml part-common" :class="{'no-expand-clause-label': !isClauseLabelExpand}">
<div class="control-clause-label-expand" @click="expandClauseLabel">
<a-icon :type="isClauseLabelExpand ? 'right' : 'left'" />
</div>
<!--条文-->
<a-tooltip placement="left">
<template #title>{{ $t('docTool.split.article') }}</template>
<div class="clause-label-change-item"
:class="{'clause-label-change-item-selected': !showClauseLabel}"
@click="handleClauseChange(false)">
<i class="iconfont icon-ios-list-box" />
<span v-show="isClauseLabelExpand">{{ $t('docTool.split.article') }}</span>
</div>
</a-tooltip>
<!--条文标签-->
<a-tooltip placement="left">
<template #title>{{ $t('docTool.split.clauseLabel') }}</template>
<div class="clause-label-change-item"
:class="{'clause-label-change-item-selected': showClauseLabel}"
@click="handleClauseChange(true)">
<i class="iconfont icon-biaoqian-mianxing" />
<span v-show="isClauseLabelExpand">{{ $t('docTool.split.clauseLabel') }}</span>
</div>
</a-tooltip>
</div>
</div>
</a-spin>
</template>
<script>
import { getDocSplitEditForm, previewDocSplit } from '@api/documentToolApi'
import { FieldType } from '@/enums/commonEnums'
export default {
name: 'StandardResolutionSheet',
data () {
return {
showClauseLabel: true, // 是否展示条文标签
// 条文标签字段
clauseField: [],
// 目录数据
treeData: [],
selectedTreeKeys: [],
hightMenuId: null, // 高亮的menuId
isClauseLabelExpand: true, // 条文/条文标签切换部分是否展开,控制是否只显示图标
isCatalogueExpand: true, // 标准目录收起
isContainerExpand: false, // 条文是否展开
loading: false,
spiltInfo: {}, // 拆分的整体信息
clauseContentList: [], // 条文内容的数据
clauseLabelInfo: {}, // 条文标签数据
clauseLabelHideField: ['item_content'],
needDictField: [FieldType.USER_SINGLE.value, FieldType.ORGAN_SINGLE.value, FieldType.STANDARD_MORE.value, FieldType.ORGAN_MORE.value, FieldType.OPTION_SINGLE.value, FieldType.OPTION_MORE.value, FieldType.TREE.value],
queryParams: {}
}
},
methods: {
/**
* 获取条文标签字段
*/
initClauseFieldList () {
getDocSplitEditForm({ type: 1 }).then(res => {
if (res.success) {
this.clauseField = res.result || []
}
})
},
initDetailInfo () {
this.loading = true
previewDocSplit(this.queryParams).then(res => {
if (res.success) {
const data = res.result || {}
this.treeData = data.sarFileSplitMenuEO || []
this.spiltInfo = data.documentSplitInfo || {}
this.clauseContentList = data.documentSplitDetail || []
}
}).finally(() => {
this.loading = false
})
},
/**
* 树节点选中
* @param selectedKeys
*/
handleTreeSelected (selectedKeys) {
this.selectedTreeKeys = selectedKeys
this.hightMenuId = this.selectedTreeKeys[0]
if (this.hightMenuId) {
this.handleJump()
} else {
this.clauseLabelInfo = {}
}
},
/**
* 内容跳转,处理条文标签数据
*/
handleJump () {
const contentItemDomList = document.getElementsByClassName('clause-content-item')
const contentDom = document.getElementsByClassName('standard-content')[0]
const contentItemIndex = this.clauseContentList.findIndex(tt => tt.menu_id === this.hightMenuId)
this.handleProcessClauseLabelInfo(contentItemIndex)
contentDom.scrollTop = contentItemDomList[contentItemIndex].offsetTop - 150
},
/**
* 处理条文标签的数据
* @param contentItemIndex
*/
handleProcessClauseLabelInfo (contentItemIndex) {
this.clauseLabelInfo = Object.assign({}, this.clauseContentList[contentItemIndex])
},
/**
* 点击条文内容
*/
handleClickClauseContentItem ({ menu_id: menuId }) {
this.selectedTreeKeys = [menuId]
this.hightMenuId = menuId
const contentItemIndex = this.clauseContentList.findIndex(tt => tt.menu_id === this.hightMenuId)
this.handleProcessClauseLabelInfo(contentItemIndex)
},
/**
* 标准内容展开
*/
handleContainerExpand () {
this.isContainerExpand = !this.isContainerExpand
if (this.isContainerExpand) {
this.isCatalogueExpand = false
} else {
this.isCatalogueExpand = true
}
},
/**
* 条文标签切换
* @param flag
*/
handleClauseChange (flag) {
this.showClauseLabel = flag
},
/**
* 展开或收起条文/条文标签面板
*/
expandClauseLabel () {
this.isClauseLabelExpand = !this.isClauseLabelExpand
},
/**
* 展开或收起标准目录
*/
expandCatalogue () {
this.isCatalogueExpand = !this.isCatalogueExpand
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
.sheet-box {
width: 100%;
height: 100%;
display: flex;
justify-content: space-between;
}
.part-ml {
margin-left: 16px;
}
.part-common {
border-radius: 8px;
background: #FFFFFF;
}
.standard-catalogue {
height: 100%;
position: relative;
transition: width .2s linear;
/deep/ .ant-tree li .ant-tree-node-content-wrapper.ant-tree-node-selected {
background-color: transparent !important;
color: @primary-color;
}
}
.control-standard-catalogue-expand {
width: 12px;
height: 24px;
border-radius: 0 12px 12px 0;
background-color: @primary-color;
color: white;
position: absolute;
left: 100%;
top: calc(50% - 52px);
.anticon {
position: absolute;
top: 50%;
left: -2px;
transform: translateY(-50%);
cursor: pointer;
}
}
.expand-catalogue {
width: 280px;
}
.no-expand-catalogue {
width: 0;
}
.sheet-container {
height: 100%;
flex: 1;
width: 0;
transition: width .2s linear;
}
.clause-label {
width: 400px;
height: 100%;
overflow: hidden;
transition: width .2s linear;
.clause-item {
display: flex;
margin-bottom: 20px;
label {
width: 7.5em;
font-size: 14px;
font-family: PingFang SC-Regular, PingFang SC, sans-serif;
color: #86909C;
margin-right: 20px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
&-content {
flex: 1;
width: 0;
white-space: pre-wrap;
word-break: break-all;
font-size: 14px;
font-family: PingFang SC-Regular, PingFang SC, sans-serif;
color: #1D2129;
}
}
}
.hide-clause-label {
width: 0;
margin-left: 0;
}
.clause-label-change {
width: 130px;
height: 100%;
padding-top: 40px;
position: relative;
transition: width .2s linear;
&-item {
height: 40px;
display: flex;
align-items: center;
padding: 0 16px;
font-size: 16px;
font-family: PingFang SC-Semibold, PingFang SC, sans-serif;
font-weight: 600;
color: #1D2129;
cursor: pointer;
.iconfont {
color: @primary-color;
}
span {
margin-left: 8px;
white-space: nowrap;
overflow: hidden;
}
}
&-item-selected {
background: #FAE6E5;
}
}
.no-expand-clause-label {
width: 45px;
min-width: 45px;
}
.part-title {
height: 40px;
background: rgba(213, 44, 38, 0.12);
border-radius: 8px 8px 0 0;
line-height: 40px;
padding: 0 24px;
font-size: 16px;
font-family: PingFang SC-Semibold, PingFang SC, sans-serif;
font-weight: 600;
color: #1D2129;
white-space: nowrap;
overflow: hidden;
}
.has-title-part-content {
height: calc(100% - 40px);
overflow: auto;
padding: 24px;
}
.standard-name {
height: 40px;
background: #FFFFFF;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
margin-bottom: 5px;
}
.standard-name > span {
font-size: 16px;
font-family: PingFang SC-Semibold, PingFang SC, sans-serif;
font-weight: 600;
color: #1D2129;
flex: 1;
width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
}
.standard-content {
height: calc(100% - 45px);
background: #FFFFFF;
border-radius: 8px;
overflow: auto;
padding: 24px;
}
.clause-content-item {
margin-bottom: 20px;
&-title {
font-size: 18px;
font-family: PingFang SC-Medium, PingFang SC, sans-serif;
font-weight: 600;
color: #1D2129;
margin-bottom: 12px;
}
&-content {
font-size: 14px;
font-family: PingFang SC-Regular, PingFang SC, sans-serif;
font-weight: 500;
color: #1D2129;
line-height: 24px;
/deep/ table {
width: 100%;
}
}
&-content-hight {
color: @primary-color;
}
}
.control-clause-label-expand {
position: absolute;
width: 12px;
height: 24px;
background-color: @primary-color;
border-radius: 12px 0 0 12px;
left: -12px;
top: calc(50% - 52px);
color: white;
cursor: pointer;
.anticon {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
}
/deep/ .ant-tree li span.ant-tree-switcher {
float: right;
}
.ant-spin-nested-loading {
height: 100%;
}
/deep/ .ant-spin-container {
height: 100%;
}
</style>