Commit c682bc98 authored by liuzhaoh's avatar liuzhaoh

设备管理

parent 8fa2603f
......@@ -107,6 +107,11 @@ service.interceptors.response.use(
) {
// 数据下沉的状态码不做报错提示
} else {
const whiteList = ['exportDeviceAndSignal']
// 判断是否是下载接口,如果是下载接口,则不进行错误提示
if (isExportUrl(whiteList, response.config.url)) {
return res
}
requestExceptCap(response.config, response.status);
const msg = res.message || res.msg || "Error";
// msg 是否包含英文字符
......@@ -196,6 +201,7 @@ service.interceptors.response.use(
* @date 2024/3/11
*/
function requestExceptCap(capData = {}, code = "Network Error") {
return
const date = new Date();
const time = format(date);
const url = "";
......@@ -261,4 +267,15 @@ function format(dataString) {
);
}
// 判断接口链接是否是导出接口
function isExportUrl (whiteList, targetUrl) {
let result = false;
for(let i = 0; i < whiteList.length; i++) {
if(targetUrl.indexOf(whiteList[i]) > -1) {
result = true;
break;
}
}
return result;
}
export default service;
......@@ -125,6 +125,18 @@ export function postDataScreen(url, data) {
});
}
export function exportFile(method, url, data) {
return request({
url: url,
method,
data,
headers: {
"Content-Type": "multipart/form-data"
},
responseType: 'blob'
});
}
// 百度坐标转高德(传入经度、纬度)
export function bd_decrypt(bd_lng, bd_lat) {
var X_PI = (Math.PI * 3000.0) / 180.0;
......
......@@ -5,22 +5,22 @@
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="工序">
<el-select
v-model="formInline.region"
v-model="formInline.productionLineId"
placeholder="请选择工序"
style="width: 120px"
clearable
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
v-for="item in processOptions"
:key="item.productionLineId"
:label="item.productionLineName"
:value="item.productionLineId"
/>
</el-select>
</el-form-item>
<el-form-item label="除尘器名称">
<el-input
v-model="formInline.deviceName"
v-model="formInline.dusterName"
placeholder="请输入除尘器名称"
style="width: 240px"
clearable
......@@ -36,34 +36,54 @@
</el-form-item>
<el-form-item label="设备类型">
<el-select
v-model="formInline.region"
v-model="formInline.deviceTypeId"
placeholder="请选择工序"
style="width: 120px"
clearable
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
v-for="item in deviceTypeEnum"
:key="item.deviceTypeId"
:label="item.deviceType"
:value="item.deviceTypeId"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="default" class="default-btn" @click="onSubmit"
<el-button type="default" class="default-btn" @click="onReset"
>重置</el-button
>
<el-button type="primary" class="search-btn" @click="onSubmit"
<el-button
type="primary"
class="search-btn margin-right-10"
@click="onQuery"
>查询</el-button
>
<el-button type="success" class="add-btn" @click="onSubmit"
>导入</el-button
<el-upload
ref="upload"
class="upload-demo"
:action="uploadUrl"
:on-exceed="handleExceed"
:on-error="handleError"
:on-success="handleSuccess"
:on-progress="handleProgress"
:before-upload="beforeUpload"
:headers="{
token: getToken('TOKEN'),
}"
>
<el-button type="success" class="add-btn" @click="onSubmit"
<el-button type="success" class="add-btn margin-right-10"
>导入</el-button
>
</el-upload>
<el-button type="success" class="add-btn" @click="onExportFile"
>导出</el-button
>
<el-button type="success" class="add-btn" @click="onSubmit"
<el-button
type="success"
class="add-btn"
@click="onDownloadTemplate"
>模板下载</el-button
>
</el-form-item>
......@@ -75,6 +95,7 @@
:columns="tableColumns"
:default-page-size="10"
@pagination-change="handlePaginationChange"
:total="total"
:pagination-texts="{
total: '共',
sizeChange: '条/页',
......@@ -102,48 +123,33 @@
</div>
</template>
<script setup>
import { ref, reactive } from "vue";
import { ref, reactive, onMounted } from "vue";
import { ElMessage } from "element-plus";
import setParamsDialog from "./components/paramsSetings.vue";
import CommonTable from "@/components/commonTable/index.vue";
import "@/css/elementUiSelf.css";
import { getDataFun, exportFile } from "@/request/method.js";
import { getToken } from "@/utils/auth";
const ENV = import.meta.env;
const uploadUrl = ENV.VITE_APP_BASE_API5 + "/importDeviceAndSignal";
const currentPage = ref(1);
const pageSize = ref(10);
const total = ref(0);
const getIndex = (index) => {
return (currentPage.value - 1) * pageSize.value + index + 1;
};
const formInline = reactive({
user: "",
region: "",
date: "",
let formInline = reactive({
deviceName: "",
dusterName: "",
deviceTypeId: " ",
productionLineId: " ",
});
const onSubmit = () => {
console.log("submit!");
};
const tableData = [
{
date: "2016-05-03",
name: "Tom",
address: "No. 189, Grove St, Los Angeles",
},
{
date: "2016-05-02",
name: "Tom",
address: "No. 189, Grove St, Los Angeles",
},
{
date: "2016-05-04",
name: "Tom",
address: "No. 189, Grove St, Los Angeles",
},
{
date: "2016-05-01",
name: "Tom",
address: "No. 189, Grove St, Los Angeles",
},
];
const tableData = ref([]);
const tableColumns = ref([
{
prop: "index",
......@@ -151,42 +157,42 @@ const tableColumns = ref([
width: "5%",
},
{
prop: "deviceName",
prop: "dusterName",
label: "除尘器名称",
width: "15%",
},
{
prop: "deviceName",
prop: "dusterNo",
label: "除尘器编号",
width: "15%",
},
{
prop: "process",
prop: "productionLine",
label: "所属工序",
width: "5%",
},
{
prop: "healthScore",
prop: "deviceName",
label: "设备名称",
width: "5%",
},
{
prop: "health2Score",
prop: "deviceTypeDesc",
label: "设备类型",
width: "5%",
},
{
prop: "status",
prop: "signalName",
label: "信号名称",
width: "25%",
},
{
prop: "alarmCount",
prop: "signalNo",
label: "信号编码",
width: "5%",
},
{
prop: "lastAlarmTime",
prop: "position",
label: "安装位置",
width: "10%",
},
......@@ -203,6 +209,170 @@ const setParams = () => {
const closeDialog = (val) => {
dialogVisible.value = val;
};
// 工序
const processOptions = ref([
{ productionLineId: " ", productionLineName: "全部" },
]);
// 获取工序
const getProcessOptions = () => {
const url = "/transaction/getProductionLine";
const params = {
branchFactoryId: getToken("dataBranchFactoryId"),
};
getDataFun(url, params)
.then((res) => {
res.data.forEach((item) => {
processOptions.value.push(item);
});
})
.catch((err) => {
processOptions.value = [
{ productionLineId: "", productionLineName: "全部" },
];
});
};
// 设备类型枚举值
const deviceTypeEnum = ref([{ deviceType: "全部", deviceTypeId: " " }]);
// 获取设备类型
const getDeviceType = () => {
const url = "/getDcTomDeviceType";
const params = {};
getDataFun(url, params)
.then((res) => {
res.data.forEach((element) => {
deviceTypeEnum.value.push(element);
});
})
.catch((err) => {
deviceTypeEnum.value = [{ deviceType: "全部", deviceTypeId: "" }];
});
};
// 获取设备列表
const getDeviceContent = () => {
const url = "/getPageDcTomDeviceResp";
const params = {
pageSize: pageSize.value, // 当前页数据条数
pageNo: currentPage.value, // 当前页页码
customerId: getToken("customerId"), // 客户ID
deviceName: formInline.deviceName, // 设备名称
dusterName: formInline.dusterName, // 除尘器名称
deviceTypeId: formInline.deviceTypeId, // 设备类型
productionLineId: formInline.productionLineId, // 工艺
};
getDataFun(url, params)
.then((res) => {
tableData.value = (res && res.data && res.data.records) || [];
total.value = res.data.total || 0;
})
.catch((err) => {
tableData.value = [];
total.value = 0;
});
};
// 重置
const onReset = () => {
formInline = {
deviceName: "",
dusterName: "",
deviceTypeId: " ",
productionLineId: " ",
};
pageSize.value = 10;
currentPage.value = 1;
getDeviceContent();
};
// 查询
const onQuery = () => {
getDeviceContent();
};
// 导入
const onImportFile = () => {
const url = "/importDeviceAndSignal";
const params = {
customerId: getToken("customerId"), // 客户ID
deviceName: formInline.deviceName, // 设备名称
dusterName: formInline.dusterName, // 除尘器名称
deviceTypeId: formInline.deviceTypeId, // 设备类型
productionLineId: formInline.productionLineId, // 工艺
};
};
// 导出
const onExportFile = () => {
const url = "/exportDeviceAndSignal";
const params = {};
exportFile("get", url, params).then((res) => {
const blob = res;
// 创建 URL 对象
const url = URL.createObjectURL(blob);
// 创建临时 <a> 元素
const a = document.createElement("a");
a.href = url;
a.download = `设备数据.xls`; // 设置下载的文件名
// 模拟点击下载
document.body.appendChild(a);
a.click();
// 清理资源
document.body.removeChild(a);
URL.revokeObjectURL(url);
});
};
// 模板下载
const onDownloadTemplate = () => {};
// 页面参数改变
const handlePaginationChange = (pagination) => {
currentPage.value = pagination.currentPage;
pageSize.value = pagination.pageSize;
getDeviceContent();
};
// 当超出限制时,执行的钩子函数
const handleExceed = (files) => {
console.log("上传超出限制");
// upload.value!.clearFiles()
// const file = files[0] as UploadRawFile
// file.uid = genFileId()
// upload.value!.handleStart(file)
};
// 上传失败
const handleError = () => {
ElMessage({
message: "文件上传失败",
type: "error",
duration: 5 * 1000,
});
};
const handleSuccess = () => {
ElMessage({
message: "文件上传成功",
type: "success",
duration: 5 * 1000,
});
};
const handleProgress = (evt, uploadFile) => {};
const beforeUpload = (file) => {
console.log(file);
if (
file.type !== "application/vnd.ms-excel" &&
file.type !==
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
) {
ElMessage({
message: "请上传excel文件",
type: "primary",
duration: 5 * 1000,
});
return false;
} else {
return true;
}
};
onMounted(() => {
getDeviceType();
getProcessOptions();
getDeviceContent();
});
</script>
<style lang="scss" scoped>
......@@ -225,7 +395,23 @@ const closeDialog = (val) => {
}
}
}
.default-btn {
width: 85px;
}
.search-btn {
width: 85px;
background: #2182a0;
border: 1px solid #2182a0;
}
.add-btn {
width: 85px;
}
.margin-right-10 {
margin-right: 10px;
}
</style>
<style scoped>
/* @import "./elementUiSelf.css"; */
<style>
.equipment-management .el-upload-list {
display: none;
}
</style>
\ No newline at end of file
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