ปรับแสดงการเผยแพร่โครงสร้าง

This commit is contained in:
Warunee Tamkoo 2024-02-01 14:32:59 +07:00
parent 039d4081d6
commit 76cd4e170b
4 changed files with 38 additions and 22 deletions

View file

@ -11,6 +11,11 @@ import config from "@/app.config";
const props = defineProps({
modal: Boolean,
close: Function,
fetchActive: {
type: Function,
require: true,
default: () => "Function fetchActive",
},
});
const store = useOrganizational();
@ -67,6 +72,7 @@ function onSubmit() {
})
.then((res) => {
props.close?.();
props.fetchActive();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
@ -82,7 +88,7 @@ watch(
() => props.modal,
() => {
if (props.modal === true) {
dateTime.value = null;
dateTime.value = store.orgPublishDate ? store.orgPublishDate : null;
}
}
);

View file

@ -3,6 +3,8 @@ interface DataActive {
activeName: string;
draftId: string;
draftName: string;
isPublic: boolean,
orgPublishDate: Date | null,
}
interface OrgTree {

View file

@ -18,12 +18,14 @@ export const useOrganizational = defineStore("organizationalStore", () => {
const treeId = ref<string>();
const level = ref<number>();
const isPublic = ref<boolean>(false);
const orgPublishDate = ref<Date>();
const orgPublishDate = ref<Date | null>(null);
function fetchDataActive(data: DataActive) {
activeId.value = data.activeId;
draftId.value = data.draftId;
dataActive.value = data;
isPublic.value = data.isPublic;
orgPublishDate.value = data.orgPublishDate;
}
function fetchPosMaster(data: PosMaster[]) {

View file

@ -20,12 +20,12 @@ import { useOrganizational } from "@/modules/02_organizationalNew/store/organiza
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
const { showLoader, hideLoader, messageError } = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
const modalNewStructure = ref<boolean>(false);
const modalPositionDetail = ref<boolean>(false);
const stroe = useOrganizational();
const store = useOrganizational();
const isStatusData = ref<boolean>(false);
const ishasActive = ref<boolean>(false);
@ -56,7 +56,7 @@ async function fetchOrganizationActive() {
.then((res) => {
const data = res.data.result;
if (data) {
stroe.fetchDataActive(data);
store.fetchDataActive(data);
if (data.activeName === null && data.draftName === null) {
isStatusData.value = false;
} else {
@ -64,10 +64,10 @@ async function fetchOrganizationActive() {
if (isStatusData.value) {
if (data.activeName === null) {
ishasActive.value = true;
stroe.typeOrganizational = "draft";
store.typeOrganizational = "draft";
} else if (data.draftName === null) {
ishasDraft.value = true;
stroe.typeOrganizational = "current";
store.typeOrganizational = "current";
}
}
}
@ -88,7 +88,6 @@ async function fetchHistory() {
await http
.get(config.API.organizationHistoryNew)
.then((res) => {
console.log(res);
const data = res.data.result;
const filterData = data.filter(
(e: OrgRevision) => !e.orgRevisionIsDraft && !e.orgRevisionIsCurrent
@ -138,7 +137,14 @@ onMounted(async () => {
<div class="toptitle text-dark row items-center">โครงสรางอตรากำล</div>
<q-space />
<div class="toptitle row" v-if="stroe.typeOrganizational === 'draft'">
<div class="toptitle row" v-if="store.typeOrganizational === 'draft'">
<div
v-if="store.isPublic && store.orgPublishDate"
class="q-pt-sm q-pr-sm text-caption"
>
นทเผยแพร
{{ date2Thai(store.orgPublishDate) }}
</div>
<q-btn
color="indigo-9"
icon="alarm"
@ -192,21 +198,21 @@ onMounted(async () => {
<q-toolbar class="q-gutter-md" style="padding: 0px">
<q-btn-group outline>
<q-btn
:outline="stroe.typeOrganizational === 'current' ? false : true"
:outline="store.typeOrganizational === 'current' ? false : true"
color="blue"
label="ปัจจุบัน"
@click="
(stroe.typeOrganizational = 'current'),
(store.typeOrganizational = 'current'),
(labelHistory = 'ประวัติโครงสร้าง')
"
:disable="ishasActive"
/>
<q-btn
:outline="stroe.typeOrganizational === 'draft' ? false : true"
:outline="store.typeOrganizational === 'draft' ? false : true"
color="blue"
label="แบบร่าง"
@click="
(stroe.typeOrganizational = 'draft'),
(store.typeOrganizational = 'draft'),
(labelHistory = 'ประวัติโครงสร้าง')
"
:disable="ishasDraft"
@ -214,8 +220,8 @@ onMounted(async () => {
<q-btn-dropdown
color="blue"
:label="labelHistory"
@click="stroe.typeOrganizational = 'old'"
:outline="stroe.typeOrganizational === 'old' ? false : true"
@click="store.typeOrganizational = 'old'"
:outline="store.typeOrganizational === 'old' ? false : true"
>
<q-list>
<q-item
@ -258,27 +264,27 @@ onMounted(async () => {
<q-btn
flat
round
:color="stroe.statusView === 'list' ? 'grey-7' : 'grey-4'"
:color="store.statusView === 'list' ? 'grey-7' : 'grey-4'"
icon="list"
@click="stroe.statusView = 'list'"
@click="store.statusView = 'list'"
/>
<q-btn
flat
round
icon="mdi-sitemap"
:color="stroe.statusView === 'tree' ? 'grey-7' : 'grey-4'"
@click="stroe.statusView = 'tree'"
:color="store.statusView === 'tree' ? 'grey-7' : 'grey-4'"
@click="store.statusView = 'tree'"
/>
</q-toolbar>
</q-card-section>
<q-separator />
<q-card-section style="padding: 0px">
<ListView
v-if="stroe.statusView === 'list'"
v-if="store.statusView === 'list'"
v-model:historyId="historyId"
v-model:count="count"
/>
<StructureView v-if="stroe.statusView === 'tree'" />
<StructureView v-if="store.statusView === 'tree'" />
</q-card-section>
</q-card>
</div>
@ -293,7 +299,7 @@ onMounted(async () => {
/>
<!-- งเวลาเผยแพร -->
<DialogDateTime :modal="modalDateTime" :close="onClickDateTime" />
<DialogDateTime :modal="modalDateTime" :close="onClickDateTime" :fetchActive="fetchOrganizationActive"/>
<!-- ประวโครงสราง -->
<!-- <DialogHistory :modal="modalHistory" :close="onClickHistory" /> -->