1
lzhe
2024-05-13 f5edc2904945f37b164a7874d502cf002fae024e
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!--
 * @Date: 2024-04-09 22:18:47
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-13 22:11:37
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/system/interfaceConfig.vue
 * 看板接口
-->
<template>
    <el-main>
        <el-card shadow="never">
            <el-container>
                <el-header style="justify-content: flex-start;">
                    <el-button type="primary" plain @click="add">新增</el-button>
                    <el-button @click="del" plain type="danger" :disabled="selection.length == 0">删除</el-button>
                    <el-input clearable v-model="urlName_like" style="max-width: 200px;margin-left: auto;">
                        <template #append>
                            <el-button @click="query" icon="el-icon-search" />
                        </template>
                    </el-input>
                </el-header>
                <el-main>
                    <scTable ref="table" @selection-change="handleSelectionChange" row-key="id" border :params="params"
                        :apiObj="apiObj" stripe>
                        <el-table-column type="selection" width="55" />
                        <el-table-column prop="url" label="接口地址" />
                        <el-table-column prop="urlName" label="接口中文名" />
                        <el-table-column prop="urlType" label="接口类型">
                            <template #default="scope">
                                <span>{{ interface_url_type?.find(v => v.dictKey == scope.row.urlType)?.dictValue
                                    }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="owningChart" label="图表类型">
                            <template #default="scope">
                                <span>{{ interface_owning_chart?.find(v => v.dictKey ==
                                    scope.row.owningChart)?.dictValue
                                    }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" fixed="right" align="left" width="160">
                            <template #default="scope">
                                <el-button-group>
                                    <el-button text type="primary" size="small"
                                        @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                                    <el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index, '0')">
                                        <template #reference>
                                            <el-button text type="primary" size="small">删除</el-button>
                                        </template>
                                    </el-popconfirm>
                                </el-button-group>
                            </template>
                        </el-table-column>
                    </scTable>
                </el-main>
                <el-dialog v-model="dialogVisible" :title="dialogTitle" width="1000" :before-close="handleClose">
                    <el-form :model="row" :rules="rules" ref="dialogForm" label-width="120px" label-position="center">
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="接口地址" prop="url">
                                    <el-input style="width: 100%" v-model="row.url" placeholder="请输入"
                                        clearable></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="接口中文名" prop="urlName">
                                    <el-input style="width: 240px" v-model="row.urlName" placeholder="请输入"
                                        clearable></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="接口类型" prop="urlType">
                                    <el-select v-model="row.urlType" placeholder="请选择" style="width: 240px">
                                        <el-option v-for="item in interface_url_type" :key="item.value"
                                            :label="item.dictValue" :value="item.dictKey - 0" />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="图表类型" prop="owningChart">
                                    <el-select v-model="row.owningChart" placeholder="请选择" style="width: 240px">
                                        <el-option v-for="item in interface_owning_chart" :key="item.value"
                                            :label="item.dictValue" :value="item.dictKey" />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <!-- <el-container>
                <el-header>
                    <el-button plain type="primary">新建</el-button>
                </el-header>
                <el-main>
                    <el-table :data="tableData"
                        row-key="id" border
                        >
                    </el-table>
                </el-main>
            </el-container> -->
                    <template #footer>
                        <div class="dialog-footer">
                            <el-button @click="dialogVisible = false">取消</el-button>
                            <el-button type="primary" @click="save">
                                保存
                            </el-button>
                        </div>
                    </template>
                </el-dialog>
            </el-container>
        </el-card>
    </el-main>
</template>
 
<script>
export default {
    data() {
        return {
            apiObj: this.$API.setting.interfaceConfig.getConList,
            selection: [],
            dialogVisible: false,
            urlName_like: '',
            row: {
                id: '',
                url: '',
                urlName: '',
                urlType: '',
                owningChart: '',
            },
            rules: {
                url: [
                    { required: true, message: '请输入' }
                ],
                urlName: [
                    { required: true, message: '请输入' }
                ],
                urlType: [
                    { required: true, message: '请输入' }
                ],
                owningChart: [
                    { required: true, message: '请输入' }
                ],
            },
            interface_url_type: [],
            interface_owning_chart: [],
            flow: [],
        }
    },
    created() {
        this.$API.system.dic.getDic.get({ code: 'interface_url_type' }).then(res => {
            this.interface_url_type = res.data
        })
        this.$API.system.dic.getDic.get({ code: 'interface_owning_chart' }).then(res => {
            this.interface_owning_chart = res.data
        })
        this.$API.system.dic.getDic.get({ code: 'flow' }).then(res => {
            this.flow = res.data
        })
    },
    methods: {
        query() {
            this.$refs.table.reload({ urlName_like: this.urlName_like })
        },
        add() {
            this?.$refs?.dialogForm?.resetFields()
            Object.keys(this.row).forEach(v => {
                this.row[v] = ''
            })
            this.dialogTitle = '新增'
            this.dialogVisible = true
        },
        save() {
            this.$refs.dialogForm.validate(async (valid) => {
                if (valid) {
                    let request = this.$API.setting.interfaceConfig.add
                    if (this?.row?.id) {
                        request = this.$API.setting.interfaceConfig.update
                    }
                    request.post(this.row).then(res => {
                        this.dialogVisible = false
                        this.query()
                    })
                }
            })
        },
        del() {
            this.$API.setting.interfaceConfig.del.delete({}, { data: this.selection.map(v => v.id) }).then(res => {
                this.query()
            })
        },
        table_edit(row) {
            this.row = { ...row }
            console.log(this.row)
            this.dialogTitle = '编辑'
            this.dialogVisible = true
        },
        table_del(row) {
            this.$API.setting.interfaceConfig.del.delete({}, { data: [row.id] }).then(res => {
                this.query()
            })
        },
        handleSelectionChange(selection) {
            this.selection = selection;
        },
    },
}
</script>
 
<style lang="scss" scoped>
.icons {
    display: flex;
    flex-wrap: wrap;
}
 
.icon {
    margin: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}
</style>