update

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