添加计量单位列表

master
fanluyan 1 year ago
parent 47a1bf3608
commit 7fa87a1df7

@ -87,6 +87,15 @@ const routes = [
title: "监测设备类型", title: "监测设备类型",
}, },
}, },
{
path: "/equipment/unitController",
component: () =>
import("../views/equipment/unitController/index.vue"),
name: "unitController",
meta: {
title: "计量单位配置",
},
},
], ],
}, },
{ {

@ -358,6 +358,47 @@ export function modevDeleteApi(data) {
}, },
}); });
} }
//计量单位相关接口Unit Controller
//查询全部
export function unitListAllApi(data) {
return request({
url: "/unit/listAll",
method: "get",
params: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
},
});
}
//新增
export function unitAddApi(data) {
return request({
url: "/unit/add",
method: "post",
data,
});
}
//修改更新
export function unitUpdateApi(data) {
return request({
url: "/unit/update",
method: "post",
data,
});
}
//删除
export function unitDeleteApi(data) {
return request({
url: "/unit/delete",
method: "post",
params: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
},
});
}
//查询全部 //查询全部
export function modevListAllApi(data) { export function modevListAllApi(data) {
return request({ return request({

@ -536,12 +536,12 @@ export default {
height: 100%; height: 100%;
//background: #fcc; //background: #fcc;
.leftTree { .leftTree {
min-width: 220px; min-width: 280px;
max-width: 220px; max-width: 280px;
height: 100%; height: 100%;
overflow: auto; overflow: auto;
//border: 1px solid #fff; //border: 1px solid #fff;
margin-right: 24px; margin-right: 16px;
background: rgba(8, 9, 36, 0.28); background: rgba(8, 9, 36, 0.28);
-webkit-backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px); backdrop-filter: blur(10px);

@ -44,6 +44,10 @@ export default {
name: "监测设备类型管理", name: "监测设备类型管理",
path: "/equipment/modevtype", path: "/equipment/modevtype",
}, },
{
name: "计量单位管理",
path: "/equipment/unitController",
},
], ],
}; };
}, },

@ -0,0 +1,131 @@
<template>
<div class="unitAddBox">
<el-dialog
class="unitAddDialogBox"
:title="title"
:visible.sync="unitDialogshow"
width="520px"
:close-on-click-modal="false"
>
<el-form
label-position="left"
ref="formInfo"
label-width="104px"
:rules="rules"
:model="formInfo"
>
<el-form-item label="名称:" prop="field">
<el-input v-model="formInfo.field"></el-input>
</el-form-item>
<el-form-item label="单位:" prop="unit">
<el-input v-model="formInfo.unit"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="hide"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { unitAddApi, unitUpdateApi } from "@/utils/api/index";
export default {
props: ["title"],
data() {
return {
unitDialogshow: false,
formInfo: {},
rules: {
field: [{ required: true, message: "请输入名称", trigger: "blur" }],
},
bdzOptions: [],
};
},
created() {},
mounted() {},
watch: {},
methods: {
//
getdataform(val) {
console.log(val);
this.formInfo = JSON.parse(JSON.stringify(val));
},
submitForm() {
this.$refs.formInfo.validate((valid) => {
if (valid) {
if (this.title == "添加计量单位") {
console.log(this.formInfo);
unitAddApi(this.formInfo)
.then((res) => {
if (res.success) {
this.$message({
duration: 1500,
showClose: true,
message: "添加成功",
type: "success",
});
this.hide();
this.$parent.getunitAllList(); //
} else {
this.$message({
duration: 1500,
showClose: true,
message: res.errorMsg,
type: "error",
});
}
})
.catch((err) => {});
} else {
unitUpdateApi(this.formInfo)
.then((res) => {
if (res.success) {
this.$message({
duration: 1500,
showClose: true,
message: "修改成功",
type: "success",
});
this.hide();
this.$parent.getunitAllList(); //
} else {
this.$message({
duration: 1500,
showClose: true,
message: res.errorMsg,
type: "error",
});
}
})
.catch((err) => {});
}
} else {
console.log("error submit!!");
return false;
}
});
},
display() {
this.unitDialogshow = true;
if (this.title == "添加计量单位") {
this.formInfo.field = "";
this.formInfo.unit = "";
}
},
hide() {
this.unitDialogshow = false;
this.$refs.formInfo.resetFields(); //
},
},
};
</script>
<style lang="less">
.unitAddBox {
.unitAddDialogBox {
.el-select {
width: 376px;
}
}
}
</style>

@ -0,0 +1,139 @@
<template>
<div class="unitController">
<div class="reportHead">
<h3>计量单位管理</h3>
</div>
<div class="page-body">
<el-button type="primary" icon="el-icon-plus" @click="handleAddClick"
>添加计量单位</el-button
>
<div class="unitTableBox">
<el-table
v-loading="unitLoading"
:data="unitTableData"
stripe
border
style="width: 100%"
height="calc(100% - 0px)"
>
<el-table-column prop="id" label="ID"> </el-table-column>
<el-table-column prop="field" label="名称"> </el-table-column>
<el-table-column prop="unit" label="单位"> </el-table-column>
<el-table-column label="操作" class-name="editClass">
<template slot-scope="scope">
<el-link
type="primary"
@click="handleEditClick(scope.row)"
size="small"
icon="el-icon-document"
>编辑</el-link
>
<el-link
type="danger"
@click="handleDeleteClick(scope.row)"
size="small"
icon="el-icon-delete"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
</div>
</div>
<addunitDialog ref="unitAddRef" :title="title"></addunitDialog>
</div>
</template>
<script>
import { unitDeleteApi, unitListAllApi } from "@/utils/api/index";
import addunitDialog from "./components/addunitDialog";
export default {
components: {
addunitDialog,
},
data() {
return {
unitLoading: false,
unitTableData: [],
title: "",
};
},
created() {},
mounted() {
this.getunitAllList();
},
watch: {},
methods: {
//
getunitAllList() {
this.unitLoading = true;
unitListAllApi()
.then((res) => {
console.log(res);
this.unitTableData = res.data;
this.unitLoading = false;
})
.catch((err) => {
console.log(err); //
});
},
//
handleAddClick() {
this.title = "添加计量单位";
this.$refs.unitAddRef.display();
//this.$refs.unitAddRef.getdataform(null);
},
//
handleEditClick(data) {
this.title = "编辑";
this.$refs.unitAddRef.display();
this.$refs.unitAddRef.getdataform(data);
},
//
handleDeleteClick(data) {
this.$confirm("确定要删除记录吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
unitDeleteApi({ id: data.id }).then((res) => {
if (res.success) {
this.$message({
duration: 1500,
showClose: true,
type: "success",
message: "删除成功",
});
this.getunitAllList(); //
} else {
this.$message({
duration: 1500,
showClose: true,
type: "error",
message: res.errorMsg,
});
}
});
})
.catch(() => {});
},
},
};
</script>
<style lang="less">
.unitController {
width: 100%;
height: 100%;
.page-body {
width: calc(100% - 24px);
height: calc(100% - 74px);
padding: 12px;
background: #eee;
.unitTableBox {
margin-top: 8px;
height: calc(100% - 38px);
box-shadow: 1px 0 10px 1px rgba(0, 0, 0, 0.3);
}
}
}
</style>

@ -20,8 +20,8 @@ module.exports = defineConfig({
proxy: { proxy: {
"/cac-api": { "/cac-api": {
//表示拦截以/api开头的请求路径 //表示拦截以/api开头的请求路径
//target: "http://192.168.1.190:88", //200服务器 target: "http://192.168.1.190:88", //200服务器
target: "http://dev.xinyingpower.com:40080/", //dell服务器 //target: "http://dev.xinyingpower.com:40080/", //dell服务器
changOrigin: true, //是否开启跨域 changOrigin: true, //是否开启跨域
pathRewrite: { pathRewrite: {
"^/api": "/cac-api", //重写api把api变成空字符因为我们真正请求的路径是没有api的 "^/api": "/cac-api", //重写api把api变成空字符因为我们真正请求的路径是没有api的

Loading…
Cancel
Save