update

parent 218c6c4b
...@@ -69,6 +69,17 @@ const formatMoney = (str: { amount: string }) => { ...@@ -69,6 +69,17 @@ const formatMoney = (str: { amount: string }) => {
} }
}; };
const formatMoneyv2 = (str: { amount: string }) => {
try {
return str == null || str.amount == null
? ''
: str.amount
.toString()
.replace(/\D/g, '')
.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
} catch (e) {}
};
const isNullOrEmpty = (str: any) => { const isNullOrEmpty = (str: any) => {
return ( return (
str === null || str === null ||
...@@ -86,4 +97,5 @@ export { ...@@ -86,4 +97,5 @@ export {
isHasVietnamese, isHasVietnamese,
formatMoney, formatMoney,
isNullOrEmpty, isNullOrEmpty,
formatMoneyv2,
}; };
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
hide-bottom-space hide-bottom-space
dense dense
:rules="errorMoney" :rules="errorMoney"
@update:model-value="(value) => checkValuePrice(value)"
label="Số tiền *" label="Số tiền *"
/> />
</div> </div>
...@@ -61,6 +62,7 @@ import { Dialog, Notify } from 'quasar'; ...@@ -61,6 +62,7 @@ import { Dialog, Notify } from 'quasar';
import { API_PATHS, config } from 'src/assets/configurations.example'; import { API_PATHS, config } from 'src/assets/configurations.example';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import { api, BaseResponseBody } from 'src/boot/axios'; import { api, BaseResponseBody } from 'src/boot/axios';
import { formatMoneyv2, formatMoney } from 'src/boot/functions';
import { ListBooking } from 'src/assets/type'; import { ListBooking } from 'src/assets/type';
export default defineComponent({ export default defineComponent({
...@@ -77,7 +79,7 @@ export default defineComponent({ ...@@ -77,7 +79,7 @@ export default defineComponent({
setup(props, context) { setup(props, context) {
const content: Ref<string | null> = ref(null); const content: Ref<string | null> = ref(null);
const money: Ref<string | null> = ref(null); const money: Ref<string | undefined> = ref(undefined);
const errorMoney = [ const errorMoney = [
(val?: string) => (val && val.trim().length) || 'Vui lòng nhập số tiền', (val?: string) => (val && val.trim().length) || 'Vui lòng nhập số tiền',
...@@ -91,8 +93,7 @@ export default defineComponent({ ...@@ -91,8 +93,7 @@ export default defineComponent({
(value) => { (value) => {
if (value) { if (value) {
content.value = null; content.value = null;
money.value = null; money.value = undefined;
} }
} }
); );
...@@ -106,7 +107,7 @@ export default defineComponent({ ...@@ -106,7 +107,7 @@ export default defineComponent({
artistBooking: { artistBooking: {
id: props.data.id, id: props.data.id,
}, },
fee: money.value, fee: money.value?.replace(/,/g, ''),
reason: content.value, reason: content.value,
}, },
})) as AxiosResponse<BaseResponseBody<unknown>>; })) as AxiosResponse<BaseResponseBody<unknown>>;
...@@ -126,10 +127,16 @@ export default defineComponent({ ...@@ -126,10 +127,16 @@ export default defineComponent({
context.emit('toggle'); context.emit('toggle');
}; };
const checkValuePrice = (value: string) => {
money.value = formatMoneyv2({ amount: value });
};
return { return {
// //
closeDialog, closeDialog,
confirmAdd, confirmAdd,
checkValuePrice,
// formatNumber,
// //
money, money,
errorMoney, errorMoney,
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<template v-slot:body-cell-artistName="item"> <template v-slot:body-cell-artistName="item">
<td style="text-align: center"> <td style="text-align: center">
<div>{{ item.row.artistBooking.artistName }}</div> <div>{{ item.row.artistBooking.artistName }}</div>
<div>SĐT: {{ item.row.artistBooking.artistName }}</div> <div>SĐT: {{ item.row.artistBooking.phoneArtist }}</div>
</td> </td>
</template> </template>
<template v-slot:body-cell-bookingRandomCode="item"> <template v-slot:body-cell-bookingRandomCode="item">
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
dense dense
type="text" type="text"
label="Số tiền" label="Số tiền"
@update:model-value="(value) => checkValuePrice(value)"
/> />
</div> </div>
...@@ -211,7 +212,7 @@ import { Dialog, Notify } from 'quasar'; ...@@ -211,7 +212,7 @@ import { Dialog, Notify } from 'quasar';
import { API_PATHS, config } from 'src/assets/configurations.example'; import { API_PATHS, config } from 'src/assets/configurations.example';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import { api, BaseResponseBody } from 'src/boot/axios'; import { api, BaseResponseBody } from 'src/boot/axios';
import { formatMoneyv2 } from 'src/boot/functions';
import { ListBooking } from 'src/assets/type'; import { ListBooking } from 'src/assets/type';
export default defineComponent({ export default defineComponent({
props: { props: {
...@@ -231,7 +232,7 @@ export default defineComponent({ ...@@ -231,7 +232,7 @@ export default defineComponent({
const contractTimeFrom: Ref<string | null> = ref(null); const contractTimeFrom: Ref<string | null> = ref(null);
const contractTimeTo: Ref<string | null> = ref(null); const contractTimeTo: Ref<string | null> = ref(null);
const email: Ref<string | null> = ref(null); const email: Ref<string | null> = ref(null);
const money: Ref<string | null> = ref(null); const money: Ref<string | undefined> = ref(undefined);
const location: Ref<string | null> = ref(null); const location: Ref<string | null> = ref(null);
watch( watch(
...@@ -249,7 +250,7 @@ export default defineComponent({ ...@@ -249,7 +250,7 @@ export default defineComponent({
contractTimeFrom.value = props.data.fromTime; contractTimeFrom.value = props.data.fromTime;
contractTimeTo.value = props.data.toTime; contractTimeTo.value = props.data.toTime;
email.value = props.data.customerDto.email; email.value = props.data.customerDto.email;
money.value = props.data.expectFee; money.value = formatMoneyv2({ amount: props.data.expectFee });
location.value = props.data.address; location.value = props.data.address;
}; };
...@@ -263,7 +264,7 @@ export default defineComponent({ ...@@ -263,7 +264,7 @@ export default defineComponent({
status: 1, status: 1,
address: location.value, address: location.value,
content: content.value, content: content.value,
expectFee: money.value, expectFee: money.value?.replace(/,/g, ''),
fromTime: contractTimeFrom.value, fromTime: contractTimeFrom.value,
toTime: contractTimeTo.value, toTime: contractTimeTo.value,
email: email.value, email: email.value,
...@@ -294,10 +295,14 @@ export default defineComponent({ ...@@ -294,10 +295,14 @@ export default defineComponent({
// (val?: string) => (val && val.trim().length) || 'Vui lòng nhập nội dung', // (val?: string) => (val && val.trim().length) || 'Vui lòng nhập nội dung',
// ]; // ];
const checkValuePrice = (value: string) => {
money.value = formatMoneyv2({ amount: value });
};
return { return {
// //
closeDialog, closeDialog,
confirmAdd, confirmAdd,
checkValuePrice,
// //
money, money,
content, content,
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
dense dense
type="text" type="text"
:rules="errorMoney" :rules="errorMoney"
@update:model-value="(value) => checkValuePrice(value)"
label="Số tiền *" label="Số tiền *"
/> />
</div> </div>
...@@ -62,7 +63,7 @@ import { Dialog, Notify } from 'quasar'; ...@@ -62,7 +63,7 @@ import { Dialog, Notify } from 'quasar';
import { API_PATHS, config } from 'src/assets/configurations.example'; import { API_PATHS, config } from 'src/assets/configurations.example';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import { api, BaseResponseBody } from 'src/boot/axios'; import { api, BaseResponseBody } from 'src/boot/axios';
import { formatMoneyv2 } from 'src/boot/functions';
import { ListBooking, ListFinedAmount } from 'src/assets/type'; import { ListBooking, ListFinedAmount } from 'src/assets/type';
export default defineComponent({ export default defineComponent({
props: { props: {
...@@ -82,14 +83,14 @@ export default defineComponent({ ...@@ -82,14 +83,14 @@ export default defineComponent({
setup(props, context) { setup(props, context) {
const content: Ref<string | null> = ref(null); const content: Ref<string | null> = ref(null);
const money: Ref<string | null> = ref(null); const money: Ref<string | undefined> = ref(undefined);
watch( watch(
() => props.open, () => props.open,
(value) => { (value) => {
if (value) { if (value) {
content.value = props.dataItem.reason; content.value = props.dataItem.reason;
money.value = props.dataItem.fee; money.value = formatMoneyv2({ amount: props.dataItem.fee });
} }
} }
); );
...@@ -104,7 +105,7 @@ export default defineComponent({ ...@@ -104,7 +105,7 @@ export default defineComponent({
artistBooking: { artistBooking: {
id: props.data.id, id: props.data.id,
}, },
fee: money.value, fee: money.value?.replace(/,/g, ''),
reason: content.value, reason: content.value,
}, },
})) as AxiosResponse<BaseResponseBody<unknown>>; })) as AxiosResponse<BaseResponseBody<unknown>>;
...@@ -123,6 +124,9 @@ export default defineComponent({ ...@@ -123,6 +124,9 @@ export default defineComponent({
const closeDialog = () => { const closeDialog = () => {
context.emit('toggle'); context.emit('toggle');
}; };
const checkValuePrice = (value: string) => {
money.value = formatMoneyv2({ amount: value });
};
// const errorMoney = [ // const errorMoney = [
// (val?: string) => (val && val.trim().length) || 'Vui lòng nhập số tiền', // (val?: string) => (val && val.trim().length) || 'Vui lòng nhập số tiền',
...@@ -136,6 +140,7 @@ export default defineComponent({ ...@@ -136,6 +140,7 @@ export default defineComponent({
// //
closeDialog, closeDialog,
confirmAdd, confirmAdd,
checkValuePrice,
// //
money, money,
content, content,
......
...@@ -10,7 +10,7 @@ export const MenuItemScript = defineComponent({ ...@@ -10,7 +10,7 @@ export const MenuItemScript = defineComponent({
}, },
}, },
setup(props) { setup(props) {
console.log(props.item,'props');
const $route = useRoute(); const $route = useRoute();
const isActive = computed(() => { const isActive = computed(() => {
return ( return (
......
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