feat : 扫码上传的本地删除改为接口删除
This commit is contained in:
@@ -66,9 +66,12 @@ const pollingTimer = ref(null);
|
|||||||
const isPolling = ref(false);
|
const isPolling = ref(false);
|
||||||
const isVisible = ref(false);
|
const isVisible = ref(false);
|
||||||
const uuid = ref(null);
|
const uuid = ref(null);
|
||||||
const fileCount = ref(0);
|
|
||||||
const fileList = ref([]);
|
const fileList = ref([]);
|
||||||
const delFiles = ref([]); //本地记录删除的文件
|
const deleting = ref(false);
|
||||||
|
|
||||||
|
const fileCount = computed(() => {
|
||||||
|
return fileList.value.length ?? 0;
|
||||||
|
});
|
||||||
|
|
||||||
// 计算加载文本
|
// 计算加载文本
|
||||||
const loadingText = computed(() => ({
|
const loadingText = computed(() => ({
|
||||||
@@ -113,10 +116,16 @@ function preViewImage(file) {
|
|||||||
$api.msg('文件地址丢失');
|
$api.msg('文件地址丢失');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function delFile(file, idx) {
|
async function delFile(file, idx) {
|
||||||
|
deleting.value = true;
|
||||||
|
try {
|
||||||
|
await $api.createRequest(`/app/kiosk/${file.id}`, {sessionId: uuid.value,ids: [file.id]}, 'delete', true);
|
||||||
|
} catch (error) {
|
||||||
|
$api.msg(error);
|
||||||
|
} finally {
|
||||||
|
deleting.value = false;
|
||||||
|
}
|
||||||
fileList.value.splice(idx, 1);
|
fileList.value.splice(idx, 1);
|
||||||
fileCount.value = fileList.value.length
|
|
||||||
delFiles.value.push(file.fileUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
@@ -149,9 +158,7 @@ function handleConfirm() {
|
|||||||
|
|
||||||
// 重置所有状态
|
// 重置所有状态
|
||||||
function resetState() {
|
function resetState() {
|
||||||
delFiles.value = []
|
|
||||||
fileList.value = [];
|
fileList.value = [];
|
||||||
fileCount.value = 0;
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
stopPolling();
|
stopPolling();
|
||||||
}
|
}
|
||||||
@@ -179,23 +186,23 @@ async function initQrCode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeQrcode() {
|
function makeQrcode() {
|
||||||
const protocol = window.location.protocol;
|
const protocol = window.location.protocol;
|
||||||
const host = window.location.host;
|
const host = window.location.host;
|
||||||
const isLocal = host.includes('localhost') || host.includes('127.0.0.1');
|
const isLocal = host.includes('localhost') || host.includes('127.0.0.1');
|
||||||
// const pathPrefix = isLocal ? '' : '/rgpp-api/all-in-one';
|
// const pathPrefix = isLocal ? '' : '/rgpp-api/all-in-one';
|
||||||
let pathPrefix = '';
|
let pathPrefix = '';
|
||||||
if (host.includes('localhost') || host.includes('127.0.0.1')) {
|
if (host.includes('localhost') || host.includes('127.0.0.1')) {
|
||||||
pathPrefix = '';
|
pathPrefix = '';
|
||||||
} else if (host.includes('qd.zhaopinzao8dian.com')) {
|
} else if (host.includes('qd.zhaopinzao8dian.com')) {
|
||||||
// 外网测试环境
|
// 外网测试环境
|
||||||
pathPrefix = '/app';
|
pathPrefix = '/app';
|
||||||
} else if (host.includes('fw.rc.qingdao.gov.cn')) {
|
} else if (host.includes('fw.rc.qingdao.gov.cn')) {
|
||||||
// 青岛政务网环境
|
// 青岛政务网环境
|
||||||
pathPrefix = '/rgpp-api/all-in-one';
|
pathPrefix = '/rgpp-api/all-in-one';
|
||||||
} else {
|
} else {
|
||||||
pathPrefix = '';
|
pathPrefix = '';
|
||||||
}
|
}
|
||||||
const htmlPath = `${protocol}//${host}${pathPrefix}/static/upload.html?sessionId=${uuid.value}&uploadApi=${config.baseUrl}/app/kiosk/upload&fileCount=${props.leaveFileCount}`;
|
const htmlPath = `${protocol}//${host}${pathPrefix}/static/upload.html?sessionId=${uuid.value}&uploadApi=${config.baseUrl}/app/kiosk/upload&fileCount=${props.leaveFileCount}`;
|
||||||
|
|
||||||
// const htmlPath = `${window.location.host}/static/upload.html?sessionId=${uuid.value}&uploadApi=${
|
// const htmlPath = `${window.location.host}/static/upload.html?sessionId=${uuid.value}&uploadApi=${
|
||||||
// config.baseUrl + '/app/kiosk/upload'
|
// config.baseUrl + '/app/kiosk/upload'
|
||||||
@@ -204,7 +211,7 @@ function makeQrcode() {
|
|||||||
// config.baseUrl + '/app/kiosk/upload'
|
// config.baseUrl + '/app/kiosk/upload'
|
||||||
// }`;
|
// }`;
|
||||||
console.log(htmlPath);
|
console.log(htmlPath);
|
||||||
console.log('剩余可上传文件数量:',props.leaveFileCount)
|
console.log('剩余可上传文件数量:', props.leaveFileCount);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uQRCode.make({
|
uQRCode.make({
|
||||||
@@ -237,20 +244,16 @@ function startPolling() {
|
|||||||
|
|
||||||
// 轮询检查上传状态
|
// 轮询检查上传状态
|
||||||
const poll = async () => {
|
const poll = async () => {
|
||||||
if (!isPolling.value || !isVisible.value) return;
|
if (!isPolling.value || !isVisible.value || deleting.value) return;
|
||||||
const { data } = await $api.createRequest('/app/kiosk/list', { sessionId: uuid.value });
|
const { data } = await $api.createRequest('/app/kiosk/list', { sessionId: uuid.value });
|
||||||
// const { data } = await $api.createRequest('/app/kiosk/list',{sessionId:props.sessionId});
|
// const { data } = await $api.createRequest('/app/kiosk/list',{sessionId:props.sessionId});
|
||||||
if (data && data.length) {
|
if (data && data.length) {
|
||||||
// 上传完成,触发事件
|
fileList.value = data;
|
||||||
fileList.value = data.filter((item) => !delFiles.value.includes(item.fileUrl))
|
|
||||||
fileCount.value = fileList.value.length;
|
|
||||||
// emit('onSend', data);
|
|
||||||
}
|
}
|
||||||
if (isPolling.value && isVisible.value) {
|
if (isPolling.value && isVisible.value) {
|
||||||
pollingTimer.value = setTimeout(poll, 2000); // 每2秒轮询一次
|
pollingTimer.value = setTimeout(poll, 2000); // 每2秒轮询一次
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
poll();
|
poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user