| <template> | 
|   <TableLayout1 :permissions="['business:member:query']"> | 
|     <!-- 搜索表单 --> | 
|     <div ref="QueryFormRef" slot="search-form"> | 
|       <el-form ref="searchForm" :model="searchForm" label-width="100px" inline> | 
|         <el-form-item label="" prop="keyword"> | 
|           <el-input v-model="searchForm.keyword" placeholder="请输入姓名/手机号" @keypress.enter.native="search"></el-input> | 
|         </el-form-item> | 
|         <section> | 
|           <el-button type="primary" @click="search">搜索</el-button> | 
|           <el-button @click="reset">重置</el-button> | 
|         </section> | 
|       </el-form> | 
|     </div> | 
|     <template v-slot:menu> | 
|       <div | 
|         style="width: 100%; height: 50px; background: rgba(242, 242, 242, 1); line-height: 50px; text-align: center; font-size: 14px;"> | 
|         企业组织</div> | 
|       <div style="width: 100%; height: calc(100vh - 130px); overflow-y: scroll;"> | 
|         <Tree :list="companyTree" :alllist="companyTree" :defaultProps="{ name: 'name', status: 'fsStatus', children: 'childList', id: 'id' }" | 
|           @callback="callback" /> | 
|       </div> | 
|     </template> | 
|     <!-- 表格和分页 --> | 
|     <template v-slot:table-wrap> | 
|       <ul class="toolbar" v-permissions="['business:member:create']"> | 
|         <li><el-button type="primary" v-permissions="['business:member:create']" :loading="loading"  @click="synchronous()">全量同步企业微信人员</el-button></li> | 
|         <li style="float: right"> | 
|           <el-checkbox style="font-size: 12px" label="1" v-model="searchForm.includeChild" key="1" | 
|             @change="search">是否包含下级组织</el-checkbox> | 
|         </li> | 
|       </ul> | 
|       <el-table :height="tableHeightNew"  v-loading="isWorking.search" :data="tableData.list" stripe @selection-change="handleSelectionChange"> | 
| <!--        <el-table-column prop="index" label="序号" width="55" fixed="left"> | 
|           <template slot-scope="scope">{{ scope.$index+1}}</template> | 
|         </el-table-column>--> | 
|         <el-table-column fixed="left" prop="name" label="姓名" min-width="80px"> | 
|           <template slot-scope="{row}"> | 
|             <span>{{ row.name }}</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="phone" label="手机号" min-width="100px"></el-table-column> | 
|         <el-table-column  prop="sex" label="性别" min-width="80px"> | 
|           <template slot-scope="{row}"> | 
|             <span v-if="row.sex == '1'">男</span> | 
|             <span v-else-if="row.sex == '2' ">女</span> | 
|             <span v-else>-</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="email" label="邮箱" min-width="100px"></el-table-column> | 
|         <el-table-column prop="companyName" label="所属部门" min-width="150px"> | 
|           <template slot-scope="{row}"> | 
|             <div v-if="row.companyNameList && row.companyNameList.length"> | 
|               <div  v-for="item in row.companyNameList" :key="item.id" style="display: block;margin-right: 20px">{{item}} | 
|               </div> | 
|             </div> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column prop="editorName" label="操作人" min-width="100px"></el-table-column> | 
|         <el-table-column prop="editDate" label="最后操作时间" min-width="150px"></el-table-column> | 
|         <el-table-column fixed="right"   v-if="containPermissions(['business:member:update'])" label="操作" min-width="100"> | 
|           <template slot-scope="{row}"> | 
|             <el-button type="text" icon="el-icon-edit" @click="$refs.OperaMemberWindow.open('编辑员工信息', row)"  v-permissions="['business:member:update']">编辑</el-button> | 
|           </template> | 
|         </el-table-column> | 
|       </el-table> | 
|       <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination"> | 
|       </pagination> | 
|       <OperaMemberWindow ref="OperaMemberWindow" @success="handlePageChange" /> | 
|     </template> | 
|   </TableLayout1> | 
| </template> | 
|   | 
| <script> | 
| import BaseTable from '@/components/base/BaseTable' | 
| import TableLayout1 from '@/layouts/TableLayout1' | 
| import Pagination from '@/components/common/Pagination' | 
| import Tree from '@/components/common/Tree' | 
| import OperaMemberWindow from '@/components/business/OperaMemberWindow' | 
| import { treeList } from '@/api/business/company' | 
| import { memberSync} from '@/api/business/member' | 
| export default { | 
|   name: 'internalMember', | 
|   extends: BaseTable, | 
|   components: { TableLayout1, Pagination, Tree,OperaMemberWindow }, | 
|   data() { | 
|     return { | 
|       TreeList: [], | 
|       // 搜索 | 
|       searchForm: { | 
|         name: '' , | 
|         includeChild: true, | 
|         keyword: '', | 
|         companyId: '' | 
|       }, | 
|       loading: false, | 
|       heading: false, | 
|       working: false, | 
|       companyTree: [], | 
|       department: [] | 
|     } | 
|   }, | 
|   created() { | 
|     this.config({ | 
|       module: '人员信息表', | 
|       api: '/business/member', | 
|       'field.id': 'id', | 
|       'field.main': 'id' | 
|     }) | 
|     // this.search() | 
|     this.getfindCompanyTreePage() | 
|   }, | 
|   methods: { | 
|     // 获取组织树 | 
|     getfindCompanyTreePage() { | 
|       treeList({}) | 
|         .then(res => { | 
|           if (res && res.length > 0) { | 
|             res[0].fsStatus = 1 | 
|             this.companyTree = res | 
|             this.search() | 
|             this.department = this.getDepartmentTree(res) | 
|           } | 
|         }) | 
|     }, | 
|     getDepartmentTree(tree) { | 
|       if (tree == null) { | 
|         return [] | 
|       } | 
|       return tree.map(item => { | 
|         const newItem = { ...item } | 
|         if (newItem) { | 
|           newItem.children = newItem.childList | 
|         } | 
|         if (item.children && item.children.length == 0) { | 
|           this.$delete(newItem, 'children') | 
|         } else { | 
|           newItem.children = this.getDepartmentTree(newItem.children) | 
|         } | 
|   | 
|         if (newItem.type === this.searchForm.companyType) { | 
|           // newItem.disabled =false | 
|         } else { | 
|           newItem.disabled = true | 
|         } | 
|         return newItem | 
|       }) | 
|     }, | 
|     // 同步信息 | 
|     async synchronous() { | 
|       this.$dialog.actionConfirm('您确认全量同步内部人员信息吗', '同步人员操作提示?') | 
|         .then(() => { | 
|           this.loading = true | 
|           memberSync({}) | 
|             .then(res => { | 
|               this.$tip.apiSuccess(res || '同步成功') | 
|               this.search() | 
|             }) | 
|             .catch(e => { | 
|               this.$tip.apiFailed(e) | 
|             }) | 
|             .finally(() => { | 
|               this.loading = false | 
|             }) | 
|         }) | 
|         .catch(() => { }) | 
|     }, | 
|     callback(row) { | 
|       console.log(row) | 
|       this.searchForm.erpOrgId = row.erpId | 
|       this.searchForm.companyId = row.id | 
|       this.search() | 
|     } | 
|   } | 
| } | 
| </script> | 
| <style lang="scss" scoped> | 
| @import '@/assets/style/variables.scss'; | 
|   | 
| .box { | 
|   width: 100%; | 
|   display: flex; | 
|   align-items: center; | 
|   | 
|   .box_menu { | 
|     width: 100px; | 
|     height: 100%; | 
|     flex-shrink: 0; | 
|   } | 
|   | 
|   .box_tab { | 
|     flex: 1; | 
|     height: 100%; | 
|   } | 
| } | 
| </style> |