Commit 7dcba6bf authored by yangkaiyi's avatar yangkaiyi

加植物管理相关接口

parent 87261d32
...@@ -34,10 +34,6 @@ export const getLastPosition = (params) => { ...@@ -34,10 +34,6 @@ export const getLastPosition = (params) => {
return axios.get(`positions`).then((res) => res.data); return axios.get(`positions`).then((res) => res.data);
}; };
export const getDevices = (params) => {
return axios.get(`devices`).then((res) => res.data);
};
// 历史轨迹 // 历史轨迹
export const getHistoryPosition = (params) => { export const getHistoryPosition = (params) => {
return axios return axios
...@@ -283,6 +279,26 @@ export const getAllDevices = (params) => { ...@@ -283,6 +279,26 @@ export const getAllDevices = (params) => {
return axios.get(`devices/all`, { params: params }).then((res) => res.data); return axios.get(`devices/all`, { params: params }).then((res) => res.data);
}; };
// 获取有害植物
export const getDevices = (id) => {
return axios.get(`devices/${id}`).then((res) => res.data);
};
// 添加有害植物
export const addDevices = (params) => {
return axios.post(`devices`, params).then((res) => res.data);
};
// 更新有害植物
export const updateDevices = (params) => {
return axios.put(`devices/${params.id}`, params).then((res) => res.data);
};
// 删除有害植物
export const deleteDevices = (id) => {
return axios.delete(`devices/${id}`).then((res) => res.data);
};
// 清理缓存 // 清理缓存
export const cleanCache = (type) => { export const cleanCache = (type) => {
return axios.delete(`cache/clean/` + type).then((res) => res.data); return axios.delete(`cache/clean/` + type).then((res) => res.data);
......
...@@ -76,15 +76,11 @@ ...@@ -76,15 +76,11 @@
highlight-current-row highlight-current-row
> >
<el-table-column type="selection" width="55"></el-table-column> <el-table-column type="selection" width="55"></el-table-column>
<!-- prop都改字段名 --> <el-table-column label="重要有害植物名称" prop="name" width="160" />
<el-table-column label="重要有害植物名称" prop="name" width="200"> <el-table-column label="IMEI" prop="imei" width="150" />
</el-table-column> <el-table-column label="报关号" prop="clearanceID" width="130" />
<el-table-column label="报关号222" width="160" prop="报关号"> <el-table-column label="来源国" prop="countryOfOrigin" width="100" />
</el-table-column> <el-table-column label="携带有害生物" prop="carryPestName" />
<el-table-column label="来源国" width="100" prop="来源国">
</el-table-column>
<el-table-column label="携带有害生物" prop="typeName">
</el-table-column>
<el-table-column width="160" label="添加时间"> <el-table-column width="160" label="添加时间">
<template slot-scope="scope"> <template slot-scope="scope">
{{ (scope.row.time / 1000) | moment("YYYY-MM-DD HH:mm:ss") }} {{ (scope.row.time / 1000) | moment("YYYY-MM-DD HH:mm:ss") }}
...@@ -97,7 +93,7 @@ ...@@ -97,7 +93,7 @@
}} }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column width="160" label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 带权限判断demo --> <!-- 带权限判断demo -->
<!-- <el-button <!-- <el-button
...@@ -152,71 +148,64 @@ ...@@ -152,71 +148,64 @@
> >
<el-form <el-form
:model="editForm" :model="editForm"
ref="editValidateForm" ref="editFormRef"
label-width="100px" label-width="100px"
class="demo-ruleForm" class="demo-ruleForm"
> >
<!-- TODO:改弹窗内容 --> <!-- 新增、编辑弹窗 -->
<el-form-item label="名称" prop="account">
<el-input
v-model.number="editForm.account"
auto-complete="off"
:disabled="true"
></el-input>
</el-form-item>
<el-form-item <el-form-item
label="邮箱" label="名称"
prop="email" prop="name"
:rules="[ :rules="[
{ {
type: 'email', required: true,
message: '请输入正确的邮箱地址', message: '请输入有害植物名称',
trigger: ['blur', 'change'], trigger: ['blur', 'change'],
}, },
]" ]"
> >
<el-input v-model="editForm.email" auto-complete="off"></el-input> <el-input
v-model="editForm.name"
auto-complete="off"
:disabled="isEdit"
></el-input>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="电话" label="IMEI"
prop="phone" prop="imei"
:rules="[ :rules="[
{ {
min: 11, required: true,
max: 11, message: '请输入IMEI',
message: '请输入正确的手机号码', trigger: ['blur', 'change'],
trigger: 'blur',
}, },
]" ]"
> >
<el-input v-model="editForm.phone" auto-complete="off"></el-input> <el-input v-model="editForm.imei" auto-complete="off"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="角色" prop="parentId"> <el-form-item label="报关号" prop="clearanceID">
<el-checkbox-group v-model="editForm.roleIds"> <el-input
<el-checkbox v-model="editForm.clearanceID"
v-for="(role, index) in roles" auto-complete="off"
:key="index" ></el-input>
:label="role.id"
:disabled="role.roleKey === 'root'"
>{{ role.name }}</el-checkbox
>
</el-checkbox-group>
</el-form-item> </el-form-item>
<el-form-item label="禁用" prop="disabled"> <el-form-item label="来源国" prop="countryOfOrigin">
<el-switch <el-input
v-model="editForm.disabled" v-model="editForm.countryOfOrigin"
active-color="#ff4949" auto-complete="off"
inactive-color="#13ce66" ></el-input>
active-text="是" </el-form-item>
inactive-text="否" <el-form-item label="携带有害生物" prop="carryPestName">
> <el-input
</el-switch> v-model="editForm.carryPestName"
auto-complete="off"
></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="editDialogVisible = false">取 消</el-button> <el-button @click="editDialogVisible = false">取 消</el-button>
<el-button type="primary" @click="editSubmit">确 定</el-button> <el-button type="primary" @click="handlerSubmit">确 定</el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
...@@ -226,7 +215,13 @@ ...@@ -226,7 +215,13 @@
import util from "@/utils/util"; import util from "@/utils/util";
import InDevice from "./components/InDevice"; import InDevice from "./components/InDevice";
import TransferDevice from "./components/TransferDevice"; import TransferDevice from "./components/TransferDevice";
import { getAllDevices } from "@/api/api"; import {
getAllDevices,
getDevices,
addDevices,
updateDevices,
deleteDevices,
} from "@/api/api";
export default { export default {
data() { data() {
...@@ -238,18 +233,17 @@ export default { ...@@ -238,18 +233,17 @@ export default {
keyword: "", keyword: "",
type: 0, type: 0,
}, },
// value改字段名
options: [ options: [
{ {
value: "name", value: "name",
label: "重要有害植物名称", label: "重要有害植物名称",
}, },
{ {
value: "报关号", value: "clearanceID",
label: "报关号", label: "报关号",
}, },
{ {
value: "来源国", value: "countryOfOrigin",
label: "来源国", label: "来源国",
}, },
{ {
...@@ -281,6 +275,7 @@ export default { ...@@ -281,6 +275,7 @@ export default {
this.init(); this.init();
}, },
methods: { methods: {
// 请求list数据、查询
init() { init() {
let para = { let para = {
page: this.page, page: this.page,
...@@ -293,30 +288,58 @@ export default { ...@@ -293,30 +288,58 @@ export default {
this.data = data; this.data = data;
}); });
}, },
// 弹窗提交
handlerSubmit() {
this.$refs["editFormRef"].validate((valid) => {
if (valid) {
if (!this.isEdit) {
addDevices(this.editForm).then((data) => {
console.log(12313123, data);
this.$message({
type: "success",
message: "保存成功!",
});
this.init();
});
} else {
updateDevices(this.editForm).then((data) => {
console.log(45565656, data);
this.$message({
type: "success",
message: "更新成功!",
});
this.init();
});
}
}
});
},
// 打开添加弹窗
handlerAdd() { handlerAdd() {
this.isEdit = false; this.isEdit = false;
this.editForm = {}; this.editForm = {};
this.editDialogVisible = true; this.editDialogVisible = true;
}, },
// 打开编辑弹窗
handleEdit(row) { handleEdit(row) {
this.isEdit = true; this.isEdit = true;
this.editForm = row; this.editForm = row;
this.editDialogVisible = true; this.editDialogVisible = true;
}, },
// 点删除
handleDelete(row) { handleDelete(row) {
this.$confirm("是否确定删除该有害植物?", "提示", { this.$confirm("是否确定删除该有害植物?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
}).then(() => { }).then(() => {
// TODO:删除接口 deleteDevices(row.id).then((data) => {
// deleteUser(row.id).then((data) => { this.$message({
// this.$message({ type: "success",
// type: "success", message: "删除成功!",
// message: "删除成功!", });
// }); this.init();
// this.init(); });
// });
}); });
}, },
...@@ -367,11 +390,10 @@ export default { ...@@ -367,11 +390,10 @@ export default {
"分组", "分组",
"添加时间", "添加时间",
]; ];
// TODO:字段名
const filterVal = [ const filterVal = [
"报关号", "clearanceID",
"name", "name",
"来源国", "countryOfOrigin",
"remarks", "remarks",
"typeId", "typeId",
"groupId", "groupId",
......
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