1
lzhe
2024-06-21 9c094a1fe3e1ae3dadef6433f8401818fe2b8304
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!--
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-05-30 18:17:23
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div class="aposcope-main">
        <div class="header" v-if="$route.query.type == 1">
            <div class="title">计划显示设置</div>
            <div class="type">
                <div class="item last" @click="openPlan">新建计划类型模版</div>
                <div :class="{item:true, activeTab: item.active}" v-for="(item,index) in planData" @click="changePlanData(item,index)">
                    <span style="margin-right: 12px;cursor: pointer;">{{item.templateName}}</span>
                    <el-popover placement="right-start" :width="30" trigger="click" :hide-after="0" :show-after="0">
                        <template #reference>...</template>
                        <template #default>
                            <span class="popvoer-title" @click="table_edit(item,index)">编辑</span>
                            <span  class="popvoer-title" style="margin-left: 12px" v-if="index != 0" @click="del_tab(item)">删除</span>
                        </template>
                    </el-popover>
                </div>
            </div>
        </div>
        <el-tabs v-model="activeName" class="demo-tabs" @tab-change="handleClick">
            <el-tab-pane label="新建页设置" name="first">
                <div>
                    <div class="add-field" @click="openSelect">+ 添加字段</div>
                    <div class="field-title">基础字段</div>
                    <el-table ref="multipleTableRef" :data="tableData0" border style="width: 100%" class="multipleTableRef">
                        <el-table-column prop="fieldName" label="字段名"></el-table-column>
                        <el-table-column prop="fieldDescription" label="提示文字"></el-table-column>
                        <el-table-column prop="defaultValue" label="默认值"></el-table-column>
                        <el-table-column prop="mustField" label="是否必填">
                            <template #default="scope">
                                <span>{{scope.row.mustField == '1'?"是": "否"}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column fixed="right" label="操作">
                            <template #default="scope">
                                <el-button text type="primary" :disabled="scope.row.mustField == '1'?true: false" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="field-title">扩展字段</div>
                    <el-table ref="multipleTableRef" :data="tableData0extend" border style="width: 100%" class="multipleTableRef">
                        <el-table-column prop="fieldName" label="字段名"></el-table-column>
                        <el-table-column prop="fieldDescription" label="提示文字"></el-table-column>
                        <el-table-column prop="defaultValue" label="默认值"></el-table-column>
                        <el-table-column prop="mustField" label="是否必填">
                            <template #default="scope">
                                <span>{{scope.row.mustField == '1'?"是": "否"}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column fixed="right" label="操作">
                            <template #default="scope">
                                <el-button text type="primary" :disabled="scope.row.mustField == '1'?true: false" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </el-tab-pane>
            <el-tab-pane label="编辑页设置" name="second">
                <div class="add-field" @click="openSelect">+ 添加字段</div>
                <div class="field-title">基础字段</div>
                <el-table ref="multipleTableRef" :data="tableData1" border style="width: 100%" class="multipleTableRef">
                    <el-table-column prop="fieldName" label="字段名"></el-table-column>
                    <el-table-column label="支持编辑" prop="supportUpdateLabel"></el-table-column>
                    <el-table-column fixed="right" label="操作">
                        <template #default="scope">
                            <el-button text type="primary" :disabled="scope.row.mustField == '1'?true: false" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="field-title">扩展字段</div>
                <el-table ref="multipleTableRef" :data="tableData1extend" border style="width: 100%" class="multipleTableRef">
                    <el-table-column prop="fieldName" label="字段名"></el-table-column>
                    <el-table-column prop="supportUpdateLabel" label="支持编辑"></el-table-column>
                    <el-table-column fixed="right" label="操作">
                        <template #default="scope">
                            <el-button text type="primary" :disabled="scope.row.mustField == '1'?true: false" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-tab-pane>
            <el-tab-pane label="查看页设置" name="third">
                <div class="add-field" @click="openSelect">+ 添加字段</div>
                <div class="field-title">基础字段</div>
                <el-table ref="multipleTableRef" :data="tableData2" border style="width: 100%" class="multipleTableRef">
                    <el-table-column prop="fieldName" label="字段名"></el-table-column>
                    <el-table-column fixed="right" label="操作">
                        <template #default="scope">
                            <el-button text type="primary" :disabled="scope.row.sysFieldMust == '1'?true: false" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="field-title">扩展字段</div>
                <el-table ref="multipleTableRef" :data="tableData2extend" border style="width: 100%" class="multipleTableRef">
                    <el-table-column prop="fieldName" label="字段名"></el-table-column>
                    <el-table-column fixed="right" label="操作">
                        <template #default="scope">
                            <el-button text type="primary" :disabled="scope.row.sysFieldMust == '1'?true: false" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-tab-pane>
        </el-tabs>
    </div>
    <!-- 新建计划 -->
    <save-dialog v-if="dialog.save" ref="saveDialog" @success="addPlanSuccess" @closed="dialog.save=false"></save-dialog>
    <!-- 添加字段 -->
    <save-select-dialog v-if="dialog.saveSelect" ref="saveSelectDialog" @success="addSelectSuccess" @closed="dialog.saveSelect=false" @addExtend="addExtend"></save-select-dialog>
    <!-- 添加扩展字段 -->
    <save-extend-dialog v-if="dialog.extendSave" ref="saveExtendDialog" @success="addExtendSuccess" @closed="dialog.save=false"></save-extend-dialog>
</template>
<script>
    import saveDialog from './addPlan'
    import saveSelectDialog from './saveSelectDialog'
    import saveExtendDialog from './addField'
    export default {
        name: "custom",
        data(){
            return {
                id: "",
                dialog: {
                    save: false,  //新增模版
                    saveSelect: false,  //添加字段
                    extendSave: false  //添加扩展字段
                },
                planData: [],
                activeName: "first",
                configType: 1,
                tableData0: [],
                tableData1: [],
                tableData2: [],
                tableData0extend: [],
                tableData1extend: []
            }
        },
        created(){
            
        },
        mounted(){
            this.getBaseData();
            this.gitProduct();
        },
        components: {
            saveDialog,saveSelectDialog,saveExtendDialog
        },
        methods: {
            gitProduct() {
                this.$HTTP.get(`/api/blade-cps/product-type/list`).then(res=> {
                    if(res.code == 200) {
                        this.productList= res.data;
                    }
                })
            },
            getBaseData() {
                this.$HTTP.get(`/api/blade-system/custom-template/list?businessType=${this.$route.query.type}`).then(res=> {
                    if(res.code == 200) {
                        this.planData = res.data.reverse();
                        this.id = this.planData[0].id;
                        this.planData[0].active = true;
                        this.getTableList();
                    }
                })
            },
            changePlanData(row,index) {
                this.id = row.id;
                this.planData.forEach(item=> {
                    item.active = false;
                })
                this.planData[index].active = true;
                this.getTableList();
            },
            getTableList() {
                this.$HTTP.get(`/api/blade-system/custom-template-field/listField?configType=${this.configType}&templateId=${this.id}`).then(res=> {
                    if(res.code == 200) {
                        if(this.activeName == "first") {
                            this.tableData0 = res.data.systemFieldList;
                            this.tableData0extend = res.data.customFieldList || [];
                        }else if(this.activeName == "second") {
                            this.tableData1 = res.data.systemFieldList;
                            this.tableData1extend = res.data.customFieldList || [];
                        }else if(this.activeName == "third") {
                            this.tableData2 = res.data.systemFieldList;
                            this.tableData2extend = res.data.customFieldList || [];
                        }
                        
                    }
                })
            },
            table_edit(row) {
                this.dialog.save = true
                this.$nextTick(() => {
                    this.$refs.saveDialog.open(this.productList,this.planData,'edit').setData(row);
                })
            },
            del_tab(row) {
                this.$HTTP.delete(`/api/blade-system/custom-template/remove`,[row.id]).then(res=> {
                    if(res.code == 200) {
                        this.$message.success("操作成功");
                        this.getBaseData();
                    }
                })
            },
            openPlan() {
                this.dialog.save = true
                this.$nextTick(() => {
                    this.$refs.saveDialog.open(this.productList,this.planData)
                })
            },
            openSelect() {
                this.dialog.saveSelect = true
                this.$HTTP.get(`/api/blade-system/custom-template-field/getSelectBox?configType=${this.configType}&templateId=${this.id}`).then(res=> {
                    if(res.code == 200) {
                        this.$refs.saveSelectDialog.open(res.data,this.id,this.configType);
                    }
                })
            },
            addPlanSuccess() {
                this.getBaseData();
            },
            addSelectSuccess() {
                this.getTableList();
            },
            addExtendSuccess() {
                this.getTableList();
            },
            addExtend() {
                this.dialog.extendSave = true
                this.$nextTick(() => {
                    this.$refs.saveExtendDialog.open();
                })
            },
            table_del(row,index) {
                this.$HTTP.delete(`/api/blade-system/custom-template-field-relation/remove`,[row.id]).then(res=> {
                    if(res.code == 200) {
                        this.$message.success("操作成功");
                        this.getTableList();
                    }
                })
            },
            handleClick(TabPaneName) {
                if(TabPaneName == "first") {
                    this.configType = 1;
                }else if(TabPaneName == "second") {
                    this.configType = 2;
                }else if(TabPaneName == "third") {
                    this.configType = 3;
                }
                this.getTableList();
            }
        }
    }
</script>
 
<style scoped>
.aposcope-main {
    min-height: 100%;
    margin: 8px;
    padding:20px;
    background: #fff;
}
.header {
    margin-bottom: 8px;
    background-color: #fff;
    font-size: 14px;
    font-weight: 700;
    color: #333;
}
.title {
    color: #000;
    margin-bottom: 21px;
}
.type {
    padding-bottom: 15px;
    display: flex;
    width: 100%;
    overflow: auto;
}
.item {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #409eff;
    cursor: pointer;
    padding: 18px 12px;
    margin-right: 24px;
    border: 1px solid #ccc;
    width: 260px;
}
.activeTab {
    border: 1px solid #409eff;
}
.add-field {
    color: #409eff;
    font-weight: 400;
    font-size: 14px;
    cursor: pointer;
    padding-left: 8px;
    margin: 0;
}
.field-title {
    font-weight: 700;
    font-size: 14px;
    color: #000;
    margin: 14px 0;
}
.popvoer-title {
    cursor: pointer;
</style>