feat: generate password for user

This commit is contained in:
0xJacky 2022-09-15 23:35:49 +08:00
parent 92fb679b55
commit 5490e48d9f
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
19 changed files with 702 additions and 259 deletions

View file

@ -1,7 +1,5 @@
<script setup lang="ts">
import gettext from '@/gettext'
const {$gettext, interpolate} = gettext
import StdTable from './StdTable.vue'
import StdDataEntry from '@/components/StdDataEntry'
@ -9,6 +7,8 @@ import StdDataEntry from '@/components/StdDataEntry'
import {reactive, ref} from 'vue'
import {message} from 'ant-design-vue'
const {$gettext} = gettext
const props = defineProps({
api: Object,
columns: Array,
@ -44,13 +44,20 @@ const props = defineProps({
type: Boolean,
default: true
},
beforeSave: {
type: Function,
default: null
},
exportCsv: {
type: Boolean,
default: false
}
})
const visible = ref(false)
const update = ref(0)
const data: any = reactive({id: null})
const error: any = reactive({})
const params = reactive({})
const selected = reactive([])
function onSelect(keys: any) {
@ -67,7 +74,7 @@ function add() {
Object.keys(data).forEach(v => {
delete data[v]
})
clear_error()
visible.value = true
}
@ -86,7 +93,7 @@ function clear_error() {
const ok = async () => {
clear_error()
await props.beforeSave(data)
props.api!.save(data.id, data).then((r: any) => {
message.success($gettext('Save Successfully'))
Object.assign(data, r)
@ -124,11 +131,13 @@ function edit(id: any) {
</template>
<std-table
ref="table"
v-bind="props"
@clickEdit="edit"
@selected="onSelect"
:key="update"
ref="table"
v-bind="props"
@clickEdit="edit"
@selected="onSelect"
:key="update"
:get_params="get_params"
:exportCsv="exportCsv"
>
<template v-slot:actions="slotProps">
<slot name="actions" :actions="slotProps.record"/>
@ -137,23 +146,24 @@ function edit(id: any) {
</a-card>
<a-modal
class="std-curd-edit-modal"
:mask="false"
:title="data.id ? $gettext('Modify') : $gettext('Add')"
:visible="visible"
:cancel-text="$gettext('Cancel')"
:ok-text="$gettext('OK')"
@cancel="cancel"
@ok="ok"
:width="600"
destroyOnClose
class="std-curd-edit-modal"
:mask="false"
:title="data.id ? $gettext('Modify') : $gettext('Add')"
:visible="visible"
:cancel-text="$gettext('Cancel')"
:ok-text="$gettext('OK')"
@cancel="cancel"
@ok="ok"
:width="600"
destroyOnClose
>
<std-data-entry
ref="std_data_entry"
:data-list="editableColumns()"
:data-source="data"
:error="error"
ref="std_data_entry"
:data-list="editableColumns()"
v-model:data-source="data"
:error="error"
/>
<slot name="edit" :data="data"/>
</a-modal>
</div>
</template>