hberp/hb_client/src/views/safeEnviro/environmetManage.vue

280 lines
8.7 KiB
Python

<template>
<div class="app-container">
<el-card>
<div>
<el-button
v-if="checkPermission(['material_create'])"
type="primary"
icon="el-icon-plus"
>
新增
</el-button>
</div>
</el-card>
<el-card style="margin-top: 2px">
<el-table
v-loading="listLoading"
:data="materialList.results"
border
fit
stripe
highlight-current-row
height="100"
v-el-height-adaptive-table="{bottomOffset: 42}"
>
<el-table-column type="index" width="50"/>
<el-table-column label="排放口">
<template slot-scope="scope">
{{ scope.row.number }}
</template>
</el-table-column>
<el-table-column label="检测时间">
<template> 成品</template>
</el-table-column>
<el-table-column label="出:干烟含量">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="出:氧含量">
<template slot-scope="scope">{{ scope.row.specification }}</template>
</el-table-column>
<el-table-column label="出:二氧化硫">
<template slot-scope="scope">{{ scope.row.piece_count }}</template>
</el-table-column>
<el-table-column label="出:二氧化硫折标">
<template slot-scope="scope">{{ scope.row.unit }}</template>
</el-table-column>
<el-table-column label="出:颗粒物">
<template slot-scope="scope">{{ scope.row.unit }}</template>
</el-table-column>
<el-table-column label="出:颗粒物折标">
<template slot-scope="scope">{{ scope.row.unit }}</template>
</el-table-column>
<el-table-column label="出:氮氧化物">
<template slot-scope="scope">{{ scope.row.unit }}</template>
</el-table-column>
<el-table-column label="出:氮氧化物折标">
<template slot-scope="scope">{{ scope.row.unit }}</template>
</el-table-column>
<el-table-column
align="center"
label="操作"
width="220px"
>
<template slot-scope="scope">
<el-link
type="danger"
@click="handleDelete(scope)"
>
删除
</el-link>
</template>
</el-table-column>
</el-table>
<pagination
v-show="materialList.count > 0"
:total="materialList.count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
/>
<!-- @pagination="getList" -->
</el-card>
<el-dialog
:visible.sync="dialogVisible"
:close-on-click-modal="false"
title="新增风险"
>
<el-form
ref="Form"
:model="material"
label-width="140px"
label-position="right"
:rules="rule1"
>
<el-form-item label="排放口">
<el-select style="width: 100%" v-model="material.type" placeholder="请选择">
<el-option
v-for="item in options"
:key="item"
:label="item"
:value="item"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="监测时间">
<el-date-picker
v-model="material.time"
type="datetime"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
<el-form-item label="出:干烟含量">
<el-input v-model="material.value" type="number" placeholder="出:干烟含量"/>
</el-form-item>
<el-form-item label="出:氧含量">
<el-input v-model="material.value2" placeholder="出:氧含量"/>
</el-form-item>
<el-form-item label="出:二氧化硫">
<el-input v-model="material.value3" placeholder="出:二氧化硫"/>
</el-form-item>
<el-form-item label="出:二氧化硫折标">
<el-input v-model="material.value4" placeholder="出:二氧化硫折标"/>
</el-form-item>
<el-form-item label="出:颗粒物">
<el-input v-model="material.value5" placeholder="出:颗粒物"/>
</el-form-item>
<el-form-item label="出:颗粒物折标">
<el-input v-model="material.value6" placeholder="出:颗粒物折标"/>
</el-form-item>
<el-form-item label="出:氮氧化物">
<el-input v-model="material.value7" placeholder="出:氮氧化物"/>
</el-form-item>
<el-form-item label="出:氮氧化物折标">
<el-input v-model="material.value8" placeholder="出:氮氧化物折标"/>
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirm('Form')">确认</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getMaterialList,
createMaterial,
updateMaterial,
deleteMaterial
} from "@/api/mtm";
import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination";
const defaultmaterial = {
name: null,
number: null,
specification: null,
unit: null,
type: '',
piece_count: null,
sort_str: null,
count_safe: 0,
processes: [],
};
export default {
name: "productList",
components: {Pagination},
data() {
return {
material: defaultmaterial,
materialList: {
count: 0,
results:[]
},
options:[
'预热器排口',
'煤粉制备排口',
],
listQuery: {
type: 1,
page: 1,
page_size: 20,
},
activeName: "",
listLoading: false,
dialogVisible: false,
dialogType: "new",
rule1: {
name: [{required: true, message: "请输入", trigger: "blur"}],
number: [{required: true, message: "请输入", trigger: "blur"}],
},
};
},
computed: {},
watch: {},
created() {
},
methods: {
checkPermission,
//成品详情
handledetail(scope) {
this.$router.push({name: "MaterialDetail", params: {id: scope.row.id, type: scope.row.type},})
},
handleFilter() {
this.listQuery.page = 1;
},
resetFilter() {
this.activeName = "";
this.listQuery = {
type: 1,
page: 1,
page_size: 20,
};
},
handleCreate() {
this.material = Object.assign({}, defaultmaterial);
this.dialogType = "new";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate();
});
},
handleDelete(scope) {
let that = this;
this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
})
.then(async () => {
await deleteMaterial(scope.row.id);
that.$message.success("成功");
})
.catch((err) => {
that.$message.error(err);
});
},
async confirm(form) {
let that = this;
that.$refs[form].validate((valid) => {
if (valid) {
const isEdit = this.dialogType === "edit";
if (isEdit) {
updateMaterial(this.material.id, this.material).then((res) => {
if (res.code >= 200) {
that.dialogVisible = false;
that.$message.success("成功");
}
});
} else {
createMaterial(this.material).then((res) => {
if (res.code >= 200) {
that.dialogVisible = false;
that.$message.success("成功");
}
});
}
} else {
return false;
}
});
},
},
}
</script>
<style scoped>
</style>