feat: base checkPropsUntilReady

This commit is contained in:
caoqianming 2025-12-05 12:49:17 +08:00
parent e2f3254e46
commit cf280974c2
2 changed files with 30 additions and 12 deletions

View File

@ -142,6 +142,7 @@ const initFileList = () => {
else if (props.xtype === "path" && props.modelValue) {
props.modelValue.forEach(item => {
clist.push({
name: item.substring(item.lastIndexOf('/') + 1, item.length),
path: item,
url: `${config.hostUrl}${item}`,
percent: 100,
@ -161,6 +162,7 @@ const initFileList = () => {
fileList.value = clist
} else if (props.xtype === "path" && props.modelValue) {
clist.push({
name: item.substring(item.lastIndexOf('/') + 1, item.length),
path: props.modelValue,
url: `${config.hostUrl}${props.modelValue}`,
percent: 100,
@ -193,6 +195,13 @@ const preview = (item) => {
uni.previewImage({
current: currentIndex >= 0 ? currentIndex : 0,
urls: urls,
fail: function(err) {
console.log(err);
uni.showToast({
title: "预览失败",
icon: "none"
})
}
})
} else if (item.type == 10) {
uni.downloadFile({
@ -206,6 +215,13 @@ const preview = (item) => {
console.log('打开文档成功');
}
});
},
fail: function (err) {
console.log("下载失败:", err)
uni.showToast({
title: "下载失败",
icon: "none"
})
}
});
} else if (item.type == 20) {

View File

@ -15,7 +15,7 @@ import API from '@/utils/api';
const props = defineProps({
workflow_key: {type: String, default: null, required: false},
ticket_: {type: Object, default: null, required: false},
ticket_: {type: [Object, String], default: "pending", 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},
@ -26,18 +26,20 @@ const workflow = ref(null);
const transitions = ref([]);
const currentUser = ref(uni.getStorageSync("userInfo").id);
onMounted(async () => {
setTimeout(()=>{init()}, 1000)
// await init();
// watch(
// () => props.ticket_,
// async (newVal) => {
// if (newVal && Object.keys(newVal).length > 0) {
// await init();
// }
// },
// { deep: true }
// )
checkPropsUntilReady()
})
const inited = ref(false)
const checkPropsUntilReady = () => {
if (inited.value) return
if (props.ticket_ !== "pending") {
init()
inited.value = true
return
}
// 200ms
setTimeout(checkPropsUntilReady, 200)
}
const suggestion = ref("")
const isOwn = ref(false)
const ticketId = ref(null)