Skip to content

Commit

Permalink
feat: updated git module
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Jun 21, 2024
1 parent 5f266f6 commit 8db9010
Show file tree
Hide file tree
Showing 43 changed files with 1,453 additions and 1,727 deletions.
4 changes: 2 additions & 2 deletions src/components/button/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const cls = computed<string>(() => {

<template>
<el-tooltip :content="tooltip" :disabled="!tooltip">
<div :id="id" :class="['button-wrapper', cls].join(' ')">
<span :id="id" :class="['button-wrapper', cls].join(' ')">
<el-button
:circle="circle"
:disabled="disabled"
Expand All @@ -49,7 +49,7 @@ const cls = computed<string>(() => {
>
<slot></slot>
</el-button>
</div>
</span>
</el-tooltip>
</template>

Expand Down
40 changes: 16 additions & 24 deletions src/components/empty/Empty.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<script setup lang="ts">
defineOptions({ name: 'ClEmpty' });
import { translate } from '@/utils';
const t = translate;
withDefaults(
defineProps<{
description?: string;
}>(),
{
description: 'components.empty.noDataAvailable',
}
);
</script>

<template>
<div class="empty">
<cl-img-empty />
Expand All @@ -7,30 +23,6 @@
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import ImgEmpty from '@/components/empty/ImgEmpty.vue';
import { useI18n } from 'vue-i18n';
export default defineComponent({
name: 'Empty',
props: {
description: {
type: String,
required: false,
default: 'components.empty.noDataAvailable',
},
},
setup() {
const { t } = useI18n();
return {
t,
};
},
});
</script>

<style lang="scss" scoped>
.empty {
max-height: 240px;
Expand Down
15 changes: 4 additions & 11 deletions src/components/empty/ImgEmpty.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<script setup lang="ts">
defineOptions({ name: 'ClImgEmpty' });
</script>

<template>
<svg
class="img-empty"
Expand Down Expand Up @@ -119,17 +123,6 @@
</svg>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
name: 'ImgEmpty',
setup() {
return {};
},
});
</script>

<style lang="scss" scoped>
.img-empty {
max-width: 100%;
Expand Down
62 changes: 26 additions & 36 deletions src/components/filter/FilterInput.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
<script setup lang="ts">
defineOptions({ name: 'ClFilterInput' });
import { defineComponent, ref } from 'vue';
import { debounce } from 'vue-debounce';
defineProps<{
label?: string;
placeholder?: string;
}>();
const emit = defineEmits<{
(e: 'change', value: any): void;
}>();
const internalModelValue = ref();
const onChange = debounce((value: any) => {
emit('change', value);
}, 500);
const onClear = () => {
internalModelValue.value = undefined;
emit('change', internalModelValue.value);
};
</script>

<template>
<div class="filter-input">
<label v-if="label" class="label">
Expand All @@ -13,40 +39,4 @@
</div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { debounce } from 'vue-debounce';
export default defineComponent({
name: 'FilterInput',
props: {
label: {
type: String,
},
placeholder: {
type: String,
},
},
emits: ['change'],
setup(props: FilterInputProps, { emit }) {
const internalModelValue = ref();
const onChange = debounce((value: any) => {
emit('change', value);
}, 500);
const onClear = () => {
internalModelValue.value = undefined;
emit('change', internalModelValue.value);
};
return {
internalModelValue,
onChange,
onClear,
};
},
});
</script>

<style lang="scss" scoped></style>
122 changes: 51 additions & 71 deletions src/components/filter/FilterSelect.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
<script setup lang="ts">
defineOptions({ name: 'ClFilterSelect' });
import { computed, defineComponent, onBeforeMount, PropType, ref } from 'vue';
import useRequest from '@/services/request';
import { cloneArray, prependAllToSelectOptions } from '@/utils';
const props = defineProps<{
label?: string;
placeholder?: string;
filterable?: boolean;
options?: SelectOption[];
optionsRemote?: FilterSelectOptionsRemote;
}>();
const emit = defineEmits<{
(e: 'change', value: any): void;
}>();
const { get } = useRequest();
const internalModelValue = ref();
const internalOptions = ref<SelectOption[]>([]);
const computedOptions = computed<SelectOption[]>(() => {
const options = cloneArray(props.options || internalOptions.value || []);
return prependAllToSelectOptions(options);
});
const onChange = (value: any) => {
if (value === '') return;
emit('change', value);
};
const onClear = () => {
internalModelValue.value = undefined;
emit('change', undefined);
};
const getOptions = async () => {
if (!props.optionsRemote) return;
const { colName, value, label } = props.optionsRemote;
let url = `/filters/${colName}`;
if (value) url += `/${value}`;
if (label) url += `/${label}`;
const res = await get(url);
internalOptions.value = res.data;
};
onBeforeMount(getOptions);
</script>

<template>
<div class="filter-select">
<label v-if="label" class="label">
Expand All @@ -22,77 +73,6 @@
</div>
</template>

<script lang="ts">
import { computed, defineComponent, onBeforeMount, PropType, ref } from 'vue';
import useRequest from '@/services/request';
import { cloneArray, prependAllToSelectOptions } from '@/utils';
const { get } = useRequest();
export default defineComponent({
name: 'FilterSelect',
props: {
label: {
type: String,
},
placeholder: {
type: String,
},
filterable: {
type: Boolean,
default: true,
},
options: {
type: Array as PropType<SelectOption[]>,
},
optionsRemote: {
type: Object as PropType<FilterSelectOptionsRemote>,
},
},
emits: ['change'],
setup(props: FilterSelectProps, { emit }) {
const internalModelValue = ref();
const internalOptions = ref<SelectOption[]>([]);
const computedOptions = computed<SelectOption[]>(() => {
const options = cloneArray(props.options || internalOptions.value || []);
return prependAllToSelectOptions(options);
});
const onChange = (value: any) => {
if (value === '') return;
emit('change', value);
};
const onClear = () => {
internalModelValue.value = undefined;
emit('change', undefined);
};
const getOptions = async () => {
if (!props.optionsRemote) return;
const { colName, value, label } = props.optionsRemote;
let url = `/filters/${colName}`;
if (value) url += `/${value}`;
if (label) url += `/${label}`;
const res = await get(url);
internalOptions.value = res.data;
};
onBeforeMount(async () => {
await getOptions();
});
return {
internalModelValue,
computedOptions,
onChange,
onClear,
};
},
});
</script>

<style lang="scss" scoped>
.filter-select {
display: flex;
Expand Down
41 changes: 6 additions & 35 deletions src/components/form/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useForm = (

// active dialog key
const activeDialogKey = computed<DialogKey | undefined>(
() => state.activeDialogKey
() => state.activeDialogKey as DialogKey
);

// is selective form
Expand All @@ -56,25 +56,8 @@ export const useForm = (
() => store.getters[`${ns}/isBatchForm`]
);

// form list ids getters
const formListIds = computed<string[]>(
() => store.getters[`${ns}/formListIds`]
);

const validateForm = async () => {
if (isBatchForm.value && activeDialogKey.value === 'create') {
let valid = true;
for (const formRef of formTableFieldRefsMap.value.values()) {
try {
await formRef.value?.validate?.();
} catch (e) {
valid = false;
}
}
return valid;
} else {
return await formRef.value?.validate();
}
return await formRef.value?.validate();
};

const resetForm = () => {
Expand Down Expand Up @@ -157,6 +140,7 @@ export const useForm = (
// validate
try {
const valid = await validateForm();
console.debug('onConfirm', activeDialogKey.value, form.value, valid);
if (!valid) return;
} catch (ex) {
console.error(ex);
Expand All @@ -181,27 +165,14 @@ export const useForm = (
let res: HttpResponse;
switch (activeDialogKey.value) {
case 'create':
if (isBatchForm.value) {
const changedFormList = formList.value.filter(d => !isEmptyForm(d));
res = await createList(changedFormList);
} else {
res = await create(form.value);
}
console.debug('create', form.value);
res = await create(form.value);
sendEvent('click_form_create_confirm', {
ns,
batch: isBatchForm.value,
});
break;
case 'edit':
if (isBatchForm.value) {
res = await updateList(
formListIds.value,
form.value,
selectedFormFields.value
);
} else {
res = await updateById(form.value._id as string, form.value);
}
res = await updateById(form.value._id as string, form.value);
sendEvent('click_form_edit_confirm', {
ns,
batch: isBatchForm.value,
Expand Down
Loading

0 comments on commit 8db9010

Please sign in to comment.