diff --git a/src/api/system/index.js b/src/api/system/index.js index c69e0b5..a9cd5ca 100644 --- a/src/api/system/index.js +++ b/src/api/system/index.js @@ -376,6 +376,13 @@ const system = { data: data }); }, + interventionV2: async (data) => { + return request({ + method: MethodsENUM.POST, + url: "/Task/addIntervention", + data: data + }); + }, complaint: async (data) => { return request({ method: MethodsENUM.POST, @@ -418,6 +425,13 @@ const system = { data: {id} }); }, + checkDownload: async (id) => { + return request({ + method: MethodsENUM.POST, + url: "/Task/checkDownload", + data: {id} + }); + }, } export default system; diff --git a/src/components/XUpload.vue b/src/components/XUpload.vue index 1cdbffa..1feaea8 100644 --- a/src/components/XUpload.vue +++ b/src/components/XUpload.vue @@ -3,6 +3,7 @@ import CLOSE_ICON from "../static/icons/close2.png"; import ADDICON from "../static/icons/add.png"; import {uploadFile} from "../utils/uils"; import XImage from "./XImage.vue"; +import useUploadLength from "../hooks/useUploadLength.js"; const {size, single, del} = defineProps({ size: { @@ -21,12 +22,21 @@ const {size, single, del} = defineProps({ const emits = defineEmits(['success']); const files = defineModel('files'); +if (single) useUploadLength({ + array: files.value, + length: 1, +}) + const upload = async () => { uploadFile({ count: 1, }).then(([res]) => { const {data} = res; - files.value?.push(data); + if (!single) { + files.value?.push(data); + } else { + files.value = [data]; + } emits('success', data); }) } diff --git a/src/hooks/useUploadLength.js b/src/hooks/useUploadLength.js new file mode 100644 index 0000000..9950ea3 --- /dev/null +++ b/src/hooks/useUploadLength.js @@ -0,0 +1,17 @@ +import {watch} from "vue"; +import {showToast} from "../utils/uils.js"; + +const useUploadLength = ({array, length}) => { + watch( + () => array, + (val) => { + if (val.length > length) { + showToast(`最多可上传${length}个`); + val.length = length; + } + }, + {deep: true,} + ) +} + +export default useUploadLength; diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 761ad13..8a0aab6 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -28,6 +28,11 @@ onLoad((options) => { }))); }); }) + +const saveM = () => { + download(detail.children?.material[current].material_arr); + Api.system.checkDownload(detail.children.id); +}