zhgdyun/src/views/projectFront/quality/acceptanceReport.vue

263 lines
7.0 KiB
Vue

<template>
<!-- 材料检测报告 -->
<div class="panoramaPlan">
<div class="header-box">
<el-button type="primary" @click="addForm"> 新增 </el-button>
</div>
<div class="table-box">
<el-table class="tables" :data="tableData">
<el-table-column prop="eventType" label="事件类型" align="center"></el-table-column>
<el-table-column prop="detectionDate" label="检测时间" align="center"></el-table-column>
<el-table-column prop="status" label="检测结果" align="center">
<template slot-scope="scope">
{{ getStatus(scope.row.status) }}
</template>
</el-table-column>
<!-- 操作 -->
<el-table-column label="操作" width="220">
<template slot-scope="scope">
<el-button
type="text"
icon="el-icon-edit-outline"
@click="editData(scope.row)"
>
编辑
</el-button>
<el-button
class="delete-btn"
type="text"
icon="el-icon-delete"
@click="deleteData(scope.row)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
class="pagerBox"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="current"
:page-sizes="$store.state.PAGESIZRS"
:page-size="size"
layout="total, sizes, prev, pager, next"
:total="Number(total)"
background
></el-pagination>
</div>
<!-- 新增弹框 -->
<el-dialog
class="dialog"
:title="dialogTitle"
:modal-append-to-body="false"
:visible.sync="dialogVisible"
width="667px"
>
<div class="dialog-content">
<vue-scroll>
<el-form
ref="form"
:model="dialogdata"
:rules="rules"
label-width="155px"
size="medium"
class="dialogFormBox"
>
<el-form-item label="事件类型" prop="eventType">
<el-input
v-model="dialogdata.eventType"
placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label="检测结果" prop="status">
<el-select v-model="dialogdata.status" placeholder="请选择">
<el-option :value="1" label="合格">
</el-option>
<el-option :value="2" label="不合格">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="检测时间" prop="detectionDate">
<el-date-picker
v-model="dialogdata.detectionDate"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
</el-form>
</vue-scroll>
</div>
<div class="dialog-btn">
<el-button type="primary" @click="submitForm"> 确定 </el-button>
<el-button @click="dialogVisible = false"> 取消 </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getMaterialDetectionReportApi, //分页查询材料检验报告
addaddMaterialDetectionReportApi,//新增
updateMaterialDetectionReportApi,//编辑
deleteMaterialDetectionReportApi,//删除
} from "@/assets/js/api/quality";
export default {
data() {
return {
tableData: [], //列表数据
dialogTitle: "",
dialogVisible: false,
dialogdata: {
eventType:'',//事件类型
detectionDate:'',//检测时间
status:'',//检测结果
},
rules: {},
fileList: [],
current: 1,
size: 10,
total: 0,
};
},
created() {
this.getData();
},
methods: {
//数据转换
getStatus(status){
if(status===1){
return '合格'
}else{
return '不合格'
}
},
//查询材料检验报告
getData() {
getMaterialDetectionReportApi({
projectSn: this.$store.state.projectSn,
size:this.size,
current:this.current
}).then((res) => {
console.log("材料检验报告", res);
this.tableData=res.result.records
this.total=res.result.total
});
},
//新增
addForm() {
this.dialogVisible = true;
this.dialogTitle = "新增材料检测报告";
this.dialogdata={
eventType:'',//事件类型
detectionDate:'',//检测时间
status:'',//检测结果
}
},
//编辑
editData(val){
this.dialogVisible = true;
this.dialogTitle = "编辑材料检测报告";
this.dialogdata=JSON.parse(JSON.stringify(val))
},
//删除
deleteData(val){
this.$confirm("此操作将永久删除, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
deleteMaterialDetectionReportApi({ id: val.id }).then((res) => {
this.$message({
type: "success",
message: "删除成功!",
});
this.getData();
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
//新增或编辑提交
submitForm() {
let params = JSON.parse(JSON.stringify(this.dialogdata));
params.projectSn = this.$store.state.projectSn;
this.$refs.form.validate((valid) => {
if (valid) {
if (this.dialogTitle == "新增材料检测报告") {
addaddMaterialDetectionReportApi(params).then((res) => {
this.$message.success("新增成功");
this.dialogVisible = false;
this.getData();
});
}else if(this.dialogTitle == "编辑材料检测报告"){
updateMaterialDetectionReportApi(params).then(res=>{
this.$message.success("编辑成功");
this.dialogVisible = false;
this.getData();
})
}
}
});
},
handleSizeChange(value) {
this.size = value;
this.getData();
},
handleCurrentChange(value) {
this.current = value;
this.getData();
},
},
};
</script>
<style lang="less" scoped>
.panoramaPlan {
width: 100%;
height: 100%;
background: #fff;
padding: 20px;
box-sizing: border-box;
.header-box {
margin-bottom: 20px;
padding-left: 10px;
.search-item {
display: inline-flex;
align-items: center;
white-space: nowrap;
margin-right: 20px;
/deep/.el-input {
width: 200px;
}
}
}
.delete-btn {
color: #f56c6c;
}
.dialog-content {
/*height: 360px;*/
margin-bottom: 60px;
}
.dialog-btn {
margin-left: 245px;
}
}
</style>