refactor: show file in peview quotation
This commit is contained in:
parent
d3bd7b986e
commit
b7f7a984b2
1 changed files with 42 additions and 6 deletions
|
|
@ -13,6 +13,7 @@ import useBranchStore from 'stores/branch';
|
||||||
import { baseUrl } from 'stores/utils';
|
import { baseUrl } from 'stores/utils';
|
||||||
import useCustomerStore from 'stores/customer';
|
import useCustomerStore from 'stores/customer';
|
||||||
import { commaInput } from 'stores/utils';
|
import { commaInput } from 'stores/utils';
|
||||||
|
import { useQuotationStore } from 'src/stores/quotations';
|
||||||
|
|
||||||
// NOTE Import Types
|
// NOTE Import Types
|
||||||
import { CustomerBranch } from 'stores/customer/types';
|
import { CustomerBranch } from 'stores/customer/types';
|
||||||
|
|
@ -35,7 +36,7 @@ const optionStore = useOptionStore();
|
||||||
const configStore = useConfigStore();
|
const configStore = useConfigStore();
|
||||||
const branchStore = useBranchStore();
|
const branchStore = useBranchStore();
|
||||||
const customerStore = useCustomerStore();
|
const customerStore = useCustomerStore();
|
||||||
|
const quotationStore = useQuotationStore();
|
||||||
const { data: config } = storeToRefs(configStore);
|
const { data: config } = storeToRefs(configStore);
|
||||||
|
|
||||||
type Product = {
|
type Product = {
|
||||||
|
|
@ -64,8 +65,15 @@ const bankList = ref<BankBook[]>([]);
|
||||||
|
|
||||||
const elements = ref<HTMLElement[]>([]);
|
const elements = ref<HTMLElement[]>([]);
|
||||||
const chunks = ref<Product[][]>([[]]);
|
const chunks = ref<Product[][]>([[]]);
|
||||||
|
const attachmentList = ref<
|
||||||
|
{
|
||||||
|
name: string;
|
||||||
|
typeFile: string;
|
||||||
|
url: string;
|
||||||
|
}[]
|
||||||
|
>([]);
|
||||||
const data = ref<
|
const data = ref<
|
||||||
QuotationPayload & { customerBranch: CustomerBranchRelation }
|
QuotationPayload & { customerBranch: CustomerBranchRelation; id: string }
|
||||||
>();
|
>();
|
||||||
|
|
||||||
const summaryPrice = ref<SummaryPrice>({
|
const summaryPrice = ref<SummaryPrice>({
|
||||||
|
|
@ -76,6 +84,25 @@ const summaryPrice = ref<SummaryPrice>({
|
||||||
finalPrice: 0,
|
finalPrice: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function getAttachment(quotationId: string) {
|
||||||
|
const attachment = await quotationStore.listAttachment({
|
||||||
|
parentId: quotationId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (attachment) {
|
||||||
|
attachment.forEach(async (v) => {
|
||||||
|
attachmentList.value.push({
|
||||||
|
name: v,
|
||||||
|
typeFile: v.substring(v.lastIndexOf('.') + 1),
|
||||||
|
url: await quotationStore.getAttachment({
|
||||||
|
parentId: quotationId,
|
||||||
|
name: v,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function assignData() {
|
async function assignData() {
|
||||||
for (let i = 0; i < productList.value.length; i++) {
|
for (let i = 0; i < productList.value.length; i++) {
|
||||||
let el = elements.value.at(-1);
|
let el = elements.value.at(-1);
|
||||||
|
|
@ -148,6 +175,8 @@ onMounted(async () => {
|
||||||
data.value = 'data' in parsed ? parsed.data : undefined;
|
data.value = 'data' in parsed ? parsed.data : undefined;
|
||||||
|
|
||||||
if (data.value) {
|
if (data.value) {
|
||||||
|
await getAttachment(data.value.id);
|
||||||
|
|
||||||
const resCustomerBranch = await customerStore.getBranchById(
|
const resCustomerBranch = await customerStore.getBranchById(
|
||||||
data.value.customerBranchId,
|
data.value.customerBranchId,
|
||||||
);
|
);
|
||||||
|
|
@ -236,9 +265,7 @@ onMounted(async () => {
|
||||||
assignData();
|
assignData();
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(elements, () => {
|
watch(elements, () => {});
|
||||||
console.log(elements.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
function print() {
|
function print() {
|
||||||
window.print();
|
window.print();
|
||||||
|
|
@ -502,6 +529,13 @@ function print() {
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section
|
||||||
|
v-for="v in attachmentList.filter((v) => v.typeFile !== 'pdf')"
|
||||||
|
class="content"
|
||||||
|
>
|
||||||
|
<q-img :src="v.url" />
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -532,6 +566,7 @@ function print() {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
background: white;
|
background: white;
|
||||||
border-bottom: 1px solid var(--gray-3);
|
border-bottom: 1px solid var(--gray-3);
|
||||||
|
z-index: 99999;
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
|
|
@ -576,7 +611,8 @@ td {
|
||||||
font-size: 95%;
|
font-size: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content,
|
||||||
|
.container > :deep(.content) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.5in;
|
padding: 0.5in;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue