fix(05): node to selected product
This commit is contained in:
parent
ad92671fd6
commit
1c3d4388f0
2 changed files with 46 additions and 6 deletions
|
|
@ -93,7 +93,7 @@ const productServiceCard = ref<{
|
||||||
product: Record<string, any>[];
|
product: Record<string, any>[];
|
||||||
}>();
|
}>();
|
||||||
const splitterModel = ref(0);
|
const splitterModel = ref(0);
|
||||||
const selectedType = ref<'group' | 'type' | 'work' | 'product' | ''>('');
|
const selectedType = ref<'group' | 'service' | 'work' | 'product' | ''>('');
|
||||||
const selectedNode = ref<Node[]>([]);
|
const selectedNode = ref<Node[]>([]);
|
||||||
const selectedItems = ref<Record<string, any>[]>([]);
|
const selectedItems = ref<Record<string, any>[]>([]);
|
||||||
const preSelectedItems = ref<Record<string, any>[]>([]);
|
const preSelectedItems = ref<Record<string, any>[]>([]);
|
||||||
|
|
@ -111,6 +111,7 @@ function triggerInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function triggerAddDialog() {
|
async function triggerAddDialog() {
|
||||||
|
convertToSelected();
|
||||||
pageState.addModal = true;
|
pageState.addModal = true;
|
||||||
await nextTick();
|
await nextTick();
|
||||||
refSelectZone.value?.assignSelect(
|
refSelectZone.value?.assignSelect(
|
||||||
|
|
@ -176,6 +177,23 @@ function toggleMove(node: Node, to?: 'up' | 'down') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convertToSelected() {
|
||||||
|
if (!nodes.value) return;
|
||||||
|
const selected = nodes.value
|
||||||
|
.flatMap((n) => {
|
||||||
|
if (n.type === 'service') {
|
||||||
|
return productServiceCard.value?.service?.filter((c) => c.id === n.id);
|
||||||
|
} else if (n.type === 'product') {
|
||||||
|
return productServiceCard.value?.product?.filter((c) => c.id === n.id);
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter((item) => item !== undefined);
|
||||||
|
|
||||||
|
selectedItems.value = selected;
|
||||||
|
}
|
||||||
|
|
||||||
function mapCard() {
|
function mapCard() {
|
||||||
const data = {
|
const data = {
|
||||||
service:
|
service:
|
||||||
|
|
@ -222,7 +240,7 @@ function mapNode() {
|
||||||
const node = selectedItems.value.map((v) => {
|
const node = selectedItems.value.map((v) => {
|
||||||
if (v.type === 'service') {
|
if (v.type === 'service') {
|
||||||
return {
|
return {
|
||||||
type: 'type',
|
type: 'service',
|
||||||
id: v.id,
|
id: v.id,
|
||||||
title: v.name,
|
title: v.name,
|
||||||
subtitle: v.code,
|
subtitle: v.code,
|
||||||
|
|
@ -292,6 +310,8 @@ function mapNode() {
|
||||||
id: p.product.id,
|
id: p.product.id,
|
||||||
title: p.product.name,
|
title: p.product.name,
|
||||||
subtitle: p.product.code || ' ',
|
subtitle: p.product.code || ' ',
|
||||||
|
detail: p.product.detail,
|
||||||
|
remark: p.product.remark,
|
||||||
checked: true,
|
checked: true,
|
||||||
value: {
|
value: {
|
||||||
workerIndex: [],
|
workerIndex: [],
|
||||||
|
|
@ -320,6 +340,8 @@ function mapNode() {
|
||||||
id: v.id,
|
id: v.id,
|
||||||
title: v.name,
|
title: v.name,
|
||||||
subtitle: v.code,
|
subtitle: v.code,
|
||||||
|
detail: v.detail,
|
||||||
|
remark: v.remark,
|
||||||
value: {
|
value: {
|
||||||
workerIndex: [],
|
workerIndex: [],
|
||||||
vat: 0,
|
vat: 0,
|
||||||
|
|
@ -631,7 +653,8 @@ watch(
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
selectedType !== 'work' && selectedType !== 'type'
|
selectedType !== 'work' &&
|
||||||
|
selectedType !== 'service'
|
||||||
? $t('general.remark')
|
? $t('general.remark')
|
||||||
: $t('productService.service.properties')
|
: $t('productService.service.properties')
|
||||||
}}
|
}}
|
||||||
|
|
@ -647,7 +670,7 @@ watch(
|
||||||
msg:
|
msg:
|
||||||
selectedType === 'group'
|
selectedType === 'group'
|
||||||
? $t('productService.group.title')
|
? $t('productService.group.title')
|
||||||
: selectedType === 'type'
|
: selectedType === 'service'
|
||||||
? $t('productService.type.title')
|
? $t('productService.type.title')
|
||||||
: selectedType === 'work'
|
: selectedType === 'work'
|
||||||
? $t('productService.service.title2')
|
? $t('productService.service.title2')
|
||||||
|
|
@ -663,7 +686,8 @@ watch(
|
||||||
<span v-if="pageState.infoTab === '2'">
|
<span v-if="pageState.infoTab === '2'">
|
||||||
<span class="app-text-muted">
|
<span class="app-text-muted">
|
||||||
{{
|
{{
|
||||||
selectedType !== 'work' && selectedType !== 'type'
|
selectedType !== 'work' &&
|
||||||
|
selectedType !== 'service'
|
||||||
? $t('general.remark', {
|
? $t('general.remark', {
|
||||||
msg:
|
msg:
|
||||||
selectedType === 'group'
|
selectedType === 'group'
|
||||||
|
|
@ -677,7 +701,8 @@ watch(
|
||||||
</span>
|
</span>
|
||||||
<aside
|
<aside
|
||||||
v-if="
|
v-if="
|
||||||
selectedType !== 'work' && selectedType !== 'type'
|
selectedType !== 'work' &&
|
||||||
|
selectedType !== 'service'
|
||||||
"
|
"
|
||||||
class="surface-3 q-pa-md"
|
class="surface-3 q-pa-md"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
import { QuotationFull } from 'src/stores/quotations/types';
|
import { QuotationFull } from 'src/stores/quotations/types';
|
||||||
|
|
||||||
export type ProductTree = {
|
export type ProductTree = {
|
||||||
|
type?: string;
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
subtitle: string;
|
subtitle: string;
|
||||||
|
detail?: string;
|
||||||
|
remark?: string;
|
||||||
|
attributes?: Record<string, any>;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
icon: string;
|
icon: string;
|
||||||
|
|
@ -46,9 +50,12 @@ export function quotationProductTree(
|
||||||
const service = current.service;
|
const service = current.service;
|
||||||
|
|
||||||
ret.push({
|
ret.push({
|
||||||
|
type: 'service',
|
||||||
id: service.id,
|
id: service.id,
|
||||||
title: service.name,
|
title: service.name,
|
||||||
subtitle: service.code,
|
subtitle: service.code,
|
||||||
|
attributes: service.attributes,
|
||||||
|
detail: service.detail,
|
||||||
opened: service.work.length > 0,
|
opened: service.work.length > 0,
|
||||||
checked: true,
|
checked: true,
|
||||||
children: service.work.flatMap((work) => {
|
children: service.work.flatMap((work) => {
|
||||||
|
|
@ -56,9 +63,12 @@ export function quotationProductTree(
|
||||||
relation: (typeof work)['productOnWork'][number],
|
relation: (typeof work)['productOnWork'][number],
|
||||||
): ProductTree[number] => {
|
): ProductTree[number] => {
|
||||||
return {
|
return {
|
||||||
|
type: 'product',
|
||||||
id: relation.product.id,
|
id: relation.product.id,
|
||||||
title: relation.product.name,
|
title: relation.product.name,
|
||||||
subtitle: relation.product.code,
|
subtitle: relation.product.code,
|
||||||
|
detail: relation.product.detail,
|
||||||
|
remark: relation.product.remark,
|
||||||
opened: true,
|
opened: true,
|
||||||
checked: !!list.find(
|
checked: !!list.find(
|
||||||
(v) =>
|
(v) =>
|
||||||
|
|
@ -86,9 +96,11 @@ export function quotationProductTree(
|
||||||
|
|
||||||
if (!!work.name) {
|
if (!!work.name) {
|
||||||
return {
|
return {
|
||||||
|
type: 'work',
|
||||||
id: work.id,
|
id: work.id,
|
||||||
title: work.name,
|
title: work.name,
|
||||||
subtitle: ' ',
|
subtitle: ' ',
|
||||||
|
attributes: work.attributes,
|
||||||
opened: true,
|
opened: true,
|
||||||
checked: !!list.find(
|
checked: !!list.find(
|
||||||
(v) => v.service?.id === service.id && v.work?.id === work.id,
|
(v) => v.service?.id === service.id && v.work?.id === work.id,
|
||||||
|
|
@ -108,9 +120,12 @@ export function quotationProductTree(
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ret.push({
|
ret.push({
|
||||||
|
type: 'product',
|
||||||
id: current.product.id,
|
id: current.product.id,
|
||||||
title: current.product.name,
|
title: current.product.name,
|
||||||
subtitle: current.product.code,
|
subtitle: current.product.code,
|
||||||
|
detail: current.product.detail,
|
||||||
|
remark: current.product.remark,
|
||||||
opened: true,
|
opened: true,
|
||||||
checked: true,
|
checked: true,
|
||||||
value: {
|
value: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue