Commit f23fbc1f authored by jiaxu.yan's avatar jiaxu.yan

Merge branch 'master' of http://gitlab.91isoft.com:90/hikvision/web-project

# Conflicts:
#	src/api/scheduling.js
parents 7f7e528b 4211ac20
/*
整个项目api的统一管理
*/
import request from "./request";
// 请求首页左侧的表格的数据
export default{
getEnergyData(params) {
return request({
url:'/home/getEnergyData',
method:"get",
data:params
})
},
deleteEnergy(params) {
return request({
url:'/home/deleteEnergy',
method:"get",
data:params
})
},
addEnergy(params) {
return request({
url:'/home/AddEnergy',
method:"get",
data:params
})
},
editEnergy(params) {
return request({
url: '/home/editEnergy',
method: 'get',
data: params
})
},
}
import Mock from 'mockjs'
import energyApi from './mockData/energy'
// 1.拦截的路径 2.拦截的方法 3.制造出的假数据
// Mock.mock('/api/home/getEnergyData','get',energyApi.getEnergyList)
Mock.mock(/home\/getEnergyData/,"get", energyApi.getEnergyList)
Mock.mock(/home\/deleteEnergy/,"get", energyApi.deleteEnergy)
Mock.mock(/home\/AddEnergy/,"get", energyApi.createEnery)
Mock.mock(/home\/editEnergy/,"get", energyApi.updateEnergy)
\ No newline at end of file
import Mock from 'mockjs'
import { ref } from 'vue'
// get请求从config.url获取参数,post从config.body中获取参数
function param2Obj(url) {
const search = url.split('?')[1]
if (!search) {
return {}
}
return JSON.parse(
'{"' +
decodeURIComponent(search)
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"') +
'"}'
)
}
let List = []
const count = 100
for (let i = 0; i < count; i++) {
List.push(
Mock.mock({
allowPagingId: "@increment()",
'supplyName|1': Mock.mock(['东部供热站', '行政区供热站', '福宛里供热站']),
'energyType|1-4': 1,
'energyType|1': Mock.mock(['热', '光', '电','机械']),
'record|100-3000': 1,
recordDate: Mock.mock('@date("yyyy/MM/dd")') + ' 0:00:00'
})
)
}
export default {
/**
* 获取列表
* 要带参数 name, page, limt; name可以不填, page,limit有默认值。
* @param name, page, limit
* @return {{code: number, count: number, data: *[]}}
*/
getEnergyList: config => {
//limit默认是10,因为分页器默认也是一页10个
const { supplyName, page = 1, limit = 10 } = param2Obj(config.url)
const mockList = List.filter(energy => {
//如果name存在会,根据name筛选数据
if (supplyName && energy.supplyName.indexOf(supplyName) === -1) return false
return true
})
//分页
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
return {
code: 200,
data: {
list: pageList,
count: mockList.length, //数据总条数需要返回
}
}
},
/**
* 删除
* @param id
* @return {*}
*/
deleteEnergy: config => {
const { allowPagingId} = param2Obj(config.url)
// console.log("前端传来的id:"+id);
if (!allowPagingId) {
return {
code: -999,
message: '参数不正确'
}
} else {
List = List.filter(item => item.allowPagingId != allowPagingId)
console.log(List);
return {
code: 200,
message: '删除成功'
}
}
},
/**
* 增加
* @param name, type, used, date
* @return {{code: number, data: {message: string}}}
*/
createEnery: config => {
const { supplyName, energyType, record, recordDate } = JSON.parse(config.body)
List.unshift({
allowPagingId:Mock.mock('@increment()'),
supplyName:supplyName,
energyType:energyType,
record:record,
recordDate:recordDate
})
return {
code: 200,
data: {
message: '添加成功'
}
}
},
updateEnergy: config => {
const { allowPagingId, supplyName, energyType, record, recordDate } = JSON.parse(config.body)
const energyType_num = parseInt(energyType)
List.some(e => {
if (e.allowPagingId === allowPagingId) {
e.supplyName = supplyName
e.energyType = energyType
e.record = record
e.recordDate = recordDate
return true
}
})
return {
code: 200,
data: {
message: '编辑成功'
}
}
}
}
\ No newline at end of file
import axios from 'axios';
import {ElMessage} from 'element-plus';
import config from '../config/index';
const service = axios.create({
baseURL:config.baseApi,
});
const NETWORK_ERROR = '网络错误...';
// 添加请求拦截器
service.interceptors.request.use(function (config) {
// 在发送请求之前做些什么
return config;
}, function (error) {
// 对请求错误做些什么
return Promise.reject(error);
});
// 添加响应拦截器
service.interceptors.response.use(
(res) => {
// console.log(res);
const {code,data,msg}= res.data;
if(code === 200) {
return data;
}else {
ElMessage.error(msg || NETWORK_ERROR);
return Promise.reject(msg || NETWORK_ERROR);
}
}
);
function request(options) {
options.method = options.method || "get";
// 关于get请求参数的调整
if(options.method.toLowerCase()==='get') {
options.params = options.data;
}
//对mock的开关做处理
let isMock = config.mock;
if(typeof options.mock !== "undefined") {
isMock = options.mock;
}
// 针对环境做一个处理
if(config.env === 'prod') {
// 不能mock
service,defaults.baseURL = config.baseApi;
}else {
service.defaults.baseURL = isMock ? config.mockApi : config.baseApi
}
return service(options);
}
export default request;
\ No newline at end of file
......@@ -32,7 +32,7 @@ export const postInstantHeat = params => {
})
}
// 瞬时热量-新增修改
export const postInstantHeatUpdate = params => {
return http.post(`api/Scheduling/BizInstantaneousHeat/Update`, params).then(res => res).catch(function (error) {
console.log(error);
......@@ -59,6 +59,12 @@ export const postEnergyManageSave = params => {
})
}
// export const postEnergyManageSave = params => {
// return http.post(`/api/energy/Save`, params).then(res => res).catch(function (error) {
// console.log(error);
// })
// }
export const getWeatherMagData = () => { // 获取气象干预数据
return http.get(`/api/cusweather/getData`)
......@@ -76,6 +82,7 @@ export const getAnnualParam = () => { // 获取年度参数列表
return http.post('/api/Scheduling/BizHeatSet/Get')
}
export const alterAnnualParam = params => { // 修改年度参数
return http.post('/api/Scheduling/BizHeatSet/Update', params)
}
......@@ -113,7 +120,7 @@ export const addWind = params => { // 新增数据————风力配置
}
export const alterWind = params => { // 修改数据————风力配置
return http.post('/api/Scheduling/WindConfiguration/Update',params)
return http.post('/api/Scheduling/WindConfiguration/Update', params)
}
export const deleteWind = params => { // 删除数据————风力配置
......
const env = import.meta.env.MODE || "prod";
const EnvConfig = {
development:{
baseApi:"/api",
mockApi:"https://apifoxmock.com/m1/4068509-0-default/api/home/getTable"
},
test:{
baseApi:"//test.future.com/api",
mockApi:"https://apifoxmock.com/m1/4068509-0-default/api/home/getTable"
},
prod:{
baseApi:"//future.com/api",
mockApi:"https://apifoxmock.com/m1/4068509-0-default/api/home/getTable"
}
};
export default {
env,
...EnvConfig[env],
//mock
mock:false,
}
\ No newline at end of file
......@@ -131,8 +131,8 @@ function resetInput() {
<el-input clearable v-model="searchKey"/>
</el-col>
</el-row>
<el-button type="primary" class="add-search-btn" @click="handleAdd">新增</el-button>
<el-button type="primary" class="add-search-btn" @click="handleSearch">查询</el-button>
<el-button type="primary" class="add-search-btn" @click="handleAdd">新增</el-button>
</div>
<div class="table-wrapper">
<el-table
......
......@@ -24,6 +24,13 @@ function revise(val){
reviseForm.value = {...val}
reviseWindowOpen.value = true
} // 修改按钮单击事件
function search(){
if(!searchKey.value){
getData()
}else {
data.value = dataBackup.value.filter(item => item.phenomenonName.includes(searchKey.value))
}
}
function omit(val){
let id = val.phenomenonId
ElMessageBox.confirm(
......@@ -40,13 +47,6 @@ function omit(val){
})
}).catch(err=>{})
} // 删除按钮单击事件
function search(){
if(!searchKey.value){
getData()
}else {
data.value = dataBackup.value.filter(item => item.phenomenonName.includes(searchKey.value) )
}
}
function handleClose(){
reviseWindowOpen.value = false
addWindowOpen.value = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment