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) { export function listDevice(query) {
return request({ return request({
url: '/device/device/list', url: "/device/device/list",
method: 'get', method: "get",
params: query params: query,
}) });
} }
// 查询设备列表详细 // 查询设备列表详细
export function getDevice(deviceId) { export function getDevice(deviceId) {
return request({ return request({
url: '/device/device/' + deviceId, url: "/device/device/" + deviceId,
method: 'get' 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) { export function watering(deviceId, wateringSwitch) {
return request({ return request({
url: '/device/device/watering/' + deviceId+"/"+wateringSwitch, url: "/device/device/watering/" + deviceId + "/" + wateringSwitch,
method: 'get' method: "get",
}) });
} }
// 新建定时
// 新增设备列表 export function getadd(data) {
export function addDevice(data) {
return request({ return request({
url: '/device/device', url: '/app/timer',
method: 'post', method: 'post',
data: data 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) { export function updateDevice(data) {
return request({ return request({
url: '/device/device', url: "/device/device",
method: 'put', method: "put",
data: data data: data,
}) });
} }
// 删除设备列表 // 删除设备列表
export function delDevice(deviceId) { export function delDevice(deviceId) {
return request({ return request({
url: '/device/device/' + deviceId, url: "/device/device/" + deviceId,
method: 'delete' method: "delete",
}) });
} }

File diff suppressed because it is too large Load Diff

View File

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

View File

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