超管后台 - 对齐项目表数据结构调整添加/编辑页面表单项目及数据
This commit is contained in:
@@ -126,7 +126,7 @@ class CreateCompanyController extends BaseController
|
||||
protected function ckbCreateUser(array $params): void
|
||||
{
|
||||
$params = ArrHelper::getValue(
|
||||
'username,account,password,companyId,s2_accountId,status,realName',
|
||||
'username,account,password,companyId,s2_accountId,status,phone',
|
||||
$params
|
||||
);
|
||||
|
||||
@@ -156,6 +156,36 @@ class CreateCompanyController extends BaseController
|
||||
$this->ckbCreateUser($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查项目名称是否已存在
|
||||
*
|
||||
* @param array $where
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function checkCompanyNameOrAccountOrPhoneExists(array $where): void
|
||||
{
|
||||
extract($where);
|
||||
|
||||
// 项目名称尽量不重名
|
||||
$exists = CompanyModel::where(compact('name'))->count() > 0;
|
||||
if ($exists) {
|
||||
throw new \Exception('项目名称已存在', 403);
|
||||
}
|
||||
|
||||
// 账号不重名
|
||||
$exists = UsersModel::where(compact('account'))->count() > 0;
|
||||
if ($exists) {
|
||||
throw new \Exception('用户账号已存在', 403);
|
||||
}
|
||||
|
||||
// 手机号不重名
|
||||
$exists = UsersModel::where(compact('phone'))->count() > 0;
|
||||
if ($exists) {
|
||||
throw new \Exception('手机号已存在', 403);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新项目
|
||||
*
|
||||
@@ -168,7 +198,7 @@ class CreateCompanyController extends BaseController
|
||||
$params = $this->dataValidate($params)->creatS2About($params);
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$this->checkCompanyNameOrAccountOrPhoneExists(ArrHelper::getValue('name,account,phone', $params));
|
||||
$this->createCkbAbout($params);
|
||||
|
||||
Db::commit();
|
||||
|
||||
@@ -85,7 +85,7 @@ class UpdateCompanyController extends BaseController
|
||||
*/
|
||||
protected function updateUserAccount(array $params): void
|
||||
{
|
||||
$params = ArrHelper::getValue('username,account,password,realName,status', $params);
|
||||
$params = ArrHelper::getValue('username,account,password,phone,status', $params);
|
||||
$params = ArrHelper::rmValue($params);
|
||||
|
||||
if (isset($params['password'])) {
|
||||
@@ -119,7 +119,7 @@ class UpdateCompanyController extends BaseController
|
||||
|
||||
/**
|
||||
* 更新触客宝端数据
|
||||
*
|
||||
*
|
||||
* @param array $params
|
||||
* @return self
|
||||
* @throws \Exception
|
||||
@@ -142,7 +142,7 @@ class UpdateCompanyController extends BaseController
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function checkCompanyNameAndAccountExists(array $where): void
|
||||
protected function checkCompanyNameOrAccountOrPhoneExists(array $where): void
|
||||
{
|
||||
extract($where);
|
||||
|
||||
@@ -152,12 +152,17 @@ class UpdateCompanyController extends BaseController
|
||||
throw new \Exception('项目名称已存在', 403);
|
||||
}
|
||||
|
||||
// 账号尽量不重名
|
||||
// TODO(数据迁移时,存客宝,主账号先查询出id,通过id查询出S2的最新信息,然后更新。)
|
||||
$exists = UsersModel::where(compact('account'))->where('companyId', '<>', $id)->count() > 0;
|
||||
if ($exists) {
|
||||
throw new \Exception('用户账号已存在', 403);
|
||||
}
|
||||
|
||||
// 手机号不重复
|
||||
$exists = UsersModel::where(compact('phone'))->where('companyId', '<>', $id)->count() > 0;
|
||||
if ($exists) {
|
||||
throw new \Exception('手机号已存在', 403);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +212,7 @@ class UpdateCompanyController extends BaseController
|
||||
|
||||
// 数据验证
|
||||
$this->dataValidate($params);
|
||||
$this->checkCompanyNameAndAccountExists(ArrHelper::getValue('id,name,account', $params));
|
||||
$this->checkCompanyNameOrAccountOrPhoneExists(ArrHelper::getValue('id,name,account,phone', $params));
|
||||
|
||||
Db::startTrans();
|
||||
$this->updateCkbAbout($params)->updateS2About($params);
|
||||
|
||||
@@ -141,7 +141,7 @@ export default function EditProjectPage({ params }: { params: { id: string } })
|
||||
|
||||
<div className="grid gap-6 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="account">账号</Label>
|
||||
<Label htmlFor="account">登录账号</Label>
|
||||
<Input
|
||||
id="account"
|
||||
value={account}
|
||||
@@ -161,29 +161,7 @@ export default function EditProjectPage({ params }: { params: { id: string } })
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="password">密码</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="不修改请留空"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="confirmPassword">确认密码</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
placeholder="不修改请留空"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="phone">手机号</Label>
|
||||
<Input
|
||||
@@ -208,6 +186,28 @@ export default function EditProjectPage({ params }: { params: { id: string } })
|
||||
<option value="0">禁用</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="password">密码</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="不修改请留空"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="confirmPassword">确认密码</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
placeholder="不修改请留空"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function NewProjectPage() {
|
||||
account: "",
|
||||
password: "",
|
||||
confirmPassword: "",
|
||||
realName: "",
|
||||
phone: "",
|
||||
nickname: "",
|
||||
description: "",
|
||||
status: "1" // 默认启用
|
||||
@@ -63,7 +63,7 @@ export default function NewProjectPage() {
|
||||
name: formData.name,
|
||||
account: formData.account,
|
||||
password: formData.password,
|
||||
realName: formData.realName,
|
||||
phone: formData.phone,
|
||||
username: formData.nickname,
|
||||
description: formData.description,
|
||||
status: formData.status
|
||||
@@ -117,17 +117,38 @@ export default function NewProjectPage() {
|
||||
|
||||
<div className="grid gap-6 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="account">账号</Label>
|
||||
<Label htmlFor="account">登录账号</Label>
|
||||
<Input
|
||||
id="account"
|
||||
type="number"
|
||||
placeholder="请输入手机号"
|
||||
placeholder="请输入登录的账号"
|
||||
required
|
||||
value={formData.account}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="nickname">昵称</Label>
|
||||
<Input
|
||||
id="nickname"
|
||||
placeholder="用于账号登录后显示的用户名,可以填真实姓名"
|
||||
required
|
||||
value={formData.nickname}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="phone">手机号</Label>
|
||||
<Input
|
||||
id="phone"
|
||||
type="number"
|
||||
placeholder="手机号可用于登录"
|
||||
required
|
||||
value={formData.phone}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="status">状态</Label>
|
||||
<Select value={formData.status} onValueChange={handleStatusChange}>
|
||||
@@ -166,30 +187,6 @@ export default function NewProjectPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-6 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="realName">真实姓名</Label>
|
||||
<Input
|
||||
id="realName"
|
||||
placeholder="请输入真实姓名"
|
||||
required
|
||||
value={formData.realName}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="nickname">昵称</Label>
|
||||
<Input
|
||||
id="nickname"
|
||||
placeholder="请输入昵称"
|
||||
required
|
||||
value={formData.nickname}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="description">项目介绍</Label>
|
||||
<Textarea
|
||||
|
||||
Reference in New Issue
Block a user