添加计量单位列表
parent
47a1bf3608
commit
7fa87a1df7
@ -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>
|
Loading…
Reference in New Issue