后台添加手机用户
This commit is contained in:
parent
27b695a965
commit
2a468004e0
|
@ -19,3 +19,8 @@ export function userEdit(params: any) {
|
||||||
export function adjustMoney(params: any) {
|
export function adjustMoney(params: any) {
|
||||||
return request.post({ url: '/user.user/adjustMoney', params })
|
return request.post({ url: '/user.user/adjustMoney', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//添加用户
|
||||||
|
export function addUser(params: any) {
|
||||||
|
return request.post({ url: '/user.user/add', params })
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||||
<el-button @click="resetParams">重置</el-button>
|
<el-button @click="resetParams">重置</el-button>
|
||||||
|
<el-button @click="dialogFormVisible=true">创建</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
@ -81,12 +82,34 @@
|
||||||
<pagination v-model="pager" @change="getLists" />
|
<pagination v-model="pager" @change="getLists" />
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<el-dialog v-model="dialogFormVisible" title="添加用户" width="30%">
|
||||||
|
<el-form :model="form">
|
||||||
|
<el-form-item label="手机号">
|
||||||
|
<el-input v-model="form.mobile" autocomplete="off" />
|
||||||
|
<span>
|
||||||
|
|
||||||
|
<el-icon><Pointer /></el-icon>
|
||||||
|
初始密码:123456
|
||||||
|
</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogFormVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="addUser">
|
||||||
|
确定
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="consumerLists">
|
<script lang="ts" setup name="consumerLists">
|
||||||
import { usePaging } from '@/hooks/usePaging'
|
import { usePaging } from '@/hooks/usePaging'
|
||||||
import { getRoutePath } from '@/router'
|
import { getRoutePath } from '@/router'
|
||||||
import { getUserList } from '@/api/consumer'
|
import { getUserList, addUser as addUserApi } from '@/api/consumer'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import { ClientMap } from '@/enums/appEnums'
|
import { ClientMap } from '@/enums/appEnums'
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
keyword: '',
|
keyword: '',
|
||||||
|
@ -102,6 +125,18 @@ const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||||
onActivated(() => {
|
onActivated(() => {
|
||||||
getLists()
|
getLists()
|
||||||
})
|
})
|
||||||
|
const dialogFormVisible = ref(false)
|
||||||
|
const form = reactive({
|
||||||
|
"mobile": ""
|
||||||
|
})
|
||||||
|
const addUser = () => {
|
||||||
|
addUserApi(form)
|
||||||
|
ElMessage({
|
||||||
|
message: '用户添加成功',
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
dialogFormVisible.value = false
|
||||||
|
getLists()
|
||||||
|
}
|
||||||
getLists()
|
getLists()
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -18,6 +18,13 @@ use app\adminapi\lists\user\UserLists;
|
||||||
use app\adminapi\logic\user\UserLogic;
|
use app\adminapi\logic\user\UserLogic;
|
||||||
use app\adminapi\validate\user\AdjustUserMoney;
|
use app\adminapi\validate\user\AdjustUserMoney;
|
||||||
use app\adminapi\validate\user\UserValidate;
|
use app\adminapi\validate\user\UserValidate;
|
||||||
|
use app\api\validate\LoginAccountValidate;
|
||||||
|
use app\common\model\auth\Admin;
|
||||||
|
use app\common\model\auth\AdminRole;
|
||||||
|
use app\common\model\user\User;
|
||||||
|
use app\common\service\ConfigService;
|
||||||
|
use think\facade\Config;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户控制器
|
* 用户控制器
|
||||||
|
@ -38,6 +45,43 @@ class UserController extends BaseAdminController
|
||||||
return $this->dataLists(new UserLists());
|
return $this->dataLists(new UserLists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$params = $this->request->param();
|
||||||
|
$userSn = User::createUserSn();
|
||||||
|
$passwordSalt = Config::get('project.unique_identification');
|
||||||
|
$password = create_password(123456, $passwordSalt);
|
||||||
|
$avatar = ConfigService::get('default_image', 'user_avatar');
|
||||||
|
|
||||||
|
Db::transaction(function () use($userSn,$password,$avatar,$params) {
|
||||||
|
$user = User::create([
|
||||||
|
'sn' => $userSn,
|
||||||
|
'avatar' => env('project.project_url').'/'.$avatar,
|
||||||
|
'nickname' => '用户' . $userSn,
|
||||||
|
'account' => $params['mobile'],
|
||||||
|
'mobile' => $params['mobile'],
|
||||||
|
'password' => $password,
|
||||||
|
'channel' => 6,
|
||||||
|
]);
|
||||||
|
$admin = Admin::create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'name' => '用户' . $userSn,
|
||||||
|
'avatar' => env('project.project_url').'/'.$avatar,
|
||||||
|
'account' => $params['mobile'],
|
||||||
|
'password' => $password
|
||||||
|
]);
|
||||||
|
AdminRole::create([
|
||||||
|
'admin_id' => $admin->id,
|
||||||
|
'role_id' => 1
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
return $this->success();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->fail($e->getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
public function datas()
|
public function datas()
|
||||||
{
|
{
|
||||||
$datas = (new UserLogic())->datas(input(''));
|
$datas = (new UserLogic())->datas(input(''));
|
||||||
|
|
Loading…
Reference in New Issue