<!--供应商列表--> <template> <div class="product_container"> <div class="productFun"> <div class="productInput"> 供应商编号 <div class="inputBox" style="width: 200px"> <el-input v-model="selectInfo.supplierCode" placeholder="请输入编号" clearable class="product-input" /> </div> 供应商名称 <div class="inputBox" style="width: 200px"> <el-input v-model="selectInfo.supplierName" placeholder="请输入名称" clearable class="product-input" /> </div> 供应商状态 <div class="inputBox" style="width: 200px"> <el-select v-model="selectInfo.supplierStatus" clearable placeholder="供应商状态" style="width: 200px"> <el-option v-for="item in supplierStatusOptions" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </div> </div> <div class="productBtn"> <el-button type="primary" icon="el-icon-search" class="btnItem" @click="selectData"> 查询 </el-button> <el-button type="primary" icon="el-icon-refresh-right" class="btnItem" @click="reset"> 重置 </el-button> <el-button type="primary" icon="el-icon-folder-opened" class="btnItem" @click="exportToExcel"> 导出 </el-button> </div> </div> <el-table ref="multipleTable" :data="tableData.rows" :row-class-name="tableRowClassName" :header-cell-style="{ 'text-align': 'center', background: ' #2483b3', color: 'white', }" :row-style="{ 'text-align': 'center' }" style="width: 100%"> <el-table-column prop="index" width="100px" label="序号" /> <el-table-column prop="supplierCode" width="200px" label="供应商编号" /> <el-table-column prop="supplierName" width="400px" label="供应商名称" /> <el-table-column prop="supplierStatusName" label="供应商状态" /> <el-table-column prop="preReviewResultName" label="资料预审结果" /> <el-table-column prop="inputReviewResultName" label="录库评审结果" /> <el-table-column prop="latestQuarterlyEvaluateResultName" label="最近季度评价结果" /> <el-table-column prop="latestAnnualAssessResultName" label="最新年度考核结果" /> <el-table-column label="操作"> <template slot-scope="scope"> <el-button type="text" size="small" @click="detail(scope.row)"> 详情 </el-button> <!-- <el-button type="text" size="small">编辑</el-button> --> </template> </el-table-column> </el-table> <!-- 分页组件 --> <group-page v-model="isFristPage" :limit="limit" :total="total" :offset="offset" :count="tableData.total" @setOffset="setOffset" @setLimit="setLimit" /> <!-- 新增弹框 --> <supplier-detail ref="supplierDetail" /> </div> </template> <script> // 组件 import GroupPage from "@/components/mycomponent/groupPage"; import SupplierDetail from "@/views/supplier/supplierDetail"; // 逻辑 import { tableRowClassName } from "@/utils/myUtils/changeTableTr"; import { getDictByCode } from "@/api/system/dict"; import { listMixin } from "@/utils/myUtils/mixins/listPage"; import { listPage } from "@/api/supplier/supplier"; import { outToExcel } from '@/utils/myUtils/exportToExcel' export default { // 加入分页逻辑 components: { SupplierDetail, GroupPage, }, mixins: [listMixin], data() { return { selectInfo: { supplierCode: "", supplierName: "", supplierStatus: "", }, supplierStatusOptions: [], }; }, mounted() { this.getSupplierStatusDict(); this.getListPage(); }, methods: { tableRowClassName: tableRowClassName, getSupplierStatusDict() { getDictByCode("supplierStatus").then((response) => { if (response.code === 200) { this.supplierStatusOptions = response.data; } }); }, // 获取指定页面 getListPage(limit = 10, offset = 1) { listPage(`limit=${limit}&offset=${offset}`, this.queryInfo).then( (res) => { // 得到相关数据 res.rows.forEach((item, index) => { item.index = index + 1 + (offset - 1) * 10; }); this.tableData = res; } ); }, reset() { this.selectInfo = { supplierCode: "", supplierName: "", supplierStatus: "", }; }, detail(row) { this.$refs.supplierDetail.initDialog("detail", row); }, exportToExcel() { console.log('导出') // 全屏加载动画; const loading = this.$loading({ lock: true, text: "数据处理中,请稍后...", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }); listPage(`limit=100000000&offset=1`, {}) .then((res) => { res.rows = res.rows.map((item, index) => { return { 序号: index + 1, 供应商编号: item.supplierCode, 供应商名称: item.supplierName, 供应商状态: item.supplierStatusName, 资料预审结果: item.preReviewResultName, 录库评审结果: item.inputReviewResultName, 最近季度评价结果: item.latestQuarterlyEvaluateResultName, 最新年度考核结果: item.latestAnnualAssessResultName } }) outToExcel(res.rows, '供应商列表'); loading.close(); // 关闭加载动画 this.$message({ message: "导出成功", type: "success", }); }) .catch((error) => { loading.close(); // 关闭加载动画 this.$message({ message: error.message, type: "error", }); }); }, }, }; </script> <style lang="scss" scoped> .product_container { position: relative; width: 100%; min-height: 700px; overflow: auto; .productData { width: 100%; display: flex; justify-content: center; .middle { margin: 0 30px; } } .productFun { margin: 10px 20px; display: flex; justify-content: space-between; .productInput { display: flex; align-items: center; .inputBox { margin: 0 50px 0 10px; } } .productBtn { .btnItem { margin-right: 10px; border-radius: 5px; // height: 32px; // width: 84px; font-size: 16px; } } } .footer { display: flex; justify-content: space-between; color: #6666; margin: 30px 10px; } } </style>