refactor: edit remark
This commit is contained in:
parent
dc163e6e97
commit
8b887f40bd
2 changed files with 73 additions and 6 deletions
|
|
@ -1,9 +1,33 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
defineProps<{
|
import { RequestWork } from 'src/stores/request-list';
|
||||||
|
import { convertTemplate } from 'src/utils/string-template';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
|
itemsDiscount?: {
|
||||||
|
productId: string;
|
||||||
|
discount?: number;
|
||||||
|
}[];
|
||||||
|
items: {
|
||||||
|
product: RequestWork['productService']['product'];
|
||||||
|
list: RequestWork[];
|
||||||
|
}[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const remark = defineModel<string>('remark', { default: '' });
|
const remark = defineModel<string>('remark', { default: '' });
|
||||||
|
|
||||||
|
const remarkWrite = ref<boolean>(false);
|
||||||
|
|
||||||
|
const getToolbarConfig = computed(() => {
|
||||||
|
const toolbar = [['left', 'center', 'justify'], ['toggle'], ['clip']];
|
||||||
|
if (props.readonly) {
|
||||||
|
return toolbar.filter((item) => !item.includes('toggle'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return toolbar;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
|
|
@ -23,16 +47,28 @@ const remark = defineModel<string>('remark', { default: '' });
|
||||||
<main class="surface-1 q-pa-md full-width">
|
<main class="surface-1 q-pa-md full-width">
|
||||||
<q-editor
|
<q-editor
|
||||||
dense
|
dense
|
||||||
:readonly="readonly"
|
:readonly="readonly || !remarkWrite"
|
||||||
:model-value="remark"
|
:model-value="
|
||||||
|
!remarkWrite || readonly
|
||||||
|
? convertTemplate(remark || '', {
|
||||||
|
'order-detail': {
|
||||||
|
items,
|
||||||
|
itemsDiscount,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: remark || ''
|
||||||
|
"
|
||||||
min-height="5rem"
|
min-height="5rem"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
|
:content-class="{
|
||||||
|
'q-my-sm rounded': true,
|
||||||
|
bordered: !readonly && remarkWrite,
|
||||||
|
}"
|
||||||
toolbar-bg="input-border"
|
toolbar-bg="input-border"
|
||||||
style="cursor: auto; color: var(--foreground)"
|
style="cursor: auto; color: var(--foreground)"
|
||||||
:content-class="readonly ? 'q-mt-sm' : 'bordered q-mt-sm rounded'"
|
|
||||||
:flat="!readonly"
|
:flat="!readonly"
|
||||||
:style="`width: ${$q.screen.gt.xs ? '100%' : '63vw'}`"
|
:style="`width: ${$q.screen.gt.xs ? '100%' : '63vw'}`"
|
||||||
:toolbar="[['left', 'center', 'justify'], ['clip']]"
|
:toolbar="getToolbarConfig"
|
||||||
:toolbar-toggle-color="readonly ? 'disabled' : 'primary'"
|
:toolbar-toggle-color="readonly ? 'disabled' : 'primary'"
|
||||||
:toolbar-color="readonly ? 'disabled' : $q.dark.isActive ? 'white' : ''"
|
:toolbar-color="readonly ? 'disabled' : $q.dark.isActive ? 'white' : ''"
|
||||||
:definitions="{
|
:definitions="{
|
||||||
|
|
@ -48,7 +84,36 @@ const remark = defineModel<string>('remark', { default: '' });
|
||||||
remark = v;
|
remark = v;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
>
|
||||||
|
<template v-if="!readonly" v-slot:toggle>
|
||||||
|
<div class="text-caption row no-wrap q-px-sm">
|
||||||
|
<MainButton
|
||||||
|
:solid="!remarkWrite"
|
||||||
|
icon="mdi-eye-outline"
|
||||||
|
color="0 0% 40%"
|
||||||
|
@click="remarkWrite = false"
|
||||||
|
style="padding: 0 var(--size-2); cursor: pointer"
|
||||||
|
:style="{
|
||||||
|
color: remarkWrite ? 'hsl(0 0% 40%)' : undefined,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ $t('general.view', { msg: $t('general.example') }) }}
|
||||||
|
</MainButton>
|
||||||
|
<MainButton
|
||||||
|
:solid="remarkWrite"
|
||||||
|
icon="mdi-pencil-outline"
|
||||||
|
color="0 0% 40%"
|
||||||
|
@click="remarkWrite = true"
|
||||||
|
style="padding: 0 var(--size-2); cursor: pointer"
|
||||||
|
:style="{
|
||||||
|
color: !remarkWrite ? 'hsl(0 0% 40%)' : undefined,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ $t('general.edit') }}
|
||||||
|
</MainButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</q-editor>
|
||||||
</main>
|
</main>
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -970,6 +970,8 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
"
|
"
|
||||||
v-model:remark="currentFormData.remark"
|
v-model:remark="currentFormData.remark"
|
||||||
:readonly="!['create', 'edit'].includes(state.mode || '')"
|
:readonly="!['create', 'edit'].includes(state.mode || '')"
|
||||||
|
:items="taskListGroup"
|
||||||
|
:items-discount="taskProduct"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<template
|
<template
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue