地质所 沉降监测网建设项目
zmk
2024-05-17 8722d2bb39c6c0697647e77a879d14b28d3ef0f5
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改爬虫字段')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-spiderField-edit" th:object="${spiderField}">
        <input name="fieldId" th:field="*{fieldId}" type="hidden">
        <div class="form-group" style="display: none;">
            <label class="col-sm-3 control-label">爬虫配置ID:</label>
            <div class="col-sm-8">
                <input name="configId" th:field="*{configId}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">字段:</label>
            <div class="col-sm-8">
                <input name="field" th:field="*{field}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">字段名称:</label>
            <div class="col-sm-8">
                <input name="fieldName" th:field="*{fieldName}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">提取类型:</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('spider_extract_type')}">
                    <input type="radio" th:id="${'extractType_' + dict.dictCode}" name="extractType" th:value="${dict.dictValue}" th:field="*{extractType}" required>
                    <label th:for="${'extractType_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group extractBy">
            <label class="col-sm-3 control-label">提取规则(xpath,css值):</label>
            <div class="col-sm-8">
                <input name="extractBy" th:field="*{extractBy}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group constant"  style="display: none;">
            <label class="col-sm-3 control-label">常量值:</label>
            <div class="col-sm-8">
                <input name="constantValue" th:field="*{constantValue}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group css"  style="display: none;">
            <label class="col-sm-3 control-label">元素的索引:</label>
            <div class="col-sm-8">
                <input name="extractIndex" th:field="*{extractIndex}" class="form-control" type="text">
            </div>
        </div>
 
        <div class="form-group css"  style="display: none;">
            <label class="col-sm-3 control-label">根据属性取值:</label>
            <div class="col-sm-8">
                <input id="extractAttrFlag" th:field="*{extractAttrFlag}"  name="extractAttrFlag" class="form-control" type="hidden">
                <label class="toggle-switch switch-solid">
                    <input type="checkbox" id="extractAttrCheckbox" th:checked="${spiderField.extractAttrFlag=='1'}"  >
                    <span></span>
                </label>
            </div>
        </div>
 
        <div class="form-group css extractAttr_extend"  style="display: none;">
            <label class="col-sm-3 control-label">属性名:</label>
            <div class="col-sm-8">
                <input name="extractAttr" th:field="*{extractAttr}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "spider/spiderField";
    $("#form-spiderField-edit").validate({
        focusCleanup: true
    });
 
    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-spiderField-edit').serialize());
        }
    }
    function showHideDiv(){
        var v=$("[name=extractType]:checked").val();
        if(v=="css"){
            $(".css").show();
            $(".constant").hide();
            $(".extractBy").show();
        }else if(v=="xpath"){
            $(".css").hide();
            $(".constant").hide();
            $(".extractBy").show();
            $("#extractAttrFlag").val("0");
        }else{
            //常量
            $(".constant").show();
            $(".css").hide();
            $(".extractBy").hide();
            $("#extractAttrFlag").val("0");
 
        }
    }
    function showHideExtractAttr(v){
        if(v){
            $("#extractAttrFlag").val("1");
            $(".extractAttr_extend").show();
            $("#extractAttr").attr("required","required");
        }else{
            $("#extractAttrFlag").val("0");
            $(".extractAttr_extend").hide();
            $("#extractAttr").removeAttr("required");
        }
    }
    $(function(){
        $('[name=extractType]').on('ifChecked', function(event){
            showHideDiv();
        });
        showHideDiv();
 
        $("#extractAttrCheckbox").on("change",function(){
            var v=$(this).prop("checked");
            showHideExtractAttr(v);
        });
        var b=$("#extractAttrCheckbox").prop("checked");
        if(b){
            $("#extractAttrFlag").val("1");
            $(".extractAttr_extend").show();
            $("#extractAttr").attr("required","required");
        }
    })
 
</script>
</body>
</html>