create customer page

parent db1fd0e0
...@@ -51,4 +51,8 @@ export enum API_PATHS { ...@@ -51,4 +51,8 @@ export enum API_PATHS {
getDetailUnit = 'artistOwner/detail', getDetailUnit = 'artistOwner/detail',
updateUnit = 'artistOwner/update', updateUnit = 'artistOwner/update',
addArtist = 'artist/add', addArtist = 'artist/add',
listCustomers = 'customer',
listCustomerLevel = 'customerLevel',
addCustomer = 'customer/add',
deleteCustomer = 'customer/delete',
} }
...@@ -216,3 +216,28 @@ export type DetailUnit = { ...@@ -216,3 +216,28 @@ export type DetailUnit = {
fields: Array<FieldType>; fields: Array<FieldType>;
contracts: Array<Contract>; contracts: Array<Contract>;
}; };
export type CustomerType = {
id: number;
code: string;
userName: string;
fullName: string;
companyName: string;
taxCode: string;
email: string;
status: number;
phone: string;
password: string;
address: string;
type: string;
representative: string;
position: string;
level: string;
};
export type CustomerLevelType = {
id: number;
name: string;
description: string;
level: number;
status: number;
};
import { defineComponent } from 'vue'; 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';
export default defineComponent({ export default defineComponent({
props: { props: {
...@@ -9,27 +10,84 @@ export default defineComponent({ ...@@ -9,27 +10,84 @@ export default defineComponent({
type: Boolean, type: Boolean,
required: true, required: true,
}, },
ratingsOptions: {type: Array, required: true}, levelOptions: {
businessTypeOptions: {type: Array, required: true}, type: Array as PropType<CustomerLevelType[]>,
userName: { type: String, required: true }, required: true,
customerName: { type: String, required: true }, },
businessName: { type: String, required: true },
taxCode: { type: Number, required: true },
email: { type: String, required: true },
ratings: { type: String, required: true },
address: { type: String, required: true },
businessType: { type: String, required: true },
representative: { type: String, required: true },
position: { type: String, required: true },
phone: { type: String, required: true },
status: { type: Boolean, required: true },
}, },
setup() { setup(props, context) {
watch(
() => props.showDialog,
(value) => {
if (value) {
void resetData();
}
}
);
const code: Ref<string | null> = ref(null);
const userName: Ref<string | null> = ref(null);
const fullName: Ref<string | null> = ref(null);
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 phone: Ref<string | null> = ref(null);
const password: Ref<string | null> = ref(null);
const address: Ref<string | null> = ref(null);
const type: Ref<string | null> = ref(null);
const representative: Ref<string | null> = ref(null);
const position: Ref<string | null> = ref(null);
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,
});
};
const resetData = () => {
code.value = null;
userName.value = null;
fullName.value = null;
companyName.value = null;
taxCode.value = null;
email.value = null;
status.value = 2;
phone.value = null;
password.value = null;
address.value = null;
type.value = null;
representative.value = null;
position.value = null;
level.value = null;
};
const userNameRules = [ const userNameRules = [
(val?: string) => (val?: string) =>
(val && val.trim().length) || (val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requireUserName'), i18n.global.t('customer.validateMessages.requireUserName'),
]; ];
const passwordRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requirePassword'),
];
const codeRules = [
(val?: string) =>
(val && val.trim().length) ||
i18n.global.t('customer.validateMessages.requireCode'),
];
const customerNameRules = [ const customerNameRules = [
(val?: string) => (val?: string) =>
(val && val.trim().length) || (val && val.trim().length) ||
...@@ -89,6 +147,8 @@ export default defineComponent({ ...@@ -89,6 +147,8 @@ export default defineComponent({
userNameRules, userNameRules,
customerNameRules, customerNameRules,
businessNameRules, businessNameRules,
passwordRules,
codeRules,
taxCodeRules, taxCodeRules,
emailRules, emailRules,
ratingsRules, ratingsRules,
...@@ -97,23 +157,22 @@ export default defineComponent({ ...@@ -97,23 +157,22 @@ export default defineComponent({
representativeRules, representativeRules,
positionRules, positionRules,
phoneRules, phoneRules,
userName,
fullName,
companyName,
taxCode,
email,
status,
phone,
password,
address,
type,
representative,
position,
level,
code,
confirmAddCustomer,
}; };
}, },
emits: [ emits: ['update:showDialog', 'click:CloseBtn', 'addNewCustomer'],
'update:showDialog',
'click:CloseBtn',
'update:userName',
'update:customerName',
'update:businessName',
'update:taxCode',
'update:email',
'update:ratings',
'update:address',
'update:businessType',
'update:representative',
'update:position',
'update:phone',
'update:status',
'addNewCustomer',
],
}); });
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
@update:model-value="$emit('update:showDialog', $event)" @update:model-value="$emit('update:showDialog', $event)"
> >
<q-card style="min-width: 900px" bordered> <q-card style="min-width: 900px" bordered>
<q-form greedy @submit.prevent="$emit('addNewCustomer')"> <q-form greedy @submit.prevent="confirmAddCustomer">
<q-card-section> <q-card-section>
<q-item> <q-item>
<q-item-section> <q-item-section>
...@@ -21,94 +21,82 @@ ...@@ -21,94 +21,82 @@
<div class="row q-col-gutter-sm"> <div class="row q-col-gutter-sm">
<div class="col-6"> <div class="col-6">
<q-input <q-input
:model-value="userName" v-model="userName"
@update:model-value="$emit('update:userName', $event)"
:label="$t('customer.dialogLabel.fieldLabels.userName')" :label="$t('customer.dialogLabel.fieldLabels.userName')"
:rules="userNameRules" :rules="userNameRules"
hide-bottom-space hide-bottom-space
type="text" type="text"
class="q-my-sm" class="q-my-sm"
outlined outlined
clearable
></q-input> ></q-input>
<q-input <q-input
:model-value="customerName" v-model="password"
@update:model-value="$emit('update:customerName', $event)" :label="$t('customer.dialogLabel.fieldLabels.password')"
:rules="passwordRules"
hide-bottom-space
type="password"
class="q-my-sm"
outlined
></q-input>
<q-input
v-model="code"
:label="$t('customer.dialogLabel.fieldLabels.code')"
:rules="codeRules"
hide-bottom-space
type="text"
class="q-my-sm"
outlined
></q-input>
<q-input
v-model="fullName"
:label="$t('customer.dialogLabel.fieldLabels.customerName')" :label="$t('customer.dialogLabel.fieldLabels.customerName')"
type="text" type="text"
class="q-my-sm" class="q-my-sm"
outlined outlined
:rules="customerNameRules" :rules="customerNameRules"
hide-bottom-space hide-bottom-space
clearable
></q-input> ></q-input>
<q-input <q-input
:model-value="businessName" v-model="companyName"
@update:model-value="$emit('update:businessName', $event)"
:label="$t('customer.dialogLabel.fieldLabels.businessName')" :label="$t('customer.dialogLabel.fieldLabels.businessName')"
type="text" type="text"
class="q-my-sm" class="q-my-sm"
outlined outlined
:rules="businessNameRules" :rules="businessNameRules"
hide-bottom-space hide-bottom-space
clearable
></q-input> ></q-input>
<q-input <q-input
:model-value="taxCode" v-model="taxCode"
@update:model-value="$emit('update:taxCode', $event)"
:label="$t('customer.dialogLabel.fieldLabels.taxCode')" :label="$t('customer.dialogLabel.fieldLabels.taxCode')"
type="number" type="number"
class="q-my-sm" class="q-my-sm"
outlined outlined
:rules="taxCodeRules" :rules="taxCodeRules"
hide-bottom-space hide-bottom-space
clearable
></q-input> ></q-input>
<q-input <q-input
:model-value="email" v-model="address"
@update:model-value="$emit('update:email', $event)" :label="$t('customer.dialogLabel.fieldLabels.address')"
:label="$t('customer.dialogLabel.fieldLabels.email')"
type="text" type="text"
class="q-my-sm" class="q-my-sm"
:rules="addressRules"
outlined outlined
:rules="emailRules"
hide-bottom-space hide-bottom-space
clearable
></q-input> ></q-input>
<q-select
:model-value="ratings"
@update:model-value="$emit('update:ratings', $event)"
:label="$t('customer.dialogLabel.fieldLabels.ratings')"
:options="ratingsOptions"
:rules="ratingsRules"
emit-value
map-options
option-value="id"
option-label="text"
type="text"
class="q-my-sm"
outlined
hide-bottom-space
clearable
></q-select>
</div> </div>
<div class="col-6"> <div class="col-6">
<q-input <q-input
:model-value="address" v-model="email"
@update:model-value="$emit('update:address', $event)" :label="$t('customer.dialogLabel.fieldLabels.email')"
:label="$t('customer.dialogLabel.fieldLabels.address')"
type="text" type="text"
class="q-my-sm" class="q-my-sm"
:rules="addressRules"
outlined outlined
:rules="emailRules"
hide-bottom-space hide-bottom-space
clearable
></q-input> ></q-input>
<q-select <q-input
:model-value="businessType" v-model="type"
@update:model-value="$emit('update:businessType', $event)"
:label="$t('customer.dialogLabel.fieldLabels.businessType')" :label="$t('customer.dialogLabel.fieldLabels.businessType')"
:options="businessTypeOptions"
:rules="businessTypeRules" :rules="businessTypeRules"
emit-value emit-value
map-options map-options
...@@ -117,52 +105,54 @@ ...@@ -117,52 +105,54 @@
class="q-my-sm" class="q-my-sm"
outlined outlined
hide-bottom-space hide-bottom-space
></q-input>
<q-select
v-model="level"
:label="$t('customer.dialogLabel.fieldLabels.ratings')"
:options="levelOptions"
:rules="ratingsRules"
map-options
option-value="id"
option-label="name"
type="text"
class="q-my-sm"
outlined
clearable clearable
hide-bottom-space
></q-select> ></q-select>
<q-input <q-input
:model-value="representative" v-model="representative"
emit-value
@update:model-value="$emit('update:representative', $event)"
:label="$t('customer.dialogLabel.fieldLabels.representative')" :label="$t('customer.dialogLabel.fieldLabels.representative')"
class="q-my-sm" class="q-my-sm"
type="text" type="text"
outlined outlined
:rules="representativeRules" :rules="representativeRules"
hide-bottom-space hide-bottom-space
clearable
></q-input> ></q-input>
<q-input <q-input
:model-value="position" v-model="position"
emit-value
@update:model-value="$emit('update:position', $event)"
:label="$t('customer.dialogLabel.fieldLabels.position')" :label="$t('customer.dialogLabel.fieldLabels.position')"
class="q-my-sm" class="q-my-sm"
type="text" type="text"
outlined outlined
:rules="positionRules" :rules="positionRules"
hide-bottom-space hide-bottom-space
clearable
></q-input> ></q-input>
<q-input <q-input
:model-value="phone" v-model="phone"
emit-value
@update:model-value="$emit('update:phone', $event)"
:label="$t('customer.dialogLabel.fieldLabels.phone')" :label="$t('customer.dialogLabel.fieldLabels.phone')"
class="q-my-sm" class="q-my-sm"
type="number" type="number"
:rules="phoneRules" :rules="phoneRules"
outlined outlined
hide-bottom-space hide-bottom-space
clearable
></q-input> ></q-input>
<div style="padding-top: 13px; padding-left: 12px"> <div style="padding-top: 13px; padding-left: 12px">
<span class="text-body1">{{ <span class="text-body1">{{
$t('customer.dialogLabel.fieldLabels.status') $t('customer.dialogLabel.fieldLabels.status')
}}</span }}</span
><q-toggle ><q-toggle :true-value="1" :false-value="2" v-model="status" />
:model-value="status"
@update:model-value="$emit('update:status', $event)"
/>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -317,6 +317,8 @@ export default { ...@@ -317,6 +317,8 @@ export default {
fieldLabels: { fieldLabels: {
userName: 'Tên đăng nhập *', userName: 'Tên đăng nhập *',
customerName: 'Họ tên *', customerName: 'Họ tên *',
password: 'Mật khẩu *',
code: 'Mã khách hàng *',
businessName: 'Tên doanh nghiệp *', businessName: 'Tên doanh nghiệp *',
taxCode: 'Mã số thuế *', taxCode: 'Mã số thuế *',
email: 'Email *', email: 'Email *',
...@@ -332,6 +334,7 @@ export default { ...@@ -332,6 +334,7 @@ export default {
toolTipMessage: { toolTipMessage: {
updateCustomerInfo: 'Cập nhật', updateCustomerInfo: 'Cập nhật',
informationCustomer: 'Thông tin', informationCustomer: 'Thông tin',
deleteCustomer: 'Xoá',
}, },
crudActions: { crudActions: {
save: 'Lưu', save: 'Lưu',
...@@ -339,6 +342,8 @@ export default { ...@@ -339,6 +342,8 @@ export default {
}, },
validateMessages: { validateMessages: {
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',
requireCode: 'Vui lòng nhập Mã khách hàng',
requireCustomerName: 'Vui lòng nhập Họ tên', requireCustomerName: 'Vui lòng nhập Họ tên',
requireBusinessName: 'Vui lòng nhập Tên Doanh nghiệp', requireBusinessName: 'Vui lòng nhập Tên Doanh nghiệp',
requireTaxCode: 'Vui lòng nhập Mã số thuế', requireTaxCode: 'Vui lòng nhập Mã số thuế',
...@@ -355,13 +360,13 @@ export default { ...@@ -355,13 +360,13 @@ export default {
confirmActionsTitle: { confirmActionsTitle: {
confirmDeleteUserTitle: 'Xác nhận', confirmDeleteUserTitle: 'Xác nhận',
confirmDeleteUserCancelBtnLabel: 'Huỷ', confirmDeleteUserCancelBtnLabel: 'Huỷ',
confirmDeleteUserContent: 'Bạn có chắc muốn xoá tài khoản', confirmDeleteUserContent: 'Bạn có chắc muốn xoá khách hàng này không ?',
confirmResetPasswordContent: confirmResetPasswordContent:
'Bạn có muốn reset mật khẩu của người dùng này không', 'Bạn có muốn reset mật khẩu của người dùng này không ?',
}, },
actionMessages: { actionMessages: {
addNewUserAccess: 'Thêm tài khoản thành công', addNewUserAccess: 'Thêm tài khoản thành công',
deleteUserAccess: 'Xoá tài khoản thành công', deleteUserAccess: 'Xoá khách hàng thành công',
updateUserAccess: 'Cập nhật thông tin tài khoản thành công', updateUserAccess: 'Cập nhật thông tin tài khoản thành công',
resetPasswordAccess: 'Reset mật khẩu thành công', resetPasswordAccess: 'Reset mật khẩu thành công',
}, },
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<q-space></q-space> <q-space></q-space>
<div class="col-2"> <div class="col-2">
<q-input <q-input
v-model="businessName" v-model="companyNameSelected"
dense dense
outlined outlined
:label="$t('customer.tableColumnsCustomer.businessName')" :label="$t('customer.tableColumnsCustomer.businessName')"
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</div> </div>
<div class="col-2"> <div class="col-2">
<q-input <q-input
v-model="taxCode" v-model="taxCodeSelected"
dense dense
outlined outlined
:label="$t('customer.tableColumnsCustomer.taxCode')" :label="$t('customer.tableColumnsCustomer.taxCode')"
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
</div> </div>
<div class="col-2" dense outlined> <div class="col-2" dense outlined>
<q-select <q-select
v-model="ratings" v-model="levelSelected"
:options="ratingsOptions" :options="levelOptions"
option-label="text" option-label="name"
option-value="id" option-value="id"
dense dense
outlined outlined
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
no-caps no-caps
:label="$t('crudActions.search')" :label="$t('crudActions.search')"
style="width: 100px" style="width: 100px"
@click="filterListCustomer" @click="getListCustomers"
> >
</q-btn> </q-btn>
</div> </div>
...@@ -65,13 +65,15 @@ ...@@ -65,13 +65,15 @@
separator="cell" separator="cell"
hide-pagination hide-pagination
> >
<template v-slot:body-cell-stt="item">
<q-td style="padding: 0; height: 100%">
<div align="center">
{{ item.rowIndex + 1 }}
</div>
</q-td>
</template>
<template v-slot:body-cell-action="rowData"> <template v-slot:body-cell-action="rowData">
<q-td style="padding: 0" class="flex flex-center"> <q-td style="padding: 0" class="flex flex-center">
<q-btn flat round color="primary" icon="mdi-information-outline">
<q-tooltip :offset="[20, 10]">{{
$t('customer.toolTipMessage.informationCustomer')
}}</q-tooltip>
</q-btn>
<q-btn <q-btn
flat flat
round round
...@@ -83,18 +85,29 @@ ...@@ -83,18 +85,29 @@
$t('customer.toolTipMessage.updateCustomerInfo') $t('customer.toolTipMessage.updateCustomerInfo')
}}</q-tooltip> }}</q-tooltip>
</q-btn> </q-btn>
<q-btn
flat
round
color="primary"
icon="mdi-delete-outline"
@click="confirmDeleteCustomer(rowData.row.id)"
>
<q-tooltip :offset="[20, 10]">{{
$t('customer.toolTipMessage.deleteCustomer')
}}</q-tooltip>
</q-btn>
</q-td> </q-td>
</template> </template>
<template v-slot:body-cell-status="rowData"> <template v-slot:body-cell-status="rowData">
<q-td> <q-td>
<div align="center"> <div align="center">
<q-chip <q-chip
:color="rowData.value ? 'positive' : 'orange'" :color="rowData.value === 1 ? 'positive' : 'orange'"
text-color="white" text-color="white"
size="sm" size="sm"
> >
{{ {{
rowData.value rowData.value === 1
? $t('customer.statusLabel.active') ? $t('customer.statusLabel.active')
: $t('customer.statusLabel.inactive') : $t('customer.statusLabel.inactive')
}} }}
...@@ -109,30 +122,17 @@ ...@@ -109,30 +122,17 @@
v-model:pageSize="pageSize" v-model:pageSize="pageSize"
:totalPage="totalPage" :totalPage="totalPage"
@update:pageSize="changePageSize" @update:pageSize="changePageSize"
@update:currentPage="getListCustomer" @update:currentPage="getListCustomers"
/> />
<AddNewCustomerDialogComponent <AddNewCustomerDialogComponent
v-model:show-dialog="showDialog" v-model:show-dialog="showDialog"
v-model:user-name="userName" :level-options="levelOptions"
v-model:customer-name="customerName"
v-model:business-name="businessName"
v-model:tax-code="taxCode"
v-model:email="email"
v-model:ratings="ratings"
v-model:address="address"
v-model:business-type="businessType"
v-model:representative="representative"
v-model:position="position"
v-model:phone="phone"
v-model:status="status"
:ratings-options="ratingsOptions"
:business-type-options="businessTypeOptions"
@click:CloseBtn="showDialog = false" @click:CloseBtn="showDialog = false"
@addNewCustomer="addNewCustomer" @addNewCustomer="addCustomer"
></AddNewCustomerDialogComponent> ></AddNewCustomerDialogComponent>
<UpdateNewCustomerDialogComponent <!-- <UpdateNewCustomerDialogComponent
v-model:show-dialog-update="showDialogUpdate" v-model:show-dialog-update="showDialogUpdate"
v-model:user-name="userName" v-model:user-name="userName"
v-model:customer-name="customerName" v-model:customer-name="customerName"
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
:business-type-options="businessTypeOptions" :business-type-options="businessTypeOptions"
@click:CloseBtn="showDialogUpdate = false" @click:CloseBtn="showDialogUpdate = false"
@updateNewCustomer="updateCustomer" @updateNewCustomer="updateCustomer"
></UpdateNewCustomerDialogComponent> ></UpdateNewCustomerDialogComponent> -->
</div> </div>
</div> </div>
</div> </div>
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
flat flat
round round
color="primary" color="primary"
icon="mdi-delete" icon="mdi-delete-outline"
@click="confirmDeleteArtist(item.row.id)" @click="confirmDeleteArtist(item.row.id)"
> >
<q-tooltip :offset="[20, 10]">{{ <q-tooltip :offset="[20, 10]">{{
......
...@@ -368,7 +368,8 @@ export default defineComponent({ ...@@ -368,7 +368,8 @@ export default defineComponent({
avatar: avatar.value, avatar: avatar.value,
artistCode: artistCode.value, artistCode: artistCode.value,
artistName: artistName.value, artistName: artistName.value,
birthday: birthday.value, // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
birthday: birthday.value + '00:00:00',
sex: sex.value, sex: sex.value,
address: address.value, address: address.value,
phoneNumber: phoneNumber.value, phoneNumber: phoneNumber.value,
......
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