修改bug

This commit is contained in:
caoyang
2022-03-18 14:09:42 +08:00
parent 109c2db9a2
commit 3279309a01
25 changed files with 87 additions and 168 deletions
@@ -0,0 +1,607 @@
<template>
<div class="split-detail">
<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"
:expanded-keys="expandedKeys"
:auto-expand-parent="autoExpandParent"
:defaultExpandAll="true"
:tree-data="gData"
@expand="onExpand"
>
<template slot="title" slot-scope="{ title }">
<span v-if="title.indexOf(searchValue) > -1">
{{ title.substr(0, title.indexOf(searchValue)) }}<span style="color: #f50">{{ searchValue }}</span>{{ title.substr(title.indexOf(searchValue) + searchValue.length) }}
</span>
<span v-else>{{ title }}</span>
</template>
</a-tree>
</div>
</div>
<div class="split-detail-right">
<div class="split-detail-right-wraper">
<div class="split-detail-search-header">
<a-form layout="inline" @keyup.enter.native="searchQuery(queryParams)">
<a-form-model
class="split-detail-content"
:model="queryParams"
ref="queryForm"
>
<a-row :gutter="24">
<a-col :md="6" :sm="8">
<a-form-model-item :label="$t('clauseName')" class="split-item">
<j-input :placeholder="$t('pleaseEnter') + $t('clauseName')" v-model="queryParams.serialNumber"></j-input>
</a-form-model-item>
</a-col>
<a-col :md="6" :sm="8">
<a-form-model-item :label="$t('clauseContent')" class="split-item">
<j-input :placeholder="$t('pleaseEnter')+$t('clauseContent')" v-model="queryParams.title"></j-input>
</a-form-model-item>
</a-col>
<a-col :md="6" :sm="6">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search">{{$t('query')}}</a-button>
<a-button @click="searchReset" icon="reload" style="margin-left: 8px">{{ $t('reset') }}</a-button>
</span>
</a-col>
</a-row>
</a-form-model>
</a-form>
</div>
<div class="table-operator">
<div class="operator-text" @click="handleCopyManage">
<a-icon type="copy" />
{{ $t('copy') }}
</div>
<div class="operator-text" @click="handleAddManage">
<a-icon type="plus" />
{{ $t('add') }}
</div>
<div class="operator-text" @click="handleImportManage">
<a-icon type="import" :rotate="-90" />
{{ $t('import') }}
</div>
<div class="operator-text" @click="handleExportManage">
<a-icon type="export" :rotate="-90"/>
{{ $t('export') }}
</div>
<div class="operator-text" @click="handleDownManage">
<a-icon type="download" />
{{ $t('TemplateDownload') }}
</div>
<div class="operator-text" @click="handleMergeManage">
<a-icon type="snippets" />
{{ $t('MergerClause') }}
</div>
<div class="operator-text" @click="handleManage">
<a-icon type="setting" />
{{ $t('BatchSetting') }}
</div>
<div class="operator-text" @click="handleBatCancel">
<a-icon type="delete" />
{{ $t('BatchDelete') }}
</div>
</div>
<div class="split-detail-table">
<a-table :data-source="tableData" :columns="columns" rowKey="id" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" :pagination="false" :loading="loading" class="tag-con-table">
<template slot="clauseContent" slot-scope="text, record">
<a class="content-show" href="javascript:;" :title="record.serialContent" @click="showContent">{{record.serialContent}}</a>
</template>
<template slot="action" slot-scope="text, record">
<a class="action-edit" href="javascript:;" @click="onEdit(record)">{{$t('edit')}}</a>
<a class="action-delete" href="javascript:;" @click="onCancel(record)">{{$t('delete')}}</a>
</template>
</a-table>
<div class="page" v-if="tableData.length > 0">
<a-pagination
:show-total="total => `共 ${total} 条`"
show-quick-jumper
show-size-changer
:current="queryParams.pageNo"
:page-size.sync="queryParams.pageSize"
:total="total"
@change="onChangePage"
@showSizeChange="SizeChange"
/>
</div>
</div>
</div>
</div>
<a-modal
:title="$t('clauseContent')"
:visible="contentVisible"
:confirm-loading="confirmLoading"
:footer="false"
@cancel="handleCancel"
>
<p>{{contentValue}}</p>
</a-modal>
<split-addF-form v-if="addVisible" :addVisible="addVisible" @closeVisible="closeVisible"></split-addF-form>
<upload ref="uploadSplit" @uploadSuccess="uploadSuccess"></upload>
</div>
</a-card>
</div>
</template>
<script>
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
import upload from '@/components/uploadFile/file.vue'
import SplitAddForm from './SplitAddForm'
export default {
name: 'SplitDetail',
components:{
SplitAddForm,
upload
},
data() {
return {
contentVisible:false, //条款内容弹框显示
queryParams:{
pageNo:1,
pageSize:10
},
total:0,
tableData:[
{
serialNumber:'001',
serialName:'条款001',
serialContent:'12. 附加光反射器,可以是贴纸,具有以下规格: a) 正面左右两侧呈白色或淡黄色; b) 背面左右两侧呈红色; c) 防护板下面是白色;和 d) 高至少400(四百)毫米和宽至少100(一百)毫米; 附加光反射器,可以是贴纸,具有以下规格: a) 正面左右两侧呈白色或淡黄色; b) 背面左右两侧呈红色; c) 防护板下面是白色;和 d) 高至少400(四百)毫米和宽至少100(一百)毫米;12. 附加光反射器,可以是贴纸,具有以下规格: a) 正面左右两侧呈白色或淡黄色; b) 背面左右两侧呈红色; c) 防护板下面是白色;和 d) 高至少400(四百)毫米和宽至少100(一百)毫米; 附加光反射器,可以是贴纸,具有以下规格: a) 正面左右两侧呈白色或淡黄色; b) 背面左右两侧呈红色; c) 防护板下面是白色;和 d) 高至少400(四百)毫米和宽至少100(一百)毫米;',
functionArea:'aaa',
tecArea:'bbb'
}
],
selectedRowKeys: [],
expandedKeys: [],
searchValue: '',
autoExpandParent: true,
dataList: [],
contentValue:'12. 附加光反射器,可以是贴纸,具有以下规格: a) 正面左右两侧呈白色或淡黄色; b) 背面左右两侧呈红色; c) 防护板下面是白色;和 d) 高至少400(四百)毫米和宽至少100(一百)毫米; 附加光反射器,可以是贴纸,具有以下规格: a) 正面左右两侧呈白色或淡黄色; b) 背面左右两侧呈红色; c) 防护板下面是白色;和 d) 高至少400(四百)毫米和宽至少100(一百)毫米;',
gData: [
{
title: '总目录',
key: '0-0',
children: [
{
title: '第一条 替代品',
key: '0-0-0',
},
{
title: '第二条',
key: '0-0-1',
},
{
title: '第三条',
key: '0-0-2',
},
{
title: '第四条',
key: '0-0-3',
},
{
title: '第五条',
key: '0-0-4',
},
],
}
],
selecIds:[],
loading:false,
columns: [
{
title: this.$t('clauseNo'),
dataIndex: 'serialNumber',
key: 'serialNumber',
align: "center",
},
{
title: this.$t('clauseName'),
dataIndex: 'serialName',
key: 'serialName',
align: "center",
},
{
title: this.$t('clauseContent'),
dataIndex: 'serialContent',
key: 'serialContent',
align: "center",
width: '50%',
scopedSlots: {customRender: 'clauseContent'},
},
{
title: this.$t('functionalAreas'),
dataIndex: 'functionArea',
key: 'functionArea',
align: "center",
},
{
title: this.$t('technicalField'),
dataIndex: 'tecArea',
key: 'tecArea',
align: "center",
},
{
title: this.$t('operation'),
dataIndex: 'action',
scopedSlots: {customRender: 'action'},
align: "center",
width: 120
}
],
addVisible:false,
attId:'',
data:[],
confirmLoading:false,
}
},
mounted() {
this.loadMenuData()
this.generateList(this.gData);
},
methods: {
//显示条款内容弹框
showContent(){
this.contentVisible=true
},
//关闭条款内容弹框
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){
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={
}
// this.loading=true
getAction(`sys/category/getSysCategoryTree`, params).then(res => {
if (res.success) {
this.data = [...res.result]
this.gData = [...this.data]
}
})
},
//获取列表数据
loadData(){
let params={
...this.queryParams
}
// this.loading=true
// getAction(``,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){
let params={
id:record.id
}
this.$confirm({
title: this.$t('ConfirmReplication'),
content: '',
onOk:
async () => {
deleteAction(``,params).then(res=> {
if(res.success){
this.$message.success(this.$t('OperationSuccessful'))
this.loadData()
}else{
this.$message.warning(this.$t('operationFailed'))
}
})
},
onCancel() {},
});
},
//新增
handleAddManage(){
this.addVisible=true
},
closeVisible(val){
this.addVisible=val
},
//导入
handleImportManage(){
this.$refs.uploadSplit.visible=true
},
//上传成功
uploadSuccess(data){
let attIdList = []
if(data && data.length > 0){
data.forEach(item => {
attIdList.push(item.id || data.name)
})
this.attId = attIdList.join(',')
}
},
//导出
handleExportManage(){
},
//模板下载
handleDownManage(){
// downloadFile('', fileName, { fileName: val.docRealName })
},
//合并条款
handleMergeManage(){
},
//批量设置
handleManage(){
},
//批量删除
handleBatCancel(){
let params={
id:this.selecIds.join(',')
}
this.$confirm({
title: this.$t('ConfirmBatchDeletion'),
content: '',
onOk:
async () => {
deleteAction(``,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()
}else{
this.$message.warning(this.$t('operationFailed'))
}
})
},
onCancel() {},
});
},
//编辑
onEdit(val){
this.addVisible=true
},
//删除
onCancel(val){
},
//选择框
onSelectChange(selectedRowKeys,rows) {
this.selectedRowKeys = selectedRowKeys;
this.selecIds=selectedRowKeys
},
//点击页数
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]);
}
}
}
},
}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
.split-detail{
.split-detail-wrap{
display: flex;
justify-content: space-between;
.split-detail-left{
min-width: 260px;
padding-right: 20px;
border-right: 1px solid #666666;
}
.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;
}
}
</style>