| <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" clearable placeholder="请选择单据类型"> | 
|           <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" | 
|           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:create']"> | 
|         <li><el-button type="primary" @click="openWOutbound(1)" v-permissions="['ext:woutboundext:create']">新建</el-button></li> | 
|         <li><el-button type="primary" @click="openWOutbound(2)" v-permissions="['ext:woutboundext:create']">销售出库</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 prop="status" label="单据类型" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ billToStr(row.billType) }} | 
|           </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 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="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">{{ 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="80px"> | 
|           <template slot-scope="{row}"> | 
|             <span v-if="row.status==0" style="margin-left:8px" v-permissions="['ext:woutboundext:delete']"> | 
|               <el-button type="text" @click="cancel(row)" >取消</el-button> | 
|             </span> | 
|             <span v-else>-</span> | 
|           </template> | 
|         </el-table-column> | 
|       </el-table> | 
|       <pagination | 
|         @size-change="handleSizeChange" | 
|         @current-change="handlePageChange" | 
|         :pagination="tableData.pagination" | 
|       ></pagination> | 
|     </template> | 
|     <!-- 新建/修改 --> | 
|     <OperaWOutboundExtWindow ref="operaWOutboundExtWindow" @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 OperaWOutboundExtWindow from '@/components/ext/OperaWOutboundExtWindow' | 
| 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: 'WOutboundExt', | 
|   extends: BaseTable, | 
|   components: { TableLayout, Pagination, OperaWOutboundExtWindow, OperaWboundDetailExtWindow, OrderCancel }, | 
|   data () { | 
|     return { | 
|       // 搜索 | 
|       searchForm: { | 
|         code: '', | 
|         originType: '', | 
|         originCode: '', | 
|         warehouseId: '', | 
|         status: '', | 
|         planDateStart: '', | 
|         planDateEnd: '', | 
|         billType: '', | 
|         type: 0 // 0出库 1入口 | 
|       }, | 
|       planDate: [], | 
|       warehouses:[], | 
|       warehousesChild: [],  // 传给子级的仓库 | 
|       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 } | 
|       ], | 
|       // 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: 18 }, | 
|       //   { name: '让步销售', id: 19 }, | 
|       //   { name: '工单投料', id: 20 }, | 
|       //   { name: '仓库报废', id: 21 }, | 
|       //   { name: '客退品检验领料', id: 22 }, | 
|       //   { name: '客返品检验领料', id: 23 }, | 
|       // ], | 
|       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: 18 }, | 
|         { name: '让步销售', id: 19 }, | 
|         { name: '工单投料', id: 20 }, | 
|         { name: '仓库报废', id: 21 }, | 
|         { name: '客退检验领料', id: 22 }, | 
|         { name: '客返检验领料', id: 23 }, | 
|         { name: '库存调整', id: 28 }, | 
|         { name: '废品入库', id: 30 }, | 
|       ] | 
|     } | 
|   }, | 
|   provide() { | 
|     return { | 
|       warehouses: () => this.warehousesChild | 
|     } | 
|   }, | 
|   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: { | 
|     openWOutbound(type) { | 
|       if (type == 1) { | 
|         this.warehousesChild = this.warehouses | 
|         this.$refs.operaWOutboundExtWindow.open('新建出库单') | 
|       } else { | 
|         let arr = [] | 
|         this.warehouses.forEach(element => { | 
|           if (element.isSales == '0') { | 
|             arr.push(element) | 
|           } | 
|         }); | 
|         this.warehousesChild = arr | 
|         this.$refs.operaWOutboundExtWindow.open('新建销售出库单') | 
|       } | 
|     }, | 
|     dateChange (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, 0) | 
|         }) | 
|         .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 === 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 | 
|       } | 
|       return '-' | 
|     } | 
|   } | 
| } | 
| </script> |