hyb
2025-05-20 e8003b5c66494c398fa8b716e0872771e2ea4af8
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template>
    <el-container>
        <el-header style="background: #fff; padding: 0; height: 50px">
            <div class="nav-api-header">
                <div
                    style="display: flex; padding-top: 10px; margin-left: 10px; align-items: center;"
                >
                    <el-button
                        type="primary"
                        size="small"
                        icon="el-icon-circle-plus-outline"
                        @click="addConfig"
                        >新增配置</el-button
                    >
                    <el-button
                        v-if="!addConfigActivate"
                        type="danger"
                        icon="el-icon-delete"
                        size="small"
                        @click="del = !del"
                        :disabled="!isSelectConfig"
                        >批量删除</el-button
                    >
                    <el-button
                        :disabled="!addConfigActivate"
                        type="text"
                        style="position: absolute; right: 30px;"
                        @click="handleBackList"
                        >返回列表</el-button
                    >
                </div>
            </div>
        </el-header>
 
        <el-container>
            <el-main style="padding: 0; margin-left: 10px">
                <config-body
                    v-show="addConfigActivate"
                    :project="$route.params.id"
                    :response="respConfig"
                    :type="type"
                    @addSuccess="handleAddSuccess"
                ></config-body>
                <config-list
                    v-show="!addConfigActivate"
                    :project="$route.params.id"
                    @respConfig="handleRespConfig"
                    @configDataChanged="handleConfigData"
                    :del="del"
                    :back="back"
                    :page-size.sync="pageSize"
                    :current-page.sync="currentPage"
                    :is-select-config.sync="isSelectConfig"
                ></config-list>
            </el-main>
        </el-container>
    </el-container>
</template>
 
<script>
import ConfigBody from "./components/ConfigBody";
import ConfigList from "./components/ConfigList";
export default {
    name: "RecordConfig",
    components: {
        ConfigBody,
        ConfigList
    },
    data() {
        return {
            back: false,
            del: false,
            addConfigActivate: false,
            respConfig: "",
            type: "",
            configData: null,
            isSelectConfig: false,
            pageSize: 10,
            currentPage: 1
        };
    },
    computed: {
        initResponse: {
            get() {
                return this.addConfigActivate;
            },
            set(value) {
                this.addConfigActivate = value;
                this.respConfig = {
                    id: "",
                    name: "",
                    base_url: "",
                    is_default: false,
                    body: {
                        name: "",
                        base_url: "",
                        header: [
                            {
                                key: "",
                                value: "",
                                desc: ""
                            }
                        ],
                        request: {
                            data: [
                                {
                                    key: "",
                                    value: "",
                                    desc: "",
                                    type: 1
                                }
                            ],
                            params: [
                                {
                                    key: "",
                                    value: "",
                                    desc: "",
                                    type: 1
                                }
                            ],
                            json_data: ""
                        },
                        variables: [
                            {
                                key: "",
                                value: "",
                                desc: "",
                                type: 1
                            }
                        ],
                        hooks: [
                            {
                                setup: "",
                                teardown: ""
                            }
                        ],
                        parameters: [
                            {
                                key: "",
                                value: "",
                                desc: ""
                            }
                        ]
                    }
                };
            }
        }
    },
    methods: {
        handleBackList() {
            this.addConfigActivate = false;
            this.respConfig = "";
        },
        handleAddSuccess() {
            this.back = !this.back;
            this.currentPage = 1;
            this.pageSize = 10;
            this.addConfigActivate = false;
        },
        addConfig() {
            this.initResponse = true;
            this.type = "add";
        },
        handleRespConfig(row) {
            this.respConfig = row;
            this.addConfigActivate = true;
            this.type = "edit";
        },
        handleConfigData(data) {
            this.configData = data;
        }
    }
};
</script>
 
<style scoped></style>