darta create page

This commit is contained in:
prabidhi 2025-12-18 10:00:04 +05:45
parent fef301045e
commit 6d0f32f68f

View File

@ -1,109 +1,197 @@
<template> <template>
<Towser <Towser
:show="show" :show="dartaTowserStore.show"
:title="towser.title" :title="towser.title"
:actions="towser.action" :actions="towser.action"
:width="800"
@onClose="onClose" @onClose="onClose"
@onSave="onSave" @onSave="onSave"
> >
<div class="p-6"> <div class="flex flex-col gap-[5px]">
<form @submit.prevent="submitForm"> <!-- Document Details Section -->
<div class="mb-8"> <div class="mb-[10px]">
<h2 class="text-lg font-semibold text-gray-700 mb-4">Document Details</h2> <!-- <h3 class="text-lg font-semibold">Document Details</h3> -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-[5px]">
<div class="flex flex-col"> <div class="flex flex-col">
<label class="block text-sm font-medium text-gray-700 mb-2">Department <span class="text-red-500">*</span></label> <label for="document_number">
<Multiselect Document Number
v-model="formData.department" <span class="text-red-500">*</span>
:options="departments" </label>
:multiple="false" <input
:searchable="true" id="document_number"
:allow-empty="false" v-model="payload.document_number"
label="name" type="text"
track-by="id" placeholder="Enter Document Number"
placeholder="Select Department" @input="errors && errors.document_number && delete errors.document_number"
/> required
</div> />
<div class="flex flex-col">
<label class="block text-sm font-medium text-gray-700 mb-2">Category <span class="text-red-500">*</span></label>
<Multiselect
v-model="formData.documentCategory"
:options="documentCategories"
:multiple="false"
:searchable="true"
:allow-empty="false"
label="name"
track-by="id"
placeholder="Select Category"
/>
</div>
</div> </div>
<div class="flex flex-col">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-6"> <label for="document_type">
<div class="flex flex-col"> Document Type
<label class="block text-sm font-medium text-gray-700 mb-2">Document Number <span class="text-red-500">*</span></label> <span class="text-red-500">*</span>
<input v-model="formData.documentNumber" type="text" placeholder="Enter document number" class="form-input" required /> </label>
</div> <Multiselect
<div class="flex flex-col"> ref="document_type"
<label class="block text-sm font-medium text-gray-700 mb-2">Subject <span class="text-red-500">*</span></label> v-model="selectedItems.document_type"
<input v-model="formData.subject" type="text" placeholder="Enter document subject" class="form-input" required /> :options="documentTypeStore.itemList"
</div> track-by="id"
placeholder="Select Document Type"
label="title"
:show-labels="false"
@select="errors && errors.document_type && delete errors.document_type"
class="bg-gray-800"
required
/>
</div> </div>
<div class="flex flex-col">
<div class="mt-6"> <label for="document_category">
<label class="block text-sm font-medium text-gray-700 mb-2">Document Body <span class="text-red-500">*</span></label> Document Category
<textarea v-model="formData.body" placeholder="Enter document body" class="w-full" rows="5"></textarea> <span class="text-red-500">*</span>
</label>
<Multiselect
ref="document_category"
v-model="selectedItems.document_category"
:options="documentCategoryStore.itemList"
track-by="id"
placeholder="Select Document Category"
label="title"
:show-labels="false"
@select="errors && errors.document_category && delete errors.document_category"
class="bg-gray-800"
required
/>
</div>
<div class="flex flex-col">
<label for="department">
Department
<span class="text-red-500">*</span>
</label>
<Multiselect
ref="department"
v-model="selectedItems.department"
:options="departmentStore.itemList"
track-by="id"
placeholder="Select Department"
label="name"
:show-labels="false"
@select="errors && errors.department && delete errors.department"
/>
</div>
<div class="flex flex-col">
<label for="date">Received Date</label>
<DateSelector id="date" v-model="payload.date" :classValue="`w-full`" />
</div> </div>
</div> </div>
</div>
<div class="mb-8"> <!-- Document Information Section -->
<h2 class="text-lg font-semibold text-gray-700 mb-4">Recipient Information</h2> <div class="mb-[10px]">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <!-- <h3 class="text-lg font-semibold">Document Information</h3> -->
<div class="flex flex-col"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-[5px]">
<label class="block text-sm font-medium text-gray-700 mb-2">Recipient Name</label> <div class="flex flex-col">
<input v-model="formData.recipientName" type="text" class="form-input" /> <label for="issued_date">Issued Date</label>
</div> <DateSelector id="issued_date" v-model="payload.issued_date" :classValue="`w-full`" />
<div class="flex flex-col"> </div>
<label class="block text-sm font-medium text-gray-700 mb-2">Recipient Contact</label>
<input v-model="formData.recipientContact" type="tel" class="form-input" /> <div class="flex flex-col">
</div> <label for="sender_name">
<div class="flex flex-col md:col-span-2"> Sender Name
<label class="block text-sm font-medium text-gray-700 mb-2">Recipient Address</label> <span class="text-red-500">*</span>
<input v-model="formData.recipientAddress" type="text" class="form-input" /> </label>
</div> <input
id="sender_name"
v-model="payload.sender_name"
type="text"
placeholder="Enter Sender Name"
@input="errors && errors.sender_name && delete errors.sender_name"
required
/>
</div>
<div class="flex flex-col">
<label for="sender_address">
Sender Address
<span class="text-red-500">*</span>
</label>
<input
id="sender_address"
v-model="payload.sender_address"
type="text"
placeholder="Enter Sender Address"
@input="errors && errors.sender_address && delete errors.sender_address"
required
/>
</div>
<div class="flex flex-col">
<label for="sender_contact">
Sender Contact
<span class="text-red-500">*</span>
</label>
<input
id="sender_contact"
v-model="payload.sender_contact"
type="text"
placeholder="Enter Sender Contact"
@input="errors && errors.sender_contact && delete errors.sender_contact"
required
/>
</div> </div>
</div> </div>
</div>
<div class="mb-8"> <!-- Subject Section -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="mb-[10px]">
<div class="flex flex-col"> <!-- <h3 class="text-lg font-semibold">Subject</h3> -->
<label class="block text-sm font-medium text-gray-700 mb-2">Issued Date</label> <div class="grid grid-cols-3 gap-[5px]">
<input v-model="formData.issuedDate" type="date" class="form-input" /> <div class="flex flex-col">
</div> <label for="subject">
<div class="flex flex-col"> Subject
<label class="block text-sm font-medium text-gray-700 mb-2">Dispatch Date</label> <span class="text-red-500">*</span>
<input v-model="formData.dispatchDate" type="date" class="form-input" /> </label>
</div> <input
id="subject"
v-model="payload.subject"
type="text"
placeholder="Enter subject of the letter"
@input="errors && errors.subject && delete errors.subject"
required
/>
</div> </div>
</div> </div>
</div>
<div class="mb-8"> <!--Attachment Section-->
<h2 class="text-lg font-semibold text-gray-700 mb-4">Attachments</h2> <div class="grid grid-cols-3">
<div class="border-2 border-dashed p-6 text-center cursor-pointer hover:bg-gray-50" @click="triggerFileInput"> <div>
<input type="file" multiple @change="handleFileUpload" class="hidden" ref="fileInputRef" accept=".pdf,.doc,.docx,.xls,.xlsx,.jpg,.png" /> <div>Attachments</div>
<p class="text-gray-600 text-sm mb-2">Click to upload or drag and drop</p> <div
class="border-2 border-dashed p-6 text-center cursor-pointer hover:bg-gray-50"
@click="triggerFileInput"
>
<input
type="file"
multiple
@change="handleFileUpload"
class="hidden"
ref="fileInputRef"
accept=".pdf,.doc,.docx,.xls,.xlsx,.jpg,.png"
/>
<p class="text-gray-600 text-sm mb-2">Click to upload</p>
<div v-if="formData.attachments.length > 0" class="mt-4 text-left"> <div v-if="formData.attachments.length > 0" class="mt-4 text-left">
<ul class="space-y-2"> <ul class="space-y-2">
<li v-for="(file, index) in formData.attachments" :key="index" class="flex justify-between items-center bg-gray-100 p-2 rounded"> <li
v-for="(file, index) in formData.attachments"
:key="index"
class="flex justify-between items-center bg-gray-100 p-2 rounded"
>
<span class="text-sm truncate">{{ file.name }}</span> <span class="text-sm truncate">{{ file.name }}</span>
<button type="button" @click.stop="removeFile(index)" class="text-red-500 text-xs">Remove</button> <button type="button" @click.stop="removeFile(index)" class="text-red-500 text-xs">
Remove
</button>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
</form> </div>
</div> </div>
</Towser> </Towser>
</template> </template>
@ -111,17 +199,19 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive } from "vue"; import { ref, reactive } from "vue";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { createGenericStore } from "@/stores/GenericStore";
import { createOverlayStore } from "@/stores/OverlayStore"; import { createOverlayStore } from "@/stores/OverlayStore";
import Multiselect from "vue-multiselect";
const DartaTowserStore = createOverlayStore("darta-towser")(); const dartaStore = createGenericStore("darta")();
const { show } = storeToRefs(DartaTowserStore); const dartaTowserStore = createOverlayStore("darta-towser")();
const { payload, selectedItems, errors } = storeToRefs(dartaStore);
const documentCategoryStore = createGenericStore("document-category")();
const documentTypeStore = createGenericStore("document-type")();
const departmentStore = createGenericStore("department")();
const emit = defineEmits(["onSave"]);
const towser = ref({ const towser = ref({
title: [ title: [{ name: "Darta", link: "#" }, { name: "Create" }],
{ name: "Darta", link: "#" },
{ name: "Create" }
],
action: [ action: [
{ {
title: "Close", title: "Close",
@ -132,35 +222,38 @@ const towser = ref({
emit: "onSave", emit: "onSave",
}, },
], ],
}) });
const departments = ref([{ id: 1, name: 'Administration' }, { id: 2, name: 'HR' }]); const departments = ref([
const documentCategories = ref([{ id: 1, name: 'Confidential' }, { id: 2, name: 'Public' }]); { id: 1, name: "Administration" },
{ id: 2, name: "HR" },
]);
const documentCategories = ref([
{ id: 1, name: "Confidential" },
{ id: 2, name: "Public" },
]);
const formData = reactive({ const formData = reactive({
department: null, department: null,
documentCategory: null, documentCategory: null,
documentNumber: '', documentNumber: "",
subject: '', subject: "",
body: '', body: "",
recipientName: '', recipientName: "",
recipientContact: '', recipientContact: "",
recipientAddress: '', recipientAddress: "",
issuedDate: '', issuedDate: "",
dispatchDate: '', dispatchDate: "",
attachments: [] as File[] attachments: [] as File[],
}); });
const fileInputRef = ref<HTMLInputElement | null>(null); const fileInputRef = ref<HTMLInputElement | null>(null);
const onClose = () => { const onClose = () => {
DartaTowserStore.close(); dartaTowserStore.close();
resetForm();
}; };
const onSave = () => { const onSave = async () => {};
submitForm();
};
const triggerFileInput = () => { const triggerFileInput = () => {
fileInputRef.value?.click(); fileInputRef.value?.click();
@ -177,14 +270,4 @@ const removeFile = (index: number) => {
formData.attachments.splice(index, 1); formData.attachments.splice(index, 1);
}; };
const resetForm = () => { </script>
formData.documentNumber = '';
formData.subject = '';
formData.attachments = [];
};
const submitForm = async () => {
console.log("Submitting:", formData);
onClose();
};
</script>