feat: base 优化ticketd组件

This commit is contained in:
caoqianming 2025-10-28 14:36:15 +08:00
parent 454294302d
commit 2d4b09c207
2 changed files with 32 additions and 23 deletions

View File

@ -63,7 +63,7 @@
</el-dialog> </el-dialog>
</template> </template>
<script setup> <script setup>
import { ref, defineProps, onMounted } from "vue"; import { ref, defineProps, onMounted, watch } from "vue";
import { actStateEnum, interveneTypeEnum } from "@/utils/enum.js"; import { actStateEnum, interveneTypeEnum } from "@/utils/enum.js";
import API from '@/api'; import API from '@/api';
import TOOL from "@/utils/tool.js"; import TOOL from "@/utils/tool.js";
@ -79,18 +79,26 @@ const ticketDetail = ref({
}); });
const ticketLog = ref([]); const ticketLog = ref([]);
const ticketId = ref(null); const ticketId = ref(null);
watch(
() => props.ticket_,
async (newVal) => {
if (newVal && Object.keys(newVal).length > 0) {
ticketId.value = newVal.id
getTicketDetail()
getTicketLog()
}
},
{ immediate: false }
)
onMounted(() => { onMounted(() => {
//
if (props.ticket_ && Object.keys(props.ticket_).length > 0) {
ticketId.value = props.ticket_.id
getTicketDetail()
getTicketLog()
}
//
watch(
() => props.ticket_,
async (newVal) => {
if (newVal && Object.keys(newVal).length > 0) {
ticketId.value = newVal.id
getTicketDetail()
getTicketLog()
}
},
{ deep: true }
)
}); });
const emit = defineEmits(['success']); const emit = defineEmits(['success']);
const refreshTicket = async () => { const refreshTicket = async () => {

View File

@ -35,21 +35,22 @@ const props = defineProps({
const workflow = ref(null); const workflow = ref(null);
const transitions = ref([]); const transitions = ref([]);
onMounted(async () => { onMounted(async () => {
init() init();
watch(
() => props.ticket_,
async (newVal) => {
if (newVal && Object.keys(newVal).length > 0) {
init();
}
},
{ deep: true }
)
}) })
watch(
() => props.ticket_,
async (newVal) => {
if (newVal && Object.keys(newVal).length > 0) {
await init()
}
},
{ immediate: false }
)
const ticketId = ref(null); const ticketId = ref(null);
const actionShow = ref(false); const actionShow = ref(false);
const init = async () => { const init = async () => {
if (props.ticket_ != null && props.ticket_ != undefined) { if (props.ticket_ && Object.keys(props.ticket_).length > 0) {
const isParticipant = const isParticipant =
(props.ticket_.participant_type === 1 && props.ticket_.participant === currentUser.value) || (props.ticket_.participant_type === 1 && props.ticket_.participant === currentUser.value) ||
(props.ticket_.participant_type === 2 && props.ticket_.participant.includes(currentUser.value)) (props.ticket_.participant_type === 2 && props.ticket_.participant.includes(currentUser.value))