update

parent b0abc23e
......@@ -229,7 +229,7 @@ export type DetailUnit = {
export type CustomerType = {
id: number;
code: string;
code: string | null;
userName: string;
fullName: string;
companyName: string;
......
......@@ -2,7 +2,8 @@ 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 { CustomerLevelType } from 'src/assets/type';
import { CustomerLevelType, CustomerType } from 'src/assets/type';
import { Notify } from 'quasar';
export default defineComponent({
props: {
......@@ -14,6 +15,10 @@ export default defineComponent({
type: Array as PropType<CustomerLevelType[]>,
required: true,
},
listCustomers: {
type: Array as PropType<CustomerType[]>,
required: true,
},
},
setup(props, context) {
watch(
......@@ -30,7 +35,7 @@ export default defineComponent({
const companyName: Ref<string | null> = ref(null);
const taxCode: Ref<string | null> = ref(null);
const email: Ref<string | null> = ref(null);
const status: Ref<number | null> = ref(2);
const status: Ref<number | null> = ref(1);
const phone: Ref<string | null> = ref(null);
const password: Ref<string | null> = ref(null);
const address: Ref<string | null> = ref(null);
......@@ -40,22 +45,78 @@ export default defineComponent({
const level: Ref<CustomerLevelType | null> = ref(null);
const confirmAddCustomer = () => {
context.emit('addNewCustomer', {
code: code.value,
userName: userName.value,
fullName: fullName.value,
companyName: companyName.value,
taxCode: taxCode.value,
email: email.value,
status: status.value,
phone: phone.value,
password: password.value,
address: address.value,
type: type.value,
representative: representative.value,
position: position.value,
level: level.value,
});
let hasError = false;
if (
props.listCustomers.filter((customer) => customer.code === code.value)
.length
) {
hasError = true;
Notify.create({
type: 'negative',
message: i18n.global.t('customer.validateMessages.codeExists'),
});
}
if (
props.listCustomers.filter(
(customer) => customer.userName === userName.value
).length
) {
hasError = true;
Notify.create({
type: 'negative',
message: i18n.global.t('customer.validateMessages.userNameExists'),
});
}
if (
props.listCustomers.filter(
(customer) => customer.taxCode === taxCode.value
).length
) {
hasError = true;
Notify.create({
type: 'negative',
message: i18n.global.t('customer.validateMessages.taxCodeExists'),
});
}
if (
props.listCustomers.filter((customer) => customer.email === email.value)
.length
) {
hasError = true;
Notify.create({
type: 'negative',
message: i18n.global.t('customer.validateMessages.emailExists'),
});
}
if (
props.listCustomers.filter((customer) => customer.phone === phone.value)
.length
) {
hasError = true;
Notify.create({
type: 'negative',
message: i18n.global.t('customer.validateMessages.phoneExists'),
});
}
if (!hasError) {
context.emit('addNewCustomer', {
code: code.value,
userName: userName.value,
fullName: fullName.value,
companyName: companyName.value,
taxCode: taxCode.value,
email: email.value,
status: status.value,
phone: phone.value,
password: password.value,
address: address.value,
type: type.value,
representative: representative.value,
position: position.value,
level: level.value,
});
}
};
const resetData = () => {
code.value = null;
......@@ -64,7 +125,7 @@ export default defineComponent({
companyName.value = null;
taxCode.value = null;
email.value = null;
status.value = 2;
status.value = 1;
phone.value = null;
password.value = null;
address.value = null;
......
......@@ -344,6 +344,11 @@ export default {
cancel: 'Đóng',
},
validateMessages: {
codeExists: 'Mã khách hàng đã tồn tại',
userNameExists: 'Tên đăng nhập đã tồn tại',
taxCodeExists: 'Mã số thuế đã tồn tại',
emailExists: 'Email đã tồn tại',
phoneExists: 'Số điện thoại đã tồn tại',
requireUserName: 'Vui lòng nhập Tên đăng nhập',
requirePassword: 'Vui lòng nhập Mật khẩu',
requireCode: 'Vui lòng nhập Mã khách hàng',
......
......@@ -109,7 +109,7 @@ export default defineComponent({
sortable: false,
},
];
const userTableRowsCustomer: Ref<unknown[]> = ref([]);
const userTableRowsCustomer: Ref<CustomerType[]> = ref([]);
const showDialog = ref(false);
const showDialogUpdate = ref(false);
const pageIndex = ref(1);
......
......@@ -129,6 +129,7 @@
<AddNewCustomerDialogComponent
v-model:show-dialog="showDialog"
:level-options="levelOptions"
:list-customers="userTableRowsCustomer"
@click:CloseBtn="showDialog = false"
@addNewCustomer="addCustomer"
></AddNewCustomerDialogComponent>
......
......@@ -158,6 +158,7 @@ export default defineComponent({
params: {
pageIndex: pageIndex.value,
pageSize: pageSize.value,
name: fullNameKeyword.value,
qualification: fieldSelected.value?.id,
artistLevel: professionSelected.value?.id,
field: artistLevelSelected.value?.id,
......
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