import Axios from 'axios' import { CONFIG_FILE_ADMQ, DOWNLOAD_CONFIG_TO_DEVICE, REQUEST_CONFIG, CONFIG_FILE_UPLOAD, LOCAL_CONFIG_FILE_UPLOAD, CONFIG_FILE_UPLOAD_LOCAL, DOWNLOAD_CONFIG_TO_LOCAL, DOWNLOAD_CONFIG_DEVICE_TO_LOCAL, CONFIG_FILE_TOTAL_PAGE, CONFIG_FILE_TOTAL } from '../../utils/RequestUrls' var staticMethods = { /** * @Description : 配置文件备份 * @author : ls * @date : 2020/6/11 15:13 * @param : * @return : */ putCopyProfile: function (deviceKeyList) { return Axios.put(CONFIG_FILE_UPLOAD, deviceKeyList, REQUEST_CONFIG) }, // 选择历史配置文件恢复到设备 putDownloadConfigToDevice: function (configFileKey, restoryToDeviceFlag, deviceKeyList) { return Axios.put(DOWNLOAD_CONFIG_TO_DEVICE + configFileKey + '/' + restoryToDeviceFlag, deviceKeyList, REQUEST_CONFIG) }, /** * @Description : 分页 * @author : ls * @date : 2020/7/16 14:58 * @param : * @return : */ putConfigFileQueryterms: function (beginItem, endItem, selectList) { return Axios.put(CONFIG_FILE_TOTAL_PAGE + '/' + beginItem + '/' + endItem + '/', selectList, REQUEST_CONFIG) }, /** * @Description : 查询总页数 * @author : ls * @date : 2020/5/6 16:06 * @param : * @return : */ putConfigFileCounts: function (selectList) { return Axios.put(CONFIG_FILE_TOTAL, selectList, REQUEST_CONFIG) }, // 获取所有配置文件 getAllConfigFileCollection: function () { return Axios.get(CONFIG_FILE_ADMQ) }, // 删除配置文件 deleteBatchDeleteConfigFile: function (configFileKeyList) { return Axios.delete(CONFIG_FILE_ADMQ, { data: configFileKeyList, headers: {'Content-Type': 'application/json', 'Encoding': 'utf-8'} }) }, // 设备配置文件上传 putBatchUploadConfigFile: function (deviceKeyList) { return Axios.put(CONFIG_FILE_UPLOAD, deviceKeyList, REQUEST_CONFIG) }, /** * @Description : oneKeyUploadConfigApi * @author : ls * @date : 2021/3/25 11:38 * @param : * @return : */ oneKeyUploadConfigApi: function (fileName, flag, deviceKey, fileFormData) { return Axios.post(LOCAL_CONFIG_FILE_UPLOAD + fileName + '/' + deviceKey + '/' + flag, fileFormData, {headers: { 'Content-Type': 'multipart/form-data', 'Accept': 'application/json' }}) }, // 本地配置文件上传 postUploadLocalConfigFile: function (fileName, fileFormData) { return Axios.post(CONFIG_FILE_UPLOAD_LOCAL + fileName, fileFormData, {headers: { 'Content-Type': 'multipart/form-data', 'Accept': 'application/json' }}) }, // 本地配置文件下载 putDownloadConfigFile: function (configFileKey) { // return Axios.put(DOWNLOAD_CONFIG_TO_LOCAL + configFileKey, conditionSet, { return Axios.get(DOWNLOAD_CONFIG_TO_LOCAL + configFileKey, { headers: { 'Content-Type': 'application/json' }, responseType: 'arraybuffer' }) }, /** * @Description : putViewConfigFile * @author : ls * @date : 2020/11/16 15:25 * @param : * @return : */ putViewConfigFile: function (key) { return Axios.get(DOWNLOAD_CONFIG_TO_LOCAL + key, { headers: { 'Content-Type': 'application/json' }, responseType: 'arraybuffer' }) }, /** * @Description : putDownloadConfigFile * @author : ls * @date : 2020/11/10 16:48 * @param : * @return : */ putDownConfFileDeviceApi: function (deviceKey) { return Axios.get(DOWNLOAD_CONFIG_DEVICE_TO_LOCAL + deviceKey, { headers: { 'Content-Type': 'application/json' }, responseType: 'arraybuffer' }) }, // 修改配置文件 putModifyConfigFile: function (configFile) { return Axios.put(CONFIG_FILE_ADMQ, configFile, REQUEST_CONFIG) } } function ConfigFileAPI (websocketService = null) { return Object.freeze(Object.assign( { // object methods comes here }, staticMethods )) } Object.assign(ConfigFileAPI, staticMethods) export default ConfigFileAPI