|
|
@@ -0,0 +1,376 @@
|
|
|
+<!-- 用户编辑弹窗 -->
|
|
|
+<template>
|
|
|
+ <ele-modal
|
|
|
+ width="1100px"
|
|
|
+ :visible="visible"
|
|
|
+ :append-to-body="true"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ custom-class="ele-dialog-form"
|
|
|
+ title="门禁"
|
|
|
+ @update:visible="updateVisible"
|
|
|
+ :maxable="true"
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ :autoComplete="false"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="100px"
|
|
|
+ >
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" style="margin-bottom: 20px;">
|
|
|
+ <!-- <el-form-item label="设备:" prop="deviceId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.deviceId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="handleDeviceChange"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in deviceOptions"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.deviceName"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ </el-form-item> -->
|
|
|
+ <!-- <el-form-item label="" prop="deviceId"> -->
|
|
|
+ <!-- <el-select
|
|
|
+ v-model="form.deviceId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="handleDeviceChange"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in deviceOptions"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.deviceName"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select> -->
|
|
|
+ <el-button type="primary" @click="handleBindDevice">添加设备</el-button>
|
|
|
+ <!-- </el-form-item> -->
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <ele-pro-table
|
|
|
+ ref="table"
|
|
|
+ :columns="columns"
|
|
|
+ :datasource="datasource"
|
|
|
+ height="calc(100vh - 405px)"
|
|
|
+ style="margin-bottom: 10px"
|
|
|
+ full-height="calc(100vh - 116px)"
|
|
|
+ tool-class="ele-toolbar-form"
|
|
|
+ :selection.sync="selection"
|
|
|
+ :page-size="20"
|
|
|
+ @columns-change="handleColumnChange"
|
|
|
+ :cache-key="cacheKeyUrl"
|
|
|
+ :needPage="false"
|
|
|
+ >
|
|
|
+ <!-- 表头工具栏 -->
|
|
|
+ <template v-slot:toolbar>
|
|
|
+
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 操作列 -->
|
|
|
+ <template v-slot:action="{ row }">
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ @click="handleAuthorize(row)"
|
|
|
+ >
|
|
|
+ 授权
|
|
|
+ </el-link>
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ @click="handleSync(row)"
|
|
|
+ >
|
|
|
+ 同步
|
|
|
+ </el-link>
|
|
|
+ <el-popconfirm
|
|
|
+ class="ele-action"
|
|
|
+ title="确定要解绑吗?"
|
|
|
+ @confirm="unbind(row)"
|
|
|
+ >
|
|
|
+ <template v-slot:reference>
|
|
|
+ <el-link type="danger" :underline="false">
|
|
|
+ 解绑
|
|
|
+ </el-link>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+ </ele-pro-table>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <template v-slot:footer>
|
|
|
+ <el-button @click="updateVisible(false)">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="loading" @click="updateVisible(false)">
|
|
|
+ 确定
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ <!-- 授权 -->
|
|
|
+ <doorAuthorize ref="doorAuthorizeRef" :current="current" :deviceInfo="deviceInfo" :list="datasource" :visible.sync="showAuthorize" @success="getData"></doorAuthorize>
|
|
|
+ <!-- 绑定 -->
|
|
|
+ <doorBind ref="doorBindRef" :current="current" :list="datasource" :visible.sync="showBind" @success="getData"></doorBind>
|
|
|
+ </ele-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ // import { emailReg, phoneReg } from 'ele-admin';
|
|
|
+ import doorAuthorize from './door-authorize.vue';
|
|
|
+ import doorBind from './door-bind.vue';
|
|
|
+ import { addUsers, putUsers, getById } from '@/api/system/user';
|
|
|
+ import { getUserDetail } from '@/api/system/organization';
|
|
|
+ import { listDoorUsers, listDevice, syncDevice, unbindDevice } from '@/api/system/doorSecurity'
|
|
|
+ import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
+ export default {
|
|
|
+ components: { doorAuthorize, doorBind },
|
|
|
+ mixins: [tabMixins],
|
|
|
+ props: {
|
|
|
+ // 弹窗是否打开
|
|
|
+ visible: Boolean,
|
|
|
+ // 修改回显的数据
|
|
|
+ current: Object,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ const defaultForm = {
|
|
|
+ deviceId: '',
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ showAuthorize: false,
|
|
|
+ deviceInfo: {},
|
|
|
+ cacheKeyUrl: 'eos-64acd1e7-202605271646-user-door',
|
|
|
+ selection: [],
|
|
|
+ statusOptions: [
|
|
|
+ {
|
|
|
+ label: '待同步',
|
|
|
+ value: 0
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '已同步',
|
|
|
+ value: 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '失败',
|
|
|
+ value: 2
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ defaultForm,
|
|
|
+ // 表单数据
|
|
|
+ form: { ...defaultForm },
|
|
|
+ // 表单验证规则
|
|
|
+ rules: {},
|
|
|
+ // 提交状态
|
|
|
+ loading: false,
|
|
|
+ // 是否是修改
|
|
|
+ userInfo: {
|
|
|
+ postName: '',
|
|
|
+ },
|
|
|
+ datasource: [],
|
|
|
+ deviceOptions: [],
|
|
|
+ showBind: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ // 是否开启响应式布局
|
|
|
+ styleResponsive() {
|
|
|
+ return this.$store.state.theme.styleResponsive;
|
|
|
+ },
|
|
|
+ columns() {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ width: 45,
|
|
|
+ type: 'selection',
|
|
|
+ columnKey: 'selection',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnKey: 'index',
|
|
|
+ label: '序号',
|
|
|
+ type: 'index',
|
|
|
+ width: 55,
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ fixed: 'left'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'deviceName',
|
|
|
+ label: '设备名称',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ sortable: true,
|
|
|
+ minWidth: 200
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'ipAddress',
|
|
|
+ label: '设备IP',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ sortable: true,
|
|
|
+ minWidth: 160
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'port',
|
|
|
+ label: '端口',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ sortable: true,
|
|
|
+ minWidth: 130
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'isPermanent',
|
|
|
+ label: '是否长期授权',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 130,
|
|
|
+ formatter: (row) => {
|
|
|
+ return row.isPermanent === 1 ? '是' : '否';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'validStart',
|
|
|
+ label: '有效期',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 200,
|
|
|
+ formatter: (row) => {
|
|
|
+ return row.validStart ? row.validStart + '~' + row.validEnd : '';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'syncStatus',
|
|
|
+ label: '状态',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 130,
|
|
|
+ formatter: (row) => {
|
|
|
+ return this.statusOptions.find(item => item.value === row.syncStatus)?.label || '';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'syncMsg',
|
|
|
+ label: '同步日志',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'createTime',
|
|
|
+ label: '创建时间',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnKey: 'action',
|
|
|
+ label: '操作',
|
|
|
+ width: 200,
|
|
|
+ align: 'center',
|
|
|
+ resizable: false,
|
|
|
+ slot: 'action',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ fixed: 'right'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ console.log('mounted~~~');
|
|
|
+ // this.getData();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ unbind(row) {
|
|
|
+ unbindDevice(row.id).then(res => {
|
|
|
+ this.$message({
|
|
|
+ message: '解绑成功',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ this.getData();
|
|
|
+ }).catch(err => {
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleBindDevice() {
|
|
|
+ this.showBind = true;
|
|
|
+ },
|
|
|
+ async handleSync(row) {
|
|
|
+ await syncDevice(row.id);
|
|
|
+ this.$message({
|
|
|
+ message: '同步成功',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ handleAuthorize(row) {
|
|
|
+ this.deviceInfo = row;
|
|
|
+ this.showAuthorize = true;
|
|
|
+ console.log(row, 'row');
|
|
|
+ },
|
|
|
+ handleDeviceChange(val) {
|
|
|
+ console.log(val, 'val');
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ getData() {
|
|
|
+ listDoorUsers({ userId: this.current.id, ...this.form }).then(res => {
|
|
|
+ console.log(res, 'res');
|
|
|
+ this.datasource = res;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getDeviceList() {
|
|
|
+ listDevice({
|
|
|
+ size: 9999,
|
|
|
+ pageNum: 1,
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res, 'res');
|
|
|
+ this.deviceOptions = res.list;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async getUserDetail() {
|
|
|
+ if (!this.form.mainUserId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.userInfo = await getUserDetail(this.form.mainUserId);
|
|
|
+ },
|
|
|
+ /* 更新visible */
|
|
|
+ updateVisible(value) {
|
|
|
+ this.$emit('update:visible', value);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ visible(visible) {
|
|
|
+ console.log(visible, 'visible');
|
|
|
+ if (visible) {
|
|
|
+ this.getDeviceList();
|
|
|
+ this.getData();
|
|
|
+ } else {
|
|
|
+ this.$refs.form?.clearValidate();
|
|
|
+ this.form = { ...this.defaultForm };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+ :deep(.el-input--medium .el-input__inner) {
|
|
|
+ height: auto !important;
|
|
|
+ }
|
|
|
+ :deep(.el-table) {
|
|
|
+ .el-form-item {
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ :deep(.organizationList .el-input__inner) {
|
|
|
+ border: 0;
|
|
|
+ background: none;
|
|
|
+ }
|
|
|
+ :deep(.organizationList .el-input__suffix) {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ :deep(.organizationList .el-tag) {
|
|
|
+ background: none;
|
|
|
+ }
|
|
|
+</style>
|