| <template> | 
|   <TableLayout v-permissions="['ext:userdeviceext:query']"> | 
|     <!-- 搜索表单 --> | 
|     <el-form ref="searchForm" slot="search-form" :model="searchForm" label-suffix=":" label-width="100px" inline> | 
|       <el-form-item label="设备名称" prop="deviceId"> | 
|         <el-select v-model="searchForm.deviceId" filterable clearable placeholder="全部"> | 
|           <el-option | 
|             v-for="item in device" | 
|             :key="item.id" | 
|             :label="'【' + item.code+' 】'+ item.name" | 
|             :value="item.id"> | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="所属工序" prop="dmodelProcedureId"> | 
|         <el-select v-model="searchForm.dmodelProcedureId" filterable clearable placeholder="全部"> | 
|           <el-option | 
|             v-for="item in productes" | 
|             :key="item.id" | 
|             :label="item.name" | 
|             :value="item.id"> | 
|           </el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="所属员工" prop="companyUserId"> | 
|         <el-select v-model="searchForm.companyUserId" clearable filterable placeholder="全部"> | 
|           <el-option | 
|             v-for="item in user" | 
|             :key="item.id" | 
|             :label="item.name + '-' + item.dmodel.name + '-' + item.phone" | 
|             :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:userdeviceext:create', 'ext:userdeviceext:delete']"> | 
|         <li><el-button type="primary" @click="$refs.operaUserDeviceExtWindow.open('新建')" v-permissions="['ext:userdeviceext:create']">新增</el-button></li> | 
|         <li><el-button type="danger" plain @click="deleteByIdInBatch" v-permissions="['ext:userdeviceext: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="brand" label="设备编号" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ row.dmodel.code }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="name" label="设备名称" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ row.dmodel.name }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="model" label="设备型号" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ row.dmodel.model }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="procedureId" label="所属工序" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ procedureIdToStr(row.dmodel.procedureId) }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="createUser" label="关联员工" min-width="100px"> | 
|           <template slot-scope="{row}"> | 
|             {{ row.umodel.name + '-' + row.tmodel.name }} | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="createTime" label="创建时间" min-width="100px"></el-table-column> | 
|         <!-- <el-table-column | 
|           v-if="containPermissions(['ext:barcodesgext:update', 'ext:barcodesgext:delete'])" | 
|           label="操作" | 
|           min-width="120" | 
|           fixed="right" | 
|         > --> | 
|         <el-table-column | 
|           v-if="containPermissions(['ext:userdeviceext:delete'])" | 
|           label="操作" | 
|           min-width="80px" | 
|           fixed="right" | 
|         > | 
|            <template slot-scope="{row}"> | 
|             <span v-permissions="['ext:userdeviceext:delete']"> | 
|               <el-button type="text" @click="deleteById(row)">删除</el-button> | 
|             </span> | 
|           </template> | 
|         </el-table-column> | 
|       </el-table> | 
|       <pagination | 
|         @size-change="handleSizeChange" | 
|         @current-change="handlePageChange" | 
|         :pagination="tableData.pagination" | 
|       > | 
|       </pagination> | 
|     </template> | 
|     <!-- 新建/修改 --> | 
|     <OperaUserDeviceExtWindow ref="operaUserDeviceExtWindow" @success="refresh"/> | 
|   </TableLayout> | 
| </template> | 
|   | 
| <script> | 
| import BaseTable from '@/components/base/BaseTable' | 
| import TableLayout from '@/layouts/TableLayout' | 
| import Pagination from '@/components/common/Pagination' | 
| import OperaUserDeviceExtWindow from '@/components/ext/OperaUserDeviceExtWindow' | 
| import { getDeviceByCondition } from '@/api/ext/deviceExt' | 
| import { productesGroup } from '@/api/ext/proceduresExt' | 
| import { companyUserExtAllUser as getUserDevice } from '@/api/ext/companyUserExt' | 
| // import { getUserDevice } from '@/api/ext/userDeviceExt' | 
| export default { | 
|   name: 'BarcodeSgExt', | 
|   extends: BaseTable, | 
|   components: { TableLayout, Pagination, OperaUserDeviceExtWindow }, | 
|   data () { | 
|     return { | 
|       // 搜索 | 
|       searchForm: { | 
|         deviceId: null, | 
|         dmodelProcedureId: null, | 
|         companyUserId: null | 
|       }, | 
|       device: [], | 
|       productes: [], | 
|       user: [] | 
|     } | 
|   }, | 
|   provide() { | 
|     return { | 
|       device: () => this.device, | 
|       user: () => this.user | 
|     } | 
|   }, | 
|   created () { | 
|     this.config({ | 
|       module: '设备绑定', | 
|       api: '/ext/userDeviceExt', | 
|       'field.id': 'id', | 
|       'field.main': 'name', | 
|       sorts: [{ direction: 'DESC', property: 'CREATE_TIME' }] | 
|     }) | 
|     this.search() | 
|     this.getUser() | 
|   }, | 
|   activated() { | 
|     getDeviceByCondition({}) | 
|       .then(res => { | 
|         this.device = res | 
|       }) | 
|       .catch(err => { | 
|         console.log(err) | 
|       }) | 
|       productesGroup({}) | 
|       .then(res => { | 
|         this.productes = res | 
|       }) | 
|       .catch(err => { | 
|         console.log(err) | 
|       }) | 
|   }, | 
|   methods: { | 
|     getUser () { | 
|       getUserDevice({ departmentId: this.$store.state.userInfo.curComDepartment.id }) | 
|         .then(res => { | 
|           this.user = res | 
|         }) | 
|         .catch(err => { | 
|           console.log(err) | 
|         }) | 
|     }, | 
|     procedureIdToStr (id) { | 
|       for (const item of this.productes) { | 
|         if (item.id === id) { | 
|           return item.name | 
|         } | 
|       } | 
|     }, | 
|     deleteById (row) { | 
|       this.$confirm('是否删除将该条设备绑定信息?', '提示', { | 
|         confirmButtonText: '确定', | 
|         cancelButtonText: '取消', | 
|         type: 'warning' | 
|       }).then(() => { | 
|         this.isWorking.delete = true | 
|         this.api.deleteById(row[this.configData['field.id']]) | 
|           .then(() => { | 
|             this.__afterDelete() | 
|           }) | 
|           .catch(e => { | 
|             this.$tip.apiFailed(e) | 
|           }) | 
|           .finally(() => { | 
|             this.isWorking.delete = false | 
|           }) | 
|       }).catch(() => {}) | 
|     }, | 
|     refresh () { | 
|       this.getUser() | 
|       this.handlePageChange() | 
|     } | 
|   } | 
| } | 
| </script> |