update

parent 284fd984
......@@ -7,4 +7,25 @@ const isMobilePhone = (str: string) => {
const phone84 = /^[84]{2}[0-9]{9,11}$/;
return phoneNot84.test(str) || phone84.test(str);
};
export { isEmail, isMobilePhone };
const isUserName = (str: string) => {
const userName = /^\w+$/;
return userName.test(str);
}
const isHasVietnamese = ( str: string) => {
const vn =
'àáạảãâầấậẩẫăằắặẳẵèéẹẻẽêềếệểễìíịỉĩòóọỏõôồốộổỗơờớợởỡùúụủũưừứựửữỳýỵỷỹđ'
const strLower = str.toLowerCase()
let isOK = false
for (let i = 0; i < strLower.length; i++) {
if (vn.indexOf(strLower[i]) >= 0) {
isOK = true
break
}
}
return isOK
}
export { isEmail, isMobilePhone, isUserName, isHasVietnamese };
......@@ -131,7 +131,16 @@
toolbar-toggle-color="yellow-8"
toolbar-bg="primary"
:spellcheck="false"
:definitions="{
upload: {
tip: 'Upload to cloud',
icon: 'cloud_upload',
label: 'Upload',
handler: selectedFile,
},
}"
:toolbar="[
['upload'],
[
{
label: $q.lang.editor.align,
......@@ -149,6 +158,7 @@
'subscript',
'superscript',
],
['token', 'hr', 'link', 'custom_btn'],
['print', 'fullscreen'],
[
......@@ -217,7 +227,9 @@
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
>
</q-editor>
<!-- <q-tabs
v-model="tabContent"
dense
......@@ -381,29 +393,30 @@ export default defineComponent({
required: true,
},
isUpdate: { type: Boolean, default: false },
image: { type: String, required: true },
namePage: { type: String, required: true },
url: { type: String, required: true },
numIndex: { type: String, required: true },
content: { type: String, required: true },
nameMenu: { type: Array, required: true },
nameMenuOptions: { type: Array, required: true },
languageOptions: {
type: Array as PropType<
{
namePage: string;
url: string;
content: string;
numIndex: number;
nameMenu: [];
language: {
id: number;
code: string;
name: string;
};
}[]
>,
required: true,
},
languageOptions: {
type: Array as PropType<
{
namePage: string;
url: string;
content: string;
numIndex: number;
nameMenu: [];
language: {
id: number;
code: string;
name: string;
};
}[]
>,
required: true,
},
},
setup() {
const namePageRules = [
......@@ -416,14 +429,10 @@ export default defineComponent({
(val && val.trim().length) ||
i18n.global.t('listConfigSystem.validateMessages.requireUrl'),
];
// const nameMenuRules = [
// (val?: Array<unknown>) =>
// val?.length ||
// i18n.global.t('listConfigSystem.validateMessages.requireNameMenu'),
// ];
// const tabNamePage = ref('vi');
// const tabContent = ref('vi');
return {
namePageRules,
urlRules,
// nameMenuRules,
......@@ -431,6 +440,13 @@ export default defineComponent({
// tabContent,
};
},
methods: {
selectedFile(file: File) {
const upload = URL.createObjectURL(file);
console.log(upload, 'upload');
},
},
emits: [
'update:isOpened',
'update:namePage',
......@@ -438,6 +454,7 @@ export default defineComponent({
'update:numIndex',
'update:nameMenu',
'update:url',
'SetAvatar',
'click:CloseBtn',
'addUpdateConfigSystem',
],
......
import { defineComponent, PropType, Ref, ref, watch } from 'vue';
import { i18n } from 'src/boot/i18n';
import { isEmail } from '../../../boot/functions';
import { isMobilePhone } from '../../../boot/functions';
import { isMobilePhone, isUserName, isHasVietnamese } from '../../../boot/functions';
import { CustomerLevelType, CustomerType } from 'src/assets/type';
export default defineComponent({
......@@ -84,6 +84,8 @@ export default defineComponent({
(val?: string) =>
(val && val.trim().length < 30) ||
i18n.global.t('customer.validateMessages.lengthUserName'),
(val: string) => (isUserName(val) ||
'vui lòng nhập đúng tên đăng nhập'),
];
const passwordRules = [
(val?: string) =>
......@@ -109,19 +111,19 @@ export default defineComponent({
(val && val.trim().length <= 50) ||
i18n.global.t('customer.validateMessages.lengthCustomerName'),
];
const businessNameRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requireBusinessName'),
];
const taxCodeRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requireTaxCode'),
(val?: string) =>
(val && val.trim().length <= 20) ||
i18n.global.t('customer.validateMessages.LengthTaxCode'),
];
// const businessNameRules = [
// (val?: string) =>
// (val && val.trim().length) ||
// i18n.global.t('customer.validateMessages.requireBusinessName'),
// ];
// const taxCodeRules = [
// (val?: string) =>
// (val && val.trim().length) ||
// i18n.global.t('customer.validateMessages.requireTaxCode'),
// (val?: string) =>
// (val && val.trim().length <= 20) ||
// i18n.global.t('customer.validateMessages.LengthTaxCode'),
// ];
const phoneRules = [
(val?: string) =>
(val && val.trim().length) ||
......@@ -137,48 +139,49 @@ export default defineComponent({
(val: string) =>
isEmail(val) || i18n.global.t('customer.validateMessages.isEmail'),
];
const addressRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requireAddress'),
];
const businessTypeRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requireBusinessType'),
];
const levelRules = [
(val?: CustomerLevelType) =>
val !== null ||
i18n.global.t('customer.validateMessages.requireRatings'),
];
const representativeRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requireRepresentative'),
(val?: string) =>
(val && val.trim().length <= 50) ||
i18n.global.t('customer.validateMessages.lengthRepresentative'),
];
const positionRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requiredPosition'),
];
// const addressRules = [
// (val?: string) =>
// (val && val.trim().length) ||
// i18n.global.t('customer.validateMessages.requireAddress'),
// ];
// const businessTypeRules = [
// (val?: string) =>
// (val && val.trim().length) ||
// i18n.global.t('customer.validateMessages.requireBusinessType'),
// ];
// const levelRules = [
// (val?: CustomerLevelType) =>
// val !== null ||
// i18n.global.t('customer.validateMessages.requireRatings'),
// ];
// const representativeRules = [
// (val?: string) =>
// (val && val.trim().length) ||
// i18n.global.t('customer.validateMessages.requireRepresentative'),
// (val?: string) =>
// (val && val.trim().length <= 50) ||
// i18n.global.t('customer.validateMessages.lengthRepresentative'),
// ];
// const positionRules = [
// (val?: string) =>
// (val && val.trim().length) ||
// i18n.global.t('customer.validateMessages.requiredPosition'),
// ];
return {
isPwd: ref(true),
userNameRules,
customerNameRules,
businessNameRules,
// businessNameRules,
passwordRules,
codeRules,
taxCodeRules,
// taxCodeRules,
emailRules,
levelRules,
addressRules,
businessTypeRules,
representativeRules,
positionRules,
// levelRules,
// addressRules,
// businessTypeRules,
// representativeRules,
// positionRules,
phoneRules,
userName,
fullName,
......
......@@ -333,15 +333,15 @@ export default {
customerName: 'Họ tên *',
password: 'Mật khẩu *',
code: 'Mã khách hàng *',
businessName: 'Tên doanh nghiệp *',
taxCode: 'Mã số thuế *',
businessName: 'Tên doanh nghiệp ',
taxCode: 'Mã số thuế ',
email: 'Email *',
ratings: 'Xếp hạng *',
address: 'Địa chỉ *',
businessType: 'Loại doanh nghiệp *',
representative: 'Người đại diện *',
position: 'Chức vụ *',
phone: 'Số điện thoại *',
ratings: 'Xếp hạng ',
address: 'Địa chỉ ',
businessType: 'Loại doanh nghiệp ',
representative: 'Người đại diện ',
position: 'Chức vụ ',
phone: 'Số điện thoại ',
status: 'Trạng thái',
},
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment