Changes Update User
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<div class="field-body">
|
<div class="field-body">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label"
|
<label class="label"
|
||||||
>{{ isVietnamese ? 'Tên tài khoản' : 'Username' }}<b class="ml-1 has-text-danger">*</b></label
|
>{{ isVietnamese ? 'Tên đăng nhập' : 'Username' }}<b class="ml-1 has-text-danger">*</b></label
|
||||||
>
|
>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text" placeholder="" v-model="username" />
|
<input class="input" type="text" placeholder="" v-model="username" />
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<div class="field-body">
|
<div class="field-body">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label"
|
<label class="label"
|
||||||
>{{ isVietnamese ? 'Họ và tên' : 'Full name' }}<b class="ml-1 has-text-danger">*</b></label
|
>{{!dealer? isVietnamese ? 'Họ và tên' : 'Full name': isVietnamese ? 'Tên tài khoản' : 'Dealer name' }}<b class="ml-1 has-text-danger">*</b></label
|
||||||
>
|
>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text" placeholder="" v-model="fullname" />
|
<input class="input" type="text" placeholder="" v-model="fullname" />
|
||||||
@@ -209,7 +209,7 @@ export default {
|
|||||||
} else if (this.username !== this.username.replace(' ', '')) {
|
} else if (this.username !== this.username.replace(' ', '')) {
|
||||||
this.errors.push({ name: 'username', text: 'Tài khoản không được chứa khoảng trắng' });
|
this.errors.push({ name: 'username', text: 'Tài khoản không được chứa khoảng trắng' });
|
||||||
} else if (this.username.length < 5) {
|
} else if (this.username.length < 5) {
|
||||||
this.errors.push({ name: 'fullname', text: 'Tài khoản quá ngắn. Yêu cầu từ 5 kí tự trở nên' });
|
this.errors.push({ name: 'username', text: 'Tài khoản quá ngắn. Yêu cầu từ 5 kí tự trở nên' });
|
||||||
}
|
}
|
||||||
if (this.$empty(this.password)) {
|
if (this.$empty(this.password)) {
|
||||||
this.errors.push({ name: 'password', text: 'Mật khẩu không được bỏ trống' });
|
this.errors.push({ name: 'password', text: 'Mật khẩu không được bỏ trống' });
|
||||||
@@ -276,24 +276,97 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
//send email
|
//send email
|
||||||
if (this.email) {
|
if (this.email) {
|
||||||
let content = `<p>Xin chào ${this.fullname}, </p>`;
|
let loginUrl = this.$mode === 'dev' ? 'https://dev.biz.utopia.com.vn/' : 'https://biz.utopia.com.vn/';
|
||||||
content += '<p>Tài khoản đăng nhập của bạn đã được khởi tạo và sẵn sàng sử dụng:</p>';
|
await this.templateEmail(loginUrl);
|
||||||
content += `<p>Username: ${this.username}</p>`;
|
|
||||||
content += `<p>Password: ${this.password}</p>`;
|
|
||||||
content += `<p>Đội ngũ Utopia.</p>`;
|
|
||||||
let info = { subject: 'Tài khoản đăng nhập Utopia', to: this.email, sender: 1, content: content };
|
|
||||||
let rs = await this.$insertapi('sendemail', info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.dealer) {
|
if (this.dealer) {
|
||||||
let copy = this.$copy(this.row);
|
let copy = this.$copy(this.row);
|
||||||
copy.user = this.user.id;
|
copy.user = this.user.id;
|
||||||
await this.$updaterow('dealer', copy, null, this.pagename);
|
await this.$updaterow('dealer', copy, null, this.pagename);
|
||||||
|
let obj = { user: this.user.id, apps: 11 };
|
||||||
|
await this.$insertapi('userapps', obj, undefined, false);
|
||||||
|
let loginUrl = this.$mode === 'dev' ? 'https://dev.dealer.utopia.com.vn/' : 'https://dealer.utopia.com.vn/';
|
||||||
|
await this.templateEmail(loginUrl);
|
||||||
}
|
}
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.$dialog('Tạo tài khoản thành công.', 'Thành công', 'Success', 10);
|
this.$dialog('Tạo tài khoản thành công.', 'Thành công', 'Success', 10);
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
},
|
},
|
||||||
|
async templateEmail(loginUrl) {
|
||||||
|
let content = `
|
||||||
|
<table width="100%" bgcolor="#f4f6f8" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:30px 15px;">
|
||||||
|
<table width="600" cellpadding="0" cellspacing="0" border="0"
|
||||||
|
style="background:#ffffff; font-family:Arial, Helvetica, sans-serif; color:#333333; border-collapse:collapse;">
|
||||||
|
<tr>
|
||||||
|
<td style="padding:30px 25px; font-size:15px; line-height:1.6;">
|
||||||
|
|
||||||
|
<p style="margin:0 0 15px 0;">
|
||||||
|
Xin chào <strong>${this.fullname}</strong>,
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="margin:0 0 15px 0;">
|
||||||
|
Tài khoản đăng nhập của bạn đã được khởi tạo thành công và sẵn sàng sử dụng.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin:15px 0;">
|
||||||
|
<tr>
|
||||||
|
<td width="120" style="padding:6px 0;"><strong>Username:</strong></td>
|
||||||
|
<td style="padding:6px 0;">${this.username}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding:6px 0;"><strong>Password:</strong></td>
|
||||||
|
<td style="padding:6px 0;">${this.password}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0" align="center" style="margin:25px auto;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" bgcolor="#2f6fed" style="border-radius:4px;">
|
||||||
|
<a href="${loginUrl}"
|
||||||
|
target="_blank"
|
||||||
|
style="display:inline-block;
|
||||||
|
padding:12px 28px;
|
||||||
|
font-size:15px;
|
||||||
|
color:#ffffff;
|
||||||
|
text-decoration:none;
|
||||||
|
font-weight:bold;">
|
||||||
|
Đăng nhập ngay
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p style="margin:25px 0 0 0;">
|
||||||
|
Trân trọng,<br/>
|
||||||
|
<strong>Đội ngũ Utopia</strong>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"
|
||||||
|
style="padding:20px; font-size:12px; color:#777777; border-top:1px solid #eeeeee;">
|
||||||
|
© ${new Date().getFullYear()} Utopia. All rights reserved.<br/>
|
||||||
|
Đây là email tự động, vui lòng không phản hồi email này.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
`;
|
||||||
|
|
||||||
|
let info = {
|
||||||
|
subject: this.dealer
|
||||||
|
? `${this.$mode === 'dev' ? '[DEV] ' : ''}Thông báo khởi tạo tài khoản – Cổng thông tin Đại lý Utopia`
|
||||||
|
: `${this.$mode === 'dev' ? '[DEV] ' : ''}Thông báo khởi tạo tài khoản – Cổng thông tin Chủ đầu tư Utopia`,
|
||||||
|
to: this.email,
|
||||||
|
sender: 1,
|
||||||
|
content: content,
|
||||||
|
};
|
||||||
|
await this.$insertapi('sendemail', info, undefined, false);
|
||||||
|
},
|
||||||
|
|
||||||
selected(attr, obj) {
|
selected(attr, obj) {
|
||||||
this.option = obj;
|
this.option = obj;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
<div class="field is-horizontal">
|
<div class="field is-horizontal">
|
||||||
<div class="field-body columns">
|
<div class="field-body columns">
|
||||||
<div class="field column">
|
<div class="field column">
|
||||||
<label class="label">{{ isVietnamese ? 'Tên tài khoản' : 'Username' }}</label>
|
<label class="label">{{ isVietnamese ? 'Tên đăng nhập' : 'Username' }}</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<p>{{ props.row.username }}</p>
|
<p>{{ props.row?.user__username ? props.row.user__username : props.row.username }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field column">
|
<div class="field column" v-if="props.row?.user__type !== 3">
|
||||||
<label class="label">{{ isVietnamese ? 'Loại tài khoản' : 'Account type' }}</label>
|
<label class="label">{{ isVietnamese ? 'Loại tài khoản' : 'Account type' }}</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<p>{{ isVietnamese ? props.row.type__name : props.row.type__en }}</p>
|
<p>{{ isVietnamese ? props.row.type__name : props.row.type__en }}</p>
|
||||||
@@ -19,15 +19,15 @@
|
|||||||
<div class="field is-horizontal mt-4">
|
<div class="field is-horizontal mt-4">
|
||||||
<div class="field-body columns">
|
<div class="field-body columns">
|
||||||
<div class="field column">
|
<div class="field column">
|
||||||
<label class="label">{{ isVietnamese ? 'Họ tên' : 'Full name' }}</label>
|
<label class="label">{{props.row?.user__fullname ? isVietnamese ? 'Tên tài khoản' : 'Full name': isVietnamese ? 'Họ tên' : 'Full name' }}</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<p>{{ props.row.fullname }}</p>
|
<p>{{ props.row?.user__fullname ? props.row.user__fullname : props.row.fullname }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field column">
|
<div class="field column">
|
||||||
<label class="label">Email</label>
|
<label class="label">Email</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<p>{{ props.row.email }}</p>
|
<p>{{ props.row?.user__email ? props.row.user__email : props.row.email }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -41,7 +41,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
const { $store, $id, $insertapi, $getdata, $getpath, $updateapi, $dialog, $snackbar, $isVietnamese } = useNuxtApp();
|
const { $store, $id, $insertapi, $getdata, $getpath, $updateapi, $dialog, $snackbar, $isVietnamese, $mode } =
|
||||||
|
useNuxtApp();
|
||||||
const emit = defineEmits(['close']);
|
const emit = defineEmits(['close']);
|
||||||
var props = defineProps({
|
var props = defineProps({
|
||||||
row: Object,
|
row: Object,
|
||||||
@@ -58,28 +59,29 @@ let pass = $id().toLocaleLowerCase();
|
|||||||
async function handlerResetPassword() {
|
async function handlerResetPassword() {
|
||||||
showModal.value.loading = true;
|
showModal.value.loading = true;
|
||||||
|
|
||||||
let user = await $getdata('user', undefined, { filter: { id: props.row.id } }, true);
|
let user = await $getdata(
|
||||||
|
'user',
|
||||||
|
undefined,
|
||||||
|
{ filter: { id: props.row?.user__type === 3 ? props.row.user__id : props.row.id } },
|
||||||
|
true,
|
||||||
|
);
|
||||||
const response = await fetch(`${$getpath()}password/${pass}/`);
|
const response = await fetch(`${$getpath()}password/${pass}/`);
|
||||||
let hash = await response.json();
|
let hash = await response.json();
|
||||||
|
|
||||||
user.password = hash;
|
user.password = hash;
|
||||||
let rs1 = await $updateapi('user', user, null, false);
|
let rs1 = await $updateapi('user', user, null, false);
|
||||||
|
|
||||||
if (rs1 === 'error') {
|
if (rs1 === 'error') {
|
||||||
$dialog('Có lỗi xảy ra. Hãy thử lại một lần nữa', 'Lỗi', 'Error');
|
$dialog('Có lỗi xảy ra. Hãy thử lại một lần nữa', 'Lỗi', 'Error');
|
||||||
} else {
|
} else {
|
||||||
showModal.value.show = false;
|
showModal.value.show = false;
|
||||||
let content = `<p>Xin chào ${props.row.fullname}, </p>`;
|
if (user.type === 3) {
|
||||||
content += '<p>Mật khẩu tài khoản của bạn trên hệ thống đã được đặt lại thành công.</p>';
|
let loginUrl = $mode === 'dev' ? 'https://dev.dealer.utopia.com.vn/' : 'https://dealer.utopia.com.vn/';
|
||||||
content += '<p>Tài khoản đăng nhập của bạn:</p>';
|
await sendEmailAlter(loginUrl, user.fullname, user.username, pass, user.email, user.type);
|
||||||
content += `<p>Username: ${props.row.username}</p>`;
|
} else {
|
||||||
content += `<p>Password: ${pass}</p>`;
|
let loginUrl = $mode === 'dev' ? 'https://dev.biz.utopia.com.vn/' : 'https://biz.utopia.com.vn/';
|
||||||
content += `<p>Đội ngũ Utopia.</p>`;
|
await sendEmailAlter(loginUrl, user.fullname, user.username, pass, user.email, user.type);
|
||||||
let info = {
|
}
|
||||||
subject: 'Thông báo đặt lại mật khẩu tài khoản đăng nhập Utopia',
|
|
||||||
to: props.row.email,
|
|
||||||
sender: 1,
|
|
||||||
content: content,
|
|
||||||
};
|
|
||||||
let rs = await $insertapi('sendemail', info, null, false);
|
|
||||||
showModal.value.loading = false;
|
showModal.value.loading = false;
|
||||||
$snackbar(
|
$snackbar(
|
||||||
'Mật khẩu đã được đặt lại thành công. Thông tin đã được gửi tới địa chỉ email đã đăng ký.',
|
'Mật khẩu đã được đặt lại thành công. Thông tin đã được gửi tới địa chỉ email đã đăng ký.',
|
||||||
@@ -98,7 +100,7 @@ function showConfirm() {
|
|||||||
width: '800px',
|
width: '800px',
|
||||||
component: 'dialog/Confirm',
|
component: 'dialog/Confirm',
|
||||||
vbind: {
|
vbind: {
|
||||||
content: `Bạn có muốn đặt lại mật khẩu cho tài khoản ${props.row.username?.toUpperCase()} này không?`,
|
content: `Bạn có muốn đặt lại mật khẩu cho tài khoản ${(props.row?.user__username ? props.row.user__username : props.row.username)?.toUpperCase()} này không?`,
|
||||||
duration: 10,
|
duration: 10,
|
||||||
},
|
},
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
@@ -106,4 +108,79 @@ function showConfirm() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function sendEmailAlter(loginUrl, fullname, username, password, email, dealer) {
|
||||||
|
let content = `
|
||||||
|
<table width="100%" bgcolor="#f4f6f8" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:30px 15px;">
|
||||||
|
<table width="600" cellpadding="0" cellspacing="0" border="0"
|
||||||
|
style="background:#ffffff; font-family:Arial, Helvetica, sans-serif; color:#333333; border-collapse:collapse;">
|
||||||
|
<tr>
|
||||||
|
<td style="padding:30px 25px; font-size:15px; line-height:1.6;">
|
||||||
|
|
||||||
|
<p style="margin:0 0 15px 0;">
|
||||||
|
Xin chào <strong>${fullname}</strong>,
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="margin:0 0 15px 0;">
|
||||||
|
Chúng tôi đã đặt lại mật khẩu cho tài khoản của bạn.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin:15px 0;">
|
||||||
|
<tr>
|
||||||
|
<td width="120" style="padding:6px 0;"><strong>Username:</strong></td>
|
||||||
|
<td style="padding:6px 0;">${username}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding:6px 0;"><strong>Password:</strong></td>
|
||||||
|
<td style="padding:6px 0;">${password}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0" align="center" style="margin:25px auto;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" bgcolor="#2f6fed" style="border-radius:4px;">
|
||||||
|
<a href="${loginUrl}"
|
||||||
|
target="_blank"
|
||||||
|
style="display:inline-block;
|
||||||
|
padding:12px 28px;
|
||||||
|
font-size:15px;
|
||||||
|
color:#ffffff;
|
||||||
|
text-decoration:none;
|
||||||
|
font-weight:bold;">
|
||||||
|
Đăng nhập ngay
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p style="margin:25px 0 0 0;">
|
||||||
|
Trân trọng,<br/>
|
||||||
|
<strong>Đội ngũ Utopia</strong>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"
|
||||||
|
style="padding:20px; font-size:12px; color:#777777; border-top:1px solid #eeeeee;">
|
||||||
|
© ${new Date().getFullYear()} Utopia. All rights reserved.<br/>
|
||||||
|
Đây là email tự động, vui lòng không phản hồi email này.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
`;
|
||||||
|
|
||||||
|
let info = {
|
||||||
|
subject:
|
||||||
|
dealer === 3
|
||||||
|
? `${$mode === 'dev' ? '[DEV] ' : ''}Thông báo đặt lại mật khẩu thành công – Cổng thông tin Đại lý Utopia`
|
||||||
|
: `${$mode === 'dev' ? '[DEV] ' : ''}Thông báo đặt lại mật khẩu thành công – Cổng thông tin Chủ đầu tư Utopia`,
|
||||||
|
to: email,
|
||||||
|
sender: 1,
|
||||||
|
content: content,
|
||||||
|
};
|
||||||
|
await $insertapi('sendemail', info, undefined, false);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default defineNuxtPlugin(() => {
|
|||||||
{name: 'approvestatus', url: 'data/Approve_Status/', url_detail: 'data-detail/Approve_Status/', params: {}},
|
{name: 'approvestatus', url: 'data/Approve_Status/', url_detail: 'data-detail/Approve_Status/', params: {}},
|
||||||
{name: 'staffstatus', url: 'data/Staff_Status/', url_detail: 'data-detail/Staff_Status/', params: {}},
|
{name: 'staffstatus', url: 'data/Staff_Status/', url_detail: 'data-detail/Staff_Status/', params: {}},
|
||||||
{name: 'userapps', url: 'data/User_Apps/', url_detail: 'data-detail/User_Apps/', params: {}},
|
{name: 'userapps', url: 'data/User_Apps/', url_detail: 'data-detail/User_Apps/', params: {}},
|
||||||
{name: 'dealer', url: 'data/Dealer/', url_detail: 'data-detail/Dealer/', params: {values: 'id,code,name,user,user__username,user__fullname,email,create_time'}},
|
{name: 'dealer', url: 'data/Dealer/', url_detail: 'data-detail/Dealer/', params: {values: 'id,code,name,user,user__id,user__username,user__fullname,user__email,user__type,email,create_time'}},
|
||||||
{name: 'datadeletion', url: 'data-deletion/', params: {}},
|
{name: 'datadeletion', url: 'data-deletion/', params: {}},
|
||||||
{name: 'emailsetup', url: 'data/Email_Setup/', url_detail: 'data-detail/Email_Setup/', params: {sort: '-id'}},
|
{name: 'emailsetup', url: 'data/Email_Setup/', url_detail: 'data-detail/Email_Setup/', params: {sort: '-id'}},
|
||||||
{name: 'emailsent', url: 'data/Email_Sent/', url_detail: 'data-detail/Email_Sent/', params: {values: 'id,subject,sender,sender__email,receiver,content,status__code,status,status__name,create_time', sort: '-id'}},
|
{name: 'emailsent', url: 'data/Email_Sent/', url_detail: 'data-detail/Email_Sent/', params: {values: 'id,subject,sender,sender__email,receiver,content,status__code,status,status__name,create_time', sort: '-id'}},
|
||||||
|
|||||||
Reference in New Issue
Block a user