feat: ticketd优化
This commit is contained in:
parent
ddb620a2f0
commit
36d72090e2
|
@ -75,7 +75,7 @@ import TOOL from "@/utils/tool.js";
|
|||
import { ElMessageBox } from 'element-plus'
|
||||
const props = defineProps({
|
||||
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 actionShow = ref(false);
|
||||
|
@ -90,8 +90,9 @@ const handleForm = ref({
|
|||
})
|
||||
const ticketId = ref(null);
|
||||
onMounted(() => {
|
||||
if (props.ticket_full_data) {
|
||||
ticketId.value = props.ticket_full_data.id;
|
||||
if (props.ticket_) {
|
||||
ticketId.value = props.ticket_.id;
|
||||
getTicketDetail();
|
||||
getTicketLog();
|
||||
}
|
||||
});
|
||||
|
@ -111,21 +112,25 @@ const refreshTicket = async () => {
|
|||
const getTicketDetail = () => {
|
||||
API.wf.ticket.ticketItem.req(ticketId.value).then(res => {
|
||||
ticketDetail.value = res;
|
||||
if (res.create_by === currentUser.value) {
|
||||
isOwn.value = true;
|
||||
actionShow.value = true;
|
||||
if (!activeNames.value.includes('2')) activeNames.value.push('2')
|
||||
const isCreator = res.create_by === currentUser.value
|
||||
const isParticipant =
|
||||
(res.participant_type === 1 && res.participant === currentUser.value) ||
|
||||
(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 (!activeNames.value.includes('2')) activeNames.value.push('2')
|
||||
getTransitions();
|
||||
|
||||
if (isCreator || isParticipant) {
|
||||
actionShow.value = true
|
||||
if (!activeNames.value.includes('2')) {
|
||||
activeNames.value.push('2')
|
||||
}
|
||||
if (res.participant_type == 2 && res.participant.includes(currentUser.value)) {
|
||||
actionShow.value = true;
|
||||
if (!activeNames.value.includes('2')) activeNames.value.push('2')
|
||||
getTransitions();
|
||||
if (isParticipant) {
|
||||
getTransitions()
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<el-button
|
||||
<span v-if="actionShow"><el-button
|
||||
v-for="item in transitions"
|
||||
:key="item.id"
|
||||
type="primary"
|
||||
|
@ -7,17 +7,18 @@
|
|||
:disabled="isSaveing"
|
||||
@click="submit(item.id)"
|
||||
style="margin-right: 2px"
|
||||
>{{ item.name }}</el-button>
|
||||
>{{ item.name }}</el-button></span>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, defineEmits } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import API from '@/api';
|
||||
import TOOL from "@/utils/tool.js";
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
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},
|
||||
title: {type: String, default: null, required: false},
|
||||
submit_b_func: {type: Function, default: null, required: false},
|
||||
|
@ -29,20 +30,28 @@ const transitions = ref([]);
|
|||
onMounted(async () => {
|
||||
init()
|
||||
})
|
||||
const ticketId = ref(null);
|
||||
const actionShow = ref(false);
|
||||
const init = async () => {
|
||||
if (props.ticketId != null && props.ticketId != undefined) {
|
||||
API.wf.ticket.ticketTransitions.req(props.ticketId).then(res => {
|
||||
transitions.value = res;
|
||||
console.log("res", res)
|
||||
});
|
||||
if (props.ticket_ != null && props.ticket_ != undefined) {
|
||||
const isParticipant =
|
||||
(props.ticket_.participant_type === 1 && props.ticket_.participant === currentUser.value) ||
|
||||
(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) {
|
||||
let res = await API.wf.workflow.initkey.req(props.workflow_key);
|
||||
actionShow.value = true
|
||||
transitions.value = res.transitions;
|
||||
workflow.value = res.workflow
|
||||
}else{
|
||||
ElMessage.error("缺少workflow_key或ticketId");
|
||||
}
|
||||
}
|
||||
const currentUser = ref(TOOL.data.get("USER_INFO").id)
|
||||
|
||||
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();
|
||||
params.transition = transition_id;
|
||||
if (props.ticket_data) {
|
||||
|
@ -67,10 +76,10 @@ const submit = async (transition_id) => {
|
|||
params.ticket_data = {};
|
||||
}
|
||||
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;
|
||||
ElMessage.success("提交成功");
|
||||
emit("success", props.ticketId)
|
||||
emit("success", ticketId.value)
|
||||
} catch (e) {
|
||||
isSaveing.value = false;
|
||||
return;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
</el-main>
|
||||
<el-aside width="30%">
|
||||
<ticketd :ticket_full_data="props.ticket_full_data"></ticketd>
|
||||
<ticketd :ticket_="props.ticket_"></ticketd>
|
||||
</el-aside>
|
||||
</el-container>
|
||||
</template>
|
||||
|
@ -13,7 +13,7 @@ import { ref, defineProps, onMounted} from "vue";
|
|||
import ticketd from './ticketd.vue'
|
||||
import API from '@/api'
|
||||
const props = defineProps({
|
||||
ticket_full_data: { type: Object, required: false, default: null }
|
||||
ticket_: { type: Object, required: false, default: null }
|
||||
});
|
||||
onMounted(() => {
|
||||
|
||||
|
|
Loading…
Reference in New Issue