feat:add item publish isorgType === 'draft'
This commit is contained in:
parent
8af6a4253c
commit
b1cdb4eef4
3 changed files with 69 additions and 6 deletions
|
|
@ -198,4 +198,8 @@ export default {
|
||||||
orgIssues: `${organization}/issues`,
|
orgIssues: `${organization}/issues`,
|
||||||
// active รักษาการในตำแหน่งตามหน่วยงาน
|
// active รักษาการในตำแหน่งตามหน่วยงาน
|
||||||
activeActPosition: (id: string) => `${orgPosAct}/${id}`,
|
activeActPosition: (id: string) => `${orgPosAct}/${id}`,
|
||||||
|
|
||||||
|
//เผยแพร่จากร่างเป็นปัจจุบัน
|
||||||
|
moveDraftToCurrent: (rootDndId: string) =>
|
||||||
|
`${organization}/move-draft-to-current/${rootDndId}`,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch, computed } from "vue";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import { checkPermission } from "@/utils/permissions";
|
import { checkPermission } from "@/utils/permissions";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
/** importType*/
|
/** importType*/
|
||||||
import type { ListMenu } from "@/modules/02_organization/interface/index/Main";
|
import type { ListMenu } from "@/modules/02_organization/interface/index/Main";
|
||||||
|
|
@ -23,8 +24,15 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
/** use*/
|
/** use*/
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const store = useOrganizational();
|
const store = useOrganizational();
|
||||||
const { dialogRemove, showLoader, hideLoader, messageError, success } =
|
const route = useRoute();
|
||||||
useCounterMixin();
|
const {
|
||||||
|
dialogRemove,
|
||||||
|
showLoader,
|
||||||
|
hideLoader,
|
||||||
|
messageError,
|
||||||
|
success,
|
||||||
|
dialogConfirm,
|
||||||
|
} = useCounterMixin();
|
||||||
|
|
||||||
/** props*/
|
/** props*/
|
||||||
const nodeTEST = defineModel<OrgTree[]>("nodeTree", { default: [] });
|
const nodeTEST = defineModel<OrgTree[]>("nodeTree", { default: [] });
|
||||||
|
|
@ -84,8 +92,30 @@ const listAdd = ref<ListMenu[]>([
|
||||||
type: "DETAIL",
|
type: "DETAIL",
|
||||||
color: "blue-9",
|
color: "blue-9",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "เผยแพร่",
|
||||||
|
icon: "mdi-publish",
|
||||||
|
type: "PUBLISH",
|
||||||
|
color: "indigo-9",
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const getMenuItems = computed(() => {
|
||||||
|
return (orgLevel: number) => {
|
||||||
|
const isOwner = checkPermission(route)?.attrOwnership === "OWNER";
|
||||||
|
const isLevel4 = orgLevel === 4;
|
||||||
|
const isRoot = orgLevel === 0;
|
||||||
|
|
||||||
|
if (isRoot && isOwner) {
|
||||||
|
return listAdd.value;
|
||||||
|
} else if (isLevel4) {
|
||||||
|
return listAdd.value.slice(1, 6);
|
||||||
|
} else {
|
||||||
|
return listAdd.value.slice(0, 6);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const filter = ref<string>("");
|
const filter = ref<string>("");
|
||||||
const nodes = ref<Array<OrgTree>>([]);
|
const nodes = ref<Array<OrgTree>>([]);
|
||||||
const dataSort = ref<Array<any>>([]);
|
const dataSort = ref<Array<any>>([]);
|
||||||
|
|
@ -372,6 +402,33 @@ function onClickHistory(level: number, id: string) {
|
||||||
modalHistory.value = true;
|
modalHistory.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันเผยแพร่โครงสร้างจากร่างเป็นปัจจุบันตามหน่วยงาน
|
||||||
|
* @param data ข้อมูลโครงสร้าง
|
||||||
|
*/
|
||||||
|
function onPublicOrganization(data: OrgTree) {
|
||||||
|
const orgName = data.orgName; // ชื่อองค์กร
|
||||||
|
const orgDnaId = data.orgDnaId; // ID ของโครงสร้างร่างที่ต้องการเผยแพร่
|
||||||
|
|
||||||
|
dialogConfirm(
|
||||||
|
$q,
|
||||||
|
async () => {
|
||||||
|
showLoader();
|
||||||
|
try {
|
||||||
|
await http.post(config.API.moveDraftToCurrent(orgDnaId));
|
||||||
|
await props.fetchDataTree?.();
|
||||||
|
await success($q, "เผยแพร่โครงสร้างสำเร็จ");
|
||||||
|
} catch (err) {
|
||||||
|
messageError($q, err);
|
||||||
|
} finally {
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ยืนยันการเผยแพร่โครงสร้างและอัตรากำลัง",
|
||||||
|
`คุณต้องการเผยแพร่โครงสร้างและอัตรากำลังของ${orgName} ใช่หรือไม่?`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => nodeTEST.value,
|
() => nodeTEST.value,
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -488,9 +545,7 @@ watch(
|
||||||
<q-menu>
|
<q-menu>
|
||||||
<q-list
|
<q-list
|
||||||
dense
|
dense
|
||||||
v-for="(item, index) in prop.node.orgLevel === 4
|
v-for="(item, index) in getMenuItems(prop.node.orgLevel)"
|
||||||
? listAdd.slice(1, 6)
|
|
||||||
: listAdd"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
style="min-width: 100px"
|
style="min-width: 100px"
|
||||||
>
|
>
|
||||||
|
|
@ -520,6 +575,8 @@ watch(
|
||||||
prop.node.orgLevel,
|
prop.node.orgLevel,
|
||||||
prop.node.orgTreeId
|
prop.node.orgTreeId
|
||||||
)
|
)
|
||||||
|
: item.type === 'PUBLISH'
|
||||||
|
? onPublicOrganization(prop.node)
|
||||||
: null
|
: null
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ interface OrgTree {
|
||||||
orgRevisionId: string;
|
orgRevisionId: string;
|
||||||
isOfficer: boolean;
|
isOfficer: boolean;
|
||||||
children: OrgTree[];
|
children: OrgTree[];
|
||||||
|
orgName: string;
|
||||||
|
orgDnaId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OrgRevision {
|
interface OrgRevision {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue