โครงสร้าง สร้างคำสั่ง
This commit is contained in:
parent
5d9131d5b7
commit
97a62de026
5 changed files with 150 additions and 104 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
import { nextTick, ref, watch, computed } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
|
|
@ -31,9 +31,13 @@ const {
|
|||
} = mixin;
|
||||
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const isOfficer = defineModel<boolean>("isOfficer");
|
||||
const isStaff = defineModel<boolean>("isStaff");
|
||||
const rootId = defineModel<string>("rootId");
|
||||
|
||||
const props = defineProps({
|
||||
commandTypeCode: String, // ไอดีประเภทคำสั่ง
|
||||
orgPublishDate: { type: Date, defult: undefined },
|
||||
orgPublishDate: { type: Date || undefined, defult: undefined },
|
||||
});
|
||||
|
||||
const commandOp = ref<ListCommand[]>([]); // ประเภทคำสั่ง
|
||||
|
|
@ -42,49 +46,36 @@ const commandNo = ref<string>(""); //คำสั่งเลขที่
|
|||
const commandYear = ref<number>(new Date().getFullYear());
|
||||
const commandAffectDate = ref<Date | null>(null); //วันที่ลงนาม
|
||||
const commandExcecuteDate = ref<Date | null>(null); //วันที่คำสั่งมีผล
|
||||
const group = ref<string>(
|
||||
"กลุ่มที่ 1.1 : ปฏิบัติงาน ชำนาญงาน ปฏิบัติการ ชำนาญการ"
|
||||
); //กลุ่ม
|
||||
|
||||
const group = ref<string>("GROUP1"); //กลุ่ม
|
||||
const isCheckOrgPublishDate = ref<boolean>(false); //เช็คค่าของวันที่คำสั่งมีผล
|
||||
const groupOp = ref<DataOption[]>([]);
|
||||
const groupDataOp = ref<DataOption[]>([
|
||||
{
|
||||
id: "1.1",
|
||||
id: "GROUP1",
|
||||
name: "กลุ่มที่ 1.1 : ปฏิบัติงาน ชำนาญงาน ปฏิบัติการ ชำนาญการ",
|
||||
},
|
||||
{
|
||||
id: "1.2",
|
||||
id: "GROUP1.2",
|
||||
name: "กลุ่มที่ 1.2 : อาวุโส ชำนาญการพิเศษ อำนวยการต้น",
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
id: "GROUP2",
|
||||
name: "กลุ่มที่ 2 : ทักษะพิเศษ เชี่ยวชาญ ทรงคุณวุฒิ อำนวยการสูง บริหารต้น บริหารสูง",
|
||||
},
|
||||
]);
|
||||
|
||||
const groupOp = ref<DataOption[]>(groupDataOp.value);
|
||||
const dataMapToSend = computed(() => {
|
||||
return selected.value.map((i: any) => ({
|
||||
refId: i.id,
|
||||
profileId: i.profileId,
|
||||
prefix: i.prefix,
|
||||
firstName: i.firstName,
|
||||
lastName: i.lastName,
|
||||
citizenId: i.citizenId,
|
||||
}));
|
||||
});
|
||||
//Table
|
||||
const rows = ref<any[]>([
|
||||
{
|
||||
id: "1",
|
||||
posMasterNo: "สกก.3",
|
||||
positionName: "นักจัดการงานทั่วไป",
|
||||
posTypeName: "ทั่วไป",
|
||||
posLevelName: "ปฏิบัติงาน",
|
||||
positionIsSelected: "นายศรัณย์ ศิลาดี",
|
||||
group: "1.1",
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
id: "4",
|
||||
posMasterNo: "สกก.4",
|
||||
positionName: "นักจัดการงานทั่วไป",
|
||||
posTypeName: "วิชาการ",
|
||||
posLevelName: "ปฏิบัติการ",
|
||||
positionIsSelected: "นางเกษมณี ใจดี",
|
||||
group: "1.1",
|
||||
selected: true,
|
||||
},
|
||||
]);
|
||||
const rows = ref<any[]>([]);
|
||||
const selected = ref<any[]>([]);
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
|
|
@ -106,20 +97,20 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posTypeName",
|
||||
name: "posType",
|
||||
align: "left",
|
||||
label: "ประเภทตำแหน่ง",
|
||||
sortable: false,
|
||||
field: "posTypeName",
|
||||
field: "posType",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posLevelName",
|
||||
name: "posLevel",
|
||||
align: "left",
|
||||
label: "ระดับตำแหน่ง",
|
||||
sortable: false,
|
||||
field: "posLevelName",
|
||||
field: "posLevel",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
|
|
@ -137,28 +128,28 @@ const columns = ref<QTableProps["columns"]>([
|
|||
/** ฟังก์ชันบันทึกและไปยังหน้าคำสั่ง*/
|
||||
function onSubmit() {
|
||||
dialogConfirm($q, async () => {
|
||||
// showLoader();
|
||||
// const body = {
|
||||
// commandYear: commandYear.value,
|
||||
// commandNo: commandNo.value,
|
||||
// commandTypeId: commandType.value,
|
||||
// commandAffectDate: commandAffectDate.value,
|
||||
// commandExcecuteDate: commandExcecuteDate.value,
|
||||
// persons: [],
|
||||
// };
|
||||
// await http
|
||||
// .post(config.API.command + `/person`, body)
|
||||
// .then(async (res) => {
|
||||
// const id = await res.data.result;
|
||||
// router.push(`/command/edit/${id}`);
|
||||
// modal.value = false;
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
showLoader();
|
||||
const body = {
|
||||
commandTypeId: commandType.value,
|
||||
commandAffectDate: commandAffectDate.value,
|
||||
commandExcecuteDate: commandExcecuteDate.value,
|
||||
commandYear: commandYear.value,
|
||||
commandNo: commandNo.value,
|
||||
persons: selected.value ? dataMapToSend.value : [],
|
||||
};
|
||||
await http
|
||||
.post(config.API.command + `/person`, body)
|
||||
.then(async (res) => {
|
||||
const id = await res.data.result;
|
||||
router.push(`/command/edit/${id}`);
|
||||
modal.value = false;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -172,10 +163,10 @@ function closeModal() {
|
|||
commandYear.value = new Date().getFullYear();
|
||||
commandAffectDate.value = null;
|
||||
commandExcecuteDate.value = null;
|
||||
group.value = "กลุ่มที่ 1.1 : ปฏิบัติงาน ชำนาญงาน ปฏิบัติการ ชำนาญการ";
|
||||
group.value = "GROUP1";
|
||||
isCheckOrgPublishDate.value = false;
|
||||
// rows.value = [];
|
||||
// selected.value = [];
|
||||
rows.value = [];
|
||||
selected.value = [];
|
||||
}
|
||||
|
||||
/** ฟังก์ชันดึงข้อมูลคำสั่ง */
|
||||
|
|
@ -207,50 +198,47 @@ function filterOption(val: string, update: Function) {
|
|||
* ฟังก์ชันเลือกกลุ่ม
|
||||
* @param val กลุ่มที่ต้องการค้นหา
|
||||
*/
|
||||
function updateGroup(val: string) {
|
||||
const data = [
|
||||
{
|
||||
id: "1",
|
||||
posMasterNo: "สกก.3",
|
||||
positionName: "นักจัดการงานทั่วไป",
|
||||
posTypeName: "ทั่วไป",
|
||||
posLevelName: "ปฏิบัติงาน",
|
||||
positionIsSelected: "นายศรัณย์ ศิลาดี",
|
||||
group: "1.1",
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
posMasterNo: "สกก.2",
|
||||
positionName: "นักทรัพยากรบุคคล",
|
||||
posTypeName: "วิชาการ",
|
||||
posLevelName: "ชำนาญการพิเศษ",
|
||||
positionIsSelected: "นางสาวพรทิพย์ กาญจนา",
|
||||
group: "1.2",
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
posMasterNo: "สกก.1",
|
||||
positionName: "นักบริหาร",
|
||||
posTypeName: "บริหาร",
|
||||
posLevelName: "สูง",
|
||||
positionIsSelected: "นางสาวพรทิพย์ กาญจนา",
|
||||
group: "2",
|
||||
selected: true,
|
||||
},
|
||||
];
|
||||
|
||||
rows.value = data.filter((e: any) => e.group === val);
|
||||
function updateGroup() {
|
||||
getPerson();
|
||||
}
|
||||
|
||||
watch(modal, () => {
|
||||
/** ดึงข้อมูลคน */
|
||||
function getPerson() {
|
||||
const body = {
|
||||
rootId: rootId.value ? rootId.value : "",
|
||||
type: group.value,
|
||||
};
|
||||
|
||||
showLoader();
|
||||
http
|
||||
.post(config.API.orgPosReport, body)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
rows.value = data;
|
||||
hideLoader();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
hideLoader();
|
||||
})
|
||||
.finally(() => {});
|
||||
}
|
||||
|
||||
watch(modal, async () => {
|
||||
if (modal.value) {
|
||||
fetchCommandType();
|
||||
if (props.orgPublishDate) {
|
||||
commandExcecuteDate.value = props.orgPublishDate;
|
||||
isCheckOrgPublishDate.value = true;
|
||||
}
|
||||
await nextTick();
|
||||
if (isOfficer.value) {
|
||||
group.value = "GROUP1.2";
|
||||
groupDataOp.value = groupDataOp.value.filter(
|
||||
(item) => item.id !== "GROUP1"
|
||||
);
|
||||
}
|
||||
getPerson();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -444,11 +432,10 @@ watch(modal, () => {
|
|||
option-value="id"
|
||||
class="inputgreen"
|
||||
dense
|
||||
:readonly="isStaff"
|
||||
emit-value
|
||||
map-options
|
||||
lazy-rules
|
||||
use-input
|
||||
hide-bottom-space
|
||||
outlined
|
||||
@update:model-value="updateGroup"
|
||||
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
|
||||
|
|
@ -493,7 +480,7 @@ watch(modal, () => {
|
|||
keep-color
|
||||
color="primary"
|
||||
dense
|
||||
v-model="props.row.selected"
|
||||
v-model="props.selected"
|
||||
/>
|
||||
</q-td>
|
||||
|
||||
|
|
@ -518,6 +505,13 @@ watch(modal, () => {
|
|||
: "-"
|
||||
}}
|
||||
</div>
|
||||
<div v-else-if="col.name === 'positionIsSelected'">
|
||||
{{
|
||||
props.row.firstName
|
||||
? `${props.row.prefix}${props.row.firstName} ${props.row.lastName}`
|
||||
: "-"
|
||||
}}
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
|
|
@ -548,7 +542,7 @@ watch(modal, () => {
|
|||
label="ส่งไปออกคำสั่ง"
|
||||
:disable="
|
||||
commandType == '' ||
|
||||
rows.filter((x) => x.selected).length === 0 ||
|
||||
selected.length === 0 ||
|
||||
!commandNo ||
|
||||
!commandYear
|
||||
"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue