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

460 lines
14 KiB
Vue
Raw Normal View History

2023-01-08 01:33:25 +08:00
<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="chargerId"
label="序号"
type="index"
></el-table-column>
<el-table-column
align="center"
prop="subsectionName"
label="分部工程名称"
></el-table-column>
<el-table-column
align="center"
prop="subentryName"
label="分项工程名称"
></el-table-column>
<el-table-column
align="center"
prop="floor"
label="巡检楼层"
></el-table-column>
<el-table-column
align="center"
prop="unit"
width="150"
label="验收单位"
>
</el-table-column>
<el-table-column
align="center"
prop="checkingPersonnel"
label="验收人员"
></el-table-column>
<el-table-column prop="status" label="验收结论">
<template slot-scope="scope">
{{ getStatus(scope.row.status) }}
</template>
</el-table-column>
<el-table-column prop="imageUrl" align="center" label="图片">
<template slot-scope="scope">
<img
:preview="scope.row.imageUrl[0] ? scope.row.imageUrl[0].url : []"
:src="scope.row.imageUrl[0] ? scope.row.imageUrl[0].url : []"
alt=""
width="50px"
/>
</template>
</el-table-column>
<el-table-column
align="center"
prop="acceptanceDate"
label="验收日期"
></el-table-column>
<!-- 操作 -->
<el-table-column label="操作" width="220" align="center">
<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="subsectionId">
<el-select
v-model="dialogdata.subsectionId"
@change="checkSubListData"
placeholder="请选择"
>
<el-option
v-for="(item, index) in listData"
:key="index"
:label="item.subdivisionProjectName"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="分项工程名称" prop="subentryId">
<el-select v-model="dialogdata.subentryId" placeholder="请选择">
<el-option
v-for="(item, index) in subListData"
:key="index"
:label="item.subdivisionProjectName"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="验收依据" prop="basis">
<el-input
v-model="dialogdata.basis"
placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label="验收楼层" prop="floor">
<el-input
v-model="dialogdata.floor"
placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label="验收单位" prop="unit">
<el-input
v-model="dialogdata.unit"
placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label="验收人员" prop="checkingPersonnel">
<el-input
v-model="dialogdata.checkingPersonnel"
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="acceptanceDate">
<el-date-picker
v-model="dialogdata.acceptanceDate"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
<el-form-item label="上传图片">
<el-upload
:action="$store.state.UPLOADURL"
list-type="picture-card"
multiple
name="files"
:limit="1"
:file-list="fileList"
:on-success="handleSuccess"
:on-remove="handleRemove"
>
<i class="el-icon-plus"></i>
</el-upload>
</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 {
getSubdivisionAcceptanceApi, //分页查询分部分项验收
addSubdivisionAcceptanceApi, //新增
updateSubdivisionAcceptanceApi, //修改
deleteSubdivisionAcceptanceApi,
getSubdivisionProjectApi, //所有分部分项工程, 以父子节点形式呈现
} from "@/assets/js/api/quality";
export default {
data() {
return {
tableData: [], //列表数据
dialogTitle: "",
dialogVisible: false,
dialogdata: {
subsectionId: "", //分部工程id
subentryId: "", //分项工程id
basis: "", //验收依据
floor: "", //验收楼层
unit: "", //验收单位
checkingPersonnel: "", //验收人员
status: "", //验收结论
imageUrl: "", //图片
acceptanceDate: "", //验收日期
projectSn: "",
},
rules: {},
fileList: [],
current: 1,
size: 10,
total: 0,
projectSn: "",
listData: [], //下拉数据
subListData: [],
};
},
created() {
this.projectSn = this.$store.state.projectSn;
this.getData();
this.getProgressListData();
},
methods: {
//数据转换
getStatus(status) {
if (status === 1) {
return "合格";
} else {
return "不合格";
}
},
checkSubListData(val) {
console.log("一级菜单改动了 ", val);
this.listData.forEach((value) => {
if (value.id == val) {
this.subListData = value.children;
if (value.children.length >= 1) {
this.dialogdata.subentryId = value.children[0].id;
}
}
});
},
// 查询分部分项验收列表
getData() {
getSubdivisionAcceptanceApi({
projectSn: this.$store.state.projectSn,
}).then((res) => {
res.result.records.map((item) => {
item.imageUrl = JSON.parse(item.imageUrl);
if (
item.imageUrl.length !== 0 &&
!item.imageUrl[0].url.includes(this.$store.state.FILEURL)
) {
item.imageUrl[0].url =
this.$store.state.FILEURL + item.imageUrl[0].url;
}
});
console.log("分部分项数据", res);
this.tableData = res.result.records;
this.total = res.result.total;
});
},
//获取分部分项工程, 以父子节点形式呈现
getProgressListData() {
let data = {
projectSn: this.projectSn,
};
getSubdivisionProjectApi(data).then((res) => {
if (res.code == 200) {
console.log("获取到的列表- 以父子节点形式呈现", res);
this.listData = res.result;
// subsectionId: "", //分部工程id
// subentryId: "", //分项工程id
if (this.listData.length >= 1) {
this.dialogdata.subsectionId = this.listData[0].id;
if (this.listData[0].children.length >= 1) {
this.subListData = this.listData[0].children;
this.dialogdata.subentryId = this.listData[0].children[0].id;
}
}
}
});
},
//新增
addForm() {
this.dialogVisible = true;
this.dialogTitle = "新增质量验收";
this.dialogdata={
subsectionId: "", //分部工程id
subentryId: "", //分项工程id
basis: "", //验收依据
floor: "", //验收楼层
unit: "", //验收单位
checkingPersonnel: "", //验收人员
status: "", //验收结论
imageUrl: "", //图片
acceptanceDate: "", //验收日期
}
this.fileList=[]
},
//编辑
editData(val) {
console.log("编辑时调用的参数 ", val);
this.dialogVisible = true;
this.dialogTitle = "编辑质量验收";
this.dialogdata = JSON.parse(JSON.stringify(val));
this.listData.forEach((value) => {
if (value.id == this.dialogdata.subsectionId) {
this.subListData = value.children;
}
});
this.fileList = val.imageUrl;
},
//删除
deleteData(val) {
this.$confirm("此操作将永久删除, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
deleteSubdivisionAcceptanceApi({ id: val.id }).then((res) => {
this.$message({
type: "success",
message: "删除成功!",
});
this.getData();
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
//新增或编辑提交
submitForm() {
this.processTheFile();
let params = JSON.parse(JSON.stringify(this.dialogdata));
params.projectSn = this.$store.state.projectSn;
this.$refs.form.validate((valid) => {
if (valid) {
if (this.dialogTitle == "新增质量验收") {
addSubdivisionAcceptanceApi(params).then((res) => {
this.$message.success("新增成功");
this.dialogVisible = false;
this.getData();
});
} else {
updateSubdivisionAcceptanceApi(params).then((res) => {
this.$message.success("编辑成功");
this.dialogVisible = false;
this.getData();
});
}
}
});
},
processTheFile() {
//处理el上传的文件格式(结构)
this.dialogdata.imageUrl = [];
this.fileList.map((item) => {
if (!item.response) {
this.dialogdata.imageUrl.push(item);
// console.log('符合的结构', item)
} else if (item.response) {
// console.log('不符合的结构', item)
this.dialogdata.imageUrl.push({
name: item.response.data[0].filename,
url: item.response.data[0].imageUrl,
});
}
});
console.log("处理el上传的结构后", this.dialogdata.imageUrl);
this.dialogdata.imageUrl = JSON.stringify(this.dialogdata.imageUrl);
console.log("转字符串后", this.dialogdata.imageUrl);
},
handleSuccess(response, file, fileList) {
console.log("图片上传成功", fileList);
this.fileList = fileList;
},
handleRemove(response, fileList) {
this.fileList = fileList;
},
handleSizeChange(value) {
this.current = value;
this.getData();
},
handleCurrentChange(value) {
this.size = 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: 630px;
margin-bottom: 60px;
}
.dialog-btn {
margin-left: 245px;
}
::v-deep .el-upload--picture-card {
position: absolute;
}
}
</style>