| <template> | 
|   <TableLayout v-permissions="['ext:routeprocedureext:query']"> | 
|     <!-- 搜索表单 --> | 
|     <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" label-suffix=":" inline> | 
|       <el-form-item label="路线名称" prop="name"> | 
|         <el-input v-model="searchForm.name" placeholder="请输入工艺路线名称" @keypress.enter.native="search"></el-input> | 
|       </el-form-item> | 
|       <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="status"> | 
|         <el-select v-model="searchForm.status" placeholder="请选择"> | 
|           <el-option | 
|             v-for="item in status" | 
|             :key="item.id" | 
|             :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" v-permissions="['ext:routeprocedureext:create', 'ext:routeprocedureext:delete']"> | 
|         <li><el-button type="primary" @click="$refs.operaRouteProcedureExtWindow.open('新建工艺路线与工序关联')" v-permissions="['ext:routeprocedureext:create']">新建</el-button></li> | 
|         <li><el-button type="danger" plain @click="loseEfficacyWithArray" v-permissions="['ext:routeprocedureext:delete']">失效</el-button></li> | 
|       </ul> | 
|       <el-table | 
|         v-loading="isWorking.search" | 
|         :data="tableData.list" | 
|         stripe | 
|         border | 
|         @selection-change="handleSelectionChange" | 
|       > | 
|         <el-table-column type="selection" width="55"></el-table-column> | 
|          <el-table-column prop="code" label="工艺路线编码" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             <el-button type="text" @click="detail(row, 0)">{{ row.code }}</el-button> | 
|           </template> | 
|          </el-table-column> | 
|         <el-table-column prop="name" label="工艺路线名称" min-width="120px"></el-table-column> | 
|         <el-table-column prop="dmodel.name" label="工厂" min-width="100px"> | 
|         </el-table-column> | 
|         <el-table-column prop="produceNum" label="工序数量" min-width="60px"></el-table-column> | 
|         <el-table-column prop="status" label="状态" min-width="60px"> | 
|           <template slot-scope="{row}"> | 
|             <el-tag v-if="row.status == 1" type="success">有效</el-tag> | 
|             <el-tag v-if="row.status == 0" type="danger">失效</el-tag> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="createTime" label="创建时间" min-width="140px"></el-table-column> | 
|         <!-- <el-table-column | 
|           v-if="containPermissions(['ext:routeprocedureext:update', 'ext:routeprocedureext:delete'])" | 
|           label="操作" | 
|           min-width="120" | 
|           fixed="right" | 
|         > --> | 
|         <el-table-column | 
|           label="操作" | 
|           min-width="100px" | 
|           fixed="right" | 
|         > | 
|           <template slot-scope="{row}"> | 
|             <div v-if="row.status==1"> | 
|               <el-button type="text" @click="detail(row, 1)"  v-permissions="['ext:routeprocedureext:update']">编辑</el-button> | 
|               <span style="margin-left:8px"> | 
|                 <el-button type="text" @click="loseEfficacy(row)"  v-permissions="['ext:routeprocedureext:delete']">失效</el-button> | 
|               </span> | 
|             </div> | 
|           </template> | 
|         </el-table-column> | 
|       </el-table> | 
|       <pagination | 
|         @size-change="handleSizeChange" | 
|         @current-change="handlePageChange" | 
|         :pagination="tableData.pagination" | 
|       ></pagination> | 
|     </template> | 
|     <!-- 新建/修改 --> | 
|     <OperaRouteProcedureExtWindow ref="operaRouteProcedureExtWindow" @success="handlePageChange"/> | 
|     <OperaRouteDetail ref="operaRouteDetail"/> | 
|   </TableLayout> | 
| </template> | 
|   | 
| <script> | 
| import BaseTable from '@/components/base/BaseTable' | 
| import TableLayout from '@/layouts/TableLayout' | 
| import Pagination from '@/components/common/Pagination' | 
| import OperaRouteProcedureExtWindow from '@/components/ext/OperaRouteProcedureExtWindow' | 
| import OperaRouteDetail from '@/components/ext/OperaRouteDetail' | 
| import { routeExt, updateStatus } from '@/api/ext/routeProcedureExt' | 
| import { getDepartmentListByConditon } from '@/api/ext/departmentExt' | 
| export default { | 
|   name: 'RouteProcedureExt', | 
|   extends: BaseTable, | 
|   components: { TableLayout, Pagination, OperaRouteProcedureExtWindow, OperaRouteDetail }, | 
|   data () { | 
|     return { | 
|       // 搜索 | 
|       searchForm: { | 
|         code: '', | 
|         name: '', | 
|         status: '' | 
|       }, | 
|       factoreis: [], | 
|       status: [ | 
|         // 状态0.无效 1.有效,示例值(1) | 
|         { name: '失效', id: 0 }, | 
|         { name: '有效', id: 1 } | 
|       ] | 
|     } | 
|   }, | 
|   provide() { | 
|     return { | 
|       factoreis: () => this.factoreis | 
|     } | 
|   }, | 
|   created () { | 
|     this.config({ | 
|       module: '工艺路线', | 
|       api: '/ext/routeProcedureExt', | 
|       'field.id': 'id', | 
|       'field.main': 'name', | 
|       sorts: [{ direction: 'DESC', property: 'CREATE_TIME' }] | 
|     }) | 
|     getDepartmentListByConditon({ | 
|       type: 1 | 
|     }) | 
|       .then(res => { | 
|         // console.log(res) | 
|         this.factoreis = res | 
|       }) | 
|       .catch(err => { | 
|         console.log(err) | 
|       }) | 
|     this.search() | 
|   }, | 
|   methods: { | 
|     detail (row, type) { | 
|       routeExt(row.id) | 
|         .then(res => { | 
|           // console.log(res) | 
|           if (type === 1) { | 
|             this.$refs.operaRouteProcedureExtWindow.open('编辑工艺路线', res) | 
|           } else { | 
|             this.$refs.operaRouteDetail.open('工艺路线详情', res) | 
|           } | 
|         }) | 
|         .catch(err => { | 
|           console.log(err) | 
|         }) | 
|     }, | 
|     loseEfficacy (row) { | 
|       this.$confirm('是否将该条工艺路线设置为失效?', '提示', { | 
|         confirmButtonText: '失效', | 
|         cancelButtonText: '取消', | 
|         type: 'warning' | 
|       }).then(() => { | 
|         const query = '?status=0&ids=' + row.id | 
|         this.isWorking.delete = true | 
|         updateStatus(query) | 
|           .then(res => { | 
|             this.$tip.apiSuccess('失效成功') | 
|             this.search() | 
|           }) | 
|           .catch(err => { | 
|             this.$tip.error(err) | 
|           }) | 
|           .fianly(() => { | 
|             this.isWorking.delete = false | 
|           }) | 
|       }).catch(() => {}) | 
|     }, | 
|     loseEfficacyWithArray () { | 
|       if (this.tableData.selectedRows.length === 0) { | 
|         this.$tip.warning('请至少选择一条数据') | 
|         return | 
|       } | 
|       for (const element of this.tableData.selectedRows) { | 
|         if (element.status !== 1) { | 
|           this.$tip.warning('只有有效状态才可以失效!') | 
|           return | 
|         } | 
|       } | 
|        | 
|       const message = `确认将已选中的 ${this.tableData.selectedRows.length} 条${this.module}记录设置为失效吗?` | 
|       const selectedIds = [] | 
|       for (const item of this.tableData.selectedRows) { | 
|         selectedIds.push(item.id) | 
|       } | 
|       this.$confirm(message, '提示', { | 
|         confirmButtonText: '失效', | 
|         cancelButtonText: '取消', | 
|         type: 'warning' | 
|       }).then(() => { | 
|         this.isWorking.delete = true | 
|         const query = '?status=0&ids=' + selectedIds.join(',') | 
|         updateStatus(query) | 
|           .then(res => { | 
|             // console.log(res) | 
|             this.$tip.apiSuccess('设置成功') | 
|             this.search() | 
|           }) | 
|           .catch(err => { | 
|             this.$tip.error(err) | 
|           }) | 
|           .fianly(() => { | 
|             this.isWorking.delete = false | 
|           }) | 
|       }).catch(() => {}) | 
|     } | 
|   } | 
| } | 
| </script> |