2023-11-9-dist

This commit is contained in:
X1627315083
2023-11-09 13:49:10 +08:00
parent 4199833607
commit 897f61a3c9
18 changed files with 146 additions and 83 deletions

View File

@@ -9,6 +9,7 @@
@onCancel="clearSetLabel"
>
<div class="setLabel_centent">
<div @click="removeLabel(options)">删除</div>
<ul class="optionsItem">
<li class="optionsItem_title" v-for="optionsItem,optionsIndex in options" :key="optionsItem.id">
<div class="setLabel_text">
@@ -20,14 +21,14 @@
</div>
<ul class="childrenItem active" v-mousewheel>
<li class="childrenItem_title setLabel_text" v-for="childrenItem,childrenIndex in optionsItem.children" :key="childrenItem.id">
<a-checkbox v-model:checked="childrenItem.checkAll"></a-checkbox>
<li class="childrenItem_title setLabel_text" v-for="childrenItem,childrenIndex in optionsItem.childList" :key="childrenItem.id">
<a-checkbox v-model:checked="childrenItem.checkAll" @change="onCheckAllchildrenItem(optionsItem)"></a-checkbox>
<span v-show="!childrenItem.openType">{{ childrenItem.classificationName }}</span>
<input v-show="childrenItem.openType" type="text" v-model="itemName">
<i v-show="childrenItem.openType" @click.stop="putName(index,'affirm',childrenItem)" class="fi fi-br-check"></i>
<i v-show="!childrenItem.openType" @click.stop="putName(childrenIndex,'put',childrenItem)" class="fi fi-rr-edit"></i>
</li>
<li @click="newLabel(optionsItem)" class="newLabel setLabel_text">
<li @click="newLabel(optionsItem,optionsItem.id)" class="newLabel setLabel_text">
<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>
<div v-show="!optionsItem.addOpenType">+</div>
@@ -62,7 +63,7 @@ export default defineComponent({
setup() {
let multiple = ref(false)
let indeterminate = ref(true)
let options:any = inject('options')//父组件传过来的数据
let options:any = ref([])//父组件传过来的数据
let type:any = inject('type')//父组件传过来的数据
let checkedList = ref([])
let openType = ref(false)
@@ -127,103 +128,156 @@ export default defineComponent({
}
},
methods:{
init(str:any){
init(str:any,data:any){
this.setLabelShow = true
if(str === 'add'){
this.multiple = false
}else{
this.multiple = true
}
this.clearOpenType()
this.options = data
},
clearSetLabel(){
this.setLabelShow = false
this.clearOpenType()
},
onCheckAllChange(value:any){
value.children.forEach((item:any) => {
item.checkAll = value.checkAll
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
if(optionsItem?.children){
optionsItem?.children?.forEach((childrenItem:any) => {
childrenItem.openType = false
});
}
});
this.openType = false
},
putName(index:number,v:string,item:any){
let data:any
if(v == 'put'){
this.options.forEach((optionsItem:any) => {
optionsItem.openType = false
optionsItem.addOpenType = false
optionsItem.children.forEach((childrenItem:any) => {
childrenItem.openType = false
});
});
this.clearOpenType()
item.openType = true
this.itemName = item.label
this.itemName = item.classificationName
// 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'));
}else{
console.log(this.itemName);
let data:any = {
label:this.itemName,
value:this.itemName,
}
if(item){
item.addOpenType = false
item.children.push(data)
data = {
classificationName:this.itemName,
parentId:item.id
}
}else{
this.openType = false
data.children = []
this.options.push(data)
data = {
classificationName:this.itemName,
parentId:''
}
}
}
}else{
item.label = this.itemName
data = {
id:item.id,
classificationName:this.itemName,
}
item.classificationName = this.itemName
item.openType = false
}
this.addLabel(data)
}
},
newLabel(item:any){
// console.log(index);
this.itemName = ''
this.options.forEach((optionsItem:any) => {
optionsItem.openType = false
optionsItem.addOpenType = false
optionsItem.children.forEach((childrenItem:any) => {
childrenItem.openType = false
});
});
this.openType = false
newLabel(item:any,id:any){
this.itemName = ''
this.clearOpenType()
if(item){
item.addOpenType = true
}else{
this.openType = true
}
// console.log(item.addOpenType);
// this.options.forEach((optionsItem:any) => {
// optionsItem.openType = false
// optionsItem.children.forEach((childrenItem:any) => {
// childrenItem.openType = false
// });
// });
// this.itemName = ''
// item.openType = true
this.addLabel()
if(item){
item.addOpenType = true
}else{
this.openType = true
}
},
addLabel(){
removeLabel(val:any){
let data:any = []
this.clearOpenType()
val.forEach((optionsItem:any) => {
if(optionsItem.checkAll){
data.push(optionsItem)
}else{
if(optionsItem.childList){
let boor = false
let dataChild:any = []
optionsItem.childList.forEach((childrenItem:any) => {
if(childrenItem.checkAll){
boor = true
dataChild.push(childrenItem)
}
});
if(boor){
optionsItem.childList = dataChild
data.push(optionsItem)
}
}
}
});
this.deleteClass(data)
},
addLabel(val:any){
let data = this.setLabelData()
console.log(data);
if(val.parentId){//新增
data.parentId = val.parentId
}
if(val.id){//修改
data.id = val.id
}
data.classificationName = val.classificationName
Https.axiosPost(Https.httpUrls.saveOrUpdate, data).then(
(rv: any) => {
console.log(rv);
this.getClass()
}
).catch((res)=>{
});
},
deleteClass(data:any){
Https.axiosPost(Https.httpUrls.classificationDelete, data).then(
(rv: any) => {
console.log(rv);
}
).catch((res)=>{
});
},
getClass(){
let data = this.setLabelData()
Https.axiosPost(Https.httpUrls.queryClassification, data).then(
(rv: any) => {
console.log(rv);
this.options = rv
}
).catch((res)=>{
});
},
setLabelData(){