diff --git a/src/components/piDialogSelect/index.vue b/src/components/piDialogSelect/index.vue index 92a4ad6..b7383c4 100644 --- a/src/components/piDialogSelect/index.vue +++ b/src/components/piDialogSelect/index.vue @@ -39,7 +39,7 @@ const emit = defineEmits(["success", "closed"]) const props = defineProps({ title: {type: String, default: '请选择'}, - apiObj: { + api: { type: Function, default: () => { } }, @@ -89,7 +89,7 @@ async function getData() { [config.request.pageSize]: pageSize.value, } Object.assign(reqData, props.params, formData.value) - const res = await props.apiObj(reqData) + const res = await props.api(reqData) tableData.value = res.data total.value = res.count initCheck() diff --git a/src/components/piExport/index.vue b/src/components/piExport/index.vue index ea6c741..5a82629 100644 --- a/src/components/piExport/index.vue +++ b/src/components/piExport/index.vue @@ -9,7 +9,7 @@ import tools from "@/utils/tools" const {proxy} = getCurrentInstance() const props = defineProps({ - apiObj: { + api: { type: Object, default: () => { } }, @@ -25,12 +25,12 @@ let loading = ref(false) async function download() { const data = {module: props.module, name: props.name, params: props.params} - let apiObj = props.apiObj - if (!apiObj) { - apiObj = api.tools.file.export + let api = props.api + if (!api) { + api = api.tools.file.export } loading.value = true - const [res, err] = await tools.go(apiObj(data)) + const [res, err] = await tools.go(api(data)) loading.value = false if (err) { proxy.$message.error(res.msg) diff --git a/src/components/piImport/index.vue b/src/components/piImport/index.vue index 522d1b8..8b9b92b 100644 --- a/src/components/piImport/index.vue +++ b/src/components/piImport/index.vue @@ -54,7 +54,7 @@ import {getCurrentInstance, ref} from "vue" const emit = defineEmits(["success"]) const uploaderRef = ref(null) const props = defineProps({ - apiObj: {type: Function, required: true}, + api: {type: Function, required: true}, data: { type: Object, default: () => { } @@ -118,7 +118,7 @@ function request(param) { for (const key in param.data) { data.append(key, param.data[key]); } - props.apiObj.post(data, { + props.api.post(data, { onUploadProgress: e => { const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10) param.onProgress({percent: complete}) diff --git a/src/components/piSelect/index.vue b/src/components/piSelect/index.vue index c57ab10..3897a48 100644 --- a/src/components/piSelect/index.vue +++ b/src/components/piSelect/index.vue @@ -15,7 +15,7 @@ const emit = defineEmits(['update:modelValue', 'change']) const props = defineProps({ modelValue: null, - apiObj: { + api: { type: Function, default: () => { } }, @@ -63,7 +63,7 @@ onMounted(() => { async function getData() { loading.value = true; - const res = await props.apiObj(props.params); + const res = await props.api(props.params); tableData.value = res.data; loading.value = false; } diff --git a/src/components/piTable/index.vue b/src/components/piTable/index.vue index f0c0d1c..411979f 100644 --- a/src/components/piTable/index.vue +++ b/src/components/piTable/index.vue @@ -117,7 +117,7 @@ const hasDoSlot = computed(() => !!slots.do) const props = defineProps({ tableName: {type: String, default: ""}, - apiObj: { + api: { type: Function, default: () => { } }, @@ -179,7 +179,7 @@ watch(() => props.data, () => { total.value = tableData.value.length; }) -watch(() => props.apiObj, () => { +watch(() => props.api, () => { tableParams.value = props.params; refresh(); }) @@ -200,7 +200,7 @@ onMounted(() => { userColumn = props.column } //判断是否静态数据 - if (props.apiObj) { + if (props.api) { getData() } else if (data.value) { tableData.value = data.value @@ -253,7 +253,7 @@ async function getData() { } Object.assign(reqData, tableParams.value) try { - var res = await props.apiObj(reqData) + var res = await props.api(reqData) } catch (error) { loading.value = false; emptyText.value = error.statusText; diff --git a/src/components/piTableSelect/index.vue b/src/components/piTableSelect/index.vue index 3989cf3..f811e8a 100644 --- a/src/components/piTableSelect/index.vue +++ b/src/components/piTableSelect/index.vue @@ -35,7 +35,7 @@ const emit = defineEmits(['update:modelValue', 'change']) const props = defineProps({ modelValue: null, - apiObj: { + api: { type: Function, default: () => { } }, @@ -109,7 +109,7 @@ async function getData() { [defaultProps.value.keyword]: keyword.value } Object.assign(reqData, props.params, formData.value) - var res = await props.apiObj(reqData); + var res = await props.api(reqData); var parseData = config.parseData(res) tableData.value = parseData.rows; total.value = parseData.total; diff --git a/src/components/piUpload/file.vue b/src/components/piUpload/file.vue index d52f591..ef443e7 100644 --- a/src/components/piUpload/file.vue +++ b/src/components/piUpload/file.vue @@ -36,11 +36,11 @@ const props = defineProps({ modelValue: { type: [String, Array], default: "" }, tip: { type: String, default: "" }, action: { type: String, default: "" }, - apiObj: { type: Function, default: () => {} }, + api: { type: Function, default: () => {} }, name: { type: String, default: config.filename }, data: { type: Object, default: () => {} }, accept: { type: String, default: "" }, - maxSize: { type: Number, default: config.maxSizeFile }, + maxSize: { type: Number, default: config.maxSiz }, limit: { type: Number, default: 0 }, autoUpload: { type: Boolean, default: true }, showFileList: { type: Boolean, default: true }, @@ -158,16 +158,16 @@ function handlePreview(uploadFile){ } function request(param){ - var apiObj = config.apiObjFile; - if(props.apiObj){ - apiObj = props.apiObj; + var api = config.api; + if(props.api){ + api = props.api; } const data = new FormData(); data.append(param.filename, param.file); for (const key in param.data) { data.append(key, param.data[key]); } - apiObj(data, { + api(data, { onUploadProgress: e => { const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10) param.onProgress({percent: complete}) diff --git a/src/components/piUpload/index.vue b/src/components/piUpload/index.vue index 83049e3..ccfef9b 100644 --- a/src/components/piUpload/index.vue +++ b/src/components/piUpload/index.vue @@ -71,11 +71,11 @@ const props = defineProps({ title: { type: String, default: "" }, icon: { type: String, default: "el-icon-plus" }, action: { type: String, default: "" }, - apiObj: { type: Object, default: () => {} }, + api: { type: Object, default: () => {} }, name: { type: String, default: config.filename }, data: { type: Object, default: () => {} }, accept: { type: String, default: "image/gif, image/jpeg, image/png" }, - maxSize: { type: Number, default: config.maxSizeFile }, + maxSize: { type: Number, default: config.maxSiz }, limit: { type: Number, default: 1 }, autoUpload: { type: Boolean, default: true }, showFileList: { type: Boolean, default: false }, @@ -226,16 +226,16 @@ function error(err){ } function request(param){ - var apiObj = config.apiObj; - if(props.apiObj){ - apiObj = props.apiObj; + var api = config.api; + if(props.api){ + api = props.api; } const data = new FormData(); data.append(param.filename, param.file); for (const key in param.data) { data.append(key, param.data[key]); } - apiObj(data, { + api(data, { onUploadProgress: e => { const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10) param.onProgress({percent: complete}) diff --git a/src/components/piUpload/multiple.vue b/src/components/piUpload/multiple.vue index 4085352..bea76cf 100644 --- a/src/components/piUpload/multiple.vue +++ b/src/components/piUpload/multiple.vue @@ -58,11 +58,11 @@ const props = defineProps({ modelValue: { type: [String, Array], default: "" }, tip: { type: String, default: "" }, action: { type: String, default: "" }, - apiObj: { type: Object, default: () => {} }, + api: { type: Object, default: () => {} }, name: { type: String, default: config.filename }, data: { type: Object, default: () => {} }, accept: { type: String, default: "image/gif, image/jpeg, image/png" }, - maxSize: { type: Number, default: config.maxSizeFile }, + maxSize: { type: Number, default: config.maxSiz }, limit: { type: Number, default: 0 }, autoUpload: { type: Boolean, default: true }, showFileList: { type: Boolean, default: true }, @@ -212,16 +212,16 @@ function handlePreview(uploadFile){ } function request(param){ - var apiObj = config.apiObj; - if(props.apiObj){ - apiObj = props.apiObj; + var api = config.api; + if(props.api){ + api = props.api; } const data = new FormData(); data.append(param.filename, param.file); for (const key in param.data) { data.append(key, param.data[key]); } - apiObj(data, { + api(data, { onUploadProgress: e => { const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10) param.onProgress({percent: complete}) diff --git a/src/config/upload.ts b/src/config/upload.ts index a5e13bc..184b092 100644 --- a/src/config/upload.ts +++ b/src/config/upload.ts @@ -3,7 +3,7 @@ import API from "@/api"; //上传配置 export default { - apiObj: API.system.upload, //上传请求API对象 + api: API.system.upload, //上传请求API对象 filename: "file", //form请求时文件的key successCode: 0, //请求完成代码 maxSize: 10, //最大文件大小 默认10MB @@ -12,7 +12,5 @@ export default { fileName: res.fileName, src: res.filePath, } - }, - apiObjFile: API.system.upload, //附件上传请求API对象 - maxSizeFile: 10 //最大文件大小 默认10MB + } } diff --git a/src/views/monitor/crontab/index.vue b/src/views/monitor/crontab/index.vue index daf4f53..9fe34db 100644 --- a/src/views/monitor/crontab/index.vue +++ b/src/views/monitor/crontab/index.vue @@ -1,5 +1,5 @@