wujianwei
2025-08-14 22976afc564c4b5b911026c6540ad48db43e2166
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {Directive} from "@vue/runtime-core";
let upSvg   = '<i class="el-icon"><svg class="icon" width="200" height="200" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M104.704 685.248a64 64 0 0090.496 0l316.8-316.8 316.8 316.8a64 64 0 0090.496-90.496L557.248 232.704a64 64 0 00-90.496 0L104.704 594.752a64 64 0 000 90.496z"/></svg></i>'
let downSvg = '<i class="el-icon"><svg class="icon" width="200" height="200" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M104.704 338.752a64 64 0 0190.496 0l316.8 316.8 316.8-316.8a64 64 0 0190.496 90.496L557.248 791.296a64 64 0 01-90.496 0L104.704 429.248a64 64 0 010-90.496z"/></svg></i>'
 
/**
 * 显示更多查询条件
 */
export const hasShowQuery: Directive = {
    mounted(el, binding, vNode) {
        const {value} = binding;
        if (el.children.length >value){
            for (let i = value; i < el.children.length; i++) {
                el.children[i].style.display = "none"
            }
            el.style.position = 'relative'
            let a = `<div class="el-form-item el-form-item--default" style="position: absolute;right: 0px;margin: 0;top: 10px"><div class="el-form-item__content"> <a class="el-link el-link--primary" style="margin-left: 10px;" id="zk">${downSvg}</a></div></div>`;
            let aFrag = document.createRange().createContextualFragment(a);
            el.appendChild(aFrag)
            el.lastChild.addEventListener('click',function (e:any) {
                let lastChild = el.lastChild.lastChild.childNodes[1];
                if (lastChild.id === 'zk'){
                    lastChild.id = 'sk';
                    let upSvgFrag = document.createRange().createContextualFragment(upSvg);
                    lastChild.replaceChild(upSvgFrag,lastChild.childNodes[0])
                    for (let i = value; i < el.children.length-1; i++) {
                        el.children[i].style.display = "inline-flex"
                    }
                }else{
                    lastChild.id = 'zk'
                    let downSvgFrag = document.createRange().createContextualFragment(downSvg);
                    lastChild.replaceChild(downSvgFrag,lastChild.childNodes[0])
                    for (let i = value; i < el.children.length-1; i++) {
                        el.children[i].style.display = "none"
                    }
                }
            })
 
        }
 
    }
}
/**
 * 显示更多操作功能
 */
export const hasShowListOpt: Directive = {
    mounted(el, binding, vNode) {
        const {value} = binding;
        if (el.children.length >value){
            el.style="margin-right:12px";
            for (let i = value; i < el.children.length; i++) {
                el.children[i].style.display = "none"
            }
            let a = `<div class="el-form-item el-form-item--default" style="position: absolute;right: 5%;margin: 0;top: 17px;text-align: right"><div class="el-form-item__content"> <a class="el-link el-link--primary" style="margin-left: 10px;" id="zk">${downSvg}</a></div></div>`;
            let aFrag = document.createRange().createContextualFragment(a);
            el.appendChild(aFrag)
            el.lastChild.addEventListener('click',function (e:any) {
                let lastChild = el.lastChild.lastChild.childNodes[1];
                if (lastChild.id === 'zk'){
                    lastChild.id = 'sk';
                    let upSvgFrag = document.createRange().createContextualFragment(upSvg);
                    lastChild.replaceChild(upSvgFrag,lastChild.childNodes[0])
                    for (let i = value; i < el.children.length-1; i++) {
                        el.children[i].style.display = "inline"
                    }
                }else{
                    lastChild.id = 'zk'
                    let downSvgFrag = document.createRange().createContextualFragment(downSvg);
                    lastChild.replaceChild(downSvgFrag,lastChild.childNodes[0])
                    for (let i = value; i < el.children.length-1; i++) {
                        el.children[i].style.display = "none"
                    }
                }
            })
 
        }
 
    }
}