feat: ticketd优化

This commit is contained in:
caoqianming 2025-09-28 10:21:11 +08:00
parent ddb620a2f0
commit 36d72090e2
3 changed files with 42 additions and 28 deletions

View File

@ -75,7 +75,7 @@ import TOOL from "@/utils/tool.js";
import { ElMessageBox } from 'element-plus' import { ElMessageBox } from 'element-plus'
const props = defineProps({ const props = defineProps({
ticket_data: { type: Object, default: null }, ticket_data: { type: Object, default: null },
ticket_full_data: { type: Object, default: null, required: true }, ticket_: { type: Object, default: null, required: true },
}); });
const currentUser = ref(TOOL.data.get("USER_INFO").id) const currentUser = ref(TOOL.data.get("USER_INFO").id)
const actionShow = ref(false); const actionShow = ref(false);
@ -90,8 +90,9 @@ const handleForm = ref({
}) })
const ticketId = ref(null); const ticketId = ref(null);
onMounted(() => { onMounted(() => {
if (props.ticket_full_data) { if (props.ticket_) {
ticketId.value = props.ticket_full_data.id; ticketId.value = props.ticket_.id;
getTicketDetail();
getTicketLog(); getTicketLog();
} }
}); });
@ -111,21 +112,25 @@ const refreshTicket = async () => {
const getTicketDetail = () => { const getTicketDetail = () => {
API.wf.ticket.ticketItem.req(ticketId.value).then(res => { API.wf.ticket.ticketItem.req(ticketId.value).then(res => {
ticketDetail.value = res; ticketDetail.value = res;
if (res.create_by === currentUser.value) { const isCreator = res.create_by === currentUser.value
isOwn.value = true; const isParticipant =
actionShow.value = true; (res.participant_type === 1 && res.participant === currentUser.value) ||
if (!activeNames.value.includes('2')) activeNames.value.push('2') (res.participant_type === 2 && res.participant.includes(currentUser.value))
if (isCreator) {
isOwn.value = true
} }
if (res.participant_type == 1 && res.participant === currentUser.value) {
actionShow.value = true; if (isCreator || isParticipant) {
if (!activeNames.value.includes('2')) activeNames.value.push('2') actionShow.value = true
getTransitions(); if (!activeNames.value.includes('2')) {
activeNames.value.push('2')
} }
if (res.participant_type == 2 && res.participant.includes(currentUser.value)) { if (isParticipant) {
actionShow.value = true; getTransitions()
if (!activeNames.value.includes('2')) activeNames.value.push('2')
getTransitions();
} }
}
}); });
}; };

View File

@ -1,5 +1,5 @@
<template> <template>
<el-button <span v-if="actionShow"><el-button
v-for="item in transitions" v-for="item in transitions"
:key="item.id" :key="item.id"
type="primary" type="primary"
@ -7,17 +7,18 @@
:disabled="isSaveing" :disabled="isSaveing"
@click="submit(item.id)" @click="submit(item.id)"
style="margin-right: 2px" style="margin-right: 2px"
>{{ item.name }}</el-button> >{{ item.name }}</el-button></span>
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted, defineEmits } from 'vue' import { ref, reactive, onMounted, defineEmits } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import API from '@/api'; import API from '@/api';
import TOOL from "@/utils/tool.js";
const props = defineProps({ const props = defineProps({
workflow_key: {type: String, default: null, required: false}, workflow_key: {type: String, default: null, required: false},
ticketId: {type: String, default: null, required: false}, ticket_: {type: Object, default: null, required: false},
t_id: {type: String, default: null, required: true}, t_id: {type: String, default: null, required: true},
title: {type: String, default: null, required: false}, title: {type: String, default: null, required: false},
submit_b_func: {type: Function, default: null, required: false}, submit_b_func: {type: Function, default: null, required: false},
@ -29,20 +30,28 @@ const transitions = ref([]);
onMounted(async () => { onMounted(async () => {
init() init()
}) })
const ticketId = ref(null);
const actionShow = ref(false);
const init = async () => { const init = async () => {
if (props.ticketId != null && props.ticketId != undefined) { if (props.ticket_ != null && props.ticket_ != undefined) {
API.wf.ticket.ticketTransitions.req(props.ticketId).then(res => { const isParticipant =
transitions.value = res; (props.ticket_.participant_type === 1 && props.ticket_.participant === currentUser.value) ||
console.log("res", res) (props.ticket_.participant_type === 2 && props.ticket_.participant.includes(currentUser.value))
}); if (isParticipant) {
actionShow.value = true;
}
ticketId.value = props.ticket_.id;
transitions.value = await API.wf.ticket.ticketTransitions.req(ticketId.value);
}else if (props.workflow_key !=null && props.workflow_key != undefined) { }else if (props.workflow_key !=null && props.workflow_key != undefined) {
let res = await API.wf.workflow.initkey.req(props.workflow_key); let res = await API.wf.workflow.initkey.req(props.workflow_key);
actionShow.value = true
transitions.value = res.transitions; transitions.value = res.transitions;
workflow.value = res.workflow workflow.value = res.workflow
}else{ }else{
ElMessage.error("缺少workflow_key或ticketId"); ElMessage.error("缺少workflow_key或ticketId");
} }
} }
const currentUser = ref(TOOL.data.get("USER_INFO").id)
const isSaveing = ref(false); const isSaveing = ref(false);
@ -58,7 +67,7 @@ const submit = async (transition_id) => {
} }
} }
if (props.ticketId != null && props.ticketId != undefined) { if (ticketId.value) {
let params = new Object(); let params = new Object();
params.transition = transition_id; params.transition = transition_id;
if (props.ticket_data) { if (props.ticket_data) {
@ -67,10 +76,10 @@ const submit = async (transition_id) => {
params.ticket_data = {}; params.ticket_data = {};
} }
try{ try{
let res = await API.wf.ticket.ticketHandle.req(props.ticketId, params); let res = await API.wf.ticket.ticketHandle.req(ticketId.value, params);
isSaveing.value = false; isSaveing.value = false;
ElMessage.success("提交成功"); ElMessage.success("提交成功");
emit("success", props.ticketId) emit("success", ticketId.value)
} catch (e) { } catch (e) {
isSaveing.value = false; isSaveing.value = false;
return; return;

View File

@ -4,7 +4,7 @@
</el-main> </el-main>
<el-aside width="30%"> <el-aside width="30%">
<ticketd :ticket_full_data="props.ticket_full_data"></ticketd> <ticketd :ticket_="props.ticket_"></ticketd>
</el-aside> </el-aside>
</el-container> </el-container>
</template> </template>
@ -13,7 +13,7 @@ import { ref, defineProps, onMounted} from "vue";
import ticketd from './ticketd.vue' import ticketd from './ticketd.vue'
import API from '@/api' import API from '@/api'
const props = defineProps({ const props = defineProps({
ticket_full_data: { type: Object, required: false, default: null } ticket_: { type: Object, required: false, default: null }
}); });
onMounted(() => { onMounted(() => {