| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- <html>
- <head>
- <style>
- .staff-list li {
- width: 180px;
- }
- </style>
- </head>
- <body>
- <div id="space-content">
- <div class="space-department-sort">
- <!--中间部分-->
- <div class="part-middle" :class="{'no-data':isData}">
- <el-form ref="obj" :model="obj" label-width="60px" size="medium" :inline="true" auto-submit="false">
- <el-container class="space-container">
- <div class="space-tbs">
- <el-tabs v-model="obj.rtcode" @tab-click="clickCheck">
- <el-tab-pane label="全部" name=""></el-tab-pane>
- <el-tab-pane :label="item.name" :name="item.rtcode" v-for="item in datas.roleTypeData">
- </el-tab-pane>
- </el-tabs>
- </div>
- </el-container>
- </el-form>
- <div class="staff-list">
- <ul>
- <li v-for="item in dataList" :key="item.id" @click="dataListClick(item.id, count)">
- <div class="staff-img">
- <el-avatar :size="36" shape="square" :src="item.icon_path">
- {{item.name}}
- </el-avatar>
- <div class="staff-img-mask" :class="{'staff-active':item.selected}">
- <i class="el-icon-check"></i>
- </div>
- </div>
- <div class="staff-msg">
- <p class="staff-msg-name" :title="item.name">
- {{item.name}}
- </p>
- <p :title="item.tag">
- {{item.tag}}
- </p>
- </div>
- </li>
- </ul>
- </div>
- <div class="staff-more">
- <el-button plain @click="loadMore" v-show="isLoadMore && !isData">加载更多</el-button>
- <div class="divider" v-if="!isLoadMore && !isData">
- <span>到底了</span>
- </div>
- </div>
- </div>
- <!--下半部分-->
- <div class="part-lower">
- <div class="part-lower-top">
- <span>
- 已选择 <span class="gray-color">{{selectedDataList.length}}</span> / {{countTop}} 项
- </span>
- <el-button v-show="selectedDataList.length > 0" type="text" icon="el-icon-delete-solid"
- @click="cancelAll">取消全部</el-button>
- </div>
- <div class="staff-list staff-noPic-list">
- <ul>
- <li v-for="item in selectedDataList" :key="item.id" @click="selectedClick(item.id)">
- <div class="staff-img">
- <el-avatar :size="36" shape="square" :src="item.icon_path">
- {{item.name}}
- </el-avatar>
- <div class="staff-img-mask">
- <i class="el-icon-close"></i>
- </div>
- </div>
- <div class="staff-msg">
- {{item.name}}
- </p>
- <p :title="item.tag">
- {{item.tag}}
- </p>
- </div>
- </li>
- </ul>
- </div>
- </div>
- </div>
- <div class="space-form-btn">
- <el-button type="primary" icon="el-icon-circle-check" :loading="loading" @click="saveBtn">保存</el-button>
- <el-button icon="el-icon-circle-close" onclick="space.allFunction.closeDialog();">关闭</el-button>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- var reqURL = '@service{ name:`website.website_getAllWebsiteApi` }@';
- space.vue = new Vue({
- el: space.appContent,
- data: function () {
- return {
- obj: {
- name: '',
- rtcode: '',
- },
- isChangeConditions: false,// 是否变动条件
- currentPageNo: 1,
- rowCountPerPage: 35,
- currentPageNoMore: 1,
- dataList: [],// 数据集合
- selectedDataList: [],// 选中的数据集合
- ids: [],
- count: "*",
- countTop: 999,
- loading: false,
- isLoadMore: true,// 是否有加载更多
- isData: false,// 是否有数据
- appendNewData: true,// 是否追加数据
- winInterval: undefined,
- datas: {
- // 类型数据
- roleTypeData: [],
- }
- }
- },
- watch: {
- dataList: function (newValue, oldValue) {
- this.dataListSelected();
- },
- selectedDataList: function (newValue, oldValue) {
- this.dataListSelected();
- },
- 'obj.name': function (newValue, oldValue) {
- this.isChangeConditions = true;
- }
- },
- created: function () {
- var _this = this;
- this.winInterval = setInterval(function () {
- if (!window.chooseRoleSetting) {
- return;
- }
- window.clearInterval(_this.winInterval);
- _this.ids = window.chooseRoleSetting.selectAry() || [];
- _this.count = window.chooseRoleSetting.selectCountNum;
- _this.countTop = window.chooseRoleSetting.selectCountNum;
- _this.winInterval = undefined;
- _this.initSelectedDataList(_this.ids);
- var param = _this.changeObj();
- _this.intiDataList(param);
- }, 100);
- this.loadMore();
- if (this.count == "*") {
- this.countTop = "不限";
- }
- },
- methods: {
- /**
- * 转换obj属性为字符串
- */
- changeObj: function () {
- var param = {};
- param["name"] = this.obj.name;
- param["rtcode"] = this.obj.rtcode == 0 ? '' : this.obj.rtcode;
- param["currentPageNo"] = this.currentPageNo;
- param["rowCountPerPage"] = this.rowCountPerPage;
- return param;
- },
- /**
- * 初始化选中的
- */
- initSelectedDataList: function (ids) {
- if (!ids || ids.length == 0) {
- return;
- }
- },
- /**
- * 初始化原数据集合
- * @param {Object} param 参数
- */
- intiDataList: function (param) {
- var _this = this;
- // 查询选中的列表
- space.utils.ajax({
- url: reqURL,
- data: param,
- dataType: 'json',
- callback: function (data) {
- var flag = false;
- if (data.data && data.data.length == 0) {
- flag = true;
- }
- if (_this.currentPageNoMore == 1) {
- _this.isData = flag;
- _this.dataList = data.data;
- }
- else {
- _this.dataList = _this.dataList.concat(data.data);
- }
- _this.isLoadMore = data.data.length < _this.rowCountPerPage ? false : true;
- }
- })
- },
- /**
- * 原数据选中
- */
- dataListSelected: function () {
- if (!this.selectedDataList || !this.dataList) {
- return;
- }
- var _this = this;
- // 回显选择人员
- _this.selectedDataList.forEach(function (selectedItem) {
- _this.dataList.forEach(function (item) {
- if (item.id == selectedItem.id) { // 对象里的唯一标识id
- item.selected = true; // 如果有已选的数组,显示遮罩
- }
- })
- })
- },
- /**
- * 加载更多
- */
- loadMore: function () {
- // 转换obj属性为字符串
- var param = this.changeObj();
- var _this = this;
- if (!this.isChangeConditions) {
- this.currentPageNoMore++;
- }
- else {
- this.currentPageNoMore = 1;
- this.isChangeConditions = false;
- }
- param["currentPageNo"] = this.currentPageNoMore;
- this.intiDataList(param);
- },
- /**
- * 查询
- */
- clickCheck: function () {
- var param = this.changeObj();
- this.currentPageNoMore = 1;
- this.isChangeConditions = false;
- this.intiDataList(param);
- },
- /**
- * 列表点击事件
- * @param {Object} id
- * @param {Object} count
- */
- dataListClick: function (id, count) {
- // 循环选中的数组,判断是否已存在元素对象,若存在,删除对象
- var flag = true;
- var _this = this;
- this.selectedDataList.forEach(function (item) {
- if (item.id == id) { // 对象里的唯一标识id
- _this.selectedDataList = _this.selectedDataList.filter(function (item) {
- return item.id != id;
- });
- flag = false;
- }
- })
- // 判断数量
- if (this.count == 1) {
- // 循环原数组,是否显示遮罩
- this.dataList.forEach(function (item) {
- if (item.id == id) { // 对象里的唯一标识id
- item.selected = !item.selected;
- } else {
- item.selected = false;
- }
- })
- // 若不存在,找到原数据的对象,替换到选中的数组
- if (flag) {
- var dataItem = this.dataList.filter(function (item) {
- return item.id == id;
- })
- this.selectedDataList = [];
- this.selectedDataList.push(dataItem[0]);
- }
- } else if (this.selectedDataList.length + 1 <= this.count || this.count == "*") {
- // 循环数组,是否显示遮罩
- this.cancelMask(id);
- // 若不存在,找到原数据的对象,添加到选中的数组中
- if (flag) {
- var dataItem = this.dataList.filter(function (item) {
- return item.id == id;
- })
- this.selectedDataList.push(dataItem[0]);
- }
- if (this.count == "*") {
- this.countTop = "不限";
- }
- } else {
- space.message.warning("最多只能选择" + this.selectedDataList.length + "个角色");
- }
- },
- // 选中的列表取消全部事件
- cancelAll: function () {
- // 取消全部遮罩
- this.dataList.forEach(function (item) {
- item.selected = false;
- });
- // 清空选中的数据
- this.selectedDataList = [];
- },
- // 选中列表点击取消单个事件
- selectedClick: function (id) {
- this.selectedDataList = this.selectedDataList.filter(function (item) {
- return item.id != id;
- });
- // 循环数组,取消遮罩
- this.cancelMask(id);
- },
- // 循环数组,取消单个遮罩
- cancelMask: function (id) {
- this.dataList.forEach(function (item) {
- if (item.id == id) { // 对象里的唯一标识id
- item.selected = !item.selected;
- }
- })
- },
- // 保存按钮
- saveBtn: function () {
- if (window.chooseCallback) {
- window.chooseCallback(this.selectedDataList);
- space.allFunction.closeDialog();
- }
- }
- }
- })
- </script>
- <script>
- function layReady() {
- space.vue.$data.selectedDataList = space.utils.isNull(window.chooseObj) ? [] : window.chooseObj;
- }
- </script>
- </html>
|