123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- <template>
- <div style=" background-color: #fff;">
- <el-row :gutter="15" style="border:1px solid #eee;">
- <el-col :span="24" style="margin-bottom:0; border-bottom:1px solid #eee;">
- <div style="margin-bottom:0; padding:15px;" class="inline-block-btn-list">
- <div class="gap-right-8" style="display:inline-block; width:100%; margin-bottom:0;">
- <el-input
- placeholder="输入关键词查找"
- ref="search-bar"
- v-model="filter.keywords"
- class="input-with-select"
- @keyup.enter.native="onFilterChanged"
- >
- <el-button slot="append" icon="el-icon-search" @click="onFilterChanged"></el-button>
- </el-input>
- </div>
- </div>
- </el-col>
- <el-col :span="6" style="margin-bottom:0;">
- <div style="padding:15px; padding-left:0; padding-right:0;">
- <el-scrollbar
- wrap-class="column-wrapper scrollable-items-container check-item-box dept_tree"
- :native="false"
- style="height: 350px;"
- >
- <a
- @click="handleNodeClick({value:0})"
- v-show="profile.manager_type > 2"
- :class="{on:filter.dept_id.length == 0}"
- style="display: block; padding:7px;"
- >
- <img src="static/images/two.png" style="width: 16px;height: 16px;vertical-align: text-bottom;margin-right: 8px;" />
- 所有部门
- </a>
- <!-- <el-tree
- ref="dept_tree_com"
- highlight-current
- :default-expand-all="true"
- :expand-on-click-node="false"
- :data="deptTree"
- img="static/images/one.jpg"
- @node-click="handleNodeClick"
- ></el-tree> -->
- <el-tree :data="deptTree" highlight-current :expand-on-click-node="false" node-key="id" default-expand-all @node-click="handleNodeClick">
- <span class="custom-tree-node" slot-scope="{ node, data }">
-
- <span >
- <img v-if="data.children.length!=0" src="static/images/one.png" style="width: 16px;height: 216x;vertical-align: text-bottom;margin-right: 8px;" />
-
- {{data.label}}
- </span>
- </span>
- </el-tree>
- </el-scrollbar>
- </div>
- </el-col>
- <el-col :span="9" style="border-left:1px solid #eee; margin-bottom:0; padding-right:0;">
- <div style="padding:15px; padding-right:0;">
- <el-scrollbar
- wrap-class="column-wrapper scrollable-items-container dept_tree"
- :native="false"
- style="height: 350px;"
- >
- <div style="padding-right:15px;">
- <el-table
- v-loading="loading"
- ref="multipleTable"
- :data="tableData"
- :border="false"
- tooltip-effect="dark"
- @row-click="rowClick"
- @selection-change="handleSelectionChange"
- @select-all="select_all"
- style="width: 100%"
- >
- <el-table-column type="selection" width="42" :selectable="isSelectable"></el-table-column>
- <el-table-column prop="name" label="选择人员">
- <template slot-scope="scope">
- <div class="rank_head" style="cursor: pointer;">
- <img
- v-if="scope.row.img_url != null"
- v-bind:src="scope.row.img_url"
- width="42px"ss
- height="42px"
- >
- <img
- v-if="scope.row.img_url == null"
- src="static/images/head_default.png"
- width="42px"
- height="42px"
- >
-
- <span>
- {{scope.row.name}}
- </span>
- </div>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </el-scrollbar>
- </div>
- </el-col>
- <el-col :span="9" style="border-left:1px solid #eee; margin-bottom:0; padding-right:0;">
- <div style="padding:15px; padding-right:0;">
- <el-scrollbar
- wrap-class="column-wrapper scrollable-items-container check-item-box dept_tree"
- :native="false"
- style="height: 350px;"
- >
- <div style="padding-right:15px;">
- <el-table
- @header-click="clearEmployee"
- :data="multipleSelection"
- :border="false"
- tooltip-effect="dark"
- style="width: 100%"
- >
- <el-table-column prop="name" :label="'已选择人员('+(multipleSelection.length)+'人)'">
- <template slot-scope="scope">
- <div class="rank_head" style="cursor: pointer;">
- <img
- v-if="scope.row.img_url != null"
- v-bind:src="scope.row.img_url"
- width="42px"
- height="42px"
- >
- <img
- v-if="scope.row.img_url == null"
- src="static/images/head_default.png"
- width="42px"
- height="42px"
- >
-
- {{scope.row.name}}
-
-
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="清空"
- width="50"
- column-key="clear"
- label-class-name="clearEmployeeBtn"
- >
- <template slot-scope="scope">
- <div class="rank_head" style="cursor: pointer; text-align: center;">
- <a
- @click="removeEmployee(scope.row.id)"
- class="el-icon-circle-close"
- style="color:#ff7d79;"
- ></a>
- </div>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </el-scrollbar>
- </div>
- </el-col>
- <el-col :span="24" style="border-top:1px solid #eee; margin-bottom:0;">
- <el-pagination
- background
- style="margin-top:0;"
- :page-sizes="[10, 20, 50, 100]"
- layout="sizes, prev, pager, next"
- @size-change="handleSizeChange"
- :page-size="pageLimit"
- :total="totalCount"
- :current-page.sync="currentPage"
- @current-change="changePage"
- ></el-pagination>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- export default {
- // multipleSelectionId
- props: {
- employeeSelectorIds: {
- type: Array,
- default: () => {return []}
- },
- include_admin: {
- type: Boolean,
- default: false
- },
- },
- watch: {
- tableData(val) {
- this.$nextTick(() => {
- this.pageSelectedId = []
- val.forEach(item => {
- if (this.employeeSelectorIds.indexOf(item.id) >= 0) {
- this.$refs['multipleTable'].toggleRowSelection(item, true)
- this.pageSelectedId.push(item.id)
- }
- })
- })
- },
- employeeSelectorIds(val) {
- this.$nextTick(() => {
- if (!this.tableData) { return }
- this.pageSelectedId = []
- this.tableData.forEach(item => {
- this.$refs['multipleTable'].toggleRowSelection(item, false)
- if (val.indexOf(item.id) >= 0) {
- this.$refs['multipleTable'].toggleRowSelection(item, true)
- this.pageSelectedId.push(item.id)
- }
- })
- })
- }
- },
- data() {
- return {
- loading: false,
- profile: this.$store.getters.user_info,
- accessEnabled: false,
- dialogTableVisible: false,
- filter: {
- dept_id: [],
- status: 1,
- keywords: ''
- },
- totalCount: 0,
- pageLimit: 6,
- currentPage: 1,
- tableData: null,
- multipleSelection: [],
- multipleSelectionId: [],
- multipleSelectionJson: {},
- pageSelectedId: [],
- dialogExcelVisible: false,
- deptTree: [],
- creatorId: '',
- department_list: []
- }
- },
- methods: {
- clearChild(column, event) {
- const self = this
- if (column == 'clear') {
- console.log("jinlail")
- for (const i in this.tableData) {
- self.$refs['multipleTable'].toggleRowSelection(
- self.tableData[i],
- false
- )
- }
- this.multipleSelectionId = []
- this.multipleSelectionJson = {}
- this.multipleSelection = []
- this.pageSelectedId = []
- }
- },
- clearEmployee(column, event) {
- const self = this
- if (column.columnKey == 'clear') {
- console.log("jinlail")
- for (const i in this.tableData) {
- self.$refs['multipleTable'].toggleRowSelection(
- self.tableData[i],
- false
- )
- }
- this.multipleSelectionId = []
- this.multipleSelectionJson = {}
- this.multipleSelection = []
- this.pageSelectedId = []
- }
- },
- removeEmployee(id) {
- console.log("kkkkkkkkkkkkkkkkkkkkkkk")
- let self = this
- const multipleSelectionId = []
- const multipleSelectionJson = {}
- const multipleSelection = []
- const pageSelectedId = []
- for (const i in this.tableData) {
- if (this.tableData[i].id == id) {
- this.$refs['multipleTable'].toggleRowSelection(
- this.tableData[i],
- false
- )
- }
- }
- for (const i in this.multipleSelection) {
- if (this.multipleSelection[i].id != id) {
- multipleSelection.push(this.multipleSelection[i])
- multipleSelectionJson[
- this.multipleSelection[i].id
- ] = this.multipleSelection[i]
- multipleSelectionId.push(this.multipleSelection[i].id)
- }
- }
- this.multipleSelectionId = multipleSelectionId
- this.multipleSelectionJson = multipleSelectionJson
- this.multipleSelection = multipleSelection
- self.$nextTick(() => {
- self.$emit('check', self.multipleSelection)
- // self.$parent.$parent.$parent.$parent.set_target_ids(self.multipleSelection)
- })
- },
- handleNodeClick(data) {
- if (data.value == 0) {
- this.loadBaseData()
- this.filter.dept_id = []
- } else {
- this.filter.dept_id = [data.value]
- }
- this.onFilterChanged()
- },
- handleSizeChange(val) {
- this.pageLimit = val
- this.onFilterChanged()
- },
- onFilterChanged: function() {
- this.currentPage = 1
- this.loadEmployeeList()
- },
- toggleSelection: function(rows) {
- if (rows) {
- rows.forEach(row => {
- this.$refs.multipleTable.toggleRowSelection(row)
- })
- } else {
- this.$refs.multipleTable.clearSelection()
- }
- },
- select_all(all) {
- const ids = []
- for (const i in all) {
- ids.push(all[i].id)
- }
- },
- handleSelectionChange: function(val) {
- // console.log(this.multipleSelectionId)
- const ids = []
- for (const i in val) {
- ids.push(val[i].id)
- }
- for (const i in val) {
- if (this.multipleSelectionId.indexOf(val[i].id) < 0) {
- this.multipleSelectionId.push(val[i].id)
- this.multipleSelectionJson[val[i].id] = val[i]
- this.multipleSelection.push(val[i])
- }
- if (this.pageSelectedId.indexOf(val[i].id) < 0) {
- this.pageSelectedId.push(val[i].id)
- }
- }
- const ids_cancel = []
- if (this.pageSelectedId.length > ids.length) {
- // 之前被选择的数量比现在的数量多,说明有一些被取消了选择
- // 求出这些被取消的选择id
- for (const i in this.pageSelectedId) {
- if (ids.indexOf(this.pageSelectedId[i]) < 0) {
- ids_cancel.push(this.pageSelectedId[i])
- }
- }
- this.pageSelectedId = ids
- }
- if (ids_cancel.length > 0) {
- const multipleSelectionId = []
- const multipleSelection = []
- const multipleSelectionJson = {}
- for (const i in this.multipleSelectionId) {
- if (ids_cancel.indexOf(this.multipleSelectionId[i]) < 0) {
- multipleSelectionId.push(this.multipleSelectionId[i])
- }
- }
- this.multipleSelectionId = multipleSelectionId
- for (const i in this.multipleSelection) {
- if (ids_cancel.indexOf(this.multipleSelection[i].id) < 0) {
- multipleSelection.push(this.multipleSelection[i])
- }
- }
- this.multipleSelection = multipleSelection
- for (const i in this.multipleSelection) {
- multipleSelectionJson[i] = this.multipleSelection[i]
- }
- this.multipleSelectionJson = multipleSelectionJson
- }
- const self = this
- self.$nextTick(() => {
- self.$emit('check', self.multipleSelection)
- // self.$parent.$parent.$parent.$parent.set_target_ids(self.multipleSelection)
- })
- },
- rowClick(row, event, column) {
- this.$refs['multipleTable'].toggleRowSelection(row)
- },
- isSelectable: function(row, index) {
- return true
- },
- toSexName: function(row, column, cellValue) {
- return cellValue == '1' ? '女' : '男'
- },
- dateFormatter: function(row, column, cellValue) {
- return this.$moment(cellValue * 1000).format('YYYY年MM月DD日')
- },
- // 获取基本数据
- loadBaseData: function() {
- var self = this
- this.$http('get','/integral.php/ajax_request_common/prepare_integral_options', {
- id: this.profile.id,
- category_tree: 1,
- dept_tree: 1})
- .then(function(response) {
- if (response.status == 200) {
- var jsonData = response.data
- try {
- self.deptTree = jsonData.dept_tree
- self.creatorId = jsonData.creator_id
- if (self.profile.manager_type < 2) {
- self.filter.dept_id = [self.deptTree[0].value]
- self.loadEmployeeList()
- }
- } catch (err) {
- console.log(err)
- }
- }
- })
- .catch(function(error) {
- console.log(error)
- })
- },
- // 获取员工列表
- loadEmployeeList: function() {
- var self = this
- self.loading = true
- const params = {
- site_id: this.$store.getters.site_id,
- page: this.currentPage,
- interval: this.pageLimit
- }
- for (const item in this.filter) {
- const value = this.filter[item]
- if (item == 'dept_id') {
- if (!value || value.length == 0) {
- continue
- }
- params[item] = value[value.length - 1]
- } else {
- const valueStr = value.toString()
- if (valueStr && valueStr.length > 0) {
- params[item] = valueStr
- }
- }
- }
- if(self.include_admin){
- params['include_admin'] = 1
- }
- this.$http('get','/integral.php/ajax_request_common/get_employee_list',params)
- .then(function(response) {
- if (response.status == 200) {
- self.loading = false
- var jsonData = response.data
- try {
- self.department_list = jsonData.filter_list.department
- self.totalCount = jsonData.total_count
- self.tableData = jsonData.list_data
- self.pageSelectedId = []
- const pageSelectedId = []
- self.$nextTick(() => {
- // console.log(self.multipleSelectionId)
- for (const i in jsonData.list_data) {
- // console.log(self.multipleSelectionId.indexOf(jsonData.list_data[i].id),jsonData.list_data[i].id,self.multipleSelectionJson[jsonData.list_data[i].id])
- if (
- self.multipleSelectionId.indexOf(
- jsonData.list_data[i].id
- ) >= 0
- ) {
- self.$refs['multipleTable'].toggleRowSelection(
- self.tableData[i],
- true
- )
- pageSelectedId.push(self.tableData[i].id)
- }
- }
- self.pageSelectedId = pageSelectedId
- })
- } catch (err) {
- console.log(err)
- }
- }
- })
- .catch(function(error) {
- console.log(error)
- })
- },
- changePage: function(current) {
- if (isNaN(current) || current < 1) {
- return false
- }
- this.loadEmployeeList()
- }
- },
- created() {
- console.log(this.profile)
- this.loadBaseData()
- if (this.profile.manager_type > 1) {
- this.loadEmployeeList()
- }
- }
- }
- </script>
- <style scoped>
- .el-pagination {
- text-align: center;
- margin-top: 15px;
- }
- .dept_tree a.on {
- background-color: #f0f7ff;
- }
- .clearEmployeeBtn {
- cursor: pointer;
- color: #409eff;
- font-weight: normal;
- }
- .clearEmployeeBtn:hover {
- color: #66b1ff;
- }
- .rank_head img {
- width: 30px;
- height: 30px;
- -webkit-border-radius: 20px;
- -moz-border-radius: 20px;
- border-radius: 20px;
- margin-right: 5px;
- }
- .rank_head * {
- vertical-align: middle;
- }
- </style>
|