Files
laws_weilai/jero-web/src/views/documentManage/splitting/modules/SplitDetail.vue
T
2022-06-14 17:54:02 +08:00

1325 lines
43 KiB
Java

<template>
<div class='mainItem'>
<div class="split-detail" @click="clearMenu" :style="'width:' + (fullWidth - 200) + 'px'">
<a-card :bordered="false" >
<div class="split-detail-wrap">
<div class="split-detail-left">
<div class="split-detail-left-tree">
<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"
>
<!-- @rightClick="rightClick"-->
<template #title="{ key: treeKey, title, record }">
<a-dropdown :trigger="['contextmenu']">
<!-- <span>{{ title }}</span>-->
<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 @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>
</template>
</a-dropdown>
</template>
</a-tree>
</div>
</div>
<div class="split-detail-right">
<div class="split-detail-right-wraper">
<div class="split-detail-search-header">
<search :flag="'4'" :url="url" :infoId="$route.query.infoId"
:menuId="menuId" @resetSearch="resetSearch" @queryParams="queryParamsValues" />
</div>
<div class="table-operator">
<div class="operator-text" @click="handleCopyManage" v-has="'split:sarFileSplitItems:copy'">
<a-icon type="copy" />
{{ $t('copy') }}
</div>
<div class="operator-text" @click="handleAddManage" v-has="'split:sarFileSplitItems:add'">
<a-icon type="plus" />
{{ $t('add') }}
</div>
<div class="operator-text upload-split" @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>
<!-- <ImportFile :url="url"/>-->
</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-has="'split:sarFileSplitItems:template'">
<a-icon type="download" />
{{ $t('TemplateDownload') }}
</div>
<div class="operator-text" @click="handleMergeManage" v-has="'split:sarFileSplitItems:merge'">
<a-icon type="snippets" />
{{ $t('MergerClause') }}
</div>
<div class="operator-text" @click="handleManage" v-has="'split:sarFileSplitItems:set'">
<a-icon type="setting" />
{{ $t('BatchSetting') }}
</div>
<div class="operator-text" @click="handleBatCancel" v-has="'split:sarFileSplitItems:delete'">
<a-icon type="delete" />
{{ $t('BatchDelete') }}
</div>
</div>
<div class="split-detail-table">
<table-data
ref="splitDetailTabel"
:url="url"
:flag="'4'"
:OperationList="OperationList"
:infoId="$route.query.infoId"
:menuId="menuId"
:showAction="true"
@onSelectChange="onSelectChange"
@deleteClick="deleteClick"
@editClick="editClick"
@showContent="showContent"
></table-data>
</div>
</div>
</div>
<!-- 条款详情-->
<a-modal
:title="$t('clauseContent')"
:visible="contentVisible"
:confirm-loading="confirmLoading"
:footer="false"
@cancel="handleCancel"
>
<p v-html='contentValue'></p>
</a-modal>
<!-- 添加节点-->
<a-modal
class="add-menus"
:title="menuTitle"
:visible="menuRightVisible"
:confirm-loading="confirmLoading"
@cancel="handleCancelMenuRight"
@ok="hideModalMenuRight"
>
<a-form-model
v-if="menuRightVisible"
class="split-click-right-form"
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model-item :label="$t('clauseNo')" prop="name">
<a-input v-model="form.name" :placeholder="$t('PleaseEnter')+$t('clauseNo')" />
</a-form-model-item>
<a-form-model-item :label="$t('clauseName')" prop="itemName">
<a-input v-model="form.itemName" :placeholder="$t('PleaseEnter')+$t('clauseName')" />
</a-form-model-item>
<a-form-model-item :label="$t('serialNumber')" prop="displaySeq">
<a-input-number v-model="form.displaySeq" :min="1" :max="99999" :placeholder="$t('PleaseEnter')+$t('serialNumber')" :formatter="limitNumber" :parser="limitNumber" style="width: 100%" />
<!-- <a-input-number v-model="rowCount" :min="1" :placeholder="$t('pleaseEnter')+$t('numberRows')" :formatter="limitNumber" :parser="limitNumber" />-->
</a-form-model-item>
</a-form-model>
</a-modal>
<!-- 批量设置弹框-->
<a-modal
class="show-setting"
:title="$t('batSetting')"
:visible="batSetVisible"
:confirm-loading="confirmLoading"
@ok="modalOk"
@cancel="batSetCancel"
style="width: 1000px"
>
<split-bat-form
ref="fileForm"
@addFormClick="addFormClick"
:flag="'4'"
v-if="batSetVisible&&ids"
:url="urlBatSet"
:ids="ids">
</split-bat-form>
</a-modal>
<split-add-form ref="splitForm" v-if="addVisible" :addVisible="addVisible" :formTitle="formTitle" :flag="'4'" :url="url" :infoId="infoId" :menuId="menuId" :itemId="itemId" @closeVisible="closeVisible" @sumber="sumber"></split-add-form>
</div>
</a-card>
</div>
</div>
</template>
<script>
import { getAction, postAction, deleteAction, putAction, downloadFile } from '@/api/manage'
import search from '@/components/SplitSearch/index'
import TableData from '@/components/SplitDetailTable/index'
// import upload from '@/components/uploadFile/file.vue'
import SplitBatForm from '@/components/SplitBatForm/index'
import SplitAddForm from './SplitAddForm'
import upload from '@/components/SplitImport/index'
import axios from 'axios'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import moment from 'moment'
import eventBUs from '@/common/event'
import Vue from 'vue'
export default {
name: 'SplitDetail',
components:{
search,
TableData,
SplitBatForm,
SplitAddForm,
upload,
// ImportFile
},
data() {
return {
labelCol: { span: 6 },
wrapperCol: { span: 16 },
contentVisible:false, //条款内容弹框显示
queryParams:{
pageNo:1,
pageSize:10
},
total:0,
tableData:[],
selectedRowKeys: [],
selectedRows:[],
expandedKeys: [],
searchValue: '',
autoExpandParent: true,
dataList: [],
contentValue:'',
gData: [],
selecIds:[],
loading:false,
columns: [],
addVisible:false,
attId:'',
data:[],
confirmLoading:false,
NodeTreeItem:null, //右键菜单
tmpStyle:'', //右键菜单位置
menuTitle:this.$t('add'),
formTitle:'',
menuRightVisible:false,
form:{},
rules: {
name: [
{ required: true, message: this.$t('PleaseEnter')+this.$t('clauseNo'), trigger: 'blur' },
{ min: 1, max: 200, message: this.$t('cantExeed') + '200' + this.$t('characters'), trigger: 'blur' },
],
itemName: [
{ required: true, message: this.$t('PleaseEnter')+this.$t('clauseName'), trigger: 'blur' },
{ min: 1, max: 200, message: this.$t('cantExeed') + '200' + this.$t('characters'), trigger: 'blur' },
],
displaySeq: [
{ required: true, message: this.$t('PleaseEnter')+this.$t('serialNumber'), trigger: 'blur' },
// { min: 1, max: 99999, message: this.$t('cantExeed') + '99999' + this.$t('characters'), trigger: 'blur' },
],
},
infoId:'',
menuId:'',
itemId:'',
itemVal:{},
// NodeTreeItemVisible:false,
flag:false, //提交按钮标识
isEdit:false,
OperationList: [ //操作栏
{
text: this.$t('edit'),
ClickEvent: 'editClick'
}, //编辑
{
text: this.$t('delete'),
ClickEvent: 'deleteClick'
} //删除
],
url:{
tableHeader: 'split/sarFileSplitItems/getHeader', //表格头部字段
seachList: 'split/sarFileSplitItems/queryCondition', //搜索字段
tableList: 'split/sarFileSplitItems/getSplitItemsByPage', //表格数据
getAddForm: 'split/sarFileSplitItems/getForm', // 表单的字段
addInfo: '/jero-boot/split/sarFileSplitItems/addSplitItems', //新增
updateInfo:'/jero-boot/split/sarFileSplitItems/updateSplitItems', //编辑
getDocumentInfo:'split/sarFileSplitItems/getSplitItemsById',
importZipUrl: '/split/sarFileSplitItems/importSplitItems',//导入
},
urlBatSet:{
getAddForm:'split/sarFileSplitItems/getBatchSetForm',
addInfo:'/jero-boot/split/sarFileSplitItems/batchSet',
},
batSetVisible:false, //批量设置弹框显示
ids:'',
token:Vue.ls.get(ACCESS_TOKEN),
// upAccept:'.zip', //导入文件类型
uploadMenuId:'',
selectedKeys:[],
deleteNode:false,
fullWidth:'',
parameter:{},
widthBrown:'',
creenWidth: document.body.clientWidth,
brownHeight:document.documentElement.clientHeight,
}
},
watch:{
deleteNode(){
},
screenWidth: {
immediate: true,
handler(newValue) {
// console.log(newValue)
}
}
},
computed:{
},
mounted() {
const that = this;
let client=''
let width=''
// this.widthBrown = window.screenWidth || document.body.clientWidth;
// let iframeTop= document.querySelector('.split-detail-left').getBoundingClientRect().top
// document.querySelector('.split-detail-left').style.height = this.brownHeight-iframeTop-24 + 'px'
// console.log(iframeTop,'iframeTop2222')
// document.querySelector('.split-detail-table .ant-table-content').style.width = width - 20 + 'px'
// window.addEventListener('resize', () => {
// that.screenWidth = window.screenWidth || document.body.clientWidth;
// client = document.querySelector('.split-detail-table .ant-table-content').getBoundingClientRect()
// // console.log('screenWidth',that.screenWidth)
// width = that.screenWidth - client.left
// document.querySelector('.split-detail-table .ant-table-content').style.width = width - 20 + 'px'
// iframeTop= document.querySelector('.split-detail-left').getBoundingClientRect().top
// console.log(iframeTop,'iframeTop111')
// document.querySelector('.split-detail-left').style.height = this.brownHeight-iframeTop-24 + 'px'
// }, false);
this.infoId=this.$route.query.infoId
console.log('info',this.$route.query)
this.loadMenuData()
// this.loadData()
this.generateList(this.gData);
},
methods: {
//显示条款内容弹框
showContent(val){
this.contentVisible=true
this.contentValue = val
},
//关闭条款内容弹框
handleCancel(){
this.contentVisible = false;
},
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){
// console.log('expandedKeys',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(){
let 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 索引数据列
let map = {};
config.forEach((item) => {
item.label = item.name;
item.key=item.id;
item.title=item.name+(item.itemName?' '+item.itemName:'')
map[item.id] = item;
});
let val = [];
config.forEach((item) => {
// 以当前遍历项,的pid,去map对象中找到索引的id
let 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?true:false
// console.log('eee',event,node)
// this.NodeTreeItemVisible=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.form.pid=this.NodeTreeItem.id
// this.form.id=this.NodeTreeItem.id
this.tmpStyle = {
position: 'absolute',
maxHeight: 40,
textAlign: 'center',
left: `${x + 10 - 0}px`,
top: `${y + 6 - 0}px`,
background:`#FFFFFF`,
zIndex:`2`
};
// console.log('NodeTreeItem',this.NodeTreeItem)
},
// 用于点击空白处隐藏增删改菜单
clearMenu () {
this.NodeTreeItem = null;
// this.NodeTreeItemVisible=false
},
//选择树节点
onSelect(selectedKeys){
this.menuId=selectedKeys[0]
this.uploadMenuId=selectedKeys[0]
this.selectedKeys=selectedKeys
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
this.parameter.info_id=this.infoId
this.parameter.menu_id=this.menuId
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
// eventBUs.$emit('searchReset')
console.log('sele',this.menuId,selectedKeys)
// console.log('uploadMenuId',this.uploadMenuId)
},
//树形新增
orgAdd(){
this.menuTitle=this.$t('add')
this.isEdit=false
this.form={}
this.menuRightVisible=true
},
//树形修改
orgEdit(){
this.menuTitle=this.$t('edit')
this.isEdit=true
this.form.id=this.nodeItem.id
this.form.pid=this.nodeItem.pid
this.form.name=this.nodeItem.name
this.form.itemName=this.nodeItem.itemName
this.form.displaySeq=this.nodeItem.displaySeq
this.menuRightVisible=true
},
//树形删除
orgDelete(){
this.$confirm({
content: this.$t('deleteNodes'),
onOk:
async () => {
getAction(`split/sarFileSplitMenu/deleteMenu`, { id: this.nodeItem.id }).then(res => {
if (res.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.loadMenuData()
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
// eventBUs.$emit('searchReset')
} else {
this.$message.warning(this.$t('operationFailed'))
}
})
}
})
},
onContextMenuClick(treeKey, menuKey,) {
// console.log(`treeKey: ${treeKey}, menuKey: ${menuKey}`);
},
//清空按钮
resetSearch(){
this.menuId=''
this.uploadMenuId=''
this.selectedKeys=[]
},
handleCancelMenuRight(){
this.menuRightVisible=false
},
//增加条款确定
hideModalMenuRight(){
let expandId=[]
expandId.push(this.form.pid)
if(!this.isEdit){
let params={
infoId: this.infoId,
pid:this.nodeItem.id,
...this.form,
}
this.$refs.ruleForm.validate(valid=>{
if(valid){
// console.log('parms',this.params)
if(!this.flag){
this.flag=true
postAction(`split/sarFileSplitMenu/addMenu`,params).then(res=>{
if(res.success){
this.menuRightVisible=false
this.$message.success(this.$t('OperationSuccessful'))
// this.onExpand(expandId)
this.form={}
this.expandedKeys.push(this.nodeItem.id)
// console.log('expandedKeys1111',this.expandedKeys)
this.loadMenuData()
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
// eventBUs.$emit('searchReset')
}else{
this.$message.warning(this.$t('operationFailed'))
}
}).finally(()=>{
this.flag=false
this.menuRightVisible=false
})
}
}
})
}else{
let params = {
info_id: this.infoId,
...this.form,
}
if(!this.flag){
this.flag=true
// console.log('parms',params)
putAction(`split/sarFileSplitMenu/updateMenu`,params).then(res=>{
if(res.success){
this.$message.success(this.$t('OperationSuccessful'))
this.onExpand(expandId)
this.form={}
this.loadMenuData()
}else{
this.$message.warning(this.$t('operationFailed'))
}
}).finally(()=>{
this.flag=false
this.menuRightVisible=false
})
}
}
},
//获取列表数据
loadData(){
let params={
...this.queryParams,
info_id:this.infoId
}
this.loading=true
postAction(`split/sarFileSplitItems/getSplitItemsByPage`,params).then(res=>{
if(res.success){
this.tableData= [ ...res.result.records ]
this.loading=false
}
})
},
//搜索
searchQuery(){
},
//清空
searchReset(){
this.queryParams={
pageNo: 1,
pageSize: 10
}
this.loadData()
},
//复制按钮
handleCopyManage(record){
// console.log('')
let ids=[]
let infoIds=[]
let menuIds=[]
this.selectedRows.forEach(item=>{
ids.push(item.id)
infoIds.push(item.info_id)
menuIds.push(item.menu_id)
})
let params={
ids:ids.join(','),
infoIds:infoIds.join(','),
menuids:menuIds.join(',')
}
if(menuIds&&menuIds.length>0) {
this.$confirm({
title: this.$t('ConfirmReplication'),
content: '',
onOk:
async () => {
axios({
url: '/jero-boot/split/sarFileSplitItems/batchCopyItems',
method: 'get',
params: params,
// transformRequest: [function (data) {
// // Do whatever you want to transform the data
// let ret = ''
// for (let it in data) {
// ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
// }
// return ret
// }],
headers: {
// 'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token': this.token
}
})
.then((res) => {
if (res.data.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.$emit('selectClear')
this.selectClear()
// this.loadData()
this.loadMenuData()
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
// eventBUs.$emit('searchReset')
} else {
this.$message.warning(this.$t('operationFailed'))
}
})
},
onCancel() {
},
})
}else if(menuIds.length==0){
this.$message.warning(this.$t('PleaseSelectData'))
}
},
//新增
handleAddManage(){
// console.log('this.menuId',this.menuId)
if(this.menuId){
this.formTitle=this.$t('add')
this.itemId=''
this.addVisible=true
this.$nextTick(() => {
this.$refs.splitForm.add()
})
}else{
this.$message.warning(this.$t('selectDirectoryTerms'))
}
},
closeVisible(val){
this.addVisible=val
},
//导入
handleImportManage(){
if(!this.menuId){
this.$message.warning(this.$t('selectDirectoryTerms'))
}
},
//上传成功
uploadSuccess(data,status){
// console.log('data111',data)
if(status==='success'){
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
this.loadMenuData()
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
}
let attIdList = []
if(data && data.length > 0){
data.forEach(item => {
attIdList.push(item.id || data.name)
})
this.attId = attIdList.join(',')
// eventBUs.$emit('searchReset')
}
},
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)
let dateName = moment(new Date()).format('YYYY-MM-DD HH-mm-ss')
let name = this.$route.query.infoNumber +' '+ dateName+'.zip'
let query = {
exportName: this.$route.query.infoNumber + ' ' + dateName,
idList: this.selectedRowKeys.join(','),
parameter: this.parameter
}
downloadFile('split/sarFileSplitItems/exportSplitInfoZip', name, query,this.selectClear)
},
selectClear() {
this.$refs.splitDetailTabel.selectedRowKeys = []
this.selectedRowKeys=[]
this.selectedRows=[]
this.selecIds=[]
},
//模板下载
handleDownManage(){
let name = this.$t('documentSplitTemplate')+'.xls'
downloadFile('split/sarFileSplitItems/exportTemplate',name, {})
},
//合并条款
handleMergeManage(){
if(this.selectedRowKeys&&this.selectedRowKeys.length<2){
this.$message.warning(this.$t('leastTwo'))
}else{
let ids = this.selectedRowKeys.join(',')
this.$confirm({
title: this.$t('mergeTerms'),
content: '',
onOk:
async () => {
axios({
url: '/jero-boot/split/sarFileSplitItems/batchMergeItems',
method: 'get',
params: {
ids:ids
},
headers: {
'X-Access-Token':this.token
}
})
.then( (res) => {
if (res.data.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.selectClear()
this.loadMenuData()
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
// eventBUs.$emit('searchReset')
this.selectedRowKeys=[]
} else {
this.$message.warning(this.$t('operationFailed'))
}
}).finally(()=>{
})
}
})
}
},
//批量设置
handleManage(){
this.ids = this.selectedRowKeys.join(',')
if(this.selectedRowKeys&&this.selectedRowKeys.length<1){
this.$message.warning(this.$t('selectLeastOne'))
}else {
// console.log('idsss',this.ids)
this.batSetVisible=true
}
},
//批量设置确定
modalOk(){
// this.confirmLoading=true
this.$refs.fileForm.sumber()
},
//批量设置取消
batSetCancel(){
this.batSetVisible=false
},
//批量设置确定提交
addFormClick(){
this.batSetVisible=false
this.selectClear()
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
},
//批量删除
handleBatCancel(){
let params={
ids:this.selecIds.join(',')
}
if(this.selecIds&&this.selecIds.length>0){
this.$confirm({
title: this.$t('ConfirmBatchDeletion'),
content: '',
onOk:
async () => {
axios({
url: '/jero-boot/split/sarFileSplitItems/batchDeleteItems',
method: 'post',
data: params,
transformRequest: [function (data) {
// Do whatever you want to transform the data
let ret = ''
for (let it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}],
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token':this.token
}
})
.then( (res) =>{
if (res.data.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.loadMenuData()
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
this.selectClear()
// eventBUs.$emit('searchReset')
}else{
this.$message.warning(res.data.message)
}
})
.catch( (error) =>{
console.log(error);
});
},
onCancel() {},
});
}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)
})
},
//保存成功
sumber(){
this.loadMenuData()
},
//删除
deleteClick(val){
let params={
ids:val.id
}
this.$confirm({
title: this.$t('areYouSure'),
content: '',
onOk:
async () => {
axios({
url: '/jero-boot/split/sarFileSplitItems/batchDeleteItems',
method: 'post',
data: params,
transformRequest: [function (data) {
// Do whatever you want to transform the data
let ret = ''
for (let it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}],
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token':this.token
}
})
.then( (res) =>{
if (res.data.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.loadMenuData()
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
eventBUs.$emit('searchQuery', JSON.parse(JSON.stringify(queryParam)))
// eventBUs.$emit('searchReset')
}else{
this.$message.warning(this.$t('operationFailed'))
}
})
.catch( (error) =>{
console.log(error);
});
// postAction(`split/sarFileSplitItems/batchDeleteItems`,params).then(res=> {
// if(res.success){
// this.$message.success(this.$t('OperationSuccessful'))
// // if(this.selecIds.length==this.tableData.length&&this.queryParams.pageNo!=1){
// // this.queryParams.pageNo=this.queryParams.pageNo-1
// // }
// // this.loadData()
// this.loadMenuData()
// eventBUs.$emit('searchReset')
// }else{
// this.$message.warning(this.$t('operationFailed'))
// }
// })
},
onCancel() {},
});
},
//选择框
onSelectChange(selectedRowKeys,rows) {
this.selectedRowKeys = selectedRowKeys;
this.selectedRows=rows
this.selecIds=selectedRowKeys
// console.log('rows',this.selectedRows)
},
//点击页数
onChangePage(page,pageSize){
this.queryParams.pageNo = page
this.loadData()
},
//一页显示条数
SizeChange(page,pageSize){
this.queryParams.pageSize = pageSize
this.queryParams.pageNo = 1
this.loadData()
},
onSearch() {
let self = this;
let 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);
});
// 没有叶子节点的根节点也要清理掉
let length = tree.length;
for (let i = length - 1; i >= 0; i--) {
let 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) {
let depth = this.getTreeDepth(node);
let self = this;
for (let i = 0; i < depth - 1; i++) {
let spliceCounter = 0;
this.traverseTree(node, n => {
if (self.isHasChildren(n)) {
let children = n.children;
let length = children.length;
for (let j = length - 1; j >= 0; j--) {
let 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 || null == node) {
return 0;
}
let r = 0;
let currentLevelNodes = [node];
while(currentLevelNodes.length > 0){
r++;
let nextLevelNodes = new Array();
for(let i = 0; i < currentLevelNodes.length; i++) {
let e = currentLevelNodes[i];
if (this.isHasChildren(e)) {
nextLevelNodes = nextLevelNodes.concat(e.children);
}
}
currentLevelNodes = nextLevelNodes;
}
return r;
},
traverseTree(node, callback) {
if (!node) {
return;
}
let 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]);
}
}
}
},
//正则替换小数点
limitNumber(value) {
if (typeof value === 'string') {
return !isNaN(Number(value)) ? value.replace(/\./g, '') : 0
} else if (typeof value === 'number') {
return !isNaN(value) ? String(value).replace(/\./g, '') : 0
} else {
return 0
}
},
},
beforeDestroy() {
window.removeEventListener('resize', {}, false);
},
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
.split-detail{
height: 100%!important;
.split-detail-wrap{
display: flex;
justify-content: space-between;
.split-detail-left{
height: 100%;
min-width: 300px;
padding-right: 20px;
border-right: 1px solid #E6E7EC;
overflow-y: auto;
.split-detail-left-tree{
}
.menu-item{
padding: 2px 8px;
border: 1px solid #000000;
border-bottom: none;
cursor: pointer;
}
.menu-bottom{
border-bottom: 1px solid #000000;
}
.menu-item:hover{
background: #00B3BE;
color: #ffffff;
}
}
.split-detail-right{
padding-left: 20px;
flex: 1;
.split-detail-search-header{
margin-bottom: 20px;
.table-page-search-submitButtons{
display: flex;
}
}
.split-detail-table{
.action-edit{
margin-right: 20px;
}
.content-show{
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
height: 60px;
line-height: 20px;
white-space: pre-wrap;
}
.page{
text-align: right;
}
}
.split-item{
display: flex;
}
}
.page{
margin-top: 20px;
}
}
}
/deep/.ant-table-body{
overflow: hidden!important;
}
</style>
<style lang="less">
.split-item{
.ant-form-item-label{
min-width: 100px;
}
}
.add-menus{
.ant-modal-wrap{
.ant-modal-footer{
text-align: center;
}
}
}
.split-detail-right-wraper{
.table-page-search-submitButtons{
.ant-col-md-6{
display: flex;
}
}
.split-detail-search-header{
.ant-col-sm-8{
min-width: 300px;
}
.ant-select-selection--multiple{
ul{
height:36px;
overflow-y: auto;
}
}
}
.upload-split{
.ant-upload{
color:#040B29;
}
.anticon-import{
display: inline-block;
margin-right: 3px!important;
}
}
}
.show-setting{
.ant-modal{
min-width:700px;
}
.ant-modal-footer{
text-align: center;
}
}
.split-detail-left{
.ant-tree-node-content-wrapper-normal{
}
ant-tree-node-content-wrapper{
.expand-title{
}
}
.ant-tree-title{
span{
//display: block;
width: auto;
overflow:hidden;
text-overflow:ellipsis;
}
}
.ant-tree-child-tree{
.ant-tree-title{
span{
//display: block;
width: auto;
overflow:hidden;
text-overflow:ellipsis;
}
}
}
}
.ant-modal-body{
max-height: 500px;
overflow-y: auto;
}
.split-detail-table{
.ant-table-body{
overflow: auto!important;
}
}
.item-content-show{
.wordImg{
width: 40px;
height: auto;
}
}
@media screen and (min-width: 600px) and (max-width: 1600px) {
.operator-text {
margin-right: 20px!important;
}
.title-text{
min-width: 73px!important;
}
.split-detail-wrap{
height: 481px!important;
}
.mainItem{
height: 500px;
}
}
@media screen and (min-width: 1600px) and (max-width: 2000px) {
.split-detail .split-detail-wrap .split-detail-left{
height: 735px!important;
}
.mainItem{
height: 800px!important;
}
}
</style>