odf_new/odf-uniapp/services/trunk.js

47 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { get, BASE_URL } from './api'
import store from '@/store'
export const getCableList = (deptId) =>
get('/business/OdfCables/list', { deptId })
export const getFaultList = (cableId, pageNum, pageSize) =>
get('/business/OdfCableFaults/list', { cableId, pageNum, pageSize })
export const getFaultDetail = (id) =>
get(`/business/OdfCableFaults/${id}`)
/**
* 新增故障multipart/form-data含图片上传
* @param {FormData|object} formData - 包含故障信息和图片的 FormData
* @returns {Promise}
*/
export function addFault(formData) {
return new Promise((resolve, reject) => {
const header = {
'Authorization': `Bearer ${store.token}`,
'Userid': store.userId,
'Username': store.userName
}
uni.uploadFile({
url: BASE_URL + '/business/OdfCableFaults/add',
files: formData.files || [],
formData: formData.data || {},
header,
success(res) {
try {
const result = JSON.parse(res.data)
resolve({ code: result.code, msg: result.msg, data: result.data })
} catch (e) {
reject({ code: -1, msg: '解析响应失败' })
}
},
fail(err) {
reject({ code: -1, msg: err.errMsg || '网络异常' })
}
})
})
}
export const searchCablesAndFaults = (deptId, keyword) =>
get('/business/OdfCables/search', { deptId, keyword })