修复BUG:

1.新增用户时,默认密码
This commit is contained in:
猿小天
2023-12-26 12:46:19 +08:00
parent 85f5ff1935
commit 6146e6edb6

View File

@@ -1,22 +1,34 @@
import * as api from './api'; import * as api from './api';
import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud'; import {
import { request } from '/@/utils/service'; dict,
import { dictionary } from '/@/utils/dictionary'; UserPageQuery,
import { successMessage } from '/@/utils/message'; AddReq,
import { auth } from '/@/utils/authFunction'; DelReq,
EditReq,
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet { compute,
CreateCrudOptionsProps,
CreateCrudOptionsRet
} from '@fast-crud/fast-crud';
import {request} from '/@/utils/service';
import {dictionary} from '/@/utils/dictionary';
import {successMessage} from '/@/utils/message';
import {auth} from '/@/utils/authFunction';
import {SystemConfigStore} from "/@/stores/systemConfig";
import {storeToRefs} from "pinia";
import {computed} from "vue";
import { Md5 } from 'ts-md5';
export const createCrudOptions = function ({crudExpose}: CreateCrudOptionsProps): CreateCrudOptionsRet {
const pageRequest = async (query: UserPageQuery) => { const pageRequest = async (query: UserPageQuery) => {
return await api.GetList(query); return await api.GetList(query);
}; };
const editRequest = async ({ form, row }: EditReq) => { const editRequest = async ({form, row}: EditReq) => {
form.id = row.id; form.id = row.id;
return await api.UpdateObj(form); return await api.UpdateObj(form);
}; };
const delRequest = async ({ row }: DelReq) => { const delRequest = async ({row}: DelReq) => {
return await api.DelObj(row.id); return await api.DelObj(row.id);
}; };
const addRequest = async ({ form }: AddReq) => { const addRequest = async ({form}: AddReq) => {
return await api.AddObj(form); return await api.AddObj(form);
}; };
@@ -24,6 +36,13 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
return await api.exportData(query) return await api.exportData(query)
} }
const systemConfigStore = SystemConfigStore()
const {systemConfig} = storeToRefs(systemConfigStore)
const getSystemConfig = computed(() => {
console.log(systemConfig.value)
return systemConfig.value
})
return { return {
crudOptions: { crudOptions: {
@@ -38,15 +57,22 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
editRequest, editRequest,
delRequest, delRequest,
}, },
form: {
initialForm: {
password: computed(() => {
return systemConfig.value['base.default_password']
}),
}
},
actionbar: { actionbar: {
buttons: { buttons: {
add: { add: {
show: auth('user:Create') show: auth('user:Create')
}, },
export:{ export: {
text:"导出",//按钮文字 text: "导出",//按钮文字
title:"导出",//鼠标停留显示的信息 title: "导出",//鼠标停留显示的信息
click(){ click() {
return exportRequest(crudExpose!.getSearchFormData()) return exportRequest(crudExpose!.getSearchFormData())
} }
} }
@@ -80,7 +106,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
}, },
//@ts-ignore //@ts-ignore
click: (ctx: any) => { click: (ctx: any) => {
const { row } = ctx; const {row} = ctx;
}, },
}, },
}, },
@@ -88,7 +114,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
columns: { columns: {
_index: { _index: {
title: '序号', title: '序号',
form: { show: false }, form: {show: false},
column: { column: {
type: 'index', type: 'index',
align: 'center', align: 'center',
@@ -120,7 +146,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
}, },
password: { password: {
title: '密码', title: '密码',
type: 'input', type: 'password',
column: { column: {
show: false, show: false,
}, },
@@ -136,17 +162,17 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
}, },
], ],
component: { component: {
span: 12, span: 12,
showPassword: true, showPassword: true,
placeholder: '请输入密码', placeholder: '请输入密码',
}, },
// value: vm.systemConfig('base.default_password'),
}, },
/* valueResolve(row, key) { valueResolve({form}) {
if (row.password) { if (form.password) {
row.password = vm.$md5(row.password) form.password = Md5.hashStr(form.password)
}
} }
} */
}, },
name: { name: {
title: '姓名', title: '姓名',
@@ -182,7 +208,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
url: '/api/system/dept/all_dept/', url: '/api/system/dept/all_dept/',
value: 'id', value: 'id',
label: 'name', label: 'name',
getData: async ({ url }: { url: string }) => { getData: async ({url}: { url: string }) => {
return request({ return request({
url: url, url: url,
}).then((ret: any) => { }).then((ret: any) => {
@@ -224,7 +250,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
value: 'id', value: 'id',
label: 'name', label: 'name',
isTree: true, isTree: true,
getData: async ({ url }: { url: string }) => { getData: async ({url}: { url: string }) => {
return request({ return request({
url: url, url: url,
params: { params: {
@@ -310,7 +336,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
span: 12, span: 12,
}, },
}, },
component: { props: { color: 'auto' } }, // 自动染色 component: {props: {color: 'auto'}}, // 自动染色
}, },
user_type: { user_type: {
title: '用户类型', title: '用户类型',