| <template> | 
|   <TableLayout v-permissions="['ext:endcheckext:query']"> | 
|     <!-- 搜索表单 --> | 
|     <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" label-suffix=":" inline> | 
|       <el-form-item label="物料名称" prop="materialName"> | 
|         <el-input v-model="searchForm.materialName" placeholder="请输入物料名称" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="物料编码" prop="materialCode"> | 
|         <el-input v-model="searchForm.materialCode" placeholder="请输入物料编码" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="工单编号" prop="workOrderCode"> | 
|         <el-input v-model="searchForm.workOrderCode" placeholder="请输入工单编号" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="检验结果" prop="downType"> | 
|         <el-select v-model="searchForm.downType" clearable filterable placeholder="请选择检验结果"> | 
|           <el-option | 
|             v-for="item in status" | 
|             :key="item.id" | 
|             :label="item.label" | 
|             :value="item.id" | 
|           ></el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="检验类型" prop="checkType"> | 
|         <el-select v-model="searchForm.checkType" clearable filterable placeholder="请选择检验类型"> | 
|           <el-option | 
|             v-for="item in checkTypes" | 
|             :key="item.id" | 
|             :label="item.label" | 
|             :value="item.id" | 
|           ></el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="检验时间"> | 
|         <el-date-picker | 
|           v-model="planDate" | 
|           type="daterange" | 
|           value-format="yyyy-MM-dd" | 
|           range-separator="~" | 
|           start-placeholder="开始日期" | 
|           end-placeholder="结束日期" | 
|           @change="dateChange" | 
|         ></el-date-picker> | 
|       </el-form-item> | 
|       <section> | 
|         <el-button type="primary" @click="search">搜索</el-button> | 
|         <el-button @click="reset">重置</el-button> | 
|       </section> | 
|     </el-form> | 
|     <!-- 表格和分页 --> | 
|     <template v-slot:table-wrap> | 
|       <ul class="toolbar"> | 
|         <!-- v-permissions="['ext:workorderrecordext:exportExcel']" --> | 
|         <li ><el-button type="primary" :loading="isWorking.export" @click="exportExcel">导出</el-button></li> | 
|       </ul> | 
|       <el-table | 
|         v-loading="isWorking.search" | 
|         :data="tableData.list" | 
|         stripe | 
|         border | 
|         :summary-method="getSummaries" | 
|         show-summary | 
|         @selection-change="handleSelectionChange" | 
|       > | 
|         <!-- <el-table-column type="selection" width="55"></el-table-column> --> | 
|         <el-table-column prop="code" label="检验记录编号" fixed="left" show-overflow-tooltip min-width="140px"></el-table-column> | 
|         <el-table-column prop="createTime" label="检验时间" min-width="140px"></el-table-column> | 
|         <el-table-column label="检验类型" min-width="140px"> | 
|           <template slot-scope="{row}"> | 
|             {{ row.type == 0 ? '生产终检' : '-' }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column label="检验结果" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             <span v-if="row.doneType==0" class="valid-style">合格</span> | 
|             <span v-else class="unvalid-style">不合格</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column label="检验方式" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ row.checkType == 0 ? '检具检' : '外观检' }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column label="检验数量" prop="num" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ row.num + (row.unitName || '') }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="workOrderCode" label="工单编号" min-width="140px"></el-table-column> | 
|         <el-table-column prop="materialName" label="物料名称" min-width="100px"></el-table-column> | 
|         <el-table-column prop="materialCode" label="物料编码" min-width="160px"></el-table-column> | 
|         <el-table-column label="操作" fixed="right" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             <el-button type="text" @click="showDetail(row)">查看详情</el-button> | 
|           </template> | 
|         </el-table-column> | 
|       </el-table> | 
|       <pagination | 
|         @size-change="handleSizeChange" | 
|         @current-change="handlePageChange" | 
|         :pagination="tableData.pagination" | 
|       ></pagination> | 
|     </template> | 
|     <OperaEndCheckDetailWindow ref="operaEndCheckDetailWindow"></OperaEndCheckDetailWindow> | 
|   </TableLayout> | 
| </template> | 
|   | 
| <script> | 
| import BaseTable from '@/components/base/BaseTable' | 
| import TableLayout from '@/layouts/TableLayout' | 
| import Pagination from '@/components/common/Pagination' | 
| import OperaEndCheckDetailWindow from '@/components/ext/OperaEndCheckDetailWindow' | 
| import { endCheckDetailById } from '@/api/ext/endcheckExt' | 
| import { addPrecision } from '@/utils/util' | 
| export default { | 
|   name: 'EndcheckExt', | 
|   extends: BaseTable, | 
|   components: { TableLayout, Pagination, OperaEndCheckDetailWindow }, | 
|   data () { | 
|     return { | 
|       // 搜索 | 
|       searchForm: { | 
|         materialName: '', | 
|         materialCode: '', | 
|         workOrderCode: '', | 
|         downType: '', | 
|         checkType: '', | 
|         checkTimeStart: '', | 
|         checkTimeEnd: '', | 
|       }, | 
|       planDate: [], | 
|       status: [ | 
|         { | 
|           label: '合格', | 
|           id: 0 | 
|         }, | 
|         { | 
|           label: '不良', | 
|           id: 1 | 
|         } | 
|       ], | 
|       checkTypes: [ | 
|         { | 
|           label: '检具检', | 
|           id: 0 | 
|         }, | 
|         { | 
|           label: '外观检', | 
|           id: 1 | 
|         } | 
|       ] | 
|     } | 
|   }, | 
|   created () { | 
|     this.config({ | 
|       module: '工单类-终检检验信息表Ext', | 
|       api: '/ext/endcheckExt', | 
|       'field.id': 'id', | 
|       'field.main': 'name' | 
|     }) | 
|     this.search() | 
|   }, | 
|   methods: { | 
|     dateChange(v) { | 
|       this.searchForm.checkTimeStart = v[0] | 
|       this.searchForm.checkTimeEnd = v[1] | 
|     }, | 
|     reset () { | 
|       this.planDate = [] | 
|       this.searchForm.checkTimeStart = '' | 
|       this.searchForm.checkTimeEnd = '' | 
|       this.$refs.searchForm.resetFields() | 
|       this.search() | 
|     }, | 
|     showDetail (row) { | 
|       // console.log(row) | 
|       endCheckDetailById(row.id) | 
|         .then(res => { | 
|           // console.log(res) | 
|           this.$refs.operaEndCheckDetailWindow.open('检验详情', res) | 
|         }) | 
|         .catch(err => { | 
|           this.$message.error(err) | 
|         }) | 
|     }, | 
|     getSummaries (param) { | 
|       const { columns, data } = param; | 
|       const sums = []; | 
|       columns.forEach((column, index) => { | 
|         if (index === 0) { | 
|           sums[index] = '合计'; | 
|           return; | 
|         } else if (index === 8) { | 
|           sums[index] = '-'; | 
|           return; | 
|         } | 
|         const values = data.map(item => Number(item[column.property])); | 
|         if (!values.every(value => isNaN(value))) { | 
|           sums[index] = 0 | 
|           values.forEach(item => { | 
|             sums[index] = addPrecision(item, sums[index]) | 
|           }) | 
|         } else { | 
|           sums[index] = '-'; | 
|         } | 
|       }); | 
|       return sums | 
|     } | 
|   } | 
|   | 
| } | 
|   | 
| </script> |