899 lines
30 KiB
Vue
899 lines
30 KiB
Vue
<template>
|
|
<a-card :bordered="false">
|
|
<div class="left-tree-div">
|
|
<div class="div-left">
|
|
<div>
|
|
<a-input-search style="margin-bottom: 8px" :placeholder="$t('nodeQuickLookup')" @change="onLeftChange"
|
|
@search="onSearch" />
|
|
<a-tree
|
|
v-if="gData.length>0"
|
|
:selected-keys="selectedKeys"
|
|
:expanded-keys.sync="expandedKeys"
|
|
:auto-expand-parent="autoExpandParent"
|
|
:defaultExpandAll="true"
|
|
:tree-data="gData"
|
|
@expand="onExpand"
|
|
@rightClick="rightClick"
|
|
@select="onSelect"
|
|
>
|
|
<template #title="{ key: treeKey, title, record }">
|
|
<a-dropdown :trigger="['contextmenu']">
|
|
<span v-if="title.indexOf(searchValue) >= -1 && title.length <= 18" :title="title"
|
|
class="expand-title">
|
|
{{ title.substr(0, title.indexOf(searchValue)) }}<span style="color: #f50">{{ searchValue }}</span>
|
|
{{ title.substr(title.indexOf(searchValue) + searchValue.length) }}
|
|
</span>
|
|
<span
|
|
v-else-if="title.indexOf(searchValue) >= -1 && title.length > 18 && title.indexOf(searchValue)>18"
|
|
:title="title">
|
|
{{ title && title.length > 18 ? title.slice(0, 17) + '...' : title }}
|
|
</span>
|
|
<span
|
|
v-else-if="title.indexOf(searchValue) >= -1 && title.length > 18 && title.indexOf(searchValue)<=18"
|
|
:title="title">
|
|
{{ title.substr(0, title.indexOf(searchValue)) }}<span style="color: #f50">
|
|
{{ title.indexOf(searchValue) + searchValue.length > 18 ? searchValue.substr(0, 18 - title.indexOf(searchValue)) : searchValue
|
|
}}</span>{{ title.indexOf(searchValue) + searchValue.length > 18 ? '...' : title.substr(title.indexOf(searchValue) + searchValue.length, 18 - title.indexOf(searchValue) - searchValue.length) + '...'
|
|
}}
|
|
</span>
|
|
<span v-else :title="title">
|
|
{{ title && title.length > 18 ? title.slice(0, 17) + '...' : title }}
|
|
</span>
|
|
<template #overlay>
|
|
<a-menu v-if="$route.query.createBy === userData.username || administrators"
|
|
@click="({ key: menuKey }) => onContextMenuClick(treeKey, menuKey, record)">
|
|
<a-menu-item key="1" @click="orgAdd" v-has="'split:sarFileSplitMenu:add'">
|
|
{{ $t('newNode') }}
|
|
</a-menu-item>
|
|
<a-menu-item key="2" @click="orgEdit" v-has="'split:sarFileSplitMenu:update'">
|
|
{{ $t('modifyNode') }}
|
|
</a-menu-item>
|
|
<a-menu-item key="3" @click="orgDelete" v-if="deleteNode"
|
|
v-has="'split:sarFileSplitMenu:delete'">{{ $t('deleteNode') }}
|
|
</a-menu-item>
|
|
<a-menu-item key="4" @click="orgMoveUp" v-if="deleteNode && moveUpFlag"
|
|
v-has="'split:sarFileSplitMenu:moveUp'">{{ $t('moveUp') }}
|
|
</a-menu-item>
|
|
<a-menu-item key="5" @click="orgmoveDown" v-if="deleteNode && moveDownFlag"
|
|
v-has="'split:sarFileSplitMenu:moveDown'">{{ $t('moveDown') }}
|
|
</a-menu-item>
|
|
</a-menu>
|
|
</template>
|
|
</a-dropdown>
|
|
</template>
|
|
</a-tree>
|
|
</div>
|
|
</div>
|
|
<div class="div-right">
|
|
<div class="div-right-wrapper">
|
|
<div class="right-search-header table-page-search-wrapper">
|
|
<search :flag="'4'" :url="url" :infoId="$route.query.infoId"
|
|
:menuId="menuId" @reset="searchReset" @search="searchQuery" />
|
|
</div>
|
|
<div class="table-operator">
|
|
<div class="operator-text" @click="handleCopyManage">
|
|
<!-- v-if="$route.query.createBy === userData.username || administrators"-->
|
|
<!-- v-has="'split:sarFileSplitItems:copy'"-->
|
|
<a-icon type="copy" />
|
|
{{ $t('copy') }}
|
|
</div>
|
|
<div class="operator-text" @click="handleAddManage">
|
|
<!-- v-if="$route.query.createBy === userData.username || administrators"-->
|
|
<!-- v-has="'split:sarFileSplitItems:add'"-->
|
|
<a-icon type="plus" />
|
|
{{ $t('add') }}
|
|
</div>
|
|
<div class="operator-text upload-split"
|
|
v-if="isCanOperate"
|
|
@click="handleImportManage" v-has="'split:sarFileSplitItems:import'">
|
|
<a-icon type="import" :rotate="-90" v-if="uploadMenuId === undefined || uploadMenuId === ''" />
|
|
{{ (uploadMenuId === '' || uploadMenuId === undefined) ? $t('import') : '' }}
|
|
<upload v-if="menuId" ref="uploadSplit" :infoId="infoId" :menuId="uploadMenuId"
|
|
@uploadSuccess="uploadSuccess"></upload>
|
|
</div>
|
|
<div class="operator-text" @click="handleExportManage"
|
|
v-has="'split:sarFileSplitItems:export'">
|
|
<a-icon type="export" :rotate="-90" />
|
|
{{ $t('export') }}
|
|
</div>
|
|
<div class="operator-text" @click="handleDownManage"
|
|
v-if="isCanOperate"
|
|
v-has="'split:sarFileSplitItems:template'">
|
|
<a-icon type="download" />
|
|
{{ $t('templateDownload') }}
|
|
</div>
|
|
<div class="operator-text" @click="handleMergeManage"
|
|
v-if="isCanOperate"
|
|
v-has="'split:sarFileSplitItems:merge'">
|
|
<a-icon type="snippets" />
|
|
{{ $t('docTool.split.mergerClause') }}
|
|
</div>
|
|
<div class="operator-text" @click="handleManage"
|
|
v-if="isCanOperate"
|
|
v-has="'split:sarFileSplitItems:set'">
|
|
<a-icon type="setting" />
|
|
{{ $t('docTool.split.batchSetting') }}
|
|
</div>
|
|
<div class="operator-text" @click="handleBatCancel"
|
|
v-if="isCanOperate"
|
|
v-has="'split:sarFileSplitItems:delete'">
|
|
<a-icon type="delete" />
|
|
{{ $t('batchDelete') }}
|
|
</div>
|
|
</div>
|
|
<div class="split-detail-table">
|
|
<j-table
|
|
v-if="columns && columns.length > 0"
|
|
:columns="columns"
|
|
:dataSource="dataSource"
|
|
:can-drag="true"
|
|
rowKey="id"
|
|
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
|
:pagination="ipagination"
|
|
:scroll="{x: '100%'}"
|
|
@change="tableOnChange">
|
|
|
|
<template slot="operation" slot-scope="{text, record}">
|
|
<a v-for="(operation, index) in operationList" :key="index" @click="operationClick(operation,record)">
|
|
<!-- v-has="operation.has"-->
|
|
<span class="text">
|
|
{{ operation.text }}
|
|
</span>
|
|
</a>
|
|
</template>
|
|
|
|
<!-- 详情-->
|
|
<template slot="detailClick" slot-scope="{text, record}">
|
|
<a-tooltip overlay-class-name="tooltip-style">
|
|
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
|
|
<a class="table-text textName" @click="detailClick(record)" v-if="text || text === 0">{{ text }}</a>
|
|
<div class="table-text" v-else>{{ global.emptyLine }}</div>
|
|
</a-tooltip>
|
|
</template>
|
|
|
|
<template slot="showContent" slot-scope="text, record">
|
|
<span class="content-show" @click="showContent(text,record)">{{record.iterms_conditions&&record.iterms_conditions!=='null'?record.iterms_conditions.replace(/<.*?>/ig, ' ') : ''}}</span>
|
|
</template>
|
|
|
|
</j-table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 条款详情 -->
|
|
<split-clause-detail ref="splitClauseDetail"></split-clause-detail>
|
|
<!-- 添加节点 -->
|
|
<split-detail-node-add ref="splitDetailNodeAdd" @ok="nodeAddOk" @update="nodeUpdateOk"></split-detail-node-add>
|
|
<!-- 批量设置弹框 -->
|
|
<split-detail-batch-setting ref="splitDetailBatchSetting" @ok="batchSettingOk"></split-detail-batch-setting>
|
|
<split-add-form ref="splitForm" :flag="'4'"
|
|
:url="url" :infoId="infoId" :menuId="menuId" :itemId="itemId" @closeVisible="closeVisible"
|
|
@sumber="sumber"></split-add-form>
|
|
|
|
</div>
|
|
</a-card>
|
|
</template>
|
|
|
|
<script>
|
|
import Search from '@/components/customField/Search'
|
|
import JTable from '@/components/jero/JTable'
|
|
// 条款添加
|
|
import SplitAddForm from './SplitAddForm'
|
|
// 条款内容弹框
|
|
import SplitClauseDetail from './SplitClauseDetail'
|
|
// 添加左侧树节点弹框
|
|
import SplitDetailNodeAdd from './SplitDetailNodeAdd'
|
|
// 批量设置弹框
|
|
import SplitDetailBatchSetting from './SplitDetailBatchSetting'
|
|
import Vue from 'vue'
|
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
|
import { mapGetters } from 'vuex'
|
|
import { postAction, getAction, downloadFile } from '@/api/manage'
|
|
import moment from 'moment'
|
|
import { ConfigurableTableMixin } from '../../../mixins/ConfigurableTableMixin'
|
|
|
|
export default {
|
|
name: 'SplitDetail',
|
|
components: {
|
|
Search,
|
|
JTable,
|
|
SplitAddForm,
|
|
SplitClauseDetail,
|
|
SplitDetailNodeAdd,
|
|
SplitDetailBatchSetting
|
|
},
|
|
mixins: [ConfigurableTableMixin],
|
|
data () {
|
|
return {
|
|
userData: {},
|
|
contentVisible: false, // 条款内容弹框显示
|
|
selectedRowKeys: [],
|
|
selectedRows: [],
|
|
selectedKeys: [],
|
|
expandedKeys: [],
|
|
searchValue: '',
|
|
autoExpandParent: true,
|
|
dataList: [],
|
|
contentValue: '',
|
|
gData: [],
|
|
attId: '',
|
|
data: [],
|
|
loading: false, // 提交的加载
|
|
confirmLoading: false,
|
|
nodeTreeItem: null, // 右键菜单
|
|
tmpStyle: '', // 右键菜单位置
|
|
infoId: '',
|
|
menuId: '',
|
|
itemId: '',
|
|
itemVal: {},
|
|
// 操作栏
|
|
operationList: [
|
|
{
|
|
text: this.$t('edit'),
|
|
ClickEvent: 'editClick'
|
|
},
|
|
{
|
|
text: this.$t('delete'),
|
|
ClickEvent: 'deleteClick'
|
|
}
|
|
],
|
|
url: {
|
|
tableHeader: 'split/sarFileSplitItems/getHeader', // 表格头部字段
|
|
getSearchList: 'split/sarFileSplitItems/queryCondition', // 搜索字段
|
|
list: 'split/sarFileSplitItems/getSplitItemsByPage', // 表格数据
|
|
getAddForm: 'split/sarFileSplitItems/getForm', // 表单的字段
|
|
getDocumentInfo: 'split/sarFileSplitItems/getSplitItemsById',
|
|
importZipUrl: '/split/sarFileSplitItems/importSplitItems' // 导入
|
|
},
|
|
token: Vue.ls.get(ACCESS_TOKEN),
|
|
uploadMenuId: '',
|
|
deleteNode: false,
|
|
moveDownFlag: false,
|
|
moveUpFlag: false,
|
|
fullWidth: '',
|
|
parameter: {},
|
|
administrators: false,
|
|
showAction: this.isCanOperate,
|
|
flag: '4' // 查询要用到
|
|
}
|
|
},
|
|
computed: {
|
|
isCanOperate () {
|
|
return !!(this.$route.query.createBy === this.userData.username || this.administrators)
|
|
},
|
|
filters () {
|
|
return {
|
|
menu_id: this.menuId,
|
|
info_id: this.infoId
|
|
}
|
|
}
|
|
},
|
|
mounted () {
|
|
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
|
|
}
|
|
})
|
|
}
|
|
this.infoId = this.$route.query.infoId
|
|
this.loadMenuData()
|
|
this.generateList(this.gData)
|
|
},
|
|
methods: {
|
|
...mapGetters(['userInfo']),
|
|
// 显示条款内容弹框
|
|
showContent (val) {
|
|
this.$refs.splitClauseDetail.open(val)
|
|
},
|
|
generateList (data) {
|
|
for (let i = 0; i < data.length; i++) {
|
|
const node = data[i]
|
|
const key = node.key
|
|
this.dataList.push({ key, title: key })
|
|
if (node.children) {
|
|
this.generateList(node.children)
|
|
}
|
|
}
|
|
},
|
|
getParentKey (key, tree) {
|
|
let parentKey
|
|
for (let i = 0; i < tree.length; i++) {
|
|
const node = tree[i]
|
|
if (node.children) {
|
|
if (node.children.some(item => item.key === key)) {
|
|
parentKey = node.key
|
|
} else if (this.getParentKey(key, node.children)) {
|
|
parentKey = this.getParentKey(key, node.children)
|
|
}
|
|
}
|
|
}
|
|
return parentKey
|
|
},
|
|
onExpand (expandedKeys) {
|
|
this.expandedKeys = expandedKeys
|
|
this.autoExpandParent = false
|
|
},
|
|
onLeftChange (e) {
|
|
const value = e.target.value
|
|
const expandedKeys = this.dataList
|
|
.map(item => {
|
|
if (item.title.indexOf(value) > -1) {
|
|
return this.getParentKey(item.key, this.gData)
|
|
}
|
|
return null
|
|
})
|
|
.filter((item, i, self) => item && self.indexOf(item) === i)
|
|
Object.assign(this, {
|
|
expandedKeys,
|
|
searchValue: value,
|
|
autoExpandParent: true
|
|
})
|
|
this.onSearch()
|
|
},
|
|
// 获取左侧目录数据
|
|
loadMenuData () {
|
|
const params = {
|
|
infoId: this.infoId
|
|
}
|
|
this.loading = true
|
|
getAction(`split/sarFileSplitMenu/getSplitMenusByInfoId`, params).then(res => {
|
|
if (res.success) {
|
|
this.data = this.toTree(res.result)
|
|
this.gData = [...this.data]
|
|
Object.assign(this, {
|
|
expandedKeys: this.expandedKeys,
|
|
autoExpandParent: true
|
|
})
|
|
}
|
|
}).finally(() => {
|
|
this.loading = false
|
|
})
|
|
},
|
|
// 将数据拼成树形结构
|
|
toTree (config) {
|
|
// 删除 所有 children,以防止多次调用
|
|
config.forEach(function (item) {
|
|
delete item.children
|
|
})
|
|
// 将数据存储为 以 id 为 KEY 的 map 索引数据列
|
|
const map = {}
|
|
config.forEach((item) => {
|
|
if (!item.name) {
|
|
item.name = ''
|
|
}
|
|
item.label = item.name
|
|
item.key = item.id
|
|
item.title = item.name + (item.itemName ? ' ' + item.itemName : '')
|
|
map[item.id] = item
|
|
})
|
|
const val = []
|
|
config.forEach((item) => {
|
|
// 以当前遍历项,的pid,去map对象中找到索引的id
|
|
const parent = map[item.pid]
|
|
// 如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中
|
|
if (parent) {
|
|
(parent.children || (parent.children = [])).push(item)
|
|
} else {
|
|
// 如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级
|
|
val.push(item)
|
|
}
|
|
})
|
|
return val
|
|
},
|
|
// 鼠标右键
|
|
rightClick ({ event, node }) {
|
|
this.deleteNode = !!node._props.dataRef.pid
|
|
this.moveDownFlag = node._props.dataRef.moveDownFlag === true
|
|
this.moveUpFlag = node._props.dataRef.moveUpFlag === true
|
|
const x = event.currentTarget.offsetLeft + event.currentTarget.clientWidth
|
|
const y = event.currentTarget.offsetTop
|
|
this.nodeTreeItem = {
|
|
pageX: x,
|
|
pageY: y,
|
|
id: node._props.dataRef.id,
|
|
name: node._props.dataRef.name,
|
|
itemName: node._props.dataRef.itemName,
|
|
displaySeq: node._props.dataRef.displaySeq,
|
|
title: node._props.dataRef.title,
|
|
pid: node._props.dataRef.pid || null
|
|
}
|
|
this.nodeItem = JSON.parse(JSON.stringify(this.nodeTreeItem))
|
|
this.tmpStyle = {
|
|
position: 'absolute',
|
|
maxHeight: 40,
|
|
textAlign: 'center',
|
|
left: `${x + 10 - 0}px`,
|
|
top: `${y + 6 - 0}px`,
|
|
background: `#FFFFFF`,
|
|
zIndex: `2`
|
|
}
|
|
},
|
|
// 用于点击空白处隐藏增删改菜单
|
|
clearMenu () {
|
|
this.nodeTreeItem = null
|
|
},
|
|
// 选择树节点
|
|
onSelect (selectedKeys) {
|
|
this.menuId = selectedKeys[0]
|
|
this.uploadMenuId = selectedKeys[0]
|
|
this.selectedKeys = selectedKeys
|
|
this.parameter.info_id = this.infoId
|
|
this.parameter.menu_id = this.menuId
|
|
this.loadData()
|
|
},
|
|
// 树形新增
|
|
orgAdd () {
|
|
this.$refs.splitDetailNodeAdd.add(this.nodeItem, this.infoId)
|
|
},
|
|
// 树形修改
|
|
orgEdit () {
|
|
this.$refs.splitDetailNodeAdd.edit(this.nodeItem, this.infoId)
|
|
},
|
|
// 添加节点完成后的回调
|
|
nodeAddOk () {
|
|
this.expandedKeys.push(this.nodeItem.id)
|
|
this.loadMenuData()
|
|
this.loadData()
|
|
},
|
|
// 修改节点完成后的回调
|
|
nodeUpdateOk (expandId) {
|
|
this.onExpand(expandId)
|
|
this.loadMenuData()
|
|
},
|
|
// 树形删除
|
|
orgDelete () {
|
|
this.$confirm({
|
|
content: this.$t('confirmDeleteNodes'),
|
|
onOk:
|
|
async () => {
|
|
getAction(`split/sarFileSplitMenu/deleteMenu`, { id: this.nodeItem.id }).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(this.$t('operationSuccessful'))
|
|
this.loadMenuData()
|
|
this.loadData()
|
|
} else {
|
|
this.$message.warning(this.$t('operationFailed'))
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
// 树上移
|
|
orgMoveUp () {
|
|
const query = {
|
|
moveFlag: 'up',
|
|
infoId: this.infoId,
|
|
sarFileSplitMenu: {
|
|
id: this.nodeItem.id,
|
|
pId: this.nodeItem.pid,
|
|
displaySeq: this.nodeItem.displaySeq
|
|
}
|
|
}
|
|
postAction(`split/sarFileSplitMenu/moveUpOrDown`, query).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(this.$t('operationSuccessful'))
|
|
this.loadMenuData()
|
|
this.loadData()
|
|
} else {
|
|
this.$message.warning(this.$t('operationFailed'))
|
|
}
|
|
})
|
|
},
|
|
// 树下移
|
|
orgmoveDown () {
|
|
const query = {
|
|
moveFlag: 'down',
|
|
infoId: this.infoId,
|
|
SarFileSplitMenu: {
|
|
id: this.nodeItem.id,
|
|
pId: this.nodeItem.pid,
|
|
displaySeq: this.nodeItem.displaySeq
|
|
}
|
|
}
|
|
postAction(`split/sarFileSplitMenu/moveUpOrDown`, query).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(this.$t('operationSuccessful'))
|
|
this.loadMenuData()
|
|
this.loadData()
|
|
} else {
|
|
this.$message.warning(this.$t('operationFailed'))
|
|
}
|
|
})
|
|
},
|
|
onContextMenuClick (treeKey, menuKey) {
|
|
// console.log(`treeKey: ${treeKey}, menuKey: ${menuKey}`);
|
|
},
|
|
// 表格操作列按钮的点击
|
|
operationClick (operation, record) {
|
|
if (this[operation.clickEvent]) {
|
|
this[operation.clickEvent](record)
|
|
}
|
|
},
|
|
/**
|
|
* 处理表头数据
|
|
* @param columns
|
|
* @returns {*[]}
|
|
*/
|
|
dealColumns (columns) {
|
|
const tempColumns = []
|
|
columns.forEach(item => {
|
|
// 可点击项加入插槽
|
|
if (item.click === 'true') {
|
|
item.scopedSlots = {
|
|
customRender: 'detailClick'
|
|
}
|
|
} else if (item.urlClick === 'true') {
|
|
item.scopedSlots = {
|
|
customRender: 'urlClick'
|
|
}
|
|
} else if (item.db_field_name === 'iterms_conditions') {
|
|
// 拆分文档详情页的条款内容点击可预览
|
|
item.scopedSlots = {
|
|
customRender: 'showContent'
|
|
}
|
|
}
|
|
// 是否可排序
|
|
item.sorter = item.sort === 'true'
|
|
item.width = 215
|
|
item.title = item.db_field_txt
|
|
item.dataIndex = item.db_field_name
|
|
item.align = 'left'
|
|
tempColumns.push(item)
|
|
})
|
|
if (this.showAction && this.operateColumn) {
|
|
let width = 0
|
|
if (this.operationList.length > 0) {
|
|
for (let i = 0; i < this.operationList.length; i++) {
|
|
width += this.getTextWith(this.operationList[i].text)
|
|
}
|
|
}
|
|
const operateColumn = JSON.parse(JSON.stringify(this.operateColumn))
|
|
operateColumn.width = width
|
|
tempColumns.push(operateColumn)
|
|
}
|
|
return tempColumns
|
|
},
|
|
// 清空按钮
|
|
resetSearch () {
|
|
this.menuId = ''
|
|
this.uploadMenuId = ''
|
|
this.selectedKeys = []
|
|
},
|
|
// 复制按钮
|
|
handleCopyManage (record) {
|
|
const ids = []
|
|
const infoIds = []
|
|
const menuIds = []
|
|
this.selectedRows.forEach(item => {
|
|
ids.push(item.id)
|
|
infoIds.push(item.info_id)
|
|
menuIds.push(item.menu_id)
|
|
})
|
|
const params = {
|
|
ids: ids.join(','),
|
|
infoIds: infoIds.join(','),
|
|
menuids: menuIds.join(',')
|
|
}
|
|
if (menuIds && menuIds.length > 0) {
|
|
this.$confirm({
|
|
title: this.$t('confirmReplication'),
|
|
content: '',
|
|
onOk: () => {
|
|
getAction('/split/sarFileSplitItems/batchCopyItems', params).then((res) => {
|
|
if (res.data.success) {
|
|
this.$message.success(this.$t('operationSuccessful'))
|
|
this.selectClear()
|
|
this.loadMenuData()
|
|
this.loadData()
|
|
} else {
|
|
this.$message.warning(this.$t('operationFailed'))
|
|
}
|
|
})
|
|
}
|
|
})
|
|
} else if (menuIds.length === 0) {
|
|
this.$message.warning(this.$t('pleaseSelectData'))
|
|
}
|
|
},
|
|
// 新增
|
|
handleAddManage () {
|
|
// console.log('this.menuId',this.menuId)
|
|
this.$nextTick(() => {
|
|
this.$refs.splitForm.add()
|
|
this.$refs.splitForm.formTitle = this.$t('add')
|
|
})
|
|
// if (this.menuId) {
|
|
// this.formTitle = this.$t('add')
|
|
// this.itemId = ''
|
|
// this.addVisible = true
|
|
// this.$nextTick(() => {
|
|
// this.$refs.splitForm.add()
|
|
// this.$refs.splitForm.formTitle = this.$t('add')
|
|
// })
|
|
// } else {
|
|
// this.$message.warning(this.$t('docTool.split.selectDirectoryTerms'))
|
|
// }
|
|
},
|
|
// 关闭新增弹框
|
|
closeVisible (val) {
|
|
this.addVisible = val
|
|
},
|
|
// 导入
|
|
handleImportManage () {
|
|
if (!this.menuId) {
|
|
this.$message.warning(this.$t('docTool.split.selectDirectoryTerms'))
|
|
}
|
|
},
|
|
// 上传成功
|
|
uploadSuccess (data, status) {
|
|
if (status === 'success') {
|
|
this.loadMenuData()
|
|
this.loadData()
|
|
}
|
|
const attIdList = []
|
|
if (data && data.length > 0) {
|
|
data.forEach(item => {
|
|
attIdList.push(item.id || data.name)
|
|
})
|
|
this.attId = attIdList.join(',')
|
|
}
|
|
},
|
|
queryParamsValues (search) {
|
|
Object.keys(search).forEach(res => {
|
|
if (search[res] instanceof Array) {
|
|
search[res] = search[res].join(',')
|
|
}
|
|
})
|
|
this.parameter = search
|
|
this.parameter.info_id = this.infoId
|
|
this.parameter.menu_id = this.menuId
|
|
},
|
|
// 导出
|
|
handleExportManage () {
|
|
if (JSON.stringify(this.parameter) === '{}') {
|
|
this.parameter.info_id = this.infoId
|
|
this.parameter.menu_id = this.menuId
|
|
}
|
|
// console.log('menuId',this.menuId)
|
|
const dateName = moment(new Date()).format('YYYY-MM-DD HH-mm-ss')
|
|
const name = this.$route.query.infoNumber + ' ' + dateName + '.zip'
|
|
const query = {
|
|
exportName: this.$route.query.infoNumber + ' ' + dateName,
|
|
idList: this.selectedRowKeys.join(','),
|
|
parameter: this.parameter
|
|
}
|
|
downloadFile('split/sarFileSplitItems/exportSplitInfoZip', name, query, this.selectClear)
|
|
},
|
|
selectClear () {
|
|
this.selectedRowKeys = []
|
|
this.selectedRows = []
|
|
},
|
|
// 模板下载
|
|
handleDownManage () {
|
|
const name = this.$t('docTool.split.documentSplitTemplate') + '.xlsx'
|
|
downloadFile('split/sarFileSplitItems/exportTemplate', name, {})
|
|
},
|
|
// 合并条款
|
|
handleMergeManage () {
|
|
if (this.selectedRowKeys && this.selectedRowKeys.length < 2) {
|
|
this.$message.warning(this.$t('leastTwo'))
|
|
} else {
|
|
const ids = this.selectedRowKeys.join(',')
|
|
this.$confirm({
|
|
title: this.$t('docTool.split.mergeTerms'),
|
|
content: '',
|
|
onOk: () => {
|
|
getAction('/split/sarFileSplitItems/batchMergeItems', { ids: ids }).then(res => {
|
|
if (res.data.success) {
|
|
this.$message.success(this.$t('operationSuccessful'))
|
|
this.selectClear()
|
|
this.loadMenuData()
|
|
this.loadData()
|
|
this.selectedRowKeys = []
|
|
} else {
|
|
this.$message.warning(this.$t('operationFailed'))
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
// 批量设置
|
|
handleManage () {
|
|
const ids = this.selectedRowKeys.join(',')
|
|
if (this.selectedRowKeys && this.selectedRowKeys.length < 1) {
|
|
this.$message.warning(this.$t('selectLeastOne'))
|
|
} else {
|
|
this.$refs.splitDetailBatchSetting.open(ids)
|
|
}
|
|
},
|
|
// 批量设置完成的回调
|
|
batchSettingOk () {
|
|
this.selectClear()
|
|
this.loadData()
|
|
},
|
|
// 批量删除
|
|
handleBatCancel () {
|
|
const params = {
|
|
ids: this.selectedRowKeys.join(',')
|
|
}
|
|
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
|
|
this.$confirm({
|
|
title: this.$t('confirmBatchDeletion'),
|
|
content: '',
|
|
onOk: () => {
|
|
postAction('/split/sarFileSplitItems/batchDeleteItems', params).then((res) => {
|
|
if (res.data.success) {
|
|
this.$message.success(this.$t('operationSuccessful'))
|
|
this.loadMenuData()
|
|
this.filter = {
|
|
menu_id: this.menuId,
|
|
info_id: this.infoId
|
|
}
|
|
this.loadData()
|
|
this.selectClear()
|
|
} else {
|
|
this.$message.warning(res.data.message)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
this.$message.warning(this.$t('selectLeastOne'))
|
|
}
|
|
},
|
|
// 编辑
|
|
editClick (val) {
|
|
this.formTitle = this.$t('edit')
|
|
this.itemVal = val
|
|
this.itemId = val.id
|
|
this.addVisible = true
|
|
this.$nextTick(() => {
|
|
this.$refs.splitForm.edit(val)
|
|
this.$refs.splitForm.formTitle = this.$t('edit')
|
|
})
|
|
},
|
|
// 保存成功
|
|
sumber () {
|
|
this.loadData()
|
|
this.loadMenuData()
|
|
},
|
|
// 删除
|
|
deleteClick (val) {
|
|
const params = {
|
|
ids: val.id
|
|
}
|
|
this.$confirm({
|
|
title: this.$t('areYouSure'),
|
|
content: '',
|
|
onOk: () => {
|
|
postAction('/split/sarFileSplitItems/batchDeleteItems', params).then((res) => {
|
|
if (res.data.success) {
|
|
this.$message.success(this.$t('operationSuccessful'))
|
|
this.loadMenuData()
|
|
this.loadData()
|
|
} else {
|
|
this.$message.warning(this.$t('operationFailed'))
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
// 选择框
|
|
onSelectChange (selectedRowKeys, rows) {
|
|
this.selectedRowKeys = selectedRowKeys
|
|
this.selectedRows = rows
|
|
},
|
|
onSearch () {
|
|
const self = this
|
|
const tree = JSON.parse(JSON.stringify(this.data))
|
|
this.expandedKeys = []
|
|
if (this.searchValue.trim() === '') {
|
|
this.gData = JSON.parse(JSON.stringify(this.data))
|
|
return
|
|
}
|
|
if (tree && tree.length > 0) {
|
|
tree.forEach((n, i, a) => {
|
|
self.searchEach(n, this.searchValue)
|
|
})
|
|
// 没有叶子节点的根节点也要清理掉
|
|
const length = tree.length
|
|
for (let i = length - 1; i >= 0; i--) {
|
|
const e2 = tree[i]
|
|
if (!this.isHasChildren(e2) && e2.title.indexOf(this.searchValue) <= -1) {
|
|
tree.splice(i, 1)
|
|
this.expandedKeys.push(e2.key)
|
|
}
|
|
}
|
|
this.gData = [...tree]
|
|
}
|
|
},
|
|
searchEach (node, value) {
|
|
const depth = this.getTreeDepth(node)
|
|
const self = this
|
|
for (let i = 0; i < depth - 1; i++) {
|
|
let spliceCounter = 0
|
|
this.traverseTree(node, n => {
|
|
if (self.isHasChildren(n)) {
|
|
const children = n.children
|
|
const length = children.length
|
|
for (let j = length - 1; j >= 0; j--) {
|
|
const e3 = children[j]
|
|
if (!self.isHasChildren(e3) && e3.title.indexOf(value) <= -1) {
|
|
children.splice(j, 1)
|
|
spliceCounter++
|
|
} else {
|
|
this.expandedKeys.push(e3.key)
|
|
}
|
|
}
|
|
}
|
|
})
|
|
if (spliceCounter === 0) {
|
|
break
|
|
}
|
|
}
|
|
},
|
|
// 判断树形结构中的一个节点是否具有孩子节点
|
|
isHasChildren (node) {
|
|
let flag = false
|
|
if (node.children && node.children.length > 0) {
|
|
flag = true
|
|
}
|
|
return flag
|
|
},
|
|
// 通过传入根节点获得树的深度
|
|
getTreeDepth (node) {
|
|
if (undefined === node || node === null) {
|
|
return 0
|
|
}
|
|
let r = 0
|
|
let currentLevelNodes = [node]
|
|
while (currentLevelNodes.length > 0) {
|
|
r++
|
|
let nextLevelNodes = []
|
|
for (let i = 0; i < currentLevelNodes.length; i++) {
|
|
const e = currentLevelNodes[i]
|
|
if (this.isHasChildren(e)) {
|
|
nextLevelNodes = nextLevelNodes.concat(e.children)
|
|
}
|
|
}
|
|
currentLevelNodes = nextLevelNodes
|
|
}
|
|
return r
|
|
},
|
|
traverseTree (node, callback) {
|
|
if (!node) {
|
|
return
|
|
}
|
|
const stack = []
|
|
stack.push(node)
|
|
let tmpNode
|
|
while (stack.length > 0) {
|
|
tmpNode = stack.pop()
|
|
callback(tmpNode)
|
|
if (tmpNode.children && tmpNode.children.length > 0) {
|
|
for (let i = tmpNode.children.length - 1; i >= 0; i--) {
|
|
stack.push(tmpNode.children[i])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
beforeDestroy () {
|
|
window.removeEventListener('resize', {}, false)
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
@import '~@assets/less/common.less';
|
|
|
|
@media screen and (min-width: 600px) and (max-width: 1600px) {
|
|
.operator-text {
|
|
margin-right: 20px !important;
|
|
}
|
|
}
|
|
</style>
|