lzhe
2024-06-14 963a2313f4f8959715293d38f69894078150d508
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
<!--
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-05-29 15:24:20
 * @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="title">{{$route.query.type == 1?"计划":"产品"}}字段</div>
        <el-button type="primary" @click="addField" style="margin: 4px 0px 10px;">添加自定义字段</el-button>
        <div class="field-table">
            <el-table ref="multipleTableRef" :data="tableData" 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="fieldTypeLabel" label="字段类型"></el-table-column>
                <el-table-column prop="systemFieldLabel" label="基础字段"></el-table-column>
                <el-table-column fixed="right" label="操作">
                    <template #default="scope">
                        <el-button type="text" size="small" @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                        <el-button text type="primary" :disabled="scope.row.systemFieldLabel == '是'?true: false" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </div>
    <save-dialog v-if="dialog.save" ref="saveDialog" @success="addFieldSuccess" @closed="dialog.save=false"></save-dialog>
</template>
<script>
    import saveDialog from './addField'
    export default {
        name: "custom",
        data(){
            return {
                tableData: [],
                dialog: {
                    save: false
                }
            }
        },
        created(){
            
        },
        mounted(){
            this.getTableData();
        },
        components: {
            saveDialog
        },
        methods: {
            addFieldSuccess() {
                this.getTableData();
            },
            addField() {
                this.dialog.save = true;
                this.$nextTick(() => {
                    this.$refs.saveDialog.open()
                })
            },
            table_edit(row) {
                this.dialog.save = true;
                this.$nextTick(() => {
                    this.$refs.saveDialog.open('edit').setData(row);
                })
            },
            table_del(row) {
                this.$HTTP.delete(`/api/blade-system/custom-template-field/remove`,[row.id]).then(res=> {
                    if(res.code == 200) {
                        this.$message.success("操作成功");
                        this.getTableData();
                    }
                })
            },
            getTableData() {
                this.$HTTP.get(`/api/blade-system/custom-template-field/list?businessType=${this.$route.query.type}`).then(res=> {
                    if(res.code == 200) {
                        this.tableData = res.data;
                    }
                })
            }
        }
    }
</script>
 
<style scoped>
.aposcope-main {
    min-height: 100%;
    margin: 8px;
    padding:20px;
    background: #fff;
}
.title {
    font-size: 16px;
    font-weight: 700;
    margin: 0px 0px 14px;
    color: #000;
}
</style>