| <template> | 
|   <TableLayout v-permissions="['ext:woutboundext:query']"> | 
|     <!-- 搜索表单 --> | 
|     <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="120px" label-suffix=":" inline> | 
|       <el-form-item label="入库单号" prop="code"> | 
|         <el-input v-model="searchForm.code" placeholder="请输入入库单号" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="入库仓库" prop="warehouseId"> | 
|         <el-select v-model="searchForm.warehouseId" clearable filterable placeholder="请选择入库仓库"> | 
|           <el-option | 
|             v-for="item in warehouses" | 
|             :key="item.id" | 
|             :label="item.name" | 
|             :value="item.id" | 
|           ></el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="来源单据类型" prop="originType"> | 
|         <el-select v-model="searchForm.originType" clearable placeholder="请选择"> | 
|           <el-option | 
|             v-for="(item, index) in originTypes" | 
|             :key="index" | 
|             :label="item.name" | 
|             :value="item.id"> | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="来源单据编号" prop="originCode"> | 
|         <el-input v-model="searchForm.originCode" placeholder="请输入来源单据编号" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="单据状态" prop="status"> | 
|         <el-select v-model="searchForm.status" clearable placeholder="请选择"> | 
|           <el-option | 
|             v-for="(item, index) in status" | 
|             :key="index" | 
|             :label="item.name" | 
|             :value="item.id"> | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="单据类型" prop="billType"> | 
|         <el-select v-model="searchForm.billType" placeholder="请选择单据类型" clearable filterable> | 
|           <el-option | 
|             v-for="(item, index) in billType" | 
|             :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:woutboundext:adjustment']"> | 
|         <!-- <li><el-button type="primary" @click="$refs.operaWInboundExtWindow.open('新建入库单')" v-permissions="['ext:woutboundext:create']">新建</el-button></li> --> | 
|         <li><el-button type="primary" @click="$refs.operaWInboundExtWindow.open('原材料入库', 1)" v-permissions="['ext:woutboundext:adjustment']">采购入库</el-button></li> | 
|         <li><el-button type="primary" @click="$refs.operaWInboundExtWindow.open('其它入库', 2)" v-permissions="['ext:woutboundext:adjustment']">其它入库</el-button></li> | 
|       </ul> | 
|       <el-table | 
|         v-loading="isWorking.search" | 
|         :data="tableData.list" | 
|         stripe | 
|         border | 
|         @selection-change="handleSelectionChange" | 
|       > | 
|         <el-table-column label="入库单号" fixed="left" min-width="140px"> | 
|           <template slot-scope="{row}"> | 
|             <el-button type="text" @click="showDetail(row)"> | 
|               {{ row.code }} | 
|             </el-button> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column label="单据类型" min-width="80px"> | 
|           <template slot-scope="{ row }"> | 
|             {{ billToStr(row.billType) }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column label="入库仓库" show-overflow-tooltip min-width="140px"> | 
|           <template slot-scope="{row}"> | 
|             <span class="long-title-style">{{ row.warehouseCode + ' | ' + row.warehouseName}}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="planDate" label="计划入库时间" min-width="100px"></el-table-column> | 
|         <el-table-column label="物料信息" min-width="180px"> | 
|           <template slot-scope="{row}"> | 
|             <div :title="materailsStr(row)" style="width:100%"> | 
|               <div class="long-title-style" v-if="row.woutboundDetails.length >= 1">{{ materailStr(row.woutboundDetails[0]) }}</div> | 
|               <div class="long-title-style" v-if="row.woutboundDetails.length >= 2">{{ materailStr(row.woutboundDetails[1]) }}</div> | 
|               <div class="long-title-style" v-if="row.woutboundDetails.length >= 3">{{ materailStr(row.woutboundDetails[2]) }}</div> | 
|               <div class="long-title-style" v-if="row.woutboundDetails.length >= 4">{{ materailStr(row.woutboundDetails[3]) }}</div> | 
|             </div> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="originType" label="来源单据类型" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ originTypeToStr(row.originType) }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="originCode" label="来源单据编号" min-width="140px"> | 
|           <template slot-scope="{row}"> | 
|             {{ row.originCode || '-'}} | 
|           </template> | 
|         </el-table-column> | 
|         <!-- <el-table-column prop="procedureName" label="申请工序" min-width="100px"></el-table-column> --> | 
|         <el-table-column prop="status" label="申请人员" show-overflow-tooltip min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             <span class="long-title-style" :title="applyStr(row)">{{ applyStr(row) }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="status" label="单据状态" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ statusToStr(row.status) }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="createTime" label="创建时间" min-width="140px"></el-table-column> | 
|         <el-table-column label="操作" fixed="right" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             <el-button v-if="row.status==0" type="text" @click="cancel(row)" v-permissions="['ext:woutboundext:delete']">取消</el-button> | 
|             <span v-else>-</span> | 
|           </template> | 
|         </el-table-column> | 
|       </el-table> | 
|       <pagination | 
|         @size-change="handleSizeChange" | 
|         @current-change="handlePageChange" | 
|         :pagination="tableData.pagination" | 
|       ></pagination> | 
|     </template> | 
|     <!-- 新建/修改 --> | 
|     <OperaWInboundExtWindow ref="operaWInboundExtWindow" @success="handlePageChange"/> | 
|     <OperaWboundDetailExtWindow ref="operaWboundDetailExtWindow"/> | 
|     <OrderCancel ref="orderCancel" @success="handlePageChange"/> | 
|   </TableLayout> | 
| </template> | 
|   | 
| <script> | 
| import BaseTable from '@/components/base/BaseTable' | 
| import TableLayout from '@/layouts/TableLayout' | 
| import Pagination from '@/components/common/Pagination' | 
| import OperaWInboundExtWindow from '@/components/ext/OperaWInboundExtWindow' | 
| import OperaWboundDetailExtWindow from '@/components/ext/OperaWboundDetailExtWindow' | 
| import OrderCancel from '@/components/ext/OperaWOrderCancel' | 
| import { wOutboundExt } from '@/api/ext/wOutboundExt' | 
| import { queryWarehouseAllData } from '@/api/ext/warehouseExt' | 
| export default { | 
|   name: 'WInboundExt', | 
|   extends: BaseTable, | 
|   components: { TableLayout, Pagination, OperaWInboundExtWindow, OperaWboundDetailExtWindow, OrderCancel }, | 
|   data () { | 
|     return { | 
|       // 搜索 | 
|       searchForm: { | 
|         code: '', | 
|         originType: '', | 
|         originCode: '', | 
|         warehouseId: '', | 
|         status: '', | 
|         planDateStart: '', | 
|         planDateEnd: '', | 
|         type: 1 // 0出库 1入库 | 
|       }, | 
|       planDate: [], | 
|       warehouses:[], | 
|       originTypes: [ | 
|       // 0采购订单、1生产工单、2销售订单、3转库单、4盘点单 | 
|         { name: '采购订单', id: 0 }, | 
|         { name: '生产工单', id: 1 }, | 
|         { name: '销售订单', id: 2 }, | 
|         { name: '转库单', id: 3 }, | 
|         { name: '盘点单', id: 4 } | 
|       ], | 
|       status: [ | 
|       // 0已生成、1已处理、2已取消 | 
|         { name: '已生成', id: 0 }, | 
|         { name: '已处理', id: 1 }, | 
|         { name: '已取消', id: 2 } | 
|       ], | 
|       // 1、车间领料;2、机台备料;3、 车间转库;4、完工入库;5、计划领料; | 
|       // 6、外协领料 ;7、外协完工转库;8、产品入库 ;9、产品转库 ;10、让步放行入库 ; | 
|       // 11、让步放行转库;12、客返返修领料;13、客返返修领料;14、客返返修领料;15、工单投料(出库),工单产出(入); | 
|       // 16、销售出库;17、让步销售 | 
|       // billType: [ | 
|       //   { 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 }, | 
|       // ], | 
|       billType: [ | 
|         { 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: 24 }, | 
|         { name: '采购入库', id: 25 }, | 
|         { name: '客退检验入库', id: 26 }, | 
|         { name: '客返检验入库', id: 27 }, | 
|         { name: '库存调整', id: 28 }, | 
|         { name: '转库退回', id: 29 }, | 
|         { name: '废品入库', id: 30 }, | 
|       ] | 
|     } | 
|   }, | 
|   provide() { | 
|     return { | 
|       warehouses: () => this.warehouses | 
|     } | 
|   }, | 
|   created () { | 
|     this.config({ | 
|       module: '入库单信息', | 
|       api: '/ext/wOutboundExt', | 
|       'field.id': 'id', | 
|       'field.main': 'name', | 
|       sorts: [{ direction: 'DESC', property: 'CREATE_TIME' }] | 
|     }) | 
|     this.search() | 
|   }, | 
|   activated() { | 
|     queryWarehouseAllData({ status: 1, rootDepartId: this.$store.state.userInfo.curComDepartment.id }) | 
|       .then(res => { | 
|         this.warehouses = res | 
|       }) | 
|       .catch(err => { | 
|         console.log(err) | 
|       }) | 
|   }, | 
|   methods: { | 
|     dateChange (v) { | 
|       // console.log(v) | 
|       this.searchForm.planDateStart = v[0] | 
|       this.searchForm.planDateEnd = v[1] | 
|     }, | 
|     reset () { | 
|       // console.log('rest', this.searchDate) | 
|       this.planDate = [] | 
|       this.searchForm.planDateStart = '' | 
|       this.searchForm.planDateEnd = '' | 
|       this.$refs.searchForm.resetFields() | 
|       this.search() | 
|     }, | 
|     showDetail (row) { | 
|       wOutboundExt(row.id) | 
|         .then(res => { | 
|           this.$refs.operaWboundDetailExtWindow.open('入库详情', res, 1) | 
|         }) | 
|         .catch(err => { | 
|           this.$tip.errpr(err) | 
|         }) | 
|     }, | 
|     cancel (row) { | 
|       this.$refs.orderCancel.open('取消入库', { id: row.id }, 0) | 
|     }, | 
|     originTypeToStr (type) { | 
|       for (const item of this.originTypes) { | 
|         if (item.id === parseInt(type)) { | 
|           return item.name | 
|         } | 
|       } | 
|       return '-' | 
|     }, | 
|     statusToStr (status) { | 
|       for (const item of this.status) { | 
|         if (item.id === parseInt(status)) { | 
|           return item.name | 
|         } | 
|       } | 
|       return '' | 
|     }, | 
|     materailsStr (row) { | 
|       let str = '' | 
|       for (const item of row.woutboundDetails) { | 
|         if (str) { | 
|           str = str.concat('\n') | 
|         } | 
|         str = str.concat(this.materailStr(item)) | 
|       } | 
|       return str | 
|     }, | 
|     materailStr (item) { | 
|       let str = ''; | 
|       str += `【${item.materialCode}】${item.materialName}` | 
|       if (item.batch) { | 
|         str += item.batch | 
|       } | 
|       if (item.procedureName) { | 
|         str += ` | ${item.procedureName}` | 
|       } | 
|       switch (item.qualityType) { | 
|         case 0: str += ' | 合格'; break; | 
|         case 1: str += ' | 不良'; break | 
|         case 2: str += ' | 报废'; break | 
|       } | 
|       str += ` X ${item.num}` | 
|       return str | 
|     }, | 
|     applyStr (row) { | 
|       return `${row.userName}/${row.userDepartName}` | 
|     }, | 
|     billToStr (type) { | 
|       for (const item of this.billType) { | 
|         if (item.id === type) return item.name | 
|       } | 
|     } | 
|   } | 
| } | 
| </script> |