perf: 新增联系电话

This commit is contained in:
kuaifan 2022-07-08 15:24:24 +08:00
parent 97d041076d
commit c13f8bbcc0
9 changed files with 146 additions and 31 deletions

View File

@ -500,12 +500,14 @@ class DialogController extends AbstractController
Base::checkClientVersion('0.13.33');
$user = User::auth();
//
$chat_nickname = Base::settingFind('system', 'chat_nickname');
if ($chat_nickname == 'required') {
$nickname = User::select(['nickname as nickname_original'])->whereUserid($user->userid)->value('nickname_original');
if (empty($nickname)) {
$chat_information = Base::settingFind('system', 'chat_information');
if ($chat_information == 'required') {
if (empty($user->getRawOriginal('nickname'))) {
return Base::retError('请设置昵称', [], -2);
}
if (empty($user->getRawOriginal('tel'))) {
return Base::retError('请设置联系电话', [], -3);
}
}
//
$dialog_id = Base::getPostInt('dialog_id');

View File

@ -28,7 +28,7 @@ class SystemController extends AbstractController
* @apiParam {String} type
* - get: 获取(默认)
* - all: 获取所有(需要管理员权限)
* - save: 保存设置(参数:['reg', 'reg_invite', 'login_code', 'password_policy', 'project_invite', 'chat_nickname', 'auto_archived', 'archived_day', 'all_group_mute', 'start_home', 'home_footer']
* - save: 保存设置(参数:['reg', 'reg_invite', 'login_code', 'password_policy', 'project_invite', 'chat_information', 'auto_archived', 'archived_day', 'all_group_mute', 'start_home', 'home_footer']
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
@ -50,7 +50,7 @@ class SystemController extends AbstractController
'login_code',
'password_policy',
'project_invite',
'chat_nickname',
'chat_information',
'auto_archived',
'archived_day',
'all_group_mute',
@ -84,7 +84,7 @@ class SystemController extends AbstractController
$setting['login_code'] = $setting['login_code'] ?: 'auto';
$setting['password_policy'] = $setting['password_policy'] ?: 'simple';
$setting['project_invite'] = $setting['project_invite'] ?: 'open';
$setting['chat_nickname'] = $setting['chat_nickname'] ?: 'optional';
$setting['chat_information'] = $setting['chat_information'] ?: 'optional';
$setting['auto_archived'] = $setting['auto_archived'] ?: 'close';
$setting['archived_day'] = floatval($setting['archived_day']) ?: 7;
$setting['all_group_mute'] = $setting['all_group_mute'] ?: 'open';

View File

@ -244,6 +244,7 @@ class UsersController extends AbstractController
* @apiName editdata
*
* @apiParam {Object} [userimg] 会员头像(地址)
* @apiParam {String} [tel] 电话
* @apiParam {String} [nickname] 昵称
* @apiParam {String} [profession] 职位/职称
*
@ -264,6 +265,17 @@ class UsersController extends AbstractController
$user->userimg = '';
}
}
// 电话
if (Arr::exists($data, 'tel')) {
$tel = trim(Request::input('tel'));
if (strlen($tel) < 6 || strlen($tel) > 20) {
return Base::retError('联系电话长度错误');
}
if ($tel != $user->tel && User::whereTel($tel)->exists()) {
return Base::retError('联系电话已存在');
}
$user->tel = $tel;
}
// 昵称
if (Arr::exists($data, 'nickname')) {
$nickname = trim(Request::input('nickname'));
@ -469,8 +481,9 @@ class UsersController extends AbstractController
* @apiName lists
*
* @apiParam {Object} [keys] 搜索条件
* - keys.key 邮箱/昵称/职位赋值后keys.email、keys.nickname、keys.profession失效
* - keys.key 邮箱/电话/昵称/职位赋值后keys.email、keys.tel、keys.nickname、keys.profession失效
* - keys.email 邮箱
* - keys.tel 电话
* - keys.nickname 昵称
* - keys.profession 职位
* - keys.identity 身份admin、noadmin
@ -504,6 +517,7 @@ class UsersController extends AbstractController
} else {
$builder->where(function($query) use ($keys) {
$query->where("email", "like", "%{$keys['key']}%")
->orWhere("tel", "like", "%{$keys['key']}%")
->orWhere("nickname", "like", "%{$keys['key']}%")
->orWhere("profession", "like", "%{$keys['key']}%");
});
@ -512,6 +526,9 @@ class UsersController extends AbstractController
if ($keys['email']) {
$builder->where("email", "like", "%{$keys['email']}%");
}
if ($keys['tel']) {
$builder->where("tel", "like", "%{$keys['tel']}%");
}
if ($keys['nickname']) {
$builder->where("nickname", "like", "%{$keys['nickname']}%");
}
@ -560,6 +577,7 @@ class UsersController extends AbstractController
* - cleardisable 取消离职
* - delete 删除会员
* @apiParam {String} [email] 邮箱地址
* @apiParam {String} [tel] 联系电话
* @apiParam {String} [password] 新的密码
* @apiParam {String} [nickname] 昵称
* @apiParam {String} [profession] 职位
@ -639,6 +657,14 @@ class UsersController extends AbstractController
}
$upArray['email'] = $email;
}
// 电话
if (Arr::exists($data, 'tel')) {
$tel = trim($data['tel']);
if (User::whereTel($tel)->where('userid', '!=', $userInfo->userid)->exists()) {
return Base::retError('联系电话已存在');
}
$upArray['tel'] = $tel;
}
// 密码
if (Arr::exists($data, 'password')) {
$password = trim($data['password']);

View File

@ -16,6 +16,7 @@ use Carbon\Carbon;
* @property string|null $az A-Z
* @property string|null $pinyin 拼音(主要用于搜索)
* @property string|null $email 邮箱
* @property string|null $tel 联系电话
* @property string $nickname 昵称
* @property string|null $profession 职位/职称
* @property string $userimg 头像
@ -56,6 +57,7 @@ use Carbon\Carbon;
* @method static \Illuminate\Database\Eloquent\Builder|User wherePinyin($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereProfession($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereTaskDialogId($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereTel($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereUserid($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereUserimg($value)

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUsersTel extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
if (!Schema::hasColumn('users', 'tel')) {
$table->string('tel', 50)->nullable()->default('')->after('email')->comment('联系电话');
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn("tel");
});
}
}

View File

@ -222,6 +222,28 @@ export default {
}, arr)
}
},
{
title: this.$L('电话'),
key: 'tel',
minWidth: 80,
render: (h, {row}) => {
return h('QuickEdit', {
props: {
value: row.tel,
},
on: {
'on-update': (val, cb) => {
this.operationUser({
userid: row.userid,
tel: val
}, true).finally(cb);
}
}
}, [
h('AutoTip', row.tel || '-')
]);
}
},
{
title: this.$L('昵称'),
key: 'nickname',

View File

@ -38,13 +38,13 @@
</RadioGroup>
<div v-if="formDatum.project_invite == 'open'" class="form-tip">{{$L('开启项目管理员可生成链接邀请成员加入项目')}}</div>
</FormItem>
<FormItem :label="$L('聊天昵称')" prop="chatNickname">
<RadioGroup v-model="formDatum.chat_nickname">
<FormItem :label="$L('聊天资料')" prop="chatInformation">
<RadioGroup v-model="formDatum.chat_information">
<Radio label="optional">{{$L('可选')}}</Radio>
<Radio label="required">{{$L('必填')}}</Radio>
</RadioGroup>
<div v-if="formDatum.chat_nickname == 'required'" class="form-tip">{{$L('必填发送聊天内容前必须设置昵称')}}</div>
<div v-else class="form-tip">{{$L('如果必填,发送聊天前必须设置昵称。')}}</div>
<div v-if="formDatum.chat_information == 'required'" class="form-tip">{{$L('必填发送聊天内容前必须设置昵称电话')}}</div>
<div v-else class="form-tip">{{$L('如果必填,发送聊天前必须设置昵称、电话。')}}</div>
</FormItem>
<FormItem :label="$L('自动归档任务')" prop="autoArchived">
<RadioGroup :value="formDatum.auto_archived" @on-change="formArchived">

View File

@ -5,9 +5,12 @@
<ImgUpload v-model="formData.userimg" :num="1" :width="512" :height="512" :whcut="1"></ImgUpload>
<span class="form-tip">{{$L('建议尺寸200x200')}}</span>
</FormItem>
<FormItem :label="$L('邮箱')">
<FormItem :label="$L('邮箱')" prop="email">
<Input v-model="userInfo.email" disabled></Input>
</FormItem>
<FormItem :label="$L('电话')" prop="tel">
<Input v-model="formData.tel" :maxlength="20" :placeholder="$L('请输入联系电话')"></Input>
</FormItem>
<FormItem :label="$L('昵称')" prop="nickname">
<Input v-model="formData.nickname" :maxlength="20" :placeholder="$L('请输入昵称')"></Input>
</FormItem>
@ -33,6 +36,8 @@ export default {
formData: {
userimg: '',
email: '',
tel: '',
nickname: '',
profession: ''
},
@ -54,6 +59,13 @@ export default {
methods: {
initLanguage() {
this.ruleData = {
email: [
{required: true, message: this.$L('请输入邮箱地址!'), trigger: 'change'},
],
tel: [
{required: true, message: this.$L('请输入联系电话!'), trigger: 'change'},
{type: 'string', min: 6, message: this.$L('电话长度至少6位'), trigger: 'change'}
],
nickname: [
{required: true, message: this.$L('请输入昵称!'), trigger: 'change'},
{type: 'string', min: 2, message: this.$L('昵称长度至少2位'), trigger: 'change'}
@ -62,11 +74,10 @@ export default {
},
initData() {
if (!$A.strExists(this.userInfo.userimg, '/avatar')) {
this.$set(this.formData, 'userimg', this.userInfo.userimg);
}
const nickname = typeof this.userInfo.nickname_original !== "undefined" ? this.userInfo.nickname_original : this.userInfo.nickname;
this.$set(this.formData, 'nickname', nickname);
this.$set(this.formData, 'userimg', $A.strExists(this.userInfo.userimg, '/avatar') ? '' : this.userInfo.userimg);
this.$set(this.formData, 'email', this.userInfo.email);
this.$set(this.formData, 'tel', this.userInfo.tel);
this.$set(this.formData, 'nickname', typeof this.userInfo.nickname_original !== "undefined" ? this.userInfo.nickname_original : this.userInfo.nickname);
this.$set(this.formData, 'profession', this.userInfo.profession);
this.formData_bak = $A.cloneJSON(this.formData);
},

View File

@ -62,15 +62,22 @@ export default {
}
if (ret === -2 && params.checkNick !== false) {
// 需要昵称
dispatch("userNickNameInput").then(() => {
dispatch("call", Object.assign(cloneParams, {
checkNick: false
})).then(resolve).catch(reject);
dispatch("userEditInput", 'nickname').then(() => {
dispatch("call", cloneParams).then(resolve).catch(reject);
}).catch(err => {
reject({ret: -1, data, msg: err || $A.L('请设置昵称!')})
});
return;
}
if (ret === -3 && params.checkTel !== false) {
// 需要联系电话
dispatch("userEditInput", 'tel').then(() => {
dispatch("call", cloneParams).then(resolve).catch(reject);
}).catch(err => {
reject({ret: -1, data, msg: err || $A.L('请设置联系电话!')})
});
return;
}
if (ret === 1) {
resolve({data, msg});
} else {
@ -420,39 +427,50 @@ export default {
},
/**
* 设置用户昵称
* 设置用户信息
* @param dispatch
* @param type
* @returns {Promise<unknown>}
*/
userNickNameInput({dispatch}) {
return new Promise(function (nameResolve, nameReject) {
userEditInput({dispatch}, type) {
return new Promise(function (userResolve, userReject) {
let desc = '';
if (type === 'nickname') {
desc = '昵称';
} else if (type === 'tel') {
desc = '联系电话';
} else {
userReject('参数错误')
return
}
setTimeout(_ => {
$A.modalInput({
title: "设置昵称",
placeholder: "请输入昵称",
title: `设置${desc}`,
placeholder: `请输入${desc}`,
okText: "保存",
onOk: (value) => {
if (!value) {
return '请输入昵称'
return `请输入${desc}`
}
return new Promise((inResolve, inReject) => {
dispatch("call", {
url: 'users/editdata',
data: {
nickname: value,
[type]: value,
},
checkNick: false,
checkTel: false,
}).then(() => {
dispatch('getUserInfo').finally(_ => {
inResolve()
nameResolve()
userResolve()
});
}).catch(({msg}) => {
inReject(msg)
});
})
},
onCancel: _ => nameReject
onCancel: _ => userReject
});
}, 100)
});