2023-11-07 09:30:25 +08:00
< template >
< a-modal class = "library_setLabel"
v - model : visible = "setLabelShow"
: footer = "null"
title = "Edit tag"
width = "65%"
: maskClosable = "false"
2023-11-28 16:21:00 +08:00
: keyboard = "false"
2023-11-07 09:30:25 +08:00
: centered = "true"
2023-11-09 16:55:20 +08:00
@ cancel = "clearSetLabel"
2023-11-07 09:30:25 +08:00
>
2023-11-08 13:01:45 +08:00
< div class = "setLabel_centent" >
2023-11-09 10:16:18 +08:00
< ul class = "optionsItem" >
2023-11-29 16:30:17 +08:00
< li class = "optionsItem_title" @click.stop ="" v-for = "optionsItem,optionsIndex in options" :key="optionsItem.id" >
2023-11-30 13:52:36 +08:00
< div class = "setLabel_text" :class = "{active:optionsItem.checAll}" >
2023-11-09 10:16:18 +08:00
< a-checkbox v -model :checked = "optionsItem.checkAll" @change ="onCheckAllChange(optionsItem)" > < / a -checkbox >
2023-11-13 09:52:57 +08:00
< span v-show = "!optionsItem.openType" :title="optionsItem.classificationName" > {{ optionsItem.classificationName }} < / span >
2023-11-09 10:16:18 +08:00
< input v-show = "optionsItem.openType" type="text" v-model="itemName" >
2023-11-13 09:52:57 +08:00
< i v-show = "optionsItem.openType" @click.stop="putName(optionsIndex,'affirm',optionsItem)" class="fi fi-br-check" > < / i >
2023-11-09 10:16:18 +08:00
< i v-show = "!optionsItem.openType" @click.stop="putName(optionsIndex,'put',optionsItem)" class="fi fi-rr-edit" > < / i >
< / div >
< ul class = "childrenItem active" v-mousewheel >
2023-11-30 14:06:05 +08:00
< li class = "childrenItem_title setLabel_text" :class = "{active:childrenItem.checAll}" v-for = "childrenItem,childrenIndex in optionsItem.childList" :key="childrenItem.id" >
<!-- { { optionsItem } } -- >
2023-11-09 13:49:10 +08:00
< a-checkbox v -model :checked = "childrenItem.checkAll" @change ="onCheckAllchildrenItem(optionsItem)" > < / a -checkbox >
2023-11-13 09:52:57 +08:00
< span v-show = "!childrenItem.openType" :title="childrenItem.classificationName" > {{ childrenItem.classificationName }} < / span >
2023-11-09 10:16:18 +08:00
< input v-show = "childrenItem.openType" type="text" v-model="itemName" >
2023-11-13 09:52:57 +08:00
< i v-show = "childrenItem.openType" @click.stop="putName(childrenIndex,'affirm',childrenItem)" class="fi fi-br-check" > < / i >
2023-11-09 10:16:18 +08:00
< i v-show = "!childrenItem.openType" @click.stop="putName(childrenIndex,'put',childrenItem)" class="fi fi-rr-edit" > < / i >
< / li >
2023-11-09 16:55:20 +08:00
< li class = "newLabel setLabel_text" >
2023-11-09 10:16:18 +08:00
< input v-show = "optionsItem.addOpenType" type="text" v-model="itemName" >
< i @click.stop ="putName(-1,'affirm',optionsItem)" v-show = "optionsItem.addOpenType" class="fi fi-br-check" > < / i >
2023-11-13 09:52:57 +08:00
< div class = "addLabel" v-show = "!optionsItem.addOpenType" @click="newLabel(optionsItem,optionsItem.id)" > + < / div >
2023-11-09 10:16:18 +08:00
< / li >
2023-11-08 13:01:45 +08:00
< / ul >
< / li >
2023-11-09 16:55:20 +08:00
< li class = "newLabel setLabel_text optionsItem_title" >
2023-11-13 09:52:57 +08:00
< div >
2023-11-21 09:58:46 +08:00
< input v-show = "openType" type="text" v-model="itemName" >
2023-11-13 09:52:57 +08:00
< i @click.stop ="putName(-1,'affirm','')" v-show = "openType" class="fi fi-br-check" > < / i >
< div class = "addLabel" v-show = "!openType" @click="newLabel('','')" > + < / div >
< / div >
2023-11-22 17:05:09 +08:00
< div class = "started_btn" @click ="removeLabel(options)" > Delete < / div >
2023-11-09 10:16:18 +08:00
< / li >
2023-11-08 09:31:40 +08:00
< / ul >
< / div >
2023-11-07 09:30:25 +08:00
< / a-modal >
< / template >
< script lang = "ts" >
2023-11-09 10:16:18 +08:00
import { defineComponent , ref , createVNode , watch , nextTick , inject } from 'vue'
2023-11-07 09:30:25 +08:00
import { Https } from "@/tool/https" ;
import { dataURLtoFile , base64toFile } from "@/tool/util"
2023-11-16 17:23:17 +08:00
import { ExclamationCircleOutlined } from '@ant-design/icons-vue' ;
2023-11-07 09:30:25 +08:00
import { getCookie } from "@/tool/cookie" ;
import 'vue-cropper/dist/index.css'
import { VueCropper } from "vue-cropper" ;
import { useStore } from "vuex" ;
import { useI18n } from 'vue-i18n' ;
import { Modal , message , Upload , CascaderProps } from 'ant-design-vue' ;
export default defineComponent ( {
components : {
VueCropper ,
} ,
setup ( ) {
let multiple = ref ( false )
2023-11-08 13:01:45 +08:00
let indeterminate = ref ( true )
2023-11-09 13:49:10 +08:00
let options : any = ref ( [ ] ) //父组件传过来的数据
2023-11-09 10:16:18 +08:00
let type : any = inject ( 'type' ) //父组件传过来的数据
2023-11-08 13:01:45 +08:00
let checkedList = ref ( [ ] )
2023-11-09 10:16:18 +08:00
let openType = ref ( false )
let itemName = ref ( '' )
2023-11-07 09:30:25 +08:00
let { t } = useI18n ( )
return {
multiple ,
2023-11-08 13:01:45 +08:00
indeterminate ,
2023-11-07 09:30:25 +08:00
value : ref < string [ ] > ( [ ] ) ,
options ,
2023-11-08 13:01:45 +08:00
checkedList ,
2023-11-09 10:16:18 +08:00
openType ,
type ,
itemName ,
2023-11-07 09:30:25 +08:00
t
}
} ,
data ( ) {
return {
setLabelShow : false ,
}
} ,
mounted ( ) {
} ,
watch : {
2023-11-08 13:01:45 +08:00
2023-11-07 09:30:25 +08:00
} ,
2023-11-09 10:16:18 +08:00
directives : {
mousewheel : {
mounted ( el ) {
2023-11-09 16:55:20 +08:00
let bodyDom : any = document . getElementsByClassName ( 'setLabel_centent' ) [ 0 ]
2023-11-09 10:16:18 +08:00
nextTick ( ) . then ( ( ) => {
2023-11-09 16:55:20 +08:00
let domParent : any = document . getElementsByClassName ( 'childrenItem' )
let mouseover = ( event : any ) => {
event . stopPropagation ( )
2023-11-09 10:16:18 +08:00
bodyDom . classList . add ( 'active' )
}
2023-11-09 16:55:20 +08:00
let mouseleave = ( event : any ) => {
event . stopPropagation ( )
2023-11-09 10:16:18 +08:00
bodyDom . classList . remove ( 'active' )
}
for ( let index = 0 ; index < domParent . length ; index ++ ) {
2023-11-09 16:55:20 +08:00
domParent [ index ] . addEventListener ( 'mouseover' , mouseover , false )
domParent [ index ] . addEventListener ( 'mouseleave' , mouseleave , false )
2023-11-09 10:16:18 +08:00
}
el . addEventListener ( 'wheel' , ( e : WheelEvent ) => {
let num = 0
if ( e . deltaY > 0 ) {
num = 25
} else {
num = - 25
}
el . scrollBy ( num , 0 ) ;
} , true )
} )
}
}
} ,
2023-11-07 09:30:25 +08:00
methods : {
2023-11-09 13:49:10 +08:00
init ( str : any , data : any ) {
2023-11-07 09:30:25 +08:00
this . setLabelShow = true
if ( str === 'add' ) {
this . multiple = false
} else {
this . multiple = true
}
2023-11-09 13:49:10 +08:00
this . clearOpenType ( )
this . options = data
2023-11-07 09:30:25 +08:00
} ,
clearSetLabel ( ) {
2023-11-09 13:49:10 +08:00
this . clearOpenType ( )
2023-11-09 16:55:20 +08:00
let parent : any = this . $parent
parent . getClass ( )
2023-11-08 13:01:45 +08:00
} ,
2023-11-09 10:16:18 +08:00
onCheckAllChange ( value : any ) {
2023-11-09 13:49:10 +08:00
if ( value ? . childList ) {
value ? . childList . forEach ( ( item : any ) => {
item . checkAll = value . checkAll
} ) ;
}
} ,
onCheckAllchildrenItem ( value : any ) {
let boor = value ? . childList . every ( ( item : any ) => item . checkAll )
if ( boor ) {
value . checkAll = true
} else {
value . checkAll = false
}
} ,
clearOpenType ( ) {
this . options . forEach ( ( optionsItem : any ) => {
optionsItem . openType = false
optionsItem . addOpenType = false
2023-11-16 09:44:53 +08:00
if ( optionsItem ? . childList ) {
optionsItem ? . childList ? . forEach ( ( childrenItem : any ) => {
2023-11-09 13:49:10 +08:00
childrenItem . openType = false
} ) ;
}
2023-11-09 10:16:18 +08:00
} ) ;
2023-11-09 13:49:10 +08:00
this . openType = false
2023-11-09 10:16:18 +08:00
} ,
putName ( index : number , v : string , item : any ) {
2023-11-09 13:49:10 +08:00
let data : any
2023-11-09 10:16:18 +08:00
if ( v == 'put' ) {
2023-11-09 13:49:10 +08:00
this . clearOpenType ( )
2023-11-29 16:30:17 +08:00
document . addEventListener ( 'click' , this . clearOpenType )
2023-11-09 10:16:18 +08:00
item . openType = true
2023-11-09 13:49:10 +08:00
this . itemName = item . classificationName
2023-11-09 10:16:18 +08:00
// this.options[index].openType = true
// this.itemName = this.workspace.workspaceList[index].workSpaceName
} else if ( v == 'affirm' ) {
if ( index == - 1 ) {
if ( this . itemName == '' ) {
message . warning ( this . t ( 'Habit.jsContent2' ) ) ;
2023-11-16 17:23:17 +08:00
return
2023-11-09 10:16:18 +08:00
} else {
2023-11-09 13:49:10 +08:00
2023-11-09 10:16:18 +08:00
if ( item ) {
item . addOpenType = false
2023-11-09 13:49:10 +08:00
data = {
classificationName : this . itemName ,
parentId : item . id
}
2023-11-09 10:16:18 +08:00
} else {
this . openType = false
2023-11-09 13:49:10 +08:00
data = {
classificationName : this . itemName ,
parentId : ''
}
2023-11-09 10:16:18 +08:00
}
}
} else {
2023-11-09 13:49:10 +08:00
data = {
id : item . id ,
classificationName : this . itemName ,
}
item . classificationName = this . itemName
2023-11-09 10:16:18 +08:00
item . openType = false
}
2023-11-09 13:49:10 +08:00
this . addLabel ( data )
2023-11-29 16:30:17 +08:00
document . removeEventListener ( 'click' , this . clearOpenType )
2023-11-09 10:16:18 +08:00
}
} ,
2023-11-09 13:49:10 +08:00
newLabel ( item : any , id : any ) {
this . itemName = ''
this . clearOpenType ( )
2023-11-09 10:16:18 +08:00
2023-11-09 13:49:10 +08:00
if ( item ) {
item . addOpenType = true
} else {
this . openType = true
}
} ,
removeLabel ( val : any ) {
2023-11-09 16:55:20 +08:00
let data = {
"classificationIdList" : [ ] ,
"deleteConfirm" : 0 ,
}
let classificationIdList : any = [ ]
2023-11-09 13:49:10 +08:00
this . clearOpenType ( )
val . forEach ( ( optionsItem : any ) => {
if ( optionsItem . checkAll ) {
2023-11-09 16:55:20 +08:00
classificationIdList . push ( optionsItem . id )
2023-11-09 10:16:18 +08:00
} else {
2023-11-09 13:49:10 +08:00
if ( optionsItem . childList ) {
optionsItem . childList . forEach ( ( childrenItem : any ) => {
if ( childrenItem . checkAll ) {
2023-11-09 16:55:20 +08:00
classificationIdList . push ( childrenItem . id )
2023-11-09 13:49:10 +08:00
}
} ) ;
}
2023-11-09 10:16:18 +08:00
}
2023-11-09 13:49:10 +08:00
} ) ;
2023-11-09 16:55:20 +08:00
data . classificationIdList = classificationIdList
2023-11-09 13:49:10 +08:00
this . deleteClass ( data )
2023-11-09 10:16:18 +08:00
} ,
2023-11-09 13:49:10 +08:00
addLabel ( val : any ) {
2023-11-09 10:16:18 +08:00
let data = this . setLabelData ( )
2023-11-09 13:49:10 +08:00
if ( val . parentId ) { //新增
data . parentId = val . parentId
}
if ( val . id ) { //修改
data . id = val . id
}
data . classificationName = val . classificationName
2023-11-09 10:16:18 +08:00
Https . axiosPost ( Https . httpUrls . saveOrUpdate , data ) . then (
( rv : any ) => {
2023-11-09 13:49:10 +08:00
this . getClass ( )
2023-11-09 10:16:18 +08:00
}
) . catch ( ( res ) => {
2023-11-29 16:30:17 +08:00
this . getClass ( )
2023-11-09 13:49:10 +08:00
} ) ;
} ,
deleteClass ( data : any ) {
Https . axiosPost ( Https . httpUrls . classificationDelete , data ) . then (
( rv : any ) => {
2023-11-09 16:55:20 +08:00
this . getClass ( )
2023-11-09 13:49:10 +08:00
}
) . catch ( ( res ) => {
2023-11-22 17:05:09 +08:00
if ( res . errCode === 2 ) {
2023-11-16 17:23:17 +08:00
let _this = this
Modal . confirm ( {
title : res . errMsg ,
icon : createVNode ( ExclamationCircleOutlined ) ,
okText : 'Yes' ,
cancelText : 'No' ,
mask : false ,
zIndex : 99999 ,
2023-11-27 16:25:32 +08:00
centered : true ,
2023-11-16 17:23:17 +08:00
onOk ( ) {
data . deleteConfirm = 1
_this . deleteClass ( data )
} ,
onCancel ( ) {
}
} ) ;
}
2023-11-09 13:49:10 +08:00
} ) ;
} ,
getClass ( ) {
let data = this . setLabelData ( )
Https . axiosPost ( Https . httpUrls . queryClassification , data ) . then (
( rv : any ) => {
this . options = rv
}
) . catch ( ( res ) => {
2023-11-09 10:16:18 +08:00
} ) ;
} ,
setLabelData ( ) {
let data = {
"classificationIdList" : [ ] ,
"classificationName" : "123221" ,
"createTime" : "" ,
"deleteConfirm" : '' ,
"id" : '' ,
"libraryId" : '' ,
"parentId" : '' ,
"type" : this . type ? . selectCode . _value ,
"updateTime" : "" ,
"userId" : ''
}
return data
}
2023-11-07 09:30:25 +08:00
}
} )
< / script >
< style lang = "less" >
. library _setLabel {
2023-11-29 16:30:17 +08:00
. ant - modal - content {
border - radius : 1 rem ;
overflow : hidden ;
}
2023-11-08 13:01:45 +08:00
. setLabel _centent {
display : flex ;
flex - direction : column ;
2023-11-09 10:16:18 +08:00
// height: 300px;
2023-11-16 09:44:53 +08:00
min - height : 50 rem ;
2023-11-09 10:16:18 +08:00
max - height : 65 rem ;
overflow - y : auto ;
// border-radius: ;
2023-11-13 09:52:57 +08:00
position : relative ;
2023-11-10 10:56:18 +08:00
& . setLabel _centent : : - webkit - scrollbar { display : none ; }
2023-11-09 16:55:20 +08:00
& . active {
overflow : hidden ;
}
2023-11-13 09:52:57 +08:00
2023-11-08 13:01:45 +08:00
ul {
display : flex ;
li {
width : 100 % ;
display : flex ;
align - items : center ;
justify - content : center ;
flex - direction : column ;
2023-11-09 10:16:18 +08:00
i {
cursor : pointer ;
}
input {
border : 0 ;
width : 80 % ;
background : rgba ( 0 , 0 , 0 , 0 ) ;
2023-11-16 09:44:53 +08:00
border - bottom : 1 px solid # b5b5b5 ;
2023-11-09 10:16:18 +08:00
}
2023-11-13 09:52:57 +08:00
2023-11-09 10:16:18 +08:00
}
. setLabel _text {
display : flex ;
flex - direction : row ;
align - items : center ;
2023-11-09 16:55:20 +08:00
padding : .5 rem 1 rem ;
width : 16 rem ;
2023-11-13 09:52:57 +08:00
margin : 2 rem 2 rem ;
2023-11-09 16:55:20 +08:00
border - radius : 1 rem ;
2023-11-09 10:16:18 +08:00
justify - content : space - between ;
flex - shrink : 0 ;
2023-11-13 09:52:57 +08:00
font - size : 1.8 rem ;
font - weight : 900 ;
2023-11-30 13:52:36 +08:00
transition : .3 s all ;
2023-11-09 10:16:18 +08:00
i {
display : flex ;
}
2023-11-13 09:52:57 +08:00
> span {
max - width : 60 % ;
white - space : nowrap ;
overflow : hidden ;
text - overflow : ellipsis ;
}
2023-11-09 10:16:18 +08:00
}
2023-11-13 09:52:57 +08:00
2023-11-09 10:16:18 +08:00
}
. optionsItem {
flex - direction : column ;
2023-11-13 09:52:57 +08:00
padding : 1 rem ;
2023-11-16 09:44:53 +08:00
flex : 1 ;
2023-11-30 13:52:36 +08:00
2023-11-09 16:55:20 +08:00
. optionsItem _title {
2023-11-13 09:52:57 +08:00
margin - bottom : 2 rem ;
2023-11-09 16:55:20 +08:00
border - radius : 1 rem ;
2023-11-13 09:52:57 +08:00
align - items : flex - start ;
background - color : # f9f9f9 ;
border : 0.1 rem solid # ebebeb ;
2023-11-09 16:55:20 +08:00
// border-bottom: 2px solid rgba(0,0,0,.2);
2023-11-13 09:52:57 +08:00
box - shadow : 0 px 0 px 5 px 0 px rgba ( 0 , 0 , 0 , .3 ) ;
2023-11-09 10:16:18 +08:00
> label {
align - items : center ;
}
2023-11-30 13:52:36 +08:00
. fi - rr - edit , . fi - br - check , . ant - checkbox - wrapper {
opacity : 0 ;
transition : .3 s all ;
}
: hover {
// background: #efefef;
. fi - rr - edit , . fi - br - check , . ant - checkbox - wrapper {
opacity : 1 ;
}
}
. active {
. fi - rr - edit , . fi - br - check , . ant - checkbox - wrapper {
opacity : 1 ! important ;
}
}
2023-11-09 10:16:18 +08:00
. childrenItem {
max - width : 100 % ;
overflow : hidden ;
overflow - x : auto ;
2023-11-13 09:52:57 +08:00
// padding-bottom: 2rem;
. setLabel _text {
font - weight : 300 ;
margin : 1 rem 1 rem ;
background : # f0f0f0 ;
// background: #d5d5d5;
font - size : 1.4 rem ;
2023-11-30 13:52:36 +08:00
2023-11-13 09:52:57 +08:00
label {
transform : scale ( .8 ) ;
}
2023-11-30 13:52:36 +08:00
. fi - rr - edit , . fi - br - check , . ant - checkbox - wrapper {
2023-11-13 09:52:57 +08:00
opacity : 0 ;
transition : .3 s all ;
}
}
. setLabel _text : hover {
// background: #efefef;
2023-11-30 13:52:36 +08:00
. fi - rr - edit , . fi - br - check , . ant - checkbox - wrapper {
2023-11-13 09:52:57 +08:00
opacity : 1 ;
}
}
2023-11-09 10:16:18 +08:00
& . active : : - webkit - scrollbar - button : single - button {
display : none ;
}
& . active : : - webkit - scrollbar {
/* 竖轴的宽度 */
width : 1 rem ;
/* 横轴的高度 */
height : 1 rem ;
transition : all .3 s ;
}
/* 进度 */
& . active : : - webkit - scrollbar - thumb {
border - radius : 1 rem ;
background : rgba ( 238 , 238 , 244 , 0 ) ;
}
/* 轨道 */
& . active : : - webkit - scrollbar - track {
border - radius : 1 rem ;
background : rgba ( 238 , 238 , 244 , 0 ) ;
}
& . active : hover {
// overflow-x: scroll;
& . active : : - webkit - scrollbar - thumb {
background : # 543087 ;
}
/* 轨道 */
& . active : : - webkit - scrollbar - track {
background : rgba ( 84 , 48 , 135 , .2 ) ;
}
}
}
}
. newLabel {
text - align : center ;
justify - content : center ;
2023-11-09 16:55:20 +08:00
& . optionsItem _title {
width : 100 % ;
margin : 0 ;
2023-11-13 09:52:57 +08:00
justify - content : space - around ;
border : none ;
background : none ;
position : sticky ;
background : # fff ;
border : none ;
2023-11-30 13:52:36 +08:00
margin - top : auto ;
bottom : 2 rem ;
2023-11-13 09:52:57 +08:00
> div {
}
. started _btn {
width : auto ;
position : sticky ;
top : 0 ;
z - index : 999 ;
// margin-right: auto;
}
}
> div {
display : flex ;
width : 16 rem ;
display : flex ;
align - items : center ;
justify - content : center ;
2023-11-09 16:55:20 +08:00
}
2023-11-13 09:52:57 +08:00
. addLabel {
2023-11-09 10:16:18 +08:00
border - radius : 50 % ;
border : 1 px solid # 000 ;
display : inline - block ;
width : 2 rem ;
height : 2 rem ;
line - height : 2 rem ;
text - align : center ;
2023-11-09 16:55:20 +08:00
cursor : pointer ;
2023-11-09 10:16:18 +08:00
}
i {
cursor : pointer ;
}
2023-11-08 13:01:45 +08:00
}
}
}
2023-11-07 09:30:25 +08:00
}
< / style >