| <template> | 
|   <div class="main_app"> | 
|     <QueryForm v-model="filters" :query-form-config="queryFormConfig" @handleQuery="getList(1)" @clear="clear" /> | 
|     <div class="mt20"> | 
|       <el-button type="primary" @click="handleEdit()" icon="el-icon-plus" | 
|         v-permissions="['business:ywpatrolline:create']">新建</el-button> | 
|     </div> | 
|     <el-table v-loading="loading" :data="list" stripe> | 
|       <el-table-column prop="name" label="公司名称" min-width="100" show-overflow-tooltip /> | 
|       <el-table-column prop="shortName" label="公司简称" min-width="100" show-overflow-tooltip /> | 
|       <el-table-column prop="code" label="纳税识别号" min-width="100" show-overflow-tooltip /> | 
|       <el-table-column prop="address" label="公司地址" min-width="100" show-overflow-tooltip /> | 
|       <el-table-column prop="accountNum" label="收支账户数量" min-width="100" show-overflow-tooltip /> | 
|       <el-table-column prop="status" label="状态" min-width="100" show-overflow-tooltip> | 
|         <template v-slot="scope"> | 
|           <el-switch v-model="scope.row.status" @change="e => changeStatus(scope.row)" :active-value="0" :inactive-value="1"> | 
|           </el-switch> | 
|         </template> | 
|       </el-table-column> | 
|       <el-table-column label="操作" min-width="120" fixed="right"> | 
|         <template slot-scope="{row}"> | 
|           <el-button type="text" @click="handleEdit(row)" icon="el-icon-edit" | 
|             v-permissions="['business:category:update']">编辑</el-button> | 
|           <el-button type="text" @click="handleDel(row)" icon="el-icon-delete" | 
|             v-permissions="['business:category:delete']">删除</el-button> | 
|         </template> | 
|       </el-table-column> | 
|     </el-table> | 
|     <div class="mt20"> | 
|       <Pagination @size-change="handleSizeChange" @current-change="getList" :pagination="pagination" /> | 
|     </div> | 
|     <Edit v-if="showEdit" ref="EditRef" @success="getList" @close="showEdit = false" /> | 
|   </div> | 
| </template> | 
|   | 
| <script> | 
| import Pagination from '@/components/common/Pagination' | 
| import QueryForm from '@/components/common/QueryForm' | 
| import Edit from './components/companyEdit.vue' | 
| import { companyGetList, deleteById, updateStatusById } from '@/api/business/company' | 
| import { Message } from 'element-ui' | 
| export default { | 
|   components: { | 
|     Pagination, | 
|     QueryForm, | 
|     Edit | 
|   }, | 
|   data() { | 
|     return { | 
|       loading: false, | 
|       showEdit: false, | 
|       pagination: { | 
|         pageSize: 10, | 
|         page: 1, | 
|         total: 0 | 
|       }, | 
|       filters: {}, | 
|       list: [], | 
|       total: 0, | 
|       queryFormConfig: { | 
|         formItems: [ | 
|           { | 
|             filed: 'name', | 
|             type: 'input', | 
|             label: '公司名称' | 
|           }, | 
|         ], | 
|         online: true | 
|       } | 
|     } | 
|   }, | 
|   created() { | 
|     this.getList() | 
|   }, | 
|   methods: { | 
|     changeStatus(row) { | 
|       updateStatusById(row).then(res => { | 
|         this.getList() | 
|         Message.success('更新状态成功') | 
|       }, () => { | 
|         this.getList() | 
|       }) | 
|     }, | 
|     getList(page) { | 
|       const { pagination, filters } = this | 
|       this.loading = true | 
|       companyGetList({ | 
|         model: { | 
|           ...filters, | 
|           type: 2 | 
|         }, | 
|         capacity: pagination.pageSize, | 
|         page: page || pagination.page, | 
|       }).then(res => { | 
|         this.loading = false | 
|         this.list = res.records || [] | 
|         this.list.forEach(item => { | 
|           item.stautsName = item.status == 0 ? '正常' : item.status == 1 ? '损坏' : '报废' | 
|         }) | 
|         this.pagination.total = res.total || 0 | 
|       }, () => { | 
|         this.loading = false | 
|       }) | 
|     }, | 
|     handleEdit(row) { | 
|       this.showEdit = true | 
|       this.$nextTick(() => { | 
|         this.$refs.EditRef.isShowModal = true | 
|         if (row && row.id) { | 
|           this.$refs.EditRef.getDetail(row.id) | 
|         } | 
|       }) | 
|   | 
|     }, | 
|     handleDel(row) { | 
|       let message = `确认删除该公司吗?` | 
|       this.$dialog.deleteConfirm(message) | 
|         .then(() => { | 
|           deleteById(row.id) | 
|             .then(() => { | 
|               this.$tip.apiSuccess('删除成功') | 
|               this.getList() | 
|             }) | 
|         }) | 
|         .catch(() => { }) | 
|     }, | 
|     clear() { | 
|       this.filters = {} | 
|       this.pagination.pageSize = 10 | 
|       this.pagination.page = 1 | 
|       this.getList() | 
|     }, | 
|     handleSizeChange(capacity) { | 
|       this.pagination.pageSize = capacity | 
|     } | 
|   } | 
| } | 
| </script> | 
|   | 
| <style></style> |