ui การลา
This commit is contained in:
parent
acbec63df7
commit
333515f570
7 changed files with 79 additions and 56 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import type { DataOption } from "@/modules/09_leave/interface/index/Main"
|
||||
const mixin = useCounterMixin();
|
||||
const { date2Thai } = mixin;
|
||||
export const useWorklistDataStore = defineStore("work", () => {
|
||||
|
|
@ -21,6 +22,7 @@ export const useWorklistDataStore = defineStore("work", () => {
|
|||
status: convertSatatus(e.status)
|
||||
}))
|
||||
dataMain.value = datalist
|
||||
fetchOption()
|
||||
searchDataFn(selectDate.value, selectStatus.value)
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +30,8 @@ export const useWorklistDataStore = defineStore("work", () => {
|
|||
const filterTable = ref<string>('')
|
||||
const selectDate = ref<Date | null>(null);
|
||||
const selectStatus = ref<String>('all')
|
||||
const optionStatus = ref<any[]>([{ id: "all", name: 'ทั้งหมด' }, { id: "1", name: 'ลงเวลาเรียบร้อย' }, { id: "2", name: 'สายทำงานครบ' }])
|
||||
const optionStatusMain = ref<DataOption[]>([])
|
||||
const optionStatus = ref<DataOption[]>([])
|
||||
function searchDataFn(searchDate: any, srarchStatus: any) {
|
||||
srarchStatus = srarchStatus || "all";
|
||||
if (searchDate == null && srarchStatus == "all") {
|
||||
|
|
@ -37,6 +40,38 @@ export const useWorklistDataStore = defineStore("work", () => {
|
|||
rows.value = dataMain.value.filter((e: any) => e.status === convertSatatus(srarchStatus))
|
||||
}
|
||||
}
|
||||
//
|
||||
function fetchOption() {
|
||||
const double_status = [
|
||||
...new Set(dataMain.value.map((item: any) => item.status)),
|
||||
];
|
||||
optionStatusMain.value = [{ id: "all", name: "ทั้งหมด" }];
|
||||
for (let i = 1; i <= double_status.length; i++) {
|
||||
const status = double_status[i - 1];
|
||||
if (typeof status === 'string') {
|
||||
const listtype: DataOption = {
|
||||
id: status,
|
||||
name: status,
|
||||
};
|
||||
optionStatusMain.value.push(listtype)
|
||||
optionStatus.value = optionStatusMain.value
|
||||
}
|
||||
}
|
||||
}
|
||||
function filterFn(val: string, update: any) {
|
||||
if (val == "") {
|
||||
update(() => {
|
||||
optionStatus.value = optionStatusMain.value;
|
||||
});
|
||||
} else {
|
||||
update(() => {
|
||||
optionStatus.value = optionStatusMain.value.filter(
|
||||
(e: any) => e.name.search(val) !== -1
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// convertSatatus
|
||||
function convertSatatus(val: string) {
|
||||
switch (val) {
|
||||
|
|
@ -58,6 +93,7 @@ export const useWorklistDataStore = defineStore("work", () => {
|
|||
selectStatus,
|
||||
optionStatus,
|
||||
searchDataFn,
|
||||
filterFn,
|
||||
convertSatatus
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue