โครงสร้าง สร้างคำสั่ง

This commit is contained in:
setthawutttty 2024-10-18 12:58:18 +07:00
parent 5d9131d5b7
commit 97a62de026
5 changed files with 150 additions and 104 deletions

View file

@ -102,6 +102,9 @@ const orgId = ref<string>("");
*/
function updateSelected(data: DataTree) {
orgRootId.value = data?.orgLevel === 0 ? data?.orgTreeId : data?.orgRootId;
store.rootId = (
data.orgLevel === 0 ? data.orgTreeId : data.orgRootId
) as string;
shortName.value = data.orgTreeShortName;
if (!store.treeId || store.treeId != data.orgTreeId) {

View file

@ -12,6 +12,10 @@ export const useOrganizational = defineStore("organizationalStore", () => {
const typeOrganizational = ref<string>("current"); // ประเภทโครงสร้าง
const statusView = ref<string>("list"); // การแสดงผล รายการ,map
const rootId = ref<string>('')
const isOfficer = ref<boolean|null>(null);
const isStaff = ref<boolean|null>(null);
const dataActive = ref<DataActive>(); //ข้อมูลโครงสร้าง
const activeId = ref<string>(); // id โครงสร้างปัจจุบัน
const draftId = ref<string>(); // id แบบร่างโครงสร้าง
@ -160,5 +164,8 @@ export const useOrganizational = defineStore("organizationalStore", () => {
fetchPosMaster,
sumPosition,
getSumPosition,
isOfficer,
isStaff,
rootId
};
});

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { ref, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
@ -30,6 +30,7 @@ import DialogCreateCommandORG from "@/modules/18_command/components/DialogCreate
const $q = useQuasar();
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
const store = useOrganizational();
const keycloakSystem = ref<string>("ORG_COMMAND");
/** ตัวแปร*/
const modalNewStructure = ref<boolean>(false); //
@ -126,6 +127,38 @@ function onClickHistory(id: string, name: string) {
count.value++;
}
async function workflowSystem() {
showLoader();
http
.get(config.API.workflowKeycloakSystem(keycloakSystem.value))
.then((res) => {
const data = res.data.result;
store.isOfficer = data.isOfficer;
store.isStaff = data.isStaff;
hideLoader();
})
.catch((e) => {
messageError($q, e);
hideLoader();
})
.finally(() => {});
}
watch(
() => store.typeOrganizational,
() => {
if (
store.typeOrganizational === "draft" &&
store.isOfficer === null &&
store.isStaff === null
) {
workflowSystem();
} else if (store.typeOrganizational === "draft") {
store.rootId = "";
}
}
);
/**
* lifecycleHook ทำงานเมอมการเรยกใช Components
*
@ -276,10 +309,14 @@ onMounted(async () => {
class="q-px-md"
/>
<q-btn
v-if="store.typeOrganizational === 'draft'"
v-if="
store.typeOrganizational === 'draft' &&
(store.isOfficer === true || store.isStaff === true)
"
flat
round
dense
:disable="store.isStaff == true && store.rootId == ''"
color="add"
icon="mdi-account-arrow-right"
@click.prevent="modalCommand = true"
@ -380,7 +417,10 @@ onMounted(async () => {
<DialogCreateCommandORG
v-model:modal="modalCommand"
command-type-code="C-PM-38"
:org-publish-date="store.orgPublishDate as Date | undefined"
:org-publish-date="store.orgPublishDate as Date||undefined"
v-model:is-officer="store.isOfficer as boolean"
v-model:is-staff="store.isStaff as boolean"
v-model:root-id="store.rootId"
/>
</template>