吉安感知网项目-前端
张含笑
2026-02-26 12e3a3301ecea615339d67d59b8a411200e21bc8
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
<template>
    <el-dialog class="gd-dialog" v-model="visible" :title="dialogTitle" @closed="handleClosed" destroy-on-close
                         :close-on-click-modal="false">
        <!--        <div class="detail-row-view" v-if="dialogReadonly">-->
        <el-table :data="list" class="gd-dialog-table">
            <el-table-column prop="resultCode" show-overflow-tooltip label="序号" />
            <el-table-column prop="resultCode" show-overflow-tooltip label="设备状态" />
            <el-table-column prop="shootTime" show-overflow-tooltip label="发生时间" />
        </el-table>
    </el-dialog>
</template>
 
<script setup>
import { computed, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { add, getUser, update } from '@/api/system/user'
import { getDeptTree } from '@/api/system/dept'
import { getRoleTree } from '@/api/system/role'
import func from '@/utils/func'
import { saveOperationLog } from '@ztzf/apis'
import { useRoute } from 'vue-router'
 
const list = ref([])
 
const initForm = () => ({
    account: '',
    password: '',
    password2: '',
    realName: '',
    phone: '',
    email: '',
    sex: null,
    birthday: '',
    code: '',
    roleId: '',
    deptId: '',
    // sysType: 6
})
 
const treeProps = {
    label: 'title',
    children: 'children',
}
const deptTreeSelectProps = {
    label: 'name',
    value: 'id',
    children: 'children',
}
 
const emit = defineEmits(['success'])
const formRef = ref(null)
const formData = ref(initForm())
const visible = ref(false)
const dialogMode = ref('add')
const submitting = ref(false)
const dialogReadonly = computed(() => dialogMode.value === 'view')
const dialogTitle = computed(() => {
    if (dialogMode.value === 'edit') return '编辑'
    if (dialogMode.value === 'view') return '查看'
    return '新增'
})
const roleTree = ref([])
const deptTree = ref([])
const route = useRoute()
 
const validatePass = (rule, value, callback) => {
    if (value === '') {
        callback(new Error('请输入密码'))
    } else {
        callback()
    }
}
const validatePass2 = (rule, value, callback) => {
    if (value === '') {
        callback(new Error('请再次输入密码'))
    } else if (value !== formData.value.password) {
        callback(new Error('两次输入密码不一致'))
    } else {
        callback()
    }
}
 
async function getRoleTreeData() {
    const res = await getRoleTree('000000')
    roleTree.value = res.data.data
}
 
async function getDeptTreeData() {
    const res = await getDeptTree('000000')
    deptTree.value = res.data.data
}
 
function handleCancel() {
    visible.value = false
}
 
async function loadDetail() {
    if (!formData.value.id) return
    const res = await getUser(formData.value.id)
    const data = res?.data?.data ?? {}
    if (data.roleId) {
        data.roleId = func.split(data.roleId)[0] || data.roleId
    }
    formData.value = data
}
 
function handleClosed() {
    formData.value = initForm()
}
 
async function open({ mode, row } = {}) {
    dialogMode.value = mode || 'add'
    visible.value = true
    if (dialogMode.value === 'add') {
        formData.value = initForm()
        return
    }
    formData.value = { id: row.id }
    await loadDetail()
}
 
onMounted(() => {
    getRoleTreeData()
    getDeptTreeData()
})
 
defineExpose({ open })
</script>
 
<style scoped lang="scss">
:deep(.el-select) {
    width: 100%;
}
 
:deep(.el-date-editor) {
    width: 100%;
}
 
:deep(.el-tree-select) {
    width: 100%;
}
</style>