<template>
|
<div class="main">
|
<div class="main_header">
|
<div class="header_item">
|
<span class="header_label">项目名称:</span>
|
<el-select v-model="projectId" :size="size" clearable placeholder="请选择项目名称" @change="changeHeaderProject">
|
<el-option
|
v-for="item in projectData"
|
:key="item.proId"
|
:label="item.proName"
|
:value="item.proId">
|
</el-option>
|
</el-select>
|
</div>
|
<div class="header_item">
|
<span class="header_labels">尺寸:</span>
|
<el-select v-model="sizeId" :size="size" clearable placeholder="请选择尺寸">
|
<el-option
|
v-for="item in sizeData"
|
:key="item.sizes"
|
:label="item.dictName"
|
:value="item.sizes">
|
</el-option>
|
</el-select>
|
</div>
|
<div class="header_item">
|
<span class="header_labels">配筋:</span>
|
<el-select v-model="reinforcementId" :size="size" clearable placeholder="请选择配筋">
|
<el-option
|
v-for="item in reinforcementData"
|
:key="item.hasSteel"
|
:label="item.dictName"
|
:value="item.hasSteel">
|
</el-option>
|
</el-select>
|
</div>
|
<div class="header_item">
|
<span class="header_labels">块号:</span>
|
<el-select v-model="blockId" :size="size" clearable placeholder="请选择块号">
|
<el-option
|
v-for="item in blockData"
|
:key="item.blockNum"
|
:label="item.dictName"
|
:value="item.blockNum">
|
</el-option>
|
</el-select>
|
</div>
|
</div>
|
<div class="main_buttons">
|
<el-button icon="el-icon-search" @click="searchRebartheoryList(true)">查询</el-button>
|
<el-button class="search_btn" icon="el-icon-plus" @click="propInsert()">新增</el-button>
|
<el-button icon="el-icon-download" @click="exportExcel()">导出Excel</el-button>
|
</div>
|
<div class="main_content">
|
<el-table
|
ref="table"
|
v-loading="loading"
|
:data="rebartheoryList"
|
height="100%">
|
<el-table-column label="序号" width="60" align="center">
|
<template #default="scope">
|
<span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="proName" label="项目名称" width="180" align="center"></el-table-column>
|
<el-table-column prop="sizeName" label="尺寸" align="center"></el-table-column>
|
<el-table-column prop="reinforcementName" label="配筋" align="center"></el-table-column>
|
<el-table-column prop="blockName" label="块号" align="center"></el-table-column>
|
<template>
|
<el-table-column v-for="item in titleData" :key="item.steelId" :label="`${item.steelName}${item.steelModel}(${item.unit})`" width="180" align="center">
|
<template #default="{ row }">
|
<span>{{showTableInfo(row, item)}}</span>
|
</template>
|
</el-table-column>
|
</template>
|
<el-table-column label="操作" align="center" width="200">
|
<template #default="{ row }">
|
<el-button class="table_btn" size="mini" v-if="showButton('update')" @click="propUpdate(row)">修改</el-button>
|
<el-button class="delete_btn" size="mini" v-if="showButton('delete')" @click="deleteInfo(row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<div class="main_footer">
|
<el-pagination
|
background
|
@current-change="changePageNum"
|
@size-change="changePageSize"
|
:current-page="pageNum"
|
:page-sizes="[10, 20, 50, 100]"
|
:page-size="pageSize"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total">
|
</el-pagination>
|
</div>
|
<!-- 新增钢筋理论耗量 修改钢筋理论耗量信息 -->
|
<el-dialog
|
class="prop_dialog"
|
:title="asyncTitle ? '新增钢筋理论耗量' : '修改钢筋理论耗量信息'"
|
:visible.sync="asyncRebartheory"
|
width="45%">
|
<el-form ref="form" :model="formRebartheory" :rules="rulesRebartheory" label-width="auto" class="rule_form">
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="项目名称:" prop="proId">
|
<el-select v-model="formRebartheory.proId" :size="size" clearable placeholder="请选择项目名称" @change="changeProject">
|
<el-option
|
v-for="item in projectData"
|
:key="item.proId"
|
:label="item.proName"
|
:value="item.proId">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="尺寸:" prop="sizeId">
|
<el-select v-model="formRebartheory.sizeId" :size="size" clearable placeholder="请选择尺寸">
|
<el-option
|
v-for="item in sizeDatas"
|
:key="item.sizes"
|
:label="item.dictName"
|
:value="item.sizes">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="配筋:" prop="reinforcementId">
|
<el-select v-model="formRebartheory.reinforcementId" :size="size" clearable placeholder="请选择配筋">
|
<el-option
|
v-for="item in reinforcementDatas"
|
:key="item.hasSteel"
|
:label="item.dictName"
|
:value="item.hasSteel">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="块号:" prop="blockId">
|
<el-select v-model="formRebartheory.blockId" :size="size" clearable placeholder="请选择块号">
|
<el-option
|
v-for="item in blockDatas"
|
:key="item.blockNum"
|
:label="item.dictName"
|
:value="item.blockNum">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<div style="height: 300px;">
|
<el-table
|
:data="rebarList"
|
height="100%"
|
:header-cell-style="() => 'background-color: #082F57; color: #18F5DB'">
|
<el-table-column label="序号" width="100" align="center">
|
<template #default="scope">
|
<span>{{scope.$index + 1}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="steelName" label="钢筋名称" align="center"></el-table-column>
|
<el-table-column prop="steelModel" label="规格型号" align="center"></el-table-column>
|
<el-table-column label="理论重量(吨)" align="center">
|
<template #default="{ row }">
|
<el-input-number
|
v-model="row.needNum"
|
:size="size"
|
:controls="false"
|
placeholder="请输入">
|
</el-input-number>
|
</template>
|
</el-table-column>
|
<el-table-column label="系数" align="center">
|
<template #default="{ row }">
|
<el-input-number
|
v-model="row.coefficient"
|
:size="size"
|
:controls="false"
|
placeholder="请输入">
|
</el-input-number>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</el-form>
|
<div slot="footer">
|
<el-button @click="asyncRebartheory = false">取 消</el-button>
|
<el-button class="submit_btn" @click="asyncTitle ? submitInsertForm() : submitUpdateForm()">提 交</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { buttonPinia } from "../../pinia/index";
|
import { changeSize, downFiles, throttle } from "../../plugins/public";
|
export default {
|
data() {
|
return {
|
projectId: '',
|
projectData: [],
|
sizeId: '',
|
sizeData: [],
|
sizeDatas: [],
|
reinforcementId: '',
|
reinforcementData: [],
|
reinforcementDatas: [],
|
blockId: '',
|
blockData: [],
|
blockDatas: [],
|
size: changeSize(),
|
pageNum: 1,
|
pageSize: 10,
|
total: 0,
|
loading: true,
|
titleData: [], // 表头信息
|
rebartheoryList: [],
|
asyncTitle: true, // true 新r增钢筋理论耗量 false 修改钢筋理论耗量信息
|
asyncRebartheory: false, // 弹窗
|
formRebartheory: {}, // 表单
|
rulesRebartheory: {
|
proId: [{
|
required: true,
|
message: '请选择项目',
|
trigger: ['change', 'blur']
|
}],
|
sizeId: [{
|
required: true,
|
message: '请选择尺寸',
|
trigger: ['change', 'blur']
|
}],
|
reinforcementId: [{
|
required: true,
|
message: '请选择配筋',
|
trigger: ['change', 'blur']
|
}],
|
blockId: [{
|
required: true,
|
message: '请选择块号',
|
trigger: ['change', 'blur']
|
}]
|
}, // 表单校验规则
|
rebarList: [],
|
}
|
},
|
mounted() {
|
const that = this;
|
// 根据窗口大小动态修改组件尺寸
|
window.onresize = () => {
|
that.size = changeSize();
|
}
|
that.getAllProjectData()
|
that.getTableTitleData().then(() => {
|
that.searchRebartheoryList(true);
|
})
|
},
|
methods: {
|
// 获取表头信息
|
async getTableTitleData() {
|
// 获取表头信息
|
const { data } = await this.$api.Production.getTableTitleInfo();
|
this.titleData = data;
|
this.$nextTick(() => {
|
this.$refs.table.doLayout();
|
})
|
},
|
// 获取项目信息
|
async getAllProjectData() {
|
const { data } = await this.$api.Engineer.searchProjects({
|
pageNum: 1,
|
pageSize: 1000000
|
});
|
this.projectData = data.list;
|
},
|
// 查询钢筋理论耗量信息
|
searchRebartheoryList(bol) {
|
if(bol) {
|
this.pageNum = 1;
|
}
|
this.$api.Production.searchRebartheoryList({
|
proId: this.projectId,
|
sizeId: this.sizeId,
|
reinforcementId: this.reinforcementId,
|
blockId: this.blockId,
|
pageNum: this.pageNum,
|
pageSize: this.pageSize
|
}).then((res) => {
|
if(res.success) {
|
this.total = res.data.total;
|
this.rebartheoryList = res.data.list;
|
}
|
this.loading = false;
|
}).catch(() => {
|
this.loading = false;
|
})
|
},
|
// 查询钢筋类型列表
|
async searchRebarTypeList() {
|
await this.$api.Rebar.searchType({
|
pageNum: 1,
|
pageSize: 1000000
|
}).then((res) => {
|
if(res.success) {
|
this.rebarList = res.data.list.map(item => {
|
this.$set(item, 'needNum', 1);
|
this.$set(item, 'coefficient', 1);
|
return item;
|
});
|
}
|
})
|
},
|
// 打开添加信息
|
propInsert() {
|
this.asyncTitle = true;
|
this.asyncRebartheory = true;
|
this.searchRebarTypeList();
|
},
|
// 打开修改信息
|
propUpdate(row) {
|
this.asyncTitle = false;
|
this.asyncRebartheory = true;
|
this.changeProject(row.proId);
|
this.searchRebarTypeList().then(() => {
|
this.$api.Production.getRebartheoryInfoData({
|
consumptionId: row.consumptionId
|
}).then((res) => {
|
if(res.success) {
|
this.$set(this.formRebartheory, 'consumptionId', row.consumptionId);
|
this.$set(this.formRebartheory, 'proId', res.data.proId);
|
this.$set(this.formRebartheory, 'sizeId', res.data.sizeId);
|
this.$set(this.formRebartheory, 'reinforcementId', res.data.reinforcementId);
|
this.$set(this.formRebartheory, 'blockId', res.data.blockId);
|
res.data.tsteelNeeds.forEach((item, index) => {
|
this.$set(this.rebarList[index], 'needNum', item.needNum);
|
this.$set(this.rebarList[index], 'coefficient', item.coefficient);
|
});
|
}
|
})
|
})
|
},
|
// 导出Excel
|
exportExcel() {
|
this.$api.Production.exportRebartheoryExcel({
|
proId: this.projectId,
|
sizeId: this.sizeId,
|
reinforcementId: this.reinforcementId,
|
blockId: this.blockId
|
}).then((res) => {
|
if( res && res.success != false) {
|
downFiles(res,'钢筋理论耗量', 'xls');
|
} else if(res && res.success === false) {
|
this.$message.warning(res.data.statusMsg || '请联系管理人员');
|
}
|
})
|
},
|
// 删除钢筋理论消耗量信息
|
deleteInfo(row) {
|
this.$confirm("该操作将删除该消耗量信息,是否继续删除?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
this.$api.Production.deleteRebartheoryList({consumptionId: row.consumptionId})
|
.then(res => {
|
if(res.success) {
|
this.searchRebartheoryList(true);
|
this.$message.success("删除成功!");
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
})
|
.catch(() => {
|
this.$message.warning("您已取消");
|
})
|
},
|
// 提交添加信息
|
submitInsertForm: throttle(function() {
|
this.$refs.form.validate((valid) => {
|
if(valid) {
|
const params = Object.assign({}, this.formRebartheory);
|
params.needList = this.rebarList.map(item => {
|
return {
|
steelId: item.steelId,
|
needNum : item.needNum,
|
coefficient: item.coefficient
|
}
|
});
|
this.$api.Production.insetRebartheoryInfo(params).then((res) => {
|
if(res.success) {
|
this.asyncRebartheory = false;
|
this.$message.success('添加成功!');
|
this.searchRebartheoryList(true);
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}
|
})
|
}, 3000),
|
// 提交修改信息
|
submitUpdateForm: throttle(function() {
|
this.$refs.form.validate((valid) => {
|
if(valid) {
|
const params = Object.assign({}, this.formRebartheory);
|
params.needList = this.rebarList.map(item => {
|
return {
|
steelId: item.steelId,
|
needNum : item.needNum,
|
coefficient: item.coefficient
|
}
|
});
|
this.$api.Production.updateRebartheoryList(params).then((res) => {
|
if(res.success) {
|
this.asyncRebartheory = false;
|
this.$message.success('修改成功!');
|
this.searchRebartheoryList(true);
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}
|
})
|
}, 3000),
|
// 动态表头信息回填
|
showTableInfo(row, item) {
|
const data = row.tsteelNeeds.find(element => element.steelId === item.steelId);
|
return data ? data.totals : 0;
|
},
|
// 根据项目获取尺寸 配筋 块号信息
|
changeHeaderProject(data) {
|
this.sizeId = '';
|
this.reinforcementId = '';
|
this.blockId = '';
|
this.blockData = [];
|
this.sizeData = [];
|
this.reinforcementData = [];
|
if(data) {
|
this.$api.Basics.getProjectSystemInfoData({
|
proId: data
|
}).then((res) => {
|
this.blockData = res.data.proBloks;
|
this.sizeData = res.data.proSizes;
|
this.reinforcementData = res.data.proHas;
|
})
|
}
|
},
|
// 根据项目获取尺寸 配筋 块号信息
|
changeProject(data) {
|
if(!this.formRebartheory.proId) {
|
this.blockDatas = [];
|
this.sizeDatas = [];
|
this.reinforcementDatas = [];
|
this.$set(this.formRebartheory, 'sizeId', '');
|
this.$set(this.formRebartheory, 'reinforcementId', '');
|
this.$set(this.formRebartheory, 'blockId', '');
|
}
|
if(data) {
|
this.$api.Basics.getProjectSystemInfoData({
|
proId: data
|
}).then((res) => {
|
this.blockDatas = res.data.proBloks;
|
this.sizeDatas = res.data.proSizes;
|
this.reinforcementDatas = res.data.proHas;
|
})
|
}
|
},
|
// 切换页码
|
changePageNum(page) {
|
this.pageNum = page;
|
this.searchRebartheoryList();
|
},
|
// 切换每页条数
|
changePageSize(size) {
|
this.pageSize = size;
|
this.searchRebartheoryList();
|
},
|
// 判断按钮权限信息
|
showButton(str) {
|
const pinia = buttonPinia();
|
return pinia.$state.buttonInfo.includes(str);
|
}
|
},
|
watch: {
|
asyncRebartheory(bol) {
|
if(!bol) {
|
this.rebarList = [];
|
this.formRebartheory = {};
|
this.$refs.form.resetFields();
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import '../../style/layout-main.scss';
|
|
.header_labels {
|
width: auto;
|
color: #fff;
|
}
|
|
.main_buttons {
|
margin: 0 10px 20px;
|
}
|
|
::v-deep .el-input-number .el-input__inner {
|
text-align: left;
|
background: transparent;
|
}
|
</style>
|