<template>
|
<div class="app-container">
|
<el-form
|
:model="queryParams"
|
ref="queryForm"
|
size="small"
|
:inline="true"
|
v-show="showSearch"
|
label-width="68px"
|
@submit.native.prevent
|
>
|
<el-form-item label="设备名称" prop="equName">
|
<el-input
|
v-model="queryParams.equName"
|
placeholder="请输入设备名称"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"
|
>搜索</el-button
|
>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-form>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="mini"
|
@click="handleAdd"
|
v-hasPermi="['system:equipment:add']"
|
>新增</el-button
|
>
|
</el-col>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
|
<el-table
|
v-loading="loading"
|
:data="equipmentList"
|
@selection-change="handleSelectionChange"
|
>
|
<!-- <el-table-column type="selection" width="55" align="center" /> -->
|
<el-table-column label="序号" align="center" type="index" />
|
<el-table-column label="码头名称" align="center" prop="whName" />
|
<el-table-column label="泊位名称" align="center" prop="beName" />
|
<el-table-column label="设备名称" align="center" prop="equName" />
|
<el-table-column label="设备类型" align="center" prop="typeName" />
|
<!-- <el-table-column label="设备详情" align="center" prop="description" /> -->
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['system:equipment:edit']"
|
>修改</el-button
|
>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['system:equipment:remove']"
|
>删除</el-button
|
>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination
|
v-show="total > 0"
|
:total="total"
|
:page.sync="queryParams.pageNum"
|
:limit.sync="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
|
<!-- 添加或修改泊位--设备对话框 -->
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form-item label="港口" prop="whId">
|
<el-select v-model="form.whId" placeholder="请选择港口" @change="getBerth">
|
<el-option
|
v-for="item in whOptions"
|
:key="item.whId"
|
:label="item.name"
|
:value="item.whId"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="泊位" prop="beId">
|
<el-select v-model="form.beId" placeholder="请选择泊位">
|
<el-option
|
v-for="item in beOptions"
|
:key="item.pkid"
|
:label="item.name"
|
:value="item.pkid"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="设备类型" prop="equTypeId">
|
<el-select v-model="form.equipmentTypeId" placeholder="菜单状态" clearable>
|
<el-option
|
v-for="(t,index) in equTypeOptions"
|
:key="index"
|
:label="t.typeName"
|
:value="t.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="设备名称" prop="equName">
|
<el-input v-model="form.equName" placeholder="请输入设备名称" />
|
</el-form-item>
|
<el-form-item label="更新时间" prop="intervalTime">
|
<el-input v-model="form.intervalTime" placeholder="请输入更新时间" />
|
</el-form-item>
|
<el-form-item label="查询时间段" prop="PERIOD_TIME">
|
<el-input v-model="form.periodTime" placeholder="请输入查询时间段" />
|
</el-form-item>
|
<el-form-item label="通信协议" prop="PROTOCOL">
|
<el-input v-model="form.protocol" placeholder="请输入通信协议" />
|
</el-form-item>
|
<el-form-item label="经度" prop="x">
|
<el-input v-model="form.x" placeholder="请输入设备经度" />
|
</el-form-item>
|
<el-form-item label="纬度" prop="y">
|
<el-input v-model="form.y" placeholder="请输入纬度" />
|
</el-form-item>
|
<el-form-item label="高度" prop="z">
|
<el-input v-model="form.z" placeholder="请输入高度" />
|
</el-form-item>
|
<el-form-item label="IP" prop="ip">
|
<el-input v-model="form.ip" placeholder="请输入IP" />
|
</el-form-item>
|
<el-form-item label="端口" prop="port">
|
<el-input-number v-model="form.port" placeholder="请输入端口" />
|
</el-form-item>
|
<el-form-item label="地址码" prop="deviceAddress">
|
<el-input-number v-model="form.deviceAddress" placeholder="请输入地址码" />
|
</el-form-item>
|
<el-form-item label="模型字段" prop="fieldName">
|
<el-input v-model="form.fieldName" placeholder="请输入模型字段" />
|
</el-form-item>
|
<!-- <el-form-item label="设备详情" prop="description">
|
<el-input
|
v-model="form.description"
|
type="textarea"
|
placeholder="请输入内容"
|
/>
|
</el-form-item> -->
|
<!-- <el-form-item label="设备图片" prop="filePath">
|
<el-upload
|
:file-list="fileList"
|
:action="uploadFileUrl"
|
list-type="picture-card"
|
:on-preview="handlePictureCardPreview"
|
:on-remove="handleRemove"
|
:on-success="handleAvatarSuccess"
|
accept=".jpg,.jpeg,.png,.rar,.zip"
|
>
|
<i class="el-icon-plus"></i>
|
</el-upload>
|
<el-dialog :visible.sync="dialogVisible">
|
<img width="100%" :src="dialogImageUrl" alt="" />
|
</el-dialog>
|
</el-form-item> -->
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import {
|
listEquipment,
|
getEquipment,
|
delEquipment,
|
addEquipment,
|
updateEquipment,
|
} from "@/api/manage/equipment";
|
import { list } from "@/api/manage/wharf";
|
import { beList } from "@/api/manage/berth";
|
import { listAll } from "@/api/manage/stock";
|
|
import { getAllEquype } from "@/api/manage/equType";
|
|
// let url = process.env.VUE_URL+'common/upload'
|
const baseUrl = process.env.VUE_APP_BASE_API;
|
|
console.log("uploadUrl", baseUrl);
|
export default {
|
name: "Equipment",
|
dicts: ["dp_equipment_type"],
|
data() {
|
return {
|
// 遮罩层
|
loading: true,
|
fileList: [],
|
dialogImageUrl: "",
|
dialogVisible: false,
|
//设备类型下拉选
|
equTypeOptions: [],
|
imageUrl: "",
|
// 选中数组
|
ids: [],
|
url: process.env.VUE_URL + "common/upload",
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 泊位--设备表格数据
|
equipmentList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 20,
|
beId: null,
|
equName: null,
|
equType: null,
|
DESCRIPTION: null,
|
filePath: null,
|
},
|
// 表单参数
|
form: {},
|
//码头选项
|
whOptions: [],
|
//泊位选项
|
beOptions: [],
|
// 表单校验
|
rules: {
|
beId: [{ required: true, message: "泊位不能为空", trigger: "blur" }],
|
whId: [{ required: true, message: "码头不能为空", trigger: "blur" }],
|
equName: [{ required: true, message: "设备名称不能为空", trigger: "blur" }],
|
equType: [{ required: true, message: "设备类型不能为空", trigger: "blur" }],
|
},
|
uploadFileUrl: baseUrl + "common/upload",
|
};
|
},
|
created() {
|
this.getList();
|
},
|
methods: {
|
/** 查询泊位--设备列表 */
|
getList() {
|
this.loading = true;
|
listEquipment(this.queryParams).then((response) => {
|
this.equipmentList = response.rows;
|
this.total = response.total;
|
this.loading = false;
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
this.imageUrl = "";
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
id: null,
|
beId: null,
|
equName: null,
|
equType: null,
|
description: null,
|
filePath: null,
|
};
|
this.resetForm("form");
|
this.fileList = [];
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.handleQuery();
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map((item) => item.ID);
|
this.single = selection.length !== 1;
|
this.multiple = !selection.length;
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
this.imageUrl = "";
|
list().then((response) => {
|
this.whOptions = response.data;
|
});
|
//获取设备类型下拉项
|
getAllEquype().then((response) => {
|
this.equTypeOptions = response.data;
|
});
|
this.open = true;
|
this.title = "添加泊位--设备";
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
getEquipment(row.id).then((response) => {
|
this.form = response.data;
|
// console.log(this.form)
|
var fileListStr = response.data.filePath;
|
if (fileListStr) {
|
if (fileListStr.endsWith(",")) {
|
this.imageUrl = fileListStr;
|
fileListStr = fileListStr.slice(0, -1); // 删除最后一个字符(逗号)
|
} else {
|
this.imageUrl = fileListStr + ",";
|
}
|
const arr = fileListStr.split(","); // 将文件路径字符串拆分成数组
|
const baseFileUrl = baseUrl.slice(0, -1);
|
this.fileList = arr.map((item, index) => ({
|
name: item.split("/").pop(), // 提取文件名
|
url: baseFileUrl + item, // 拼接完整的文件 URL
|
status: "success", // 上传状态设置为成功
|
uid: `uid-${index}`, // 使用唯一的 uid
|
}));
|
console.log(this.fileList); // 检查文件列表
|
} else {
|
this.imageUrl = "";
|
}
|
// console.log(this.form); // 检查表单数据
|
this.open = true;
|
this.title = "修改泊位--设备";
|
});
|
list().then((response) => {
|
this.whOptions = response.data;
|
});
|
beList(row.whId).then((response) => {
|
this.beOptions = response.data;
|
});
|
//获取设备类型下拉项
|
getAllEquype().then((response) => {
|
this.equTypeOptions = response.data;
|
});
|
|
},
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
if (this.form.id != null) {
|
updateEquipment(this.form).then((response) => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addEquipment(this.form).then((response) => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
this.$modal
|
.confirm('是否确认删除泊位--设备编号为"' + row.id + '"的数据项?')
|
.then(function () {
|
return delEquipment(row.id);
|
})
|
.then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {});
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download(
|
"system/equipment/export",
|
{
|
...this.queryParams,
|
},
|
`equipment_${new Date().getTime()}.xlsx`
|
);
|
},
|
|
//选中码头触发事件
|
getBerth(whId) {
|
this.form.beId = null;
|
|
beList(whId).then((response) => {
|
console.log(response);
|
this.beOptions = response.data;
|
});
|
},
|
handleRemove(file, fileList) {
|
// var fileUrl = this.imageUrl.replace(file.response.fileName + ",", "");
|
// this.form.filePath = fileUrl;
|
// console.log(this.form.filePath);
|
|
// console.log(baseUrl.slice(0, -1))
|
const remainingUrls = fileList.map((item) =>
|
item.url.replace(baseUrl.slice(0, -1), "")
|
);
|
this.form.filePath = remainingUrls.join(",");
|
this.imageUrl = remainingUrls.join(",");
|
console.log(this.form.filePath);
|
},
|
handlePictureCardPreview(file) {
|
console.log(file + "777");
|
this.dialogImageUrl = file.url;
|
this.dialogVisible = true;
|
},
|
handleAvatarSuccess(res, file) {
|
this.imageUrl += res.fileName + ",";
|
this.form.filePath = this.imageUrl;
|
console.log(this.form.filePath);
|
},
|
beforeupload(file, fileList) {
|
let types = ["image/jpeg", "image/jpg", "image/png"];
|
|
const isImage = types.includes(file.type);
|
|
const isLt20M = file.size / 1024 / 1024 < 9999999999;
|
if (!isLt20M) {
|
this.$message.error("上传头像图片大小不能超过 20MB!");
|
return false;
|
}
|
return true;
|
},
|
},
|
};
|
</script>
|