Commit 0b6be647 authored by Mac's avatar Mac

1

parent a27c4cc1
...@@ -41,13 +41,14 @@ ...@@ -41,13 +41,14 @@
no-connectors no-connectors
v-model:ticked="defaultArray" v-model:ticked="defaultArray"
@update:ticked="tickedTree" @update:ticked="tickedTree"
/> />
</div> </div>
<div class="col-6 q-px-sm"> <div class="col-6 q-px-sm">
<div class="list-title">已选择的部门或成员</div> <div class="list-title">已选择的部门或成员</div>
<div class="q-pb-none col-12 list-box"> <div class="q-pb-none col-12 list-box">
<div <div
v-for="(item,index) in defaultArray" v-for="(item,index) in selectArray"
:key="index" :key="index"
class="list-item" class="list-item"
> >
...@@ -55,14 +56,14 @@ ...@@ -55,14 +56,14 @@
<q-icon <q-icon
name="work" name="work"
color="primary" color="primary"
v-if="item.slice(0, 1) == 1" v-if="item.Id.slice(0, 1) == 1"
/> />
<q-icon <q-icon
name="person" name="person"
color="accent" color="accent"
v-if="item.slice(0, 1) == 2" v-if="item.Id.slice(0, 1) == 2"
/> />
<span class="q-ml-sm">{{ item.split('-')[1] }}</span> <span class="q-ml-sm">{{ item.Name }}</span>
</div> </div>
<q-icon name="cancel" @click="delItem(index)"></q-icon> <q-icon name="cancel" @click="delItem(index)"></q-icon>
</div> </div>
...@@ -84,6 +85,10 @@ import { ref } from 'vue' ...@@ -84,6 +85,10 @@ import { ref } from 'vue'
interface parmas { interface parmas {
[key: string]: any [key: string]: any
} }
interface SelectParams{
Id:number,
Name:string
}
export default { export default {
props: { props: {
modelValue: { modelValue: {
...@@ -136,43 +141,48 @@ export default { ...@@ -136,43 +141,48 @@ export default {
setup(props, ctx) { setup(props, ctx) {
let tree = ref<any>(null); let tree = ref<any>(null);
let list = ref<Array<string>>([]) let list = ref<Array<string>>([])
let selectArray = ref<Array<SelectParams>>([])
let hideDialog = () => { let hideDialog = () => {
ctx.emit("update:modelValue", false) ctx.emit("update:modelValue", false)
} }
let findChild = (arr: parmas) => {
arr.map((e) => { const getselectArray=(arr: parmas)=>{
if (e[props.childrenKey] && e[props.childrenKey].length > 0) { for(var i = 0;i<arr.length;i++){
let parentId = e[props.nodeKey] let j = arr[i]
let flag= tree.value.isTicked (parentId) let flag= tree.value.isTicked (j.newId)
if(flag==true){
// let childArr = e[props.childrenKey].map(_e => _e[props.nodeKey]) selectArray.value.push({Id:j.newId , Name:j.DeptName})
// let flag2 = childArr.every(_e => { }else{
// return props.defaultArray.toString().indexOf(_e) != -1 if(j.ChildList && j.ChildList.length>0){
// }) getselectArray(j.ChildList)
}
console.log(147,parentId, flag) }
}
findChild(e[props.childrenKey])
}
})
} }
let tickedTree = (val) => { let tickedTree = (val) => {
ctx.emit("update:defaultArray", val) ctx.emit("update:defaultArray", val)
console.log('defaultArray',val) setTimeout(()=>{
findChild(props.treeData) selectArray.value=[]
getselectArray(props.treeData)
console.log(selectArray.value,'selectArray')
},100)
} }
let delItem = (i: number) => { let delItem = (i: number) => {
props.defaultArray.splice(i, 1) props.defaultArray.splice(i, 1)
} }
return { return {
tree, tree,
hideDialog, hideDialog,
tickedTree, tickedTree,
delItem, delItem,
list list,
getselectArray,
selectArray
} }
} }
} }
......
...@@ -67,7 +67,8 @@ const editRuleModule = () => { ...@@ -67,7 +67,8 @@ const editRuleModule = () => {
// 重组唯一id // 重组唯一id
if (data.dataTree.length == 0) return if (data.dataTree.length == 0) return
data.dataTree.forEach(x => { data.dataTree.forEach(x => {
x.newId = x.DataType + '-' +x. DeptName + '-' + x.DeptId // x.newId = x.DataType + '-' +x. DeptName + '-' + x.DeptId
x.newId = x.DataType + '-' + x.DeptId
if (x.ChildList && x.ChildList.length > 0) { if (x.ChildList && x.ChildList.length > 0) {
getChildList(x.ChildList) getChildList(x.ChildList)
} }
...@@ -76,7 +77,8 @@ const editRuleModule = () => { ...@@ -76,7 +77,8 @@ const editRuleModule = () => {
} }
const getChildList = (ChildList: Array<any>) => { const getChildList = (ChildList: Array<any>) => {
ChildList.forEach(x => { ChildList.forEach(x => {
x.newId = x.DataType + '-' + x.DeptName + '-' + x.DeptId // x.newId = x.DataType + '-' + x.DeptName + '-' + x.DeptId
x.newId = x.DataType + '-' + x.DeptId
if (x.ChildList && x.ChildList.length > 0) { if (x.ChildList && x.ChildList.length > 0) {
getChildList(x.ChildList) getChildList(x.ChildList)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment