zsysview 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +3 -1
  2. package/assets/default_avatar.png +0 -0
  3. package/assets/login_bg.jpg +0 -0
  4. package/components/export/export_dialog.vue +150 -0
  5. package/components/export/export_progress.vue +62 -0
  6. package/components/list/zsyslist.vue +2 -2
  7. package/components/list/zsyslist_header.vue +1 -1
  8. package/components/zsys_delbutton.vue +60 -0
  9. package/core/app.ts +13 -2
  10. package/core/common/common.ts +29 -0
  11. package/core/common/zsys_eventBus.ts +45 -0
  12. package/core/common/zsys_time.ts +26 -0
  13. package/core/httpapi/http_api_return_data.ts +43 -0
  14. package/core/httpapi/http_api_v1.ts +149 -0
  15. package/core/httpapi/http_axios.ts +54 -0
  16. package/core/router copy.ts +148 -0
  17. package/core/router.ts +95 -0
  18. package/core/user_token.ts +17 -0
  19. package/css/common.css +16 -0
  20. package/package.json +6 -2
  21. package/view/app.vue +0 -1
  22. package/view/backup/backup.vue +308 -0
  23. package/view/building.vue +22 -0
  24. package/view/department/department.vue +111 -0
  25. package/view/department/department_edit_dialog.vue +267 -0
  26. package/view/desktop/desktop.vue +11 -0
  27. package/view/log/log.vue +60 -0
  28. package/view/log/log_setting.vue +41 -0
  29. package/view/login.vue +5 -5
  30. package/view/main/breadcrumb.vue +41 -0
  31. package/view/main/main.vue +60 -0
  32. package/view/main/userHeader.vue +72 -0
  33. package/view/main/userMenu.vue +132 -0
  34. package/view/main/userMenuItem.vue +49 -0
  35. package/view/position/position.vue +58 -0
  36. package/view/position/position_edit_dialog.vue +203 -0
  37. package/view/role/role.vue +72 -0
  38. package/view/role/role_edit_dialog.vue +271 -0
  39. package/view/self/change_password.vue +97 -0
  40. package/view/self/self.vue +62 -0
  41. package/view/user/change_user_password_dialog.vue +155 -0
  42. package/view/user/user.vue +110 -0
  43. package/view/user/user_edit_dialog.vue +283 -0
@@ -0,0 +1,283 @@
1
+ <!-- ReusableDialog.vue -->
2
+ <template>
3
+ <el-dialog v-model="visible" title="用户" :align-center="true" :before-close="handleBeforeClose" @open="open"
4
+ width="550" :draggable="true" :overflow="true" @opened="focus" destroy-on-close :close-on-click-modal="false">
5
+ <!-- 默认插槽放主要内容 -->
6
+ <el-form @submit.prevent ref="ruleFormRef" :model="form" :rules="rules"
7
+ style="padding-left: 10px;padding-right: 10px;" label-width="auto" v-loading="view.loading"
8
+ :disabled="view.saving">
9
+ <el-form-item label="姓名" prop="uname">
10
+ <el-input ref="inputRef" v-model="form.uname" style="width: 300px;" />
11
+ <el-switch v-model="form.is_enable" inline-prompt active-text="已启用" inactive-text="已禁用"
12
+ style="margin-left: 10px;" />
13
+ </el-form-item>
14
+ <el-form-item label="用户名" prop="username">
15
+ <el-input v-model="form.username" style="width: 300px;" />
16
+ </el-form-item>
17
+ <el-form-item v-if="form.uid == 0n" label="初始密码" prop="password">
18
+ <el-input v-model="form.password" style="width: 300px;" />
19
+ </el-form-item>
20
+ <el-form-item label="角色权限" prop="role_title">
21
+ <el-select multiple v-model="form.role_value" placeholder="未选择" clearable>
22
+ <el-option v-for="item in role_option" :key="item.value" :label="item.label" :value="item.value">
23
+ <span style="float: left">{{ item.label }}</span>
24
+ <span v-if="!item.enable" style="
25
+ float: right;
26
+ color: var(--el-text-color-secondary);
27
+ font-size: 13px;
28
+ ">
29
+ 禁用不生效
30
+ </span>
31
+ </el-option>
32
+ </el-select>
33
+ </el-form-item>
34
+
35
+ </el-form>
36
+
37
+ <!-- 底部按钮区插槽 -->
38
+ <template #footer>
39
+ <div style="display: flex;justify-content: right;">
40
+ <el-tooltip v-if="view.isnew" content="保存成功后不关闭窗口">
41
+ <el-checkbox v-model="view.donotClose" label="连续录入" style="margin-right: 10px;" />
42
+ </el-tooltip>
43
+
44
+ <el-tooltip content="快捷键 Alt+S" :show-after="800">
45
+ <el-button type="primary" @click="submitForm(ruleFormRef)" :disabled="view.loading"
46
+ :loading="view.saving">保存(<el-text tag="ins" style="color: white;">S</el-text>)</el-button>
47
+ </el-tooltip>
48
+
49
+ <el-button @click="close">取消</el-button>
50
+ </div>
51
+
52
+ </template>
53
+ </el-dialog>
54
+ </template>
55
+
56
+ <script setup lang="ts">
57
+ import { ref, watch, reactive, type PropType } from 'vue';
58
+ import { HttpApiV1 as http } from '../../core/httpapi/http_api_v1';
59
+ import { ZSYSMessage } from '../../components/message';
60
+ import type { FormInstance, FormRules, ElInput } from 'element-plus'
61
+ import { useMagicKeys, whenever } from '@vueuse/core'
62
+ import type { HttpApiReturnData } from '../../core/httpapi/http_api_return_data';
63
+ import { zsysEventBus } from '../../core/common/zsys_eventBus';
64
+ import { Md5 } from 'ts-md5'
65
+ const eventBus = zsysEventBus()
66
+ const inputRef = ref<InstanceType<typeof ElInput> | null>(null)
67
+ const props = defineProps({
68
+ modelValue: { type: Boolean, required: true }, // 控制显示隐藏
69
+ id: { type: BigInt as unknown as PropType<bigint>, required: true }
70
+ });
71
+
72
+ const emit = defineEmits<{
73
+ (e: 'update:modelValue', value: boolean): void;
74
+ // (e: 'confirm'): void;
75
+ // (e: 'close'): void;
76
+ }>();
77
+
78
+ const visible = ref(false);
79
+
80
+ // 同步外部 v-model 变化
81
+ watch(
82
+ () => props.modelValue,
83
+ (val) => {
84
+ visible.value = val;
85
+ },
86
+ { immediate: true }
87
+ );
88
+
89
+ // 内部状态变化通知外部
90
+ watch(visible, (val) => {
91
+ emit('update:modelValue', val);
92
+ });
93
+
94
+ //弹窗显示时的处理
95
+ const open = () => {
96
+ view.isnew = (props.id == 0n ? true : false)
97
+ getData()
98
+ }
99
+
100
+ const close = () => {
101
+ visible.value = false;
102
+ // emit('close');
103
+ };
104
+
105
+ const handleBeforeClose = (done: () => void) => {
106
+ ruleFormRef.value?.clearValidate();
107
+ // 可以在这里添加关闭前的拦截逻辑
108
+ done();
109
+ };
110
+
111
+ const view = reactive({
112
+ loading: true,
113
+ saving: false,
114
+ donotClose: false,
115
+ isnew: true
116
+ })
117
+
118
+
119
+ if (props.id == 0n) { view.isnew = true }
120
+ //^^^^^^^^^^^^^^^上方为对话框功能^^^^^^^^^^^^^^^
121
+
122
+ //===============下方为数据部分===============
123
+ interface RoleOption {
124
+ value: string,
125
+ label: string,
126
+ enable: boolean
127
+ }
128
+
129
+
130
+ const getRoleOption = async () => {
131
+ let d: RoleOption[] = []
132
+ let res = await http.Post(http.url_sysrole_list, { "page_size": 999, "page_index": 1 })
133
+ if (res.IsSuccess) {
134
+ let data = res.data as {
135
+ listdata: {
136
+ role_name: string,
137
+ role_id: bigint,
138
+ role_enable: boolean
139
+ }[]
140
+ }
141
+ for (let i = 0; i < data.listdata.length; i++) {
142
+ let r = data.listdata[i]
143
+ d.push({ value: r.role_id.toString(), label: r.role_name, enable: r.role_enable })
144
+ }
145
+ return d
146
+ }
147
+ return []
148
+ }
149
+
150
+ const role_option = ref<RoleOption[]>([])
151
+
152
+ //=================表单
153
+ const ruleFormRef = ref<FormInstance>()
154
+ const form = ref({
155
+ uid: props.id as bigint,
156
+ uname: "",
157
+ username: "",
158
+ password: "",
159
+ is_enable: true,
160
+ role_value: [] as string[],
161
+ })
162
+ const rules = reactive<FormRules<typeof form>>({
163
+ uname: [
164
+ { required: true, message: '请输入姓名', trigger: 'blur' },
165
+ ],
166
+ })
167
+ //=================
168
+
169
+ //获取修改数据
170
+ const getData = async () => {
171
+ view.loading = true
172
+ //获取可以用的权限值
173
+ role_option.value = await getRoleOption()
174
+ form.value.uid = props.id
175
+ if (props.id != 0n) {
176
+ view.donotClose = false
177
+ try {
178
+ let res = await http.Post(http.url_user_detail, { id: props.id })
179
+ if (res.IsSuccess) {
180
+ let data = res.data as {
181
+ uid: bigint
182
+ uname: string
183
+ username: string
184
+ user_enable: number
185
+ role_ids: bigint[]
186
+ }
187
+
188
+ form.value.uid = data.uid
189
+ form.value.uname = data.uname
190
+ form.value.username = data.username
191
+ form.value.is_enable = data.user_enable == 1
192
+ let rs: string[] = []
193
+ for (const s of data.role_ids) {
194
+ for (let tmp of role_option.value) {
195
+ if (tmp.value == s.toString()) {
196
+ rs.push(s.toString())
197
+ break
198
+ }
199
+ }
200
+ }
201
+ form.value.role_value = rs
202
+ }
203
+ } catch (e) {
204
+ console.log(e);
205
+ } finally {
206
+
207
+ }
208
+ } else {
209
+
210
+ }
211
+ view.loading = false
212
+ }
213
+
214
+ //保存
215
+ const saveData = async (): Promise<HttpApiReturnData> => {
216
+ let r: bigint[] = []
217
+ for (const s of form.value.role_value) {
218
+ r.push(BigInt(s))
219
+ }
220
+ let postdata = {
221
+ uid: form.value.uid,
222
+ username: form.value.username,
223
+ password: form.value.uid == 0n ? Md5.hashStr(form.value.password) : "",
224
+ uname: form.value.uname,
225
+ user_enable: form.value.is_enable ? 1 : 0,
226
+ role_ids: r
227
+ }
228
+
229
+ return await http.Post(http.url_user_save, postdata)
230
+ }
231
+
232
+ //验证表单处理界面并保存
233
+ const submitForm = (formEl: FormInstance | undefined) => {
234
+ if (!formEl) return
235
+ formEl.validate(async (valid) => {
236
+ if (valid) {
237
+ view.saving = true
238
+ try {
239
+ let res = await saveData()
240
+ if (res.IsSuccess) {
241
+ // emit('confirm');
242
+ if (view.donotClose) {
243
+ form.value.uid = 0n
244
+ setTimeout(() => { focus() }, 200);
245
+ } else {
246
+ close();
247
+ }
248
+ ZSYSMessage.ShowSuccess("保存成功")
249
+ eventBus.emit('aud', { module: 'user', id: form.value.uid })
250
+ } else {
251
+ ZSYSMessage.ShowError(res.message)
252
+ }
253
+ } catch (e) {
254
+
255
+ } finally {
256
+ // emit('confirm');
257
+ // close();
258
+ view.saving = false
259
+
260
+ }
261
+ }
262
+ })
263
+ }
264
+
265
+ const focus = () => {
266
+ inputRef.value?.focus()
267
+ inputRef.value?.select()
268
+ }
269
+
270
+ //==========快捷键
271
+ const keys = useMagicKeys()
272
+
273
+ whenever(keys.alt_s, () => {
274
+ if (visible.value) {
275
+ console.log('Alt+S提交')
276
+ submitForm(ruleFormRef.value)
277
+ }
278
+ // 在这里执行你的业务逻辑
279
+ })
280
+
281
+ </script>
282
+
283
+ <style scoped></style>