| <template> | 
|   <TableLayout v-permissions="['ext:bomext:query']"> | 
|     <!-- 搜索表单 --> | 
|     <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="120px" label-suffix=":" inline> | 
|       <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="materialName"> | 
|         <el-input v-model="searchForm.materialName" placeholder="请输入" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="工艺路线" prop="routeId"> | 
|         <el-select v-model="searchForm.routeId" filterable clearable placeholder="请选择工艺路线"> | 
|           <el-option | 
|             v-for="(item, index) in routes" | 
|             :key="index" | 
|             :label="item.name" | 
|             :value="item.id"> | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="状态" prop="status"> | 
|         <el-select v-model="searchForm.status" filterable 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="type"> | 
|         <el-select v-model="searchForm.type" clearable placeholder="请选择投料方式"> | 
|           <el-option | 
|             v-for="(item, index) in type" | 
|             :key="index" | 
|             :label="item.name" | 
|             :value="item.id"> | 
|           </el-option> | 
|         </el-select> | 
|       </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"> | 
|         <!-- ext:bomext:create --> | 
|         <li><el-button type="primary" v-permissions="['ext:bomext:create']" @click="$refs.operaBomExtWindow.open('新增BOM信息')">新增</el-button></li> | 
|       </ul> | 
|       <el-table | 
|         v-loading="isWorking.search" | 
|         :data="tableData.list" | 
|         stripe | 
|         border | 
|         @selection-change="handleSelectionChange" | 
|       > | 
|         <el-table-column label="物料名称" fixed="left" show-overflow-tooltip min-width="140px"> | 
|           <template slot-scope="{row}"> | 
|             <div class="long-title-style"> | 
|               <el-button type="text" @click="showDetail(row)"> | 
|                 {{ row.materialName }} | 
|               </el-button> | 
|             </div> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="materialCode" label="物料编码" min-width="160px"></el-table-column> | 
|         <el-table-column prop="unitName" label="单位" min-width="50px"></el-table-column> | 
|         <el-table-column prop="version" label="版本号" min-width="60px"></el-table-column> | 
|         <el-table-column prop="factoryName" label="工厂" min-width="100px"></el-table-column> | 
|         <el-table-column prop="routeName" label="工艺路线" show-overflow-tooltip min-width="140px"> | 
|           <template slot-scope="{row}"> | 
|             <span class="long-title-style">{{ '【' + row.routeCode + '】' + row.routeName }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="routeNum" label="工序数" min-width="60px"></el-table-column> | 
|         <!-- <el-table-column prop="unitName" label="单位数量" min-width="100px"></el-table-column> --> | 
|         <el-table-column prop="status" label="投料方式" min-width="70px"> | 
|           <template slot-scope="{row}"> | 
|            <!-- {{ row.status }} --> | 
|            <!-- 0: 待生效 ;1:有效 ;2:无效; --> | 
|             <span v-if="row.type == 0">推式</span> | 
|             <span v-if="row.type == 1">拉式</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="status" label="状态" min-width="70px"> | 
|           <template slot-scope="{row}"> | 
|            <!-- {{ row.status }} --> | 
|            <!-- 0: 待生效 ;1:有效 ;2:无效; --> | 
|             <el-tag v-if="row.status == 0">待启用</el-tag> | 
|             <el-tag v-if="row.status == 1" type="success">启用</el-tag> | 
|             <el-tag v-if="row.status == 2" type="danger">失效</el-tag> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="validTime" label="启用日期" min-width="140px"></el-table-column> | 
|         <el-table-column prop="invalidTime" label="失效日期" min-width="140px"> | 
|           <template slot-scope="{row}"> | 
|             <span class="long-title-style">{{ row.invalidTime || '-' }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column | 
|           label="操作" | 
|           min-width="100" | 
|           fixed="right" | 
|         > | 
|           <template slot-scope="{row}"> | 
|             <!-- 0: 待生效 ;1:有效 ;2:无效; --> | 
|             <div v-if="row.status == 0"> | 
|               <el-button type="text" v-permissions="['ext:bomext:update']" @click="goToWindow(row.id, '编辑BOM')">编辑</el-button> | 
|               <el-button type="text" v-permissions="['ext:bomext:update']" @click="startBom(row)">启用</el-button> | 
|             </div> | 
|             <div v-else-if="row.status == 1"> | 
|               <el-button type="text" v-permissions="['ext:bomext:create']" @click="goToWindow(row.id, '升级BOM')">升级</el-button> | 
|               <span style="margin-left:8px"> | 
|                 <el-button  type="text" v-permissions="['ext:bomext:delete']" @click="unValid(row)">失效</el-button> | 
|               </span> | 
|             </div> | 
|             <div v-else>-</div> | 
|           </template> | 
|         </el-table-column> | 
|       </el-table> | 
|       <pagination | 
|         @size-change="handleSizeChange" | 
|         @current-change="handlePageChange" | 
|         :pagination="tableData.pagination" | 
|       ></pagination> | 
|     </template> | 
|     <!-- 新建/修改 --> | 
|     <OperaBomExtWindow ref="operaBomExtWindow" @success="handlePageChange"/> | 
|     <OperaBomDetailWindow ref="operaBomDetailWindow" @success="handlePageChange"/> | 
|      | 
|   </TableLayout> | 
| </template> | 
|   | 
| <script> | 
| import BaseTable from '@/components/base/BaseTable' | 
| import TableLayout from '@/layouts/TableLayout' | 
| import Pagination from '@/components/common/Pagination' | 
| import OperaBomExtWindow from '@/components/ext/OperaBomExtWindow' | 
| import OperaBomDetailWindow from '@/components/ext/OperaBomDetailWindow' | 
| import { getAllListRoute as routList } from '@/api/ext/routeProcedureExt' | 
| import { openOrClose, bomExt } from '@/api/ext/bomExt' | 
| export default { | 
|   name: 'BomExt', | 
|   extends: BaseTable, | 
|   components: { TableLayout, Pagination, OperaBomExtWindow, OperaBomDetailWindow }, | 
|   data () { | 
|     return { | 
|       // 搜索 | 
|       searchForm: { | 
|         materialName: '', | 
|         materialCode: '', | 
|         routeId: '', | 
|         status: '', | 
|         type: '' | 
|       }, | 
|       routes: [], | 
|       status: [ | 
|         { name: '全部', id: '' }, | 
|         { name: '待启用', id: '0' }, | 
|         { name: '启用', id: '1' }, | 
|         { name: '失效', id: '2' } | 
|       ], | 
|   | 
|       list: [], | 
|       type: [ | 
|         // 0推式 1拉式 | 
|          { name: '推式', id: 0 }, | 
|         { name: '拉式', id: 1 }, | 
|       ] | 
|     } | 
|   }, | 
|   provide() { | 
|     return { | 
|       type: this.type | 
|     } | 
|   }, | 
|   created () { | 
|     this.config({ | 
|       module: '物料清单信息', | 
|       api: '/ext/bomExt', | 
|       'field.id': 'id', | 
|       'field.main': 'name', | 
|       sorts: [{ direction: 'DESC', property: 'CREATE_TIME' }] | 
|     }) | 
|     routList({}) | 
|       .then(res => { | 
|         this.routes = res | 
|         // console.log(res) | 
|       }) | 
|     this.search() | 
|   }, | 
|   methods: { | 
|     statusToStr (status) { | 
|       for (const item of this.status) { | 
|         if (item.id === status) { | 
|           return item.name | 
|         } | 
|       } | 
|     }, | 
|     showDetail (row) { | 
|       // console.log('详情') | 
|       const query = '?id=' + row.id | 
|       bomExt(query) | 
|         .then(res => { | 
|           this.$refs.operaBomDetailWindow.open('BOM详情', res) | 
|         }) | 
|         .catch(err => { | 
|           this.$tip.error(err.message) | 
|         }) | 
|     }, | 
|     goToWindow (id, title) { | 
|       // console.log(id, title) | 
|       const query = '?id=' + id | 
|       bomExt(query) | 
|         .then(res => { | 
|           this.$refs.operaBomExtWindow.open(title, res) | 
|         }) | 
|         .catch(err => { | 
|           this.$tip.error(err.message) | 
|         }) | 
|     }, | 
|     startBom (row) { | 
|       // console.log('启用') | 
|       // ?id=21&optType=1 | 
|       const query = '?optType=1&id=' + row.id | 
|       openOrClose(query) | 
|         .then(res => { | 
|           this.$tip.success('启用成功') | 
|           this.search() | 
|         }) | 
|         .catch(err => { | 
|           this.$tip.error(err.message) | 
|         }) | 
|     }, | 
|     unValid (row) { | 
|       // console.log('失效') | 
|       this.$confirm('确认将当前bom失效?', '确认', { | 
|         distinguishCancelAndClose: true, | 
|         confirmButtonText: '确认', | 
|         cancelButtonText: '取消' | 
|       }) | 
|         .then(() => { | 
|           const query = '?optType=2&id=' + row.id | 
|           openOrClose(query) | 
|             .then(res => { | 
|               this.$tip.success('失效成功') | 
|               this.search() | 
|             }) | 
|             .catch(err => { | 
|               this.$tip.error(err.message) | 
|             }) | 
|         }) | 
|         .catch(() => {}) | 
|        | 
|     } | 
|   } | 
| } | 
| </script> |