|
@@ -81,7 +81,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="state" align="center" label="状态" width="100">
|
|
|
<template slot-scope="{ row }">
|
|
|
- {{ row.state == 1 ? '启用' : '停用' }}
|
|
|
+ {{ row.state == 1 ? "启用" : "停用" }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="createTime" align="center" label="创建时间">
|
|
@@ -141,62 +141,51 @@
|
|
|
<el-dialog
|
|
|
:title="title"
|
|
|
:visible.sync="nuedialog"
|
|
|
- width="860px"
|
|
|
+ width="520px"
|
|
|
@close="resetForm"
|
|
|
+
|
|
|
>
|
|
|
- <div class="addition">
|
|
|
- <span @click="addition">
|
|
|
- <SvgIcons
|
|
|
- name="jia"
|
|
|
- class="jia"
|
|
|
- width="20px"
|
|
|
- height="22px"
|
|
|
- color="#222"
|
|
|
- ></SvgIcons>
|
|
|
- </span>
|
|
|
- <span @click="subtraction">
|
|
|
- <SvgIcons
|
|
|
- name="jian"
|
|
|
- class="jian"
|
|
|
- width="20px"
|
|
|
- height="22px"
|
|
|
- color="#222"
|
|
|
- ></SvgIcons>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- <div class="general">
|
|
|
- <div class="condition">
|
|
|
- <p>测风塔名称:</p>
|
|
|
- <el-input v-model="anemometerName"></el-input>
|
|
|
- </div>
|
|
|
- <div class="condition">
|
|
|
- <p>经度:</p>
|
|
|
- <el-input v-model="latitude"></el-input>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="condition">
|
|
|
- <p>纬度:</p>
|
|
|
- <el-input v-model="longitude"></el-input>
|
|
|
- </div>
|
|
|
- <div
|
|
|
- v-for="(tower, index) in anemometerTowerHeightDtoList || [
|
|
|
- { anemometerHeight: '' }
|
|
|
- ]"
|
|
|
+ <el-form
|
|
|
+ :model="dynamicValidateForm"
|
|
|
+ ref="dynamicValidateForm"
|
|
|
+ label-width="100px"
|
|
|
+ class="demo-dynamic"
|
|
|
+ :rules="rules"
|
|
|
+ >
|
|
|
+ <el-form-item prop="anemometerName" label="测风塔名称">
|
|
|
+ <el-input v-model="dynamicValidateForm.anemometerName"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="longitude" label="经度">
|
|
|
+ <el-input v-model="dynamicValidateForm.longitude"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="latitude" label="纬度">
|
|
|
+ <el-input v-model="dynamicValidateForm.latitude"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ v-for="(
|
|
|
+ tower, index
|
|
|
+ ) in dynamicValidateForm.anemometerTowerHeightDtoList"
|
|
|
+ :label="'测风塔高度' + (index + 1)"
|
|
|
:key="index"
|
|
|
- class="condition"
|
|
|
+ :prop="'anemometerTowerHeightDtoList.' + index + '.anemometerHeight'"
|
|
|
+ :rules="[
|
|
|
+ { required: true, message: '请输入测风塔高度', trigger: 'blur' },
|
|
|
+ { validator: validateUniqueHeight, trigger: 'blur' },
|
|
|
+ ]"
|
|
|
>
|
|
|
- <p>测风塔高度{{ index + 1 }}:</p>
|
|
|
- <el-input
|
|
|
- v-model="tower.anemometerHeight"
|
|
|
- placeholder="请输入测风塔高度"
|
|
|
- ></el-input>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <el-input v-model="tower.anemometerHeight"></el-input>
|
|
|
+ <el-button v-if="index > 0" @click.prevent="removeTower(index)"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="nuedialog = false" size="small">取 消</el-button>
|
|
|
- <el-button type="primary" @click="newly" size="small">确 定</el-button>
|
|
|
- </span>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="submitForm('dynamicValidateForm')"
|
|
|
+ >提交</el-button
|
|
|
+ >
|
|
|
+ <el-button @click="addDomain">新增测风塔高度</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 测风塔详情 -->
|
|
@@ -205,7 +194,7 @@
|
|
|
<p>测风塔编号:{{ hightower.anemometerCode }}</p>
|
|
|
<p>经度:{{ hightower.longitude }}</p>
|
|
|
<p>维度:{{ hightower.latitude }}</p>
|
|
|
- <p>状态: {{ hightower.state === 1 ? '启用' : '停用' }}</p>
|
|
|
+ <p>状态: {{ hightower.state === 1 ? "启用" : "停用" }}</p>
|
|
|
<p v-for="(item, index) in cftList" :key="index">
|
|
|
测风塔高度:{{ item.anemometerHeight }}米
|
|
|
</p>
|
|
@@ -220,29 +209,38 @@ import {
|
|
|
getAnemometerTower,
|
|
|
getAnemometerTowerPage,
|
|
|
updateAnemometerTower,
|
|
|
- updateAnemometerTowerState
|
|
|
-} from '@/api/ledger.js'
|
|
|
+ updateAnemometerTowerState,
|
|
|
+} from "@/api/ledger.js";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
tableData: [],
|
|
|
formInline: {
|
|
|
- anemometerName: '',
|
|
|
+ anemometerName: "",
|
|
|
timeQuantum: [],
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
- totalSize: 0
|
|
|
+ totalSize: 0,
|
|
|
},
|
|
|
- startDate: '',
|
|
|
- endDate: '',
|
|
|
+ startDate: "",
|
|
|
+ endDate: "",
|
|
|
// 新增测风塔信息
|
|
|
- anemometerName: '',
|
|
|
- latitude: '',
|
|
|
- longitude: '',
|
|
|
+
|
|
|
+ dynamicValidateForm: {
|
|
|
+ anemometerTowerHeightDtoList: [
|
|
|
+ {
|
|
|
+ anemometerHeight: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ anemometertower: "",
|
|
|
+ longitude: "",
|
|
|
+ latitude: "",
|
|
|
+ },
|
|
|
+
|
|
|
anemometerTowerHeightDtoList: [
|
|
|
{
|
|
|
- anemometerHeight: ''
|
|
|
- }
|
|
|
+ anemometerHeight: "",
|
|
|
+ },
|
|
|
],
|
|
|
errors: [],
|
|
|
hightower: [],
|
|
@@ -250,28 +248,41 @@ export default {
|
|
|
// 新增信息
|
|
|
nuedialog: false,
|
|
|
unusualdialog: false,
|
|
|
- title: '',
|
|
|
+ title: "",
|
|
|
isEdit: false,
|
|
|
- detail: {}
|
|
|
- }
|
|
|
+ detail: {},
|
|
|
+ rules: {
|
|
|
+ anemometerName: [
|
|
|
+ { required: true, message: "请输入测风塔名称", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ longitude: [
|
|
|
+ { required: true, message: "请输入经度", trigger: "blur" },
|
|
|
+ { validator: this.validateNumber, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ latitude: [
|
|
|
+ { required: true, message: "请输入纬度", trigger: "blur" },
|
|
|
+ { validator: this.validateNumber, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ };
|
|
|
},
|
|
|
created() {
|
|
|
- this.onSubmit()
|
|
|
+ this.onSubmit();
|
|
|
},
|
|
|
methods: {
|
|
|
rowStyle() {
|
|
|
- return 'text-align:center'
|
|
|
+ return "text-align:center";
|
|
|
},
|
|
|
onDateChange(date) {
|
|
|
if (Array.isArray(date)) {
|
|
|
- this.startDate = this.$formatDate(date[0])
|
|
|
- this.endDate = this.$formatDate(date[1])
|
|
|
+ this.startDate = this.$formatDate(date[0]);
|
|
|
+ this.endDate = this.$formatDate(date[1]);
|
|
|
if (this.endDate < this.startDate) {
|
|
|
- this.endDate = this.startDate
|
|
|
+ this.endDate = this.startDate;
|
|
|
}
|
|
|
} else {
|
|
|
- this.startDate = null
|
|
|
- this.endDate = null
|
|
|
+ this.startDate = null;
|
|
|
+ this.endDate = null;
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -282,194 +293,195 @@ export default {
|
|
|
beginTime: this.startDate || undefined,
|
|
|
endTime: this.endDate || undefined,
|
|
|
pageNum: this.formInline.pageNum,
|
|
|
- pageSize: this.formInline.pageSize
|
|
|
- }
|
|
|
+ pageSize: this.formInline.pageSize,
|
|
|
+ };
|
|
|
getAnemometerTowerPage(paramsData).then((res) => {
|
|
|
- this.tableData = res.data.list
|
|
|
- this.formInline.totalSize = res.data.totalSize
|
|
|
- })
|
|
|
+ this.tableData = res.data.list;
|
|
|
+ this.formInline.totalSize = res.data.totalSize;
|
|
|
+ });
|
|
|
},
|
|
|
// 重置
|
|
|
reset() {
|
|
|
- this.formInline.anemometerName = ''
|
|
|
- this.formInline.timeQuantum = []
|
|
|
- this.endDate = ''
|
|
|
- this.startDate = ''
|
|
|
+ this.formInline.anemometerName = "";
|
|
|
+ this.formInline.timeQuantum = [];
|
|
|
+ this.endDate = "";
|
|
|
+ this.startDate = "";
|
|
|
},
|
|
|
// 重置
|
|
|
resetForm() {
|
|
|
- this.anemometerName = ''
|
|
|
- this.latitude = ''
|
|
|
- this.longitude = ''
|
|
|
- this.anemometerTowerHeightDtoList = [
|
|
|
- {
|
|
|
- anemometerHeight: ''
|
|
|
- }
|
|
|
- ]
|
|
|
+ Object.assign(this.$data.dynamicValidateForm, this.$options.data().dynamicValidateForm);
|
|
|
},
|
|
|
//打开新增
|
|
|
newnuedialog() {
|
|
|
- this.nuedialog = true
|
|
|
- this.title = '新增'
|
|
|
- },
|
|
|
- // 新增提交
|
|
|
- newly() {
|
|
|
- const isEmptyAnemometerHeight = this.anemometerTowerHeightDtoList.some(
|
|
|
- (tower) =>
|
|
|
- !tower.anemometerHeight || !tower.anemometerHeight.toString().trim()
|
|
|
- )
|
|
|
-
|
|
|
- if (isEmptyAnemometerHeight) {
|
|
|
- this.$message({
|
|
|
- message: '测风塔高度不能为空',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // Other validation checks
|
|
|
- if (!this.anemometerName) {
|
|
|
- this.$message({
|
|
|
- message: '请填写测风塔名称',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (!this.latitude) {
|
|
|
- this.$message({
|
|
|
- message: '请填写纬度',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (!this.longitude) {
|
|
|
- this.$message({
|
|
|
- message: '请填写经度',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- let paramsData = {
|
|
|
- anemometerName: this.anemometerName,
|
|
|
- latitude: this.latitude,
|
|
|
- longitude: this.longitude,
|
|
|
- }
|
|
|
- if (!this.isEdit) {
|
|
|
- paramsData.anemometerTowerHeightDtoList=this.anemometerTowerHeightDtoList
|
|
|
- createAnemometerTower(paramsData).then((res) => {
|
|
|
- this.nuedialog = false
|
|
|
- this.$message.success('新增成功')
|
|
|
- this.onSubmit()
|
|
|
- })
|
|
|
- } else {
|
|
|
- paramsData.anemometerTowerHeightListDtos=this.anemometerTowerHeightDtoList
|
|
|
- paramsData.anemometerCode = this.detail.anemometerCode
|
|
|
- // delete objectval.parentCode
|
|
|
- updateAnemometerTower(paramsData).then((res) => {
|
|
|
- this.isEdit = false
|
|
|
- this.nuedialog = false
|
|
|
- this.onSubmit()
|
|
|
- this.$message.success('编辑成功')
|
|
|
- })
|
|
|
- }
|
|
|
- this.resetForm()
|
|
|
+ this.nuedialog = true;
|
|
|
+ this.title = "新增";
|
|
|
},
|
|
|
|
|
|
// 查看详情
|
|
|
particulars(row) {
|
|
|
getAnemometerTower({ anemometerCode: row.anemometerCode }).then((res) => {
|
|
|
- this.hightower = res.data
|
|
|
- this.cftList = res.data.list
|
|
|
- })
|
|
|
- this.unusualdialog = true
|
|
|
+ this.hightower = res.data;
|
|
|
+ this.cftList = res.data.list;
|
|
|
+ });
|
|
|
+ this.unusualdialog = true;
|
|
|
},
|
|
|
// 启用/停用
|
|
|
start(row, type) {
|
|
|
let objectval = {
|
|
|
anemometerCode: row.anemometerCode,
|
|
|
- state: type === 0 ? 0 : 1
|
|
|
- }
|
|
|
+ state: type === 0 ? 0 : 1,
|
|
|
+ };
|
|
|
updateAnemometerTowerState(objectval).then((res) => {
|
|
|
this.$message({
|
|
|
- message: '状态已更新成功',
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
+ message: "状态已更新成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
// this.$message(`${type === 1 ? '状态已更新成功' : '状态已更新成功'}`);
|
|
|
- row.state = type === 1 ? 0 : 1
|
|
|
- this.onSubmit()
|
|
|
- })
|
|
|
+ row.state = type === 1 ? 0 : 1;
|
|
|
+ this.onSubmit();
|
|
|
+ });
|
|
|
},
|
|
|
// 删除
|
|
|
deleted(row) {
|
|
|
- console.log(row, 'row')
|
|
|
- if (row.state == '1') {
|
|
|
+ console.log(row, "row");
|
|
|
+ if (row.state == "1") {
|
|
|
this.$message({
|
|
|
- type: 'error',
|
|
|
- message: '该项处于启用状态,无法删除!'
|
|
|
- })
|
|
|
- return
|
|
|
+ type: "error",
|
|
|
+ message: "该项处于启用状态,无法删除!",
|
|
|
+ });
|
|
|
+ return;
|
|
|
}
|
|
|
- this.$confirm('此操作将永久删除该文件,是否继续?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
+ this.$confirm("此操作将永久删除该文件,是否继续?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
})
|
|
|
.then(() => {
|
|
|
delAnemometerTower({ anemometerCode: row.anemometerCode }).then(
|
|
|
(res) => {
|
|
|
- this.onSubmit()
|
|
|
+ this.onSubmit();
|
|
|
// 执行删除操作
|
|
|
this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
- })
|
|
|
+ type: "success",
|
|
|
+ message: "删除成功!",
|
|
|
+ });
|
|
|
}
|
|
|
- )
|
|
|
+ );
|
|
|
})
|
|
|
.catch(() => {
|
|
|
// 取消删除
|
|
|
this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '已取消删除'
|
|
|
- })
|
|
|
- })
|
|
|
+ type: "info",
|
|
|
+ message: "已取消删除",
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
// 编辑
|
|
|
compile(row) {
|
|
|
- this.title = '编辑'
|
|
|
- this.isEdit = true
|
|
|
+ this.title = "编辑";
|
|
|
+ this.isEdit = true;
|
|
|
getAnemometerTower({ anemometerCode: row.anemometerCode }).then((res) => {
|
|
|
- this.hightower = res.data
|
|
|
- this.cftList = res.data.list
|
|
|
- const item = JSON.parse(JSON.stringify(res.data))
|
|
|
- this.detail = item
|
|
|
- this.anemometerName = item.anemometerName
|
|
|
- this.latitude = item.latitude
|
|
|
- this.longitude = item.longitude
|
|
|
- this.anemometerTowerHeightDtoList = this.cftList
|
|
|
- this.nuedialog = true
|
|
|
- })
|
|
|
+ this.hightower = res.data;
|
|
|
+ this.cftList = res.data.list;
|
|
|
+ const item = JSON.parse(JSON.stringify(res.data));
|
|
|
+ this.detail = item;
|
|
|
+ this.dynamicValidateForm.anemometerName = item.anemometerName;
|
|
|
+ this.dynamicValidateForm.latitude = item.latitude;
|
|
|
+ this.dynamicValidateForm.longitude = item.longitude;
|
|
|
+ this.dynamicValidateForm.anemometerTowerHeightDtoList = this.cftList;
|
|
|
+ this.nuedialog = true;
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
//分页数据切换
|
|
|
handleCurrentChange(val) {
|
|
|
- this.formInline.pageNum = val
|
|
|
- this.onSubmit()
|
|
|
+ this.formInline.pageNum = val;
|
|
|
+ this.onSubmit();
|
|
|
},
|
|
|
|
|
|
- // 测风塔高度
|
|
|
- addition() {
|
|
|
- this.anemometerTowerHeightDtoList.push({ anemometerHeight: '' })
|
|
|
+ // 修改的
|
|
|
+ submitForm(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (!valid) {
|
|
|
+ this.$message.error("请填写必填项");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let paramsData = {
|
|
|
+ anemometerName: this.dynamicValidateForm.anemometerName,
|
|
|
+ latitude: this.dynamicValidateForm.latitude,
|
|
|
+ longitude: this.dynamicValidateForm.longitude,
|
|
|
+ };
|
|
|
+
|
|
|
+ if (!this.isEdit) {
|
|
|
+ paramsData.anemometerTowerHeightDtoList =
|
|
|
+ this.dynamicValidateForm.anemometerTowerHeightDtoList;
|
|
|
+ createAnemometerTower(paramsData).then((res) => {
|
|
|
+ this.nuedialog = false;
|
|
|
+ this.$message.success("新增成功");
|
|
|
+ this.onSubmit();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ paramsData.anemometerTowerHeightListDtos =
|
|
|
+ this.dynamicValidateForm.anemometerTowerHeightDtoList;
|
|
|
+ paramsData.anemometerCode = this.detail.anemometerCode;
|
|
|
+ updateAnemometerTower(paramsData).then((res) => {
|
|
|
+ this.isEdit = false;
|
|
|
+ this.nuedialog = false;
|
|
|
+ this.onSubmit();
|
|
|
+ this.$message.success("编辑成功");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // xz
|
|
|
+ addDomain() {
|
|
|
+ this.dynamicValidateForm.anemometerTowerHeightDtoList.push({
|
|
|
+ anemometerHeight: "",
|
|
|
+ });
|
|
|
},
|
|
|
- subtraction() {
|
|
|
- if (this.anemometerTowerHeightDtoList.length > 1) {
|
|
|
- // Ensure at least one input remains
|
|
|
- this.anemometerTowerHeightDtoList.pop()
|
|
|
+ // 删除
|
|
|
+ removeTower(index) {
|
|
|
+ this.dynamicValidateForm.anemometerTowerHeightDtoList.splice(index, 1);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 数字验证
|
|
|
+ validateNumber(rule, value, callback) {
|
|
|
+ const numberRegex = /^\d{1,4}(\.\d{1,2})?$/; // 匹配不超过四位数且小数点后不超过二位数的数字
|
|
|
+ if (!value) {
|
|
|
+ callback(new Error("该项不能为空"));
|
|
|
+ } else if (!numberRegex.test(value)) {
|
|
|
+ callback(
|
|
|
+ new Error("该项必须为不超过四位数且小数点后不超过三位数的数字")
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+ },
|
|
|
+ validateUniqueHeight(rule, value, callback) {
|
|
|
+ const heights = this.dynamicValidateForm.anemometerTowerHeightDtoList.map(
|
|
|
+ (tower) => tower.anemometerHeight
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ const isDuplicate =
|
|
|
+ heights.filter((height) => height === value).length > 1;
|
|
|
+
|
|
|
+
|
|
|
+ const isInvalidLength = value && value.toString().length > 3;
|
|
|
+
|
|
|
+ if (isDuplicate) {
|
|
|
+ callback(new Error("输入的测风塔高度不能重复"));
|
|
|
+ } else if (isInvalidLength) {
|
|
|
+ callback(new Error("测风塔高度不能超过三位数"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
@@ -504,32 +516,13 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-.attachment {
|
|
|
- display: flex;
|
|
|
- padding-top: 10px;
|
|
|
-
|
|
|
- p {
|
|
|
- margin-right: 20px;
|
|
|
- color: #409eff;
|
|
|
+.demo-dynamic {
|
|
|
+ .el-input {
|
|
|
+ width: 300px;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+ .el-form-item {
|
|
|
+ margin-bottom: 20px;
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-.addition {
|
|
|
- display: flex;
|
|
|
- justify-content: flex-end;
|
|
|
- margin-bottom: 10px;
|
|
|
-}
|
|
|
-
|
|
|
-.error {
|
|
|
- color: red;
|
|
|
- position: absolute;
|
|
|
- bottom: 85px;
|
|
|
- left: 91px;
|
|
|
- width: 213px !important;
|
|
|
- font-size: 12px;
|
|
|
-}
|
|
|
-
|
|
|
-.forinput {
|
|
|
- position: relative;
|
|
|
}
|
|
|
</style>
|