<template>
|
<div class="main" v-if="!showDrawing">
|
<div class="main_header">
|
<div class="header_item">
|
<!-- <el-button
|
:size="size"
|
icon="el-icon-search"
|
v-if="showButton('search')"
|
@click="searchDrawingTypeList(true)"
|
>查询</el-button> -->
|
<el-button
|
class="search_btn"
|
icon="el-icon-plus"
|
v-if="showButton('insert')"
|
@click="propInsert()"
|
>新增</el-button>
|
</div>
|
</div>
|
<div class="main_content">
|
<el-table
|
v-loading="loading"
|
:data="drawingList"
|
height="100%">
|
<el-table-column label="序号" align="center">
|
<template #default="scope">
|
<span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="drawTypeName" label="图纸类型" align="center"></el-table-column>
|
<el-table-column label="操作" align="center">
|
<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>
|
<el-button class="table_btn" size="mini" v-if="showButton('delete')" @click="propDrawingList(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="asyncDrawing"
|
width="35%">
|
<el-form ref="form" :model="formDrawing" label-width="auto" class="rule_form">
|
<el-form-item label="图纸类型名称:" :rules="{
|
required: true,
|
message: '请输入图纸类型',
|
trigger: 'blur'}">
|
<el-input v-model="formDrawing.drawTypeName"></el-input>
|
</el-form-item>
|
</el-form>
|
<div slot="footer">
|
<el-button @click="asyncDrawing = false">取 消</el-button>
|
<el-button class="submit_btn" @click="asyncTitle ? submitInsertForm() : submitUpdateForm()">提 交</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
<div v-else>
|
<drawing-list :show-drawing.sync="showDrawing" :draw-type-id="drawTypeId"></drawing-list>
|
</div>
|
</template>
|
|
<script>
|
import { buttonPinia } from '../../pinia';
|
import { changeSize, throttle } from '../../plugins/public';
|
import DrawingList from './components/DrawingList';
|
export default {
|
data() {
|
return {
|
size: changeSize(),
|
total: 0,
|
pageNum: 1,
|
pageSize: 10,
|
loading: false,
|
drawingList: [],
|
asyncTitle: true, // true 新增图纸类型 false 修改图纸类型
|
asyncDrawing: false, // 弹窗
|
formDrawing: {}, // 表单信息
|
showDrawing: false,
|
drawTypeId: ''
|
}
|
},
|
mounted() {
|
const that = this;
|
// 根据窗口大小动态修改组件尺寸
|
window.onresize = () => {
|
that.size = changeSize();
|
}
|
that.searchDrawingTypeList(true);
|
},
|
methods: {
|
// 查询图纸类型列表
|
searchDrawingTypeList(bol) {
|
if(bol) {
|
this.pageNum = 1;
|
}
|
this.loading = true;
|
this.drawingList = [];
|
this.$api.Project.searchDrawingTypeList({
|
pageNum: this.pageNum,
|
pageSize: this.pageSize
|
}).then((res) => {
|
if(res.success) {
|
this.total = res.data.total;
|
this.drawingList = res.data.list;
|
}
|
this.loading = false;
|
}).catch(() => {
|
this.loading = false;
|
})
|
},
|
// 打开添加信息
|
propInsert() {
|
this.asyncTitle = true;
|
this.asyncDrawing = true;
|
},
|
// 打开修改信息
|
propUpdate(row) {
|
this.asyncTitle = false;
|
this.asyncDrawing = true;
|
this.$set(this.formDrawing, 'drawTypeId', row.drawTypeId);
|
this.$set(this.formDrawing, 'drawTypeName', row.drawTypeName);
|
},
|
// 删除图纸类型信息
|
deleteInfo(row) {
|
this.$confirm("该操作将删除该图纸类型信息,是否继续删除?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
this.$api.Project.deleteDrawingTypeInfo({drawTypeId: row.drawTypeId})
|
.then(res => {
|
if(res.statusMsg === 'ok') {
|
this.searchDrawingTypeList(true);
|
this.$message.success("删除成功!");
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
})
|
.catch(() => {
|
this.$message.warning("您已取消");
|
})
|
},
|
// 打开图纸列表
|
propDrawingList(row) {
|
this.showDrawing = true;
|
this.drawTypeId = row.drawTypeId
|
},
|
// 提交添加信息
|
submitInsertForm: throttle(function() {
|
this.$refs.form.validate((valid) => {
|
if(valid) {
|
const params = Object.assign({}, this.formDrawing);
|
this.$api.Project.insertDrawingTypeInfo(params).then((res) => {
|
if(res.success) {
|
this.asyncDrawing = false;
|
this.searchDrawingTypeList(true);
|
this.$message.success('添加成功!');
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}
|
})
|
}, 3000),
|
// 提交修改信息
|
submitUpdateForm: throttle(function() {
|
this.$refs.form.validate((valid) => {
|
if(valid) {
|
const params = Object.assign({}, this.formDrawing);
|
this.$api.Project.insertDrawingTypeInfo(params).then((res) => {
|
if(res.success) {
|
this.asyncDrawing = false;
|
this.searchDrawingTypeList(true);
|
this.$message.success('修改成功!');
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}
|
})
|
}, 3000),
|
// 切换页码
|
changePageNum(page) {
|
this.pageNum = page;
|
this.searchDrawingTypeList();
|
},
|
// 切换每页条数
|
changePageSize(size) {
|
this.pageSize = size;
|
this.searchDrawingTypeList();
|
},
|
// 判断按钮权限信息
|
showButton(str) {
|
const pinia = buttonPinia();
|
return pinia.$state.buttonInfo.includes(str);
|
}
|
},
|
components: {
|
DrawingList
|
},
|
watch: {
|
asyncDrawing(bol) {
|
if(!bol) {
|
this.formDrawing = {};
|
this.$refs.form.resetFields();
|
}
|
},
|
showDrawing(bol) {
|
if(!bol) {
|
this.drawTypeId = ''
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import '../../style/layout-main.scss';
|
|
// .drawing_index {
|
// position: relative;
|
// }
|
</style>
|