马宇豪
2025-01-10 03f0e2a3220106ec2a9dd8f53d3ef5ab824c3ae7
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
<template>
    <el-dialog :visible.sync="authDialogVisible" :modal-append-to-body="false" :close-on-click-modal="false"
               width="900px">
        <div style="padding-bottom: 20px">
            <el-button v-show="userType != 3" type="primary" plain @click="createAuthHandle">生成授权码</el-button>
        </div>
 
        <el-table v-loading="listLoading"
                  :key="tableKey"
                  :data="authData"
                  border
                  fit
                  highlight-current-row
                  :header-cell-style="turnRed"
                  style="width: 100%;">
            <el-table-column type="index" label="" align="center" width="60"/>
            <el-table-column label="授权码" prop="authcode" align="center">
            </el-table-column>
            <el-table-column label="合同编号" prop="contractcode" align="center">
            </el-table-column>
            <el-table-column label="状态" prop="status" align="center">
                <template slot-scope="scope">
                    <div v-for="item in status">
                        <div v-if="scope.row.status === item.id">
                            {{item.name}}
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="类型" prop="status" align="center">
                <template slot-scope="scope">
                    <div v-for="item in flagList">
                        <div v-if="scope.row.flag === item.id">
                            {{item.name}}
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="OCR状态" prop="isocr" align="center">
                <template slot-scope="scope">
                    {{scope.row.isocr == 0?'禁用':scope.row.isocr == 1?'启用':'--'}}
                </template>
            </el-table-column>
            <el-table-column label="创建时间" prop="createdat" align="center">
            </el-table-column>
            <el-table-column label="最后登录时间" prop="lasttime" align="center">
            </el-table-column>
            <el-table-column label="到期时间" prop="expiredat" align="center">
            </el-table-column>
            <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width" v-if="userType != 3">
                <template slot-scope="scope">
                    <el-button type="text" @click="changStatus(scope.row,0)" v-if="scope.row.status === 1" >停用</el-button>
                    <el-button type="text" @click="changStatus(scope.row,1)" v-else>启用</el-button>
                    <el-button type="text" @click="deleteAuth(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-dialog :visible="addAuthDialogVisible" :modal-append-to-body="false" :close-on-click-modal="false"
                    width="400px" append-to-body>
            <el-input v-model="contractCode" placeholder="请选择合同编号" ></el-input><br>
            <el-select v-model="flag" placeholder="请选择类型">
                <el-option
                    class="filter-item"
                    v-for="item in flagList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">
                </el-option>
            </el-select>
            <el-select v-model="isocr" placeholder="请选择是否启用OCR">
                <el-option class="filter-item" label="启用OCR" :value="1"></el-option>
                <el-option class="filter-item" label="禁用OCR" :value="0"></el-option>
            </el-select>
            <div slot="footer" class="dialog-footer">
                <el-button @click="addAuthDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="createAuth">确认</el-button>
            </div>
        </el-dialog>
 
    </el-dialog>
</template>
 
<script>
    import {changeStatus, createAuth, deleteAuth, getAuthListById} from "../../../api/auth";
    import { mapGetters } from 'vuex'
    export default {
        name: "authDetail",
        // props: ["userId"],
        data() {
            return {
                userId:'',
                addAuthDialogVisible: false,
                authDialogVisible: false,
                authForm: {},
                authData: [],
                listLoading: true,
                pageSize: 10,
                recordTotal: 0,
                currentPage: 1,
                pageTotal: 0,
                tableKey: 0,
                status:[{id:0,name:"已停用"},{id:1,name:"已启用"}],
                flagList:[{id:0,name:"标配"},{id:1,name:"无身份证阅读器"},{id:2,name:"无扫码枪"},{id:3,name:"全无"}],
                contractCode:"",
                flag:0,
                isocr: 0
            }
        },
        computed: {
            ...mapGetters([
                'userType',
                'username'
            ])
        },
        methods: {
            open(userId){
                this.userId = userId;
                this.authDialogVisible = true;
                this.getAuthDataList();
            },
 
            getAuthDataList() {
                const params = {}
                params['userId'] = this.userId;
                getAuthListById(params).then(response => {
                    const res = response.data;
                    if (res.code === "200") {
                        this.authData = res.result;
                        this.listLoading = false;
                    }
                })
            },
 
            changStatus(row,status){
                const param = {
                    id:row.id,
                    status:status
                };
                changeStatus(param).then(response=>{
                    const res = response.data;
                    if (res.code === "200") {
                        this.getAuthDataList();
                        this.$emit('getinfo')
                    }
                })
            },
            deleteAuth(row){
                const param = {
                    id:row.id,
                };
                deleteAuth(param).then(response=>{
                    const res = response.data;
                    if (res.code === "200") {
                        this.getAuthDataList();
                        this.$emit('getinfo')
                    }
                })
            },
 
            createAuthHandle() {
                this.addAuthDialogVisible = true;
                this.contractCode = ''
                this.flag = 0
                this.isocr = 0
            },
 
            createAuth(){
                const param = {
                    userId:this.userId,
                    contractCode:this.contractCode,
                    flag:this.flag,
                    isocr: this.isocr
                };
                createAuth(param).then(response=>{
                    const res = response.data;
                    if (res.code === "200") {
                        this.getAuthDataList();
                        this.$emit('getinfo')
                        this.addAuthDialogVisible = false;
                    }
                })
            },
            turnRed({row, column, rowIndex, columnIndex}){
                if(rowIndex == 0 && columnIndex==7){
                    return 'color: red'
                }
            }
        }
    }
</script>
 
<style scoped>
 
</style>