|
@@ -8,14 +8,6 @@
|
|
|
<div class="body">
|
|
|
<div class="content">
|
|
|
<a-form ref="searchForm" layout="inline" style="display:flex;flex-wrap:wrap;">
|
|
|
- <!-- <div style="width:80%;display:flex;flex-wrap:wrap;">
|
|
|
- <a-form-item
|
|
|
- style="width:300px;margin: 5px 40px 5px 0;"
|
|
|
- label="分类名称"
|
|
|
- name="name">
|
|
|
- <a-input v-model="queryParam.name" placeholder="请输入"/>
|
|
|
- </a-form-item>
|
|
|
- </div> -->
|
|
|
<a-form-item
|
|
|
class="form-item-style"
|
|
|
label="分类名称"
|
|
@@ -46,7 +38,14 @@
|
|
|
idField="pkId"
|
|
|
>
|
|
|
<template slot="name" slot-scope="{text}">
|
|
|
- <div style="white-space: pre-line">{{ text }}</div>
|
|
|
+ <a-tooltip placement="topLeft">
|
|
|
+ <template slot="title">
|
|
|
+ {{ text }}
|
|
|
+ </template>
|
|
|
+ <!-- <div style="white-space: pre-line">{{ text }}</div> -->
|
|
|
+ <!-- <div style="white-space: nowrap">{{ text }}</div> -->
|
|
|
+ <div style="white-space: nowrap;overflow-x: scroll;">{{ text }}</div>
|
|
|
+ </a-tooltip>
|
|
|
</template>
|
|
|
<template slot="action" slot-scope="{text,record,index}">
|
|
|
<rx-button class="clearBtn" alias="classificationEdit" :butn-icon="'none'" v-if="record.isSys != 1" @click="handleUpdateClassifyClick(record)">编辑</rx-button>
|
|
@@ -93,7 +92,7 @@
|
|
|
import breadcrumb from '../components/breadcrumb.vue'
|
|
|
import api from '@/api/knowledge/classify'
|
|
|
import classApi from '@/api/knowledge/classify'
|
|
|
-import { getCategoryId } from '../aJs/getClassifyTree'
|
|
|
+import { getCategoryId, getChildrenLength, hideChooseLevel } from '../aJs/getClassifyTree'
|
|
|
import mixin from "../aMixin/mixin"
|
|
|
const classifyMixin = new mixin('classify')
|
|
|
export default {
|
|
@@ -114,23 +113,27 @@ export default {
|
|
|
{
|
|
|
title: 'ID',
|
|
|
dataIndex: 'pkId',
|
|
|
- align: 'center'
|
|
|
+ align: 'center',
|
|
|
+ width: 200
|
|
|
},
|
|
|
{
|
|
|
title: '分类名称',
|
|
|
dataIndex: 'name',
|
|
|
// align: 'center',
|
|
|
- scopedSlots: {customRender: 'name'}
|
|
|
+ scopedSlots: {customRender: 'name'},
|
|
|
+ minWidth: 1000
|
|
|
},
|
|
|
{
|
|
|
title: '操作人',
|
|
|
dataIndex: 'operatorName',
|
|
|
- align: 'center'
|
|
|
+ align: 'center',
|
|
|
+ width: 200
|
|
|
},
|
|
|
{
|
|
|
title: '操作时间',
|
|
|
dataIndex: 'updateTime',
|
|
|
- align: 'center'
|
|
|
+ align: 'center',
|
|
|
+ width: 200
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
@@ -162,54 +165,65 @@ export default {
|
|
|
return function(record) {
|
|
|
if(record.level == 1) {
|
|
|
return this.$refs.classifyRef.getData().length
|
|
|
- } else if(record.level == 2) {
|
|
|
- let levelTwo = this.$refs.classifyRef.getData().find(item => item.pkId == record.parent)
|
|
|
- if(levelTwo.children) {
|
|
|
- return levelTwo.children.length
|
|
|
- } else {
|
|
|
- return 0
|
|
|
- }
|
|
|
} else {
|
|
|
- for(let i of this.$refs.classifyRef.getData()) {
|
|
|
- if(i.children) {
|
|
|
- for(let j of i.children) {
|
|
|
- if(j.pkId == record.parent) {
|
|
|
- if(j.children) {
|
|
|
- return j.children.length
|
|
|
- } else {
|
|
|
- return 0
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ return getChildrenLength(this.$refs.classifyRef.getData(),record)
|
|
|
}
|
|
|
+ // if(record.level == 1) {
|
|
|
+ // return this.$refs.classifyRef.getData().length
|
|
|
+ // } else if(record.level == 2) {
|
|
|
+ // let levelTwo = this.$refs.classifyRef.getData().find(item => item.pkId == record.parent)
|
|
|
+ // if(levelTwo.children) {
|
|
|
+ // console.log(levelTwo.children.length)
|
|
|
+ // return levelTwo.children.length
|
|
|
+ // } else {
|
|
|
+ // return 0
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // for(let i of this.$refs.classifyRef.getData()) {
|
|
|
+ // if(i.children) {
|
|
|
+ // for(let j of i.children) {
|
|
|
+ // if(j.pkId == record.parent) {
|
|
|
+ // if(j.children) {
|
|
|
+ // return j.children.length
|
|
|
+ // } else {
|
|
|
+ // return 0
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.init()
|
|
|
},
|
|
|
+ // mounted() {
|
|
|
+ // document.querySelector('.ant-table-thead tr th:nth-child(2)')
|
|
|
+ // console.log(document.querySelector('.ant-table-thead tr th:nth-child(2)').getAttribute('width'))
|
|
|
+ // document.querySelector('.ant-table-thead tr th:nth-child(2)').setAttribute('width', 1000)
|
|
|
+ // },
|
|
|
methods: {
|
|
|
async init() {
|
|
|
let res = await classApi.getAllByCategoryId()
|
|
|
- this.classifyList = this.getData(res.data.children)
|
|
|
+ this.classifyList = res.data.children
|
|
|
this.classifyLevelList = JSON.parse(JSON.stringify(this.classifyList))
|
|
|
},
|
|
|
// 格式化数据 disabled 编辑三分类时,只有一级分类没有二级分类,则不可选一级分类
|
|
|
- getData(data,disabled = false) {
|
|
|
- data.forEach((element) => {
|
|
|
- if(element.children && element.children.length > 0 && element.level == 2) {
|
|
|
- this.getData(element.children)
|
|
|
- } else {
|
|
|
- if(disabled && element.level == 2) {
|
|
|
- element.disabled = true
|
|
|
- }
|
|
|
- delete element.children
|
|
|
- }
|
|
|
- })
|
|
|
- return data
|
|
|
- },
|
|
|
+ // getData(data,level) {
|
|
|
+ // data.forEach((element) => {
|
|
|
+ // if(element.children && element.children.length > 0 && element.level == 2) {
|
|
|
+ // this.getData(element.children)
|
|
|
+ // } else {
|
|
|
+ // if(disabled && element.level == 2) {
|
|
|
+ // element.disabled = true
|
|
|
+ // }
|
|
|
+ // delete element.children
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // return data
|
|
|
+ // },
|
|
|
// 搜索
|
|
|
handleSearchClick() {
|
|
|
this.isShowButton = this.queryParam.name ? false : true
|
|
@@ -227,17 +241,19 @@ export default {
|
|
|
this.title = '编辑分类'
|
|
|
this.chooseLevel = record.level
|
|
|
this.changeOnSelect = false
|
|
|
- if(record.level == 2) {
|
|
|
- this.classifyLevelList = JSON.parse(JSON.stringify(this.classifyList))
|
|
|
- this.classifyLevelList.forEach(element => {
|
|
|
- if(element.level == 2) {
|
|
|
- delete element.children
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- if(record.level == 3) {
|
|
|
- this.classifyLevelList = this.getData(JSON.parse(JSON.stringify(this.classifyList)), true)
|
|
|
- }
|
|
|
+ // if(record.level == 2) {
|
|
|
+ // this.classifyLevelList = JSON.parse(JSON.stringify(this.classifyList))
|
|
|
+ // this.classifyLevelList.forEach(element => {
|
|
|
+ // // if(element.level == 2) {
|
|
|
+ // // delete element.children
|
|
|
+ // // }
|
|
|
+ // element.disabled = true
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // if(record.level == 3) {
|
|
|
+ // this.classifyLevelList = this.getData(JSON.parse(JSON.stringify(this.classifyList)), true)
|
|
|
+ // }
|
|
|
+ this.classifyLevelList = hideChooseLevel(JSON.parse(JSON.stringify(this.classifyList)), record.level)
|
|
|
let res = await this.api.findAllParentByCategoryId(record.pkId)
|
|
|
let gategoryId
|
|
|
if(!res.data.parents) {
|
|
@@ -258,7 +274,7 @@ export default {
|
|
|
this.$message.error("请输入分类名称");
|
|
|
return
|
|
|
}
|
|
|
- if((this.chooseLevel == 2 || this.chooseLevel == 3) && !this.classForm.parent.length) {
|
|
|
+ if((this.chooseLevel != 0 && this.chooseLevel != 1) && !this.classForm.parent.length) {
|
|
|
this.$message.error("请选择上级分类");
|
|
|
return
|
|
|
}
|
|
@@ -376,4 +392,8 @@ export default {
|
|
|
/deep/ .gridContent .ant-table-content .ant-table-tbody>tr>td:nth-child(2) {
|
|
|
padding-left: 60px!important;
|
|
|
}
|
|
|
+/* /deep/ .gridContent .ant-table-content .ant-table-tbody>tr>td:nth-child(2)>div:last-child {
|
|
|
+ white-space: nowrap!important;
|
|
|
+ overflow-x: scroll;
|
|
|
+} */
|
|
|
</style>
|