feat: base checkPropsUntilReady
This commit is contained in:
parent
e2f3254e46
commit
cf280974c2
|
|
@ -142,6 +142,7 @@ const initFileList = () => {
|
||||||
else if (props.xtype === "path" && props.modelValue) {
|
else if (props.xtype === "path" && props.modelValue) {
|
||||||
props.modelValue.forEach(item => {
|
props.modelValue.forEach(item => {
|
||||||
clist.push({
|
clist.push({
|
||||||
|
name: item.substring(item.lastIndexOf('/') + 1, item.length),
|
||||||
path: item,
|
path: item,
|
||||||
url: `${config.hostUrl}${item}`,
|
url: `${config.hostUrl}${item}`,
|
||||||
percent: 100,
|
percent: 100,
|
||||||
|
|
@ -161,6 +162,7 @@ const initFileList = () => {
|
||||||
fileList.value = clist
|
fileList.value = clist
|
||||||
} else if (props.xtype === "path" && props.modelValue) {
|
} else if (props.xtype === "path" && props.modelValue) {
|
||||||
clist.push({
|
clist.push({
|
||||||
|
name: item.substring(item.lastIndexOf('/') + 1, item.length),
|
||||||
path: props.modelValue,
|
path: props.modelValue,
|
||||||
url: `${config.hostUrl}${props.modelValue}`,
|
url: `${config.hostUrl}${props.modelValue}`,
|
||||||
percent: 100,
|
percent: 100,
|
||||||
|
|
@ -193,6 +195,13 @@ const preview = (item) => {
|
||||||
uni.previewImage({
|
uni.previewImage({
|
||||||
current: currentIndex >= 0 ? currentIndex : 0,
|
current: currentIndex >= 0 ? currentIndex : 0,
|
||||||
urls: urls,
|
urls: urls,
|
||||||
|
fail: function(err) {
|
||||||
|
console.log(err);
|
||||||
|
uni.showToast({
|
||||||
|
title: "预览失败",
|
||||||
|
icon: "none"
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else if (item.type == 10) {
|
} else if (item.type == 10) {
|
||||||
uni.downloadFile({
|
uni.downloadFile({
|
||||||
|
|
@ -206,6 +215,13 @@ const preview = (item) => {
|
||||||
console.log('打开文档成功');
|
console.log('打开文档成功');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
fail: function (err) {
|
||||||
|
console.log("下载失败:", err)
|
||||||
|
uni.showToast({
|
||||||
|
title: "下载失败",
|
||||||
|
icon: "none"
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (item.type == 20) {
|
} else if (item.type == 20) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import API from '@/utils/api';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
workflow_key: {type: String, default: null, required: false},
|
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},
|
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},
|
||||||
|
|
@ -26,18 +26,20 @@ const workflow = ref(null);
|
||||||
const transitions = ref([]);
|
const transitions = ref([]);
|
||||||
const currentUser = ref(uni.getStorageSync("userInfo").id);
|
const currentUser = ref(uni.getStorageSync("userInfo").id);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
setTimeout(()=>{init()}, 1000)
|
checkPropsUntilReady()
|
||||||
// await init();
|
|
||||||
// watch(
|
|
||||||
// () => props.ticket_,
|
|
||||||
// async (newVal) => {
|
|
||||||
// if (newVal && Object.keys(newVal).length > 0) {
|
|
||||||
// await init();
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// { deep: true }
|
|
||||||
// )
|
|
||||||
})
|
})
|
||||||
|
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 suggestion = ref("")
|
||||||
const isOwn = ref(false)
|
const isOwn = ref(false)
|
||||||
const ticketId = ref(null)
|
const ticketId = ref(null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue