| <template> | 
| <!-- :permissions="['business:appliancechange:query']" --> | 
|   <TableLayout :permissions="['ext:appliancechange:query']"> | 
|     <!-- 搜索表单 --> | 
|     <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" label-suffix=":" inline> | 
|       <el-form-item label="工装编码" prop="appliancesCode"> | 
|         <el-input v-model="searchForm.appliancesCode" 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="produceName"> | 
|         <el-input v-model="searchForm.produceName" placeholder="请输入工序名称" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="批次号" prop="batch"> | 
|         <el-input v-model="searchForm.batch" placeholder="请输入批次号" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="类型" prop="type"> | 
|         <el-select v-model="searchForm.type" filterable clearable placeholder="请选择类型"> | 
|           <el-option | 
|             v-for="(item, index) in types" | 
|             :key="index" | 
|             :label="item.name" | 
|             :value="item.id" | 
|           > | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="所在仓库" prop="warehouseId"> | 
|         <el-select v-model="searchForm.warehouseId" filterable clearable placeholder="请选择所在仓库"  @change="selectWarehouse"> | 
|           <el-option | 
|             v-for="(item, index) in warehouse" | 
|             :key="index" | 
|             :label="item.name" | 
|             :value="item.id" | 
|           > | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="所在货位" prop="locationId"> | 
|         <el-select v-model="searchForm.locationId" :disabled="searchForm.warehouseId==''" filterable clearable placeholder="请选择所在仓库"> | 
|           <el-option | 
|             v-for="(item, index) in warehouseLocation" | 
|             :key="index" | 
|             :label="item.unionName" | 
|             :value="item.id" | 
|           > | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="单据编号" prop="billNO"> | 
|         <el-input v-model="searchForm.billNO" placeholder="请输入单据编号" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="单据类型" prop="billType"> | 
|         <el-select v-model="searchForm.billType" filterable clearable placeholder="请选择单据类型"> | 
|           <el-option | 
|             v-for="(item, index) in billTypes" | 
|             :key="index" | 
|             :label="item.name" | 
|             :value="item.id" | 
|           > | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="质量属性" prop="qualityType"> | 
|         <el-select v-model="searchForm.qualityType" filterable clearable placeholder="请选择质量属性"> | 
|           <el-option | 
|             v-for="(item, index) in qualityTypes" | 
|             :key="index" | 
|             :label="item.name" | 
|             :value="item.id" | 
|           > | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="创建日期" prop="planDate"> | 
|         <el-date-picker | 
|           v-model="planDate" | 
|           value-format="yyyy-MM-dd" | 
|           type="daterange" | 
|           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 | 
|       > | 
|       <!--创建人、创建时间; --> | 
|         <el-table-column prop="billDate" label="单据日期" fixed="left" min-width="140px"></el-table-column>   | 
|         <el-table-column prop="materialCode" label="物料编码" min-width="180px"> | 
|           <template slot-scope="{ row }"> | 
|             <span>{{ row.materialCode }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="materialName" label="物料名称" show-overflow-tooltip min-width="100px"> | 
|           <template slot-scope="{ row }"> | 
|             <span class="long-title-style">{{ row.materialName }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="batch" label="批次号" min-width="100px"></el-table-column> | 
|         <el-table-column prop="produceName" label="工序" show-overflow-tooltip min-width="100px"> | 
|           <template slot-scope="{ row }"> | 
|             <span class="long-title-style">{{ row.produceName }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column label="质量属性" min-width="80px"> | 
|           <template slot-scope="{row}"> | 
|             <span v-if="row.qualityType==0" class="valid-style">合格</span> | 
|             <span v-else-if="row.qualityType==1" class="unvalid-style">不良</span> | 
|             <span v-else-if="row.qualityType==2" class="scrap-style">报废</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="num" label="数量" min-width="80px"> | 
|           <template slot-scope="{ row }"> | 
|             <span>{{ row.num + row.unitName }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="appliancesCode" label="工装编码" min-width="100px"></el-table-column> | 
|         <el-table-column label="类型" min-width="80px"> | 
|           <template slot-scope="{row}"> | 
|             <span>{{row.type==0?'出库单':'入库单'}}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="warehouseName" label="所在仓库" show-overflow-tooltip min-width="140px"> | 
|           <template slot-scope="{ row }"> | 
|             <span class="long-title-style">{{ row.warehouseName }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="locationName" label="库位" show-overflow-tooltip min-width="140px"> | 
|           <template slot-scope="{ row }"> | 
|             <span class="long-title-style">{{ row.locationName }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="billNo" label="单据编码" show-overflow-tooltip min-width="140px"> | 
|           <template slot-scope="{ row }"> | 
|             <span class="long-title-style">{{ row.billNo }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="billType" label="单据类型" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             <span >{{billTypeToStr(row.billType)}}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="createUserName" label="创建人" min-width="100px"></el-table-column> | 
|         <el-table-column prop="createTime" label="创建时间" min-width="140px" fixed="right"> | 
|         </el-table-column> | 
|       </el-table> | 
|       <pagination | 
|         @size-change="handleSizeChange" | 
|         @current-change="handlePageChange" | 
|         :pagination="tableData.pagination" | 
|       ></pagination> | 
|     </template> | 
|     <OperaApplianceChangeDetailWindow ref="operaApplianceChangeDetailWindow"/> | 
|   </TableLayout> | 
| </template> | 
|   | 
| <script> | 
| import BaseTable from '@/components/base/BaseTable' | 
| import TableLayout from '@/layouts/TableLayout' | 
| import Pagination from '@/components/common/Pagination' | 
| import OperaApplianceChangeDetailWindow from '@/components/ext/OperaApplianceChangeDetailWindow' | 
| import { queryWarehouseAllData } from '@/api/ext/warehouseExt' | 
| import { getListByWarehouseId } from '@/api/ext/warehouseLocationExt' | 
| import { addPrecision } from '@/utils/util' | 
| export default { | 
|   name: 'warehouseApplianceExt', | 
|   extends: BaseTable, | 
|   components: { TableLayout, Pagination, OperaApplianceChangeDetailWindow }, | 
|   data () { | 
|     return { | 
|       // 搜索 | 
|       searchForm: { | 
|         appliancesCode: '', | 
|         batch: '', | 
|         beginDate: '', | 
|         billNO: '', | 
|         billType: '', | 
|         // departId: 1, | 
|         endDate: '', | 
|         locationId: '', | 
|         materialCode: '', | 
|         produceName: '', | 
|         qualityType: '', | 
|         // rootDepartId: , | 
|         type: '', | 
|         warehouseId: '' | 
|       }, | 
|       planDate: [], | 
|       warehouse: [], | 
|       types: [ | 
|         {name: '出库单', id: 0}, | 
|         {name: '入库单', id: 1}, | 
|       ], | 
|       billTypes: [ | 
|         { name: '车间领料', id: 1 }, | 
|         { name: '计划领料', id: 2 }, | 
|         { name: '机台备料', id: 3 }, | 
|         { name: '完工入库', id: 4 }, | 
|         { name: '车间转库', id: 5 }, | 
|         { name: '外协领料转库', id: 6 }, | 
|         { name: '外协完工转库', id: 7 }, | 
|         { name: '产品入库', id: 8 }, | 
|         { name: '产品转库', id: 9 }, | 
|         { name: '让步放行入库', id: 10 }, | 
|         { name: '让步放行转库', id: 11 }, | 
|         { name: '客返返修领料', id: 12 }, | 
|         { name: '客返返修入库', id: 13 }, | 
|         { name: '跨组织转库', id: 14 }, | 
|         { name: '工序报废', id: 15 }, | 
|         { name: '客退返修领料', id: 16 }, | 
|         { name: '客退返修入库', id: 17 }, | 
|         { name: '销售出库', id: 18 }, | 
|         { name: '让步销售', id: 19 }, | 
|         { name: '工单投料', id: 20 }, | 
|         { name: '仓库报废', id: 21 }, | 
|         { name: '客退检验领料', id: 22 }, | 
|         { name: '客返检验领料', id: 23 }, | 
|         { name: '工单产出', id: 24 }, | 
|         { name: '采购入库', id: 25 }, | 
|         { name: '客退检验入库', id: 26 }, | 
|         { name: '客返检验入库', id: 27 }, | 
|         { name: '库存调整', id: 28 }, | 
|         { name: '废品入库', id: 30 }, | 
|       ], | 
|       qualityTypes: [ | 
|         {name: '合格', id: 0}, | 
|         {name: '不良', id: 1}, | 
|         {name: '报废', id: 2}, | 
|       ], | 
|       warehouseLocation: [] | 
|     } | 
|   }, | 
|   created () { | 
|     this.config({ | 
|       module: '出入库篮筐明细', | 
|       api: '/ext/warehouseApplianceExt', | 
|       'field.id': 'id', | 
|       'field.main': 'id', | 
|       sorts: [{ direction: 'DESC', property: 'CREATE_TIME' }] | 
|     }) | 
|     queryWarehouseAllData({ status: 1, rootDepartId: this.$store.state.userInfo.curComDepartment.id }) | 
|       .then(res => { | 
|         this.warehouse = res | 
|       }) | 
|       .catch(err => { | 
|         console.log(err) | 
|       }) | 
|     this.search() | 
|      | 
|   }, | 
|   methods: { | 
|     dateChange (v) { | 
|       this.searchForm.beginDate = v[0] | 
|       this.searchForm.endDate = v[1] | 
|     }, | 
|     reset () { | 
|       this.$refs.searchForm.resetFields() | 
|       this.searchForm.beginDate = null | 
|       this.searchForm.endDate = null | 
|       this.planDate = [] | 
|       this.search() | 
|     }, | 
|     billTypeToStr (billType) { | 
|       for (const item of this.billTypes) { | 
|         if (item.id === billType) { | 
|           return item.name | 
|         } | 
|       } | 
|       return '' | 
|     }, | 
|     selectWarehouse(value) { | 
|       // console.log(value); | 
|       this.warehouseLocation = [] | 
|       this.searchForm.locationId = '' | 
|       if (!value) { | 
|         return | 
|       } | 
|       getListByWarehouseId(value, 1) | 
|         .then(res => { | 
|           // console.log(res) | 
|           this.warehouseLocation = res | 
|         }) | 
|         .catch(err => { | 
|           console.log(err) | 
|         }) | 
|     }, | 
|     getSummaries (param) { | 
|       const { columns, data } = param; | 
|       const sums = []; | 
|       columns.forEach((column, index) => { | 
|         if (index === 0) { | 
|           sums[index] = '合计'; | 
|           return; | 
|         } else if (index === 12 || index === 3 || index === 7) { | 
|           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> |