jiangping
2024-06-20 09da100729793848bc01b51f7b05ca3f1e7ec64f
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
<template>
    <GlobalWindow
        :title="title"
        submitText="修改"
        :visible.sync="visible"
        :confirm-working="isWorking"
        @confirm="$refs.operaInsuranceWindow.open('编辑保险公司', form)"
    >
        <div class="box">
            <div class="box_name">
                <span>保险公司:{{form.name}}</span>
                <span>是否启用:{{form.status == 0 ? '启用' : '禁用'}}</span>
            </div>
            <el-table
                :data="tableData"
                border>
                <el-table-column
                    label="序号"
                    align="center"
                    width="80">
                    <template slot-scope="scope">
                        <span>{{scope.$index + 1}}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="name"
                    align="center"
                    label="工种名称">
                </el-table-column>
            </el-table>
        </div>
        <!-- 新建/修改 -->
        <OperaInsuranceWindow ref="operaInsuranceWindow" @success="success"/>
    </GlobalWindow>
</template>
 
<script>
    import BaseOpera from '@/components/base/BaseOpera'
    import GlobalWindow from '@/components/common/GlobalWindow'
    import OperaInsuranceWindow from '@/components/business/OperaInsuranceWindow'
    import { all } from '@/api/business/worktype'
    export default {
        name: 'OperaInsuranceDescWindow',
        extends: BaseOpera,
        components: { GlobalWindow, OperaInsuranceWindow },
        data () {
            return {
                // 表单数据
                form: {
                    id: null,
                    name: '',
                    status: ''
                },
                tableData: []
            }
        },
        created () {
            this.config({
                api: '/business/insurance',
                'field.id': 'id'
            })
        },
        methods: {
            open (title, target) {
                this.title = title
                this.visible = true
                // 新建
                if (target == null) {
                    this.$nextTick(() => {
                        this.$refs.form.resetFields()
                        this.form[this.configData['field.id']] = null
                    })
                    return
                }
                // 编辑
                this.$nextTick(() => {
                    for (const key in this.form) {
                        this.form[key] = target[key]
                    }
                    all({ insuranceId: this.form.id })
                        .then(res => {
                            let arr = []
                            res.forEach(item => {
                                arr.push({ name: item.name })
                            })
                            this.tableData = arr
                        })
                })
            },
            success() {
                this.$emit('success')
                this.visible = false
            }
        }
    }
</script>
<style lang="scss" scoped>
    .box {
        width: 100%;
        .box_name {
            display: flex;
            align-items: center;
            margin-bottom: 10px;
            span {
                font-size: 16px;
                color: black;
                margin-right: 30px;
            }
        }
    }
</style>