import 'dart:async'; import 'dart:io'; import 'package:dio/dio.dart'; import 'package:sk_base_mobile/constants/global_url.dart'; import 'package:sk_base_mobile/models/base_response.dart'; import 'package:sk_base_mobile/services/dio.service.dart'; import '../constants/constants.dart'; class Api { /// 登录 static Future login(String username, String password) { return DioService.dio.post( Urls.login, data: {'username': username, 'password': password}, ); } /// 删除报价模板列表 static Future> deleteSaleQuotationTemplate(int id) { return DioService.dio .delete('${Urls.saleQuotationTemplate}/$id'); } /// 获取报价模板列表 static Future> getSaleQuotationTemplate( {Map? params}) { return DioService.dio.get(Urls.saleQuotationTemplate, queryParameters: {'page': 1, 'pageSize': 99, ...(params ?? {})}); } /// 获取报价配件列表 static Future> getSaleQuotationComponents( {Map? params}) { return DioService.dio.get(Urls.saleQuotationComponent, queryParameters: {'page': 1, 'pageSize': 99, ...(params ?? {})}); } /// 获取报价分组列表 static Future> getSaleQuotationGroups( {Map? params}) { return DioService.dio.get(Urls.saleQuotationGroup, queryParameters: {'page': 1, 'pageSize': 99, ...(params ?? {})}); } /// 获取权限资源 static Future getResources() { return DioService.dio.get(Urls.accountResources); } /// 获取分页角色列表 static Future> getRoles(Map params) { return DioService.dio.get(Urls.roles, queryParameters: {'page': 1, 'pageSize': 10, ...params}); } /// 获取部门树 static Future getDepts() { return DioService.dio.get(Urls.depts); } /// 查询参数配置信息By key static Future getSystemParamConfigByCode(String code) { return DioService.dio.get( '${Urls.systemParamConfig}/key/$code', ); } /// 获取我的个人信息 static Future getMyProfile() { return DioService.dio.get( Urls.myProfile, ); } /// 获取个人信息 static Future getUserInfo(int userid) { return DioService.dio.get('${Urls.sysUser}/$userid'); } /// 更新个人信息 static Future updateUserInfo(int userid, Map params) { return DioService.dio.put('${Urls.sysUser}/$userid', data: params); } /// 分页获取项目列表 static Future> getProjects(Map params) { return DioService.dio.get(Urls.projects, queryParameters: {'page': 1, 'pageSize': 10, ...params}); } /// 分页获取产品列表 static Future> getProducts(Map params) { return DioService.dio.get(Urls.products, queryParameters: {'page': 1, 'pageSize': 10, ...params}); } /// 分页获取原材料出入库列表 static Future> getInventoryInout(Map params) { return DioService.dio.get(Urls.inventoryInout, queryParameters: {'page': 1, 'pageSize': 10, ...(params)}); } /// 获取原材料出入库详情 static Future getInventoryInOutInfo(int id) { return DioService.dio.get( '${Urls.inventoryInout}/$id', ); } /// 创建出入库记录 static Future createInventoryInout(Map params) { return DioService.dio.post(Urls.inventoryInout, data: params); } /// 创建报价计算模板 static Future createSaleQuotationTemplate(Map params) { return DioService.dio.post(Urls.saleQuotationTemplate, data: params); } /// 更新报价计算模板 static Future updateSaleQuotationTemplate(int id, Map params) { return DioService.dio .put('${Urls.saleQuotationTemplate}/$id', data: params); } /// 更新出入库记录 static Future updateInventoryInout(int id, Map params) { return DioService.dio.put('${Urls.inventoryInout}/$id', data: params); } /// 分页获取库存列表 static Future> getInventory(Map params) { return DioService.dio.get(Urls.inventory, queryParameters: {'page': 1, 'pageSize': 10, ...(params)}); } /// 分页获取用户 static Future> getUsers(Map params) { return DioService.dio.get(Urls.sysUser, queryParameters: {'page': 1, 'pageSize': 10, ...(params)}); } /// 一次性获取所有的字典类型(不分页) static Future getDictTypeAll(Map params) { return DioService.dio.post(Urls.getDictType, data: params); } static Future logout() { return DioService.dio.post( Urls.logout, ); } static Future deleteAccount() { return DioService.dio.post( Urls.deleteAccount, ); } static Future saveUserInfo(Map data) { return DioService.dio.post(Urls.saveUserInfo, data: data); } static Future uploadImg(File file, {String? bussinessModule, String? bussinessRecordId}) async { String fileName = file.path.split('/').last; final filePath = await MultipartFile.fromFile(file.path, filename: fileName); final formData = FormData.fromMap({ 'bussinessRecordId': bussinessRecordId, 'bussinessModule': bussinessModule, 'file': filePath, }); return DioService.dio.post(Urls.uploadAttachemnt, data: formData); } static Future updateAvatar(String filename) { return DioService.dio .post(Urls.updateAvatar, data: {'avatarPath': filename}); } }