wangqiujuan0808 2024-05-11 15:15:16 +08:00
parent ac0559f5bb
commit b05fb583ed
9 changed files with 124 additions and 46 deletions

View File

@ -84,6 +84,11 @@ const infoApi = {
detP(params) {
return postPBRequest('/template', params, 53310, params.template_name)
},
//
importP(params) {
return postPBRequest('/template', params, 53310, params.template_name)
},
//
getTx(params) {
return postPBRequest('/driver', params, 54000)

View File

@ -208,15 +208,7 @@ export default {
{ required: true, validator: validName, trigger: "blur" },
],
description: [{ required: true, message: "请输入驱动描述", trigger: "blur" }],
type: [{ required: true, message: "请选择通讯驱动", trigger: "blur" }],
// com: [{ required: true, message: "COM", trigger: "blur" }],
// baudRate: [{ required: true, message: "", trigger: "blur" }],
// parity: [{ required: true, message: "", trigger: "blur" }],
// dataBits: [{ required: true, message: "", trigger: "blur" }],
// stopBits: [{ required: true, message: "", trigger: "blur" }],
// timeout: [{ required: true, message: "", trigger: "blur" }],
// port: [{ required: true, message: "", trigger: "blur" }],
// host: [{ required: true, message: "", trigger: "blur" }]
type: [{ required: true, message: "请选择通讯驱动", trigger: "blur" }]
},
});
const visible = computed(() => {
@ -269,7 +261,7 @@ export default {
ElMessage.success(res.message || "请求成功");
ctx.emit("dialogSuccess");
} else {
ElMessage.error(res.message || "请求失败");
ElMessage.error(res.data || res.message);
}
} else {
console.log("error submit!");

View File

@ -171,10 +171,6 @@ export default {
ctx.emit("dialogClose");
};
const importData = () => { };
const exportData = () => { };
const saveP = async () => {
console.log(ruleFormRef.value);
await ruleFormRef.value.validate(async (valid) => {
@ -203,8 +199,6 @@ export default {
...toRefs(state),
visible,
closeDialog,
importData,
exportData,
saveP,
ruleFormRef
};

View File

@ -2,7 +2,7 @@
<el-dialog v-model="visible" title="设备管理" width="40%" :before-close="closeDialog">
<el-form :model="addForm" label-width="100px" :rules="rules" ref="ruleFormRef">
<el-form-item label="设备名称:" prop="name">
<el-input v-model="addForm.name" placeholder="请输入点位名称" clearable :disabled="type!=='I'"/>
<el-input v-model="addForm.name" placeholder="请输入设备名称" clearable :disabled="type!=='I'"/>
</el-form-item>
<el-form-item label="设备id:" prop="id">
<el-input v-model="addForm.id" placeholder="请输入设备id:1-255" clearable type="number" />

View File

@ -0,0 +1,84 @@
<template>
<el-dialog v-model="visible" title="点位导入" width="40%" :before-close="closeDialog">
<input style="display:none" type="file" @change="uploadFile" id="fileinput1" class="fileinput" />
<label class="filelabel" for="fileinput1">上传</label>
<div class="fileName">
<span>{{ fileName }}</span>
<delete style="width: 18px; height: 18px; margin-left: 8px;" @click="delFile" v-if="fileName"/>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="closeDialog"></el-button>
<el-button type="primary" @click="saveP"> </el-button>
</span>
</template>
</el-dialog>
</template>
<script>
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
export default {
props: ["formData", "dialogVisible"],
emits: ["dialogClose", "dialogSuccess"],
setup(props, ctx) {
const state = reactive({
fileName: '',
formData: new FormData()
});
const visible = computed(() => {
return props.dialogVisible;
});
onMounted(() => {
state.addForm = props.pointData
});
const closeDialog = () => {
ctx.emit("dialogClose");
};
const saveP = async () => {
const res = await infoApi.importP(state.formData);
ctx.emit("dialogSuccess");
};
const uploadFile = (e) => {
let file = e.target.files[0];
state.fileName = file.name;
state.formData.append("file", file);
state.formData.append("folderName", file.name);
}
const delFile = () => {
state.fileName = '';
state.formData = new FormData();
}
return {
...toRefs(state),
visible,
closeDialog,
saveP,
uploadFile,
delFile
};
},
};
</script>
<style lang="scss" scoped>
.filelabel {
background: #1890ff;
border: 1px solid #1890ff;
font-weight: 500;
padding: 5px 15px 5px;
margin: 0 2px 0 6px;
border-radius: 4px;
color: #fff;
font-size: 12px;
}
.fileName {
margin: 15px 0;
font-size:16px;
}
</style>

View File

@ -20,7 +20,7 @@
</div>
</template>
<div class="nickname">
<p>登录名{{ (userInfo && userInfo.loginUserName) || "" }}</p>
<p>登录名{{ (userInfo && userInfo.nickName) || "" }}</p>
<p>昵称{{ (userInfo && userInfo.nickName) || "" }}</p>
<el-tag effect="dark" class="reStart" @click="reStart"
>重启设备</el-tag
@ -62,15 +62,12 @@ export default {
const store = useStore();
const state = reactive({
name: "dashboard",
userInfo: null,
userInfo: store.state.userInfo,
hasBack: false,
dialogVisible: false,
});
onMounted(() => {
const pathname = window.location.hash.split("/")[1] || "";
if (!["login"].includes(pathname)) {
getUserInfo();
}
});
const dialogClose = () => {
state.dialogVisible = false;
@ -79,19 +76,6 @@ export default {
const dialogSuccess = () => {
state.dialogVisible = false;
};
const getUserInfo = async () => {
// const userInfo = await myApi.getUserInfo();
// state.userInfo = userInfo
state.userInfo = {
adminUserId: 1,
locked: 0,
loginPassword: "******",
loginUserName: "admin",
nickName: "admin",
};
store.commit("setUserInfo", state.userInfo);
};
const reStart = async () => {
const res = await infoApi.reboot();
if (res.code == 0) {

View File

@ -56,9 +56,11 @@
</template>
</el-table-column>
</el-table>
<AddPoint :type="type" :formData="formData1" :pointData="pointData" :dialogVisible="dialogVisible1" v-if="dialogVisible1"
@dialogClose="dialogVisible1 = false" @dialogSuccess="dialogSuccess1">
<AddPoint :type="type" :formData="formData1" :pointData="pointData" :dialogVisible="dialogVisible1"
v-if="dialogVisible1" @dialogClose="dialogVisible1 = false" @dialogSuccess="dialogSuccess1">
</AddPoint>
<ExportPoint :formData="formData1" :dialogVisible="dialogVisible2" v-if="dialogVisible2" @dialogClose="dialogVisible2 = false"
@dialogSuccess="dialogSuccess2"></ExportPoint>
</el-drawer>
</template>
<script>
@ -66,9 +68,11 @@ import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
import AddPoint from "@/components/AddPoint.vue";
import ExportPoint from "@/components/ExportPoint.vue";
export default {
components: {
AddPoint
AddPoint,
ExportPoint
},
props: ["formData", "dialogVisible", "templateData"],
emits: ["dialogClose", "dialogSuccess"],
@ -77,6 +81,7 @@ export default {
pointData: {},
formData1: {},
dialogVisible1: false,
dialogVisible2: false,
propertiesData: [],
typeData: {
1: 'bool',
@ -184,8 +189,14 @@ export default {
getPointList();
};
const importData = () => {
const dialogSuccess2 = () => {
state.dialogVisible2 = false;
getPointList();
}
const importData = () => {
state.formData1 = props.formData;
state.dialogVisible2 = true;
}
const exportData = () => {
@ -199,6 +210,7 @@ export default {
delData,
manageData,
dialogSuccess1,
dialogSuccess2,
importData,
exportData,
editData

View File

@ -26,11 +26,14 @@ axios.interceptors.request.use(
axios.interceptors.response.use(
(res) => {
const token = res.headers["token"]
// token
for (const key in res.headers) {
if (Object.hasOwnProperty.call(res.headers, "token")) {
const token = res.headers["token"];
if (typeof (token) != "undefined") {
localSet("token", token);
}
}
}
const ret = res.data;
// token
if (ret.code === 3004) {

View File

@ -45,10 +45,12 @@ import { user, token, response } from '../proto/data/pd'
import axios from "axios";
import md5 from 'js-md5'
import { localRemove, pathMap } from "@/utils";
import { useStore } from "vuex";
export default {
name: "Login",
setup() {
const store = useStore();
const loginForm = ref(null);
const state = reactive({
ruleForm: {
@ -78,10 +80,12 @@ export default {
password: md5(state.ruleForm.password).toUpperCase(),
}
// 2.
// const send_userInfo = userInfo.slice(0, userInfo.length);
myApi.login(userInfo).then(async (res) => {
if (res.code == 0) {
let userInfo = {
nickName: state.ruleForm.username,
};
store.commit("setUserInfo", userInfo);
getLoginStatus();
} else {
ElMessage.error(res.message);