Browse Source

合并框架接口取值

zswxt
lzp 4 months ago
parent
commit
4c376458ef
  1. 2
      src/api/login.js
  2. 119
      src/api/school.js
  3. 15
      src/store/modules/user.js
  4. 120
      src/views/index.vue
  5. 2
      src/views/login.vue
  6. 2
      vue.config.js

2
src/api/login.js

@ -9,7 +9,7 @@ export function login(username, password, code, uuid) {
uuid,
};
return request({
url: "/login",
url: "/app/user/login",
headers: {
isToken: false,
repeatSubmit: false,

119
src/api/school.js

@ -1,116 +1,41 @@
import request from "@/utils/request";
// ------ 教务处学校管理 ------
// 学校列表
export function schoolList(data) {
// 获取设备信息
export function attributes(data) {
return request({
url: "/school/list",
method: "post",
data: data,
});
}
// 新增/修改学校
export function schoolAdd(data) {
return request({
url: "/school/add",
method: "post",
data: data,
});
}
// 新增/修改学校
export function schoolDel(data) {
return request({
url: "/school/del",
method: "post",
data: data,
url: "/app/device/attributes",
method: "get",
params: data,
});
}
// ------ 教务处评审管理 ------
// 评审列表
export function commentList(data) {
// 根据项目key查找项目id
export function queryProjectInfoByKey(data) {
return request({
url: "/come/list",
method: "post",
data: data,
});
}
// 评审详情
export function reviewDetails(data) {
return request({
url: "/come/detail",
method: "post",
data: data,
url: "/app/device/queryProjectInfoByKey",
method: "get",
params: data,
});
}
// ------ 专家评审 ------
// 学校列表
export function expertschoolist(data) {
// 根据项目id查找设备列表
export function deviceList(data) {
return request({
url: "/expert/school/list",
method: "post",
data: data,
url: "/app/device/list",
method: "get",
params: data,
});
}
// 评审详情
export function expertReviewDetails(data) {
// 下发属性
export function sendAttribute(data) {
return request({
url: "/expert/comment/list",
url: "/app/device/sendAttribute",
method: "post",
data: data,
});
}
// 评审
export function expertReviewAdd(data) {
// 下发命令
export function sendCommand(data) {
return request({
url: "/expert/comment/add",
url: "/app/device/sendCommand",
method: "post",
data: data,
});
}
// ------ 分片相关接口 ------
// 校验文件是否已上传
export function register(data) {
return request({
url: "/mediaUpload/register",
method: "post",
data: data,
});
}
// 校验分片是否已上传
export function checkchunk(data) {
return request({
url: "/mediaUpload/checkchunk",
method: "post",
data: data,
});
}
// 循环上传分片
export function uploadchunk(data) {
return request({
url: "/mediaUpload/uploadchunk",
method: "post",
data: data,
headers: {
"Content-Type": "multipart/form-data",
},
});
}
// 合并分片
export function mergechunks(data) {
return request({
url: "/mediaUpload/mergechunks",
method: "post",
data: data,
});
}
// 合并后上传文件
export function addFile(data) {
return request({
url: "/netdisk/file/add",
method: "post",
data: data,
});
}
}

15
src/store/modules/user.js

@ -43,8 +43,10 @@ const user = {
const uuid = userInfo.uuid
return new Promise((resolve, reject) => {
login(username, password, code, uuid).then(res => {
setToken(res.token)
commit('SET_TOKEN', res.token)
console.log('res.data',res.data);
setToken(res.data.token)
commit('SET_TOKEN', res.data.token)
resolve()
}).catch(error => {
reject(error)
@ -56,14 +58,15 @@ const user = {
GetInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getInfo().then(res => {
const user = res.user
console.log('获取用户信息',res);
const user = res.data.user
let avatar = user.avatar || ""
if (!isHttp(avatar)) {
avatar = (isEmpty(avatar)) ? defAva : process.env.VUE_APP_BASE_API + avatar
}
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
commit('SET_ROLES', res.roles)
commit('SET_PERMISSIONS', res.permissions)
if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
commit('SET_ROLES', res.data.roles)
commit('SET_PERMISSIONS', res.data.permissions)
} else {
commit('SET_ROLES', ['ROLE_DEFAULT'])
}

120
src/views/index.vue

@ -1,31 +1,50 @@
<template>
<div style="padding: 16px;min-height: calc(100vh - 84px);display: flex; justify-content: center;align-items: center;">
<div v-loading="loading"
style="padding: 16px;min-height: calc(100vh - 84px);display: flex; justify-content: center;align-items: center;">
<div class="div-box">
<div class="div-box-title"> 智能生猪饲喂系统 </div>
<div class="div-ul">
<div class="div-li">
<div>
<<<<<<< HEAD
<span>当前饲料重量</span>15kg
=======
<span>温度</span>{{ deviceInfo.temperature }}
</div>
<div>
<span>报警器</span>
<el-switch disabled v-model="value2" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
>>>>>>> znsw
</div>
</div>
<!-- ON开启 OFF关闭 -->
<div class="div-li">
<div>
<<<<<<< HEAD
<span>电池状态</span>
<el-switch v-model="value2" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
=======
<span>加热器</span>
<el-switch disabled v-model="value2" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</div>
<div class="div-tips">
<span>阈值设定</span>{{ deviceInfo.threshold }} <i class="el-icon-edit"
style="color: rgb(64, 158, 255);margin-left: 4px;cursor: pointer;" @click="handleSettings"></i>
>>>>>>> znsw
</div>
</div>
</div>
<div class="div-tips"><span>阈值设定</span>30 <i class="el-icon-edit"
style="color: rgb(64, 158, 255);margin-left: 4px;cursor: pointer;" @click="handleSettings"></i></div>
</div>
<!-- 添加或修改公告对话框 -->
<el-dialog title="阈值设定" :visible.sync="open" width="780px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="阈值" prop="noticeTitle">
<el-input v-model="form.noticeTitle" placeholder="请输入阈值" />
<el-form-item label="阈值" prop="threshold">
<el-input v-model="form.threshold" placeholder="请输入阈值" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -37,46 +56,104 @@
</template>
<script>
import { updateNotice } from "@/api/system/notice";
import { queryProjectInfoByKey, deviceList, attributes, sendAttribute, sendCommand } from "@/api/school";
export default {
name: "Index",
data() {
return {
deviceId: "", // id
deviceInfo: {
temperature: 0, //
threshold: 0, //
},
open: false,
value2: false,
loading: false,
//
form: {},
//
rules: {
noticeTitle: [
{ required: true, message: "公告标题不能为空", trigger: "blur" }
threshold: [
{ required: true, message: "阈值不能为空", trigger: "blur" }
],
noticeType: [
{ required: true, message: "公告类型不能为空", trigger: "change" }
]
},
//
version: "3.8.9",
};
},
created() {
this.getqueryProjectInfoByKey() // keyid
},
methods: {
//
handleSettings() {
this.open = true;
this.form = {
noticeTitle: "30",
threshold: this.deviceInfo.threshold,
};
// this.$message.success('');
},
/** 提交按钮 */
submitForm: function() {
// keyid
getqueryProjectInfoByKey() {
this.loading = true;
queryProjectInfoByKey({
projectKey: "qKStHKKt"
}).then(res => {
this.getDeviceList(res.data.id) // id
});
},
// id
getDeviceList(_id) {
deviceList({
projectId: _id
}).then(res => {
const w2Device = res.rows.find(device => device.deviceName === "W2");
this.deviceId = w2Device.id;
this.getAttributes(this.deviceId); // id
})
},
// id
getAttributes(_id) {
attributes({
deviceId: _id,
}).then(res => {
this.loading = false;
// deviceInfo
let deviceAttributeRecordList = res.data.deviceAttributeRecordList
let temperature = deviceAttributeRecordList.find(row => row.id === 447236074165760).attributeValue;
let threshold = deviceAttributeRecordList.find(row => row.id === 447236078508288).attributeValue;
// threshold
if (threshold.indexOf("#") !== -1) {
threshold = threshold.slice(1); // #
}
this.deviceInfo = {
temperature: temperature,
threshold: threshold,
}
//
this.value2 = false;
if (temperature < threshold) {
this.value2 = true;
}
});
},
/** 下发属性 */
submitForm: function () {
this.$refs["form"].validate(valid => {
if (valid) {
updateNotice(this.form).then(response => {
this.$modal.msgSuccess("操作成功");
this.open = false;
this.getList();
});
let param = {"Wen":`#${this.form.threshold}`} //
sendAttribute({
"attributeParams": JSON.stringify(param), // JSON
"deviceId": this.deviceId // id
}).then(response => {
this.getAttributes(this.deviceId); // id
this.$modal.msgSuccess("操作成功");
this.open = false;
});
}
});
},
@ -86,6 +163,7 @@ export default {
<style scoped lang="scss">
.div-box {
transform: scale(1.4);
width: 500px;
box-sizing: border-box;
padding: 16px;
@ -125,6 +203,10 @@ export default {
}
}
.div-li:last-child {
margin-bottom: 0;
}
.div-tips {
font-size: 18px;
line-height: 22px;

2
src/views/login.vue

@ -139,7 +139,7 @@ export default {
this.captchaEnabled =
res.captchaEnabled === undefined ? true : res.captchaEnabled;
if (this.captchaEnabled) {
this.codeUrl = "data:image/gif;base64," + res.img;
this.codeUrl = "data:image/gif;base64," + res.data.img;
this.loginForm.uuid = res.uuid;
}
});

2
vue.config.js

@ -40,7 +40,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `https://test.tall.wiki/commen/`,
target: `http://121.37.81.216/multimodal/`,
changeOrigin: true,
pathRewrite: {
["^" + process.env.VUE_APP_BASE_API]: "",

Loading…
Cancel
Save