Merge remote-tracking branch 'origin/wp'

# Conflicts:
#	AutoSprout-ui/src/views/device/device/index.vue
This commit is contained in:
邱贞招 2024-04-18 11:05:03 +08:00
commit 8fa35003e7
4 changed files with 1623 additions and 297 deletions

View File

@ -1,51 +1,81 @@
import request from '@/utils/request'
import request from "@/utils/request";
// 查询设备列表列表
export function listDevice(query) {
return request({
url: '/device/device/list',
method: 'get',
params: query
})
url: "/device/device/list",
method: "get",
params: query,
});
}
// 查询设备列表详细
export function getDevice(deviceId) {
return request({
url: '/device/device/' + deviceId,
method: 'get'
})
url: "/device/device/" + deviceId,
method: "get",
});
}
// 查询定时列表
export function getregulartime(params) {
return request({
url: "/app/timer/list/",
method: "get",
params: params,
});
}
// 定时删除
export function deleteTimer(deviceId,index) {
return request({
url: '/app/timer/' + deviceId + '/' + index,
method: 'DELETE',
});
}
// 手动浇水
export function watering(deviceId, wateringSwitch) {
return request({
url: '/device/device/watering/' + deviceId+"/"+wateringSwitch,
method: 'get'
})
url: "/device/device/watering/" + deviceId + "/" + wateringSwitch,
method: "get",
});
}
// 新增设备列表
export function addDevice(data) {
// 新建定时
export function getadd(data) {
return request({
url: '/device/device',
url: '/app/timer',
method: 'post',
data: data
})
}
// 定时修改
export function getxiug(data) {
return request({
url: '/app/timer',
method: 'PUT',
data: data
})
}
// 新增设备列表
export function addDevice(data) {
return request({
url: "/device/device",
method: "post",
data: data,
});
}
// 修改设备列表
export function updateDevice(data) {
return request({
url: '/device/device',
method: 'put',
data: data
})
url: "/device/device",
method: "put",
data: data,
});
}
// 删除设备列表
export function delDevice(deviceId) {
return request({
url: '/device/device/' + deviceId,
method: 'delete'
})
url: "/device/device/" + deviceId,
method: "delete",
});
}

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,29 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="浇水时间" prop="waterTime">
<el-date-picker clearable
<el-date-picker
clearable
v-model="queryParams.waterTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择浇水时间">
placeholder="请选择浇水时间"
>
</el-date-picker>
</el-form-item>
<el-form-item label="启动模式" prop="startMode">
<el-select v-model="queryParams.startMode" placeholder="请选择启动模式" clearable>
<el-select
v-model="queryParams.startMode"
placeholder="请选择启动模式"
clearable
>
<el-option
v-for="dict in dict.type.as_start_mode"
:key="dict.value"
@ -29,8 +41,16 @@
/>
</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-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>
@ -43,28 +63,49 @@
size="mini"
@click="handleExport"
v-hasPermi="['device:record:export']"
>导出</el-button>
>导出</el-button
>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="recordList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="设备id" align="center" prop="deviceId" />
<el-table-column label="浇水时间" align="center" prop="waterTime" width="180">
<el-table-column
label="浇水时间"
align="center"
prop="waterTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.waterTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.waterTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="脉冲模式" align="center" prop="pulseMode" />
<el-table-column label="启动模式" align="center" prop="startMode">
<template slot-scope="scope">
<dict-tag :options="dict.type.as_start_mode" :value="scope.row.startMode"/>
<dict-tag
:options="dict.type.as_start_mode"
:value="scope.row.startMode"
/>
</template>
</el-table-column>
<el-table-column label="喷洒时间" align="center" prop="sprayingTime" width="180">
<el-table-column
label="喷洒时间"
align="center"
prop="sprayingTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.sprayingTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.sprayingTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="用户账号" align="center" prop="userName" />
@ -91,11 +132,17 @@
</template>
<script>
import { listRecord, getRecord, delRecord, addRecord, updateRecord } from "@/api/device/record";
import {
listRecord,
getRecord,
delRecord,
addRecord,
updateRecord,
} from "@/api/device/record";
export default {
name: "Record",
dicts: ['as_start_mode'],
dicts: ["as_start_mode"],
data() {
return {
//
@ -122,13 +169,12 @@ export default {
pageSize: 10,
waterTime: null,
startMode: null,
userName: null
userName: null,
},
//
form: {},
//
rules: {
}
rules: {},
};
},
created() {
@ -138,8 +184,16 @@ export default {
/** 查询浇水记录列表 */
getList() {
this.loading = true;
listRecord(this.queryParams).then(response => {
listRecord(this.queryParams).then((response) => {
this.recordList = response.rows;
this.recordList.forEach((record) => {
// pulseMode
if (record.pulseMode) {
this.$set(record, "pulseMode", "开");
} else {
this.$set(record, "pulseMode", "关");
}
});
this.total = response.total;
this.loading = false;
});
@ -157,7 +211,7 @@ export default {
pulseMode: null,
startMode: null,
sprayingTime: null,
userName: null
userName: null,
};
this.resetForm("form");
},
@ -173,9 +227,9 @@ export default {
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.deviceId)
this.single = selection.length!==1
this.multiple = !selection.length
this.ids = selection.map((item) => item.deviceId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
@ -186,8 +240,8 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const deviceId = row.deviceId || this.ids
getRecord(deviceId).then(response => {
const deviceId = row.deviceId || this.ids;
getRecord(deviceId).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改浇水记录";
@ -195,16 +249,16 @@ export default {
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.deviceId != null) {
updateRecord(this.form).then(response => {
updateRecord(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addRecord(this.form).then(response => {
addRecord(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
@ -216,19 +270,27 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const deviceIds = row.deviceId || this.ids;
this.$modal.confirm('是否确认删除浇水记录编号为"' + deviceIds + '"的数据项?').then(function() {
this.$modal
.confirm('是否确认删除浇水记录编号为"' + deviceIds + '"的数据项?')
.then(function () {
return delRecord(deviceIds);
}).then(() => {
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('device/record/export', {
...this.queryParams
}, `record_${new Date().getTime()}.xlsx`)
}
}
this.download(
"device/record/export",
{
...this.queryParams,
},
`record_${new Date().getTime()}.xlsx`
);
},
},
};
</script>

View File

@ -35,8 +35,10 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://localhost:8081`,
// target: `http://localhost:8081`,
// target: `http://117.50.215.20:8080`,
target:`https://yxd.ccttiot.com/prod-api/`,
// target:`http://192.168.2.5:8081`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''