1000510077_edit.jsp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <div id="space-content">
  6. <div class="space-department-sort">
  7. <!--中间部分-->
  8. <div class="part-middle" :class="{'no-data':isData}">
  9. <el-form ref="obj" :model="obj" label-width="60px" size="medium" :inline="true" auto-submit="false">
  10. <el-container class="space-container">
  11. <div class="space-tbs">
  12. <el-tabs v-model="obj.rtcode" @tab-click="clickCheck">
  13. <el-tab-pane label="全部" name=""></el-tab-pane>
  14. <el-tab-pane :label="item.name" :name="item.rtcode" v-for="item in datas.roleTypeData"></el-tab-pane>
  15. </el-tabs>
  16. <div class="tab-right">
  17. <div class="tabs-right-search">
  18. <el-input placeholder="搜索名称" v-model="obj.name" size="small" clearable collapse-tags>
  19. <i slot="suffix" class="el-input__icon el-icon-search space-search-icon" @click="clickCheck" ></i>
  20. </el-input>
  21. </div>
  22. </div>
  23. </div>
  24. </el-container>
  25. </el-form>
  26. <div class="staff-list">
  27. <ul>
  28. <li v-for="item in dataList" :key="item.id" @click="dataListClick(item.id, count)">
  29. <div class="staff-img">
  30. <i class="spaceicon icon-person staff-icon"></i>
  31. <div class="staff-img-mask" :class="{'staff-active':item.selected}">
  32. <i class="el-icon-check"></i>
  33. </div>
  34. </div>
  35. <div class="staff-msg">
  36. <p class="staff-msg-name" :title="item.name">
  37. {{item.name}}
  38. </p>
  39. <p :title="item.tag">
  40. {{item.tag}}
  41. </p>
  42. </div>
  43. </li>
  44. </ul>
  45. </div>
  46. <div class="staff-more">
  47. <el-button plain @click="loadMore" v-show="isLoadMore && !isData">加载更多</el-button>
  48. <div class="divider" v-if="!isLoadMore && !isData">
  49. <span >到底了</span>
  50. </div>
  51. </div>
  52. </div>
  53. <!--下半部分-->
  54. <div class="part-lower">
  55. <div class="part-lower-top">
  56. <span>
  57. 已选择 <span class="gray-color">{{selectedDataList.length}}</span> / {{countTop}} 项
  58. </span>
  59. <el-button v-show="selectedDataList.length > 0" type="text" icon="el-icon-delete-solid" @click="cancelAll">取消全部</el-button>
  60. </div>
  61. <div class="staff-list staff-noPic-list">
  62. <ul>
  63. <li v-for="item in selectedDataList" :key="item.id" @click="selectedClick(item.id)">
  64. <div class="staff-img">
  65. <i class="spaceicon icon-person staff-icon"></i>
  66. <div class="staff-img-mask">
  67. <i class="el-icon-close"></i>
  68. </div>
  69. </div>
  70. <div class="staff-msg">
  71. <p class="staff-msg-name" :title="item.name">
  72. {{item.name}}
  73. </p>
  74. <p :title="item.tag">
  75. {{item.tag}}
  76. </p>
  77. </div>
  78. </li>
  79. </ul>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="space-form-btn">
  84. <el-button type="primary" icon="el-icon-circle-check" :loading="loading" @click="saveBtn">保存</el-button>
  85. <el-button icon="el-icon-circle-close" onclick="space.allFunction.closeDialog();">关闭</el-button>
  86. </div>
  87. </div>
  88. </body>
  89. <script type="text/javascript">
  90. var reqURL = '@service{ name:`roleList_api`, params:`{dcode:"61"}` }@';
  91. var roleTypeStr = '<app:codeBookOption type="json" name="sys.roleType" />';
  92. space.vue = new Vue({
  93. el: space.appContent,
  94. data: function() {
  95. return {
  96. obj: {
  97. name: '',
  98. rtcode: '',
  99. },
  100. isChangeConditions: false,// 是否变动条件
  101. currentPageNo: 1,
  102. rowCountPerPage: 35,
  103. currentPageNoMore: 1,
  104. dataList: [],// 数据集合
  105. selectedDataList: [],// 选中的数据集合
  106. ids: [],
  107. count: 0,
  108. countTop: 0,
  109. loading: false,
  110. isLoadMore: true,// 是否有加载更多
  111. isData: false,// 是否有数据
  112. appendNewData: true,// 是否追加数据
  113. winInterval: undefined,
  114. datas: {
  115. // 类型数据
  116. roleTypeData: space.utils.notNull(roleTypeStr) ? JSON.parse(roleTypeStr) : [],
  117. }
  118. }
  119. },
  120. watch: {
  121. dataList: function(newValue, oldValue) {
  122. this.dataListSelected();
  123. },
  124. selectedDataList: function(newValue, oldValue) {
  125. this.dataListSelected();
  126. },
  127. 'obj.name': function(newValue, oldValue) {
  128. this.isChangeConditions = true;
  129. }
  130. },
  131. created: function() {
  132. var _this = this;
  133. this.winInterval = setInterval(function() {
  134. if (!window.chooseRoleSetting) {
  135. return;
  136. }
  137. window.clearInterval(_this.winInterval);
  138. _this.ids = window.chooseRoleSetting.selectAry() || [];
  139. _this.count = window.chooseRoleSetting.selectCountNum;
  140. _this.countTop = window.chooseRoleSetting.selectCountNum;
  141. if (_this.count == "*") {
  142. _this.countTop = "不限";
  143. }
  144. _this.winInterval = undefined;
  145. _this.initSelectedDataList(_this.ids);
  146. var param = _this.changeObj();
  147. _this.intiDataList(param);
  148. }, 100);
  149. },
  150. methods: {
  151. /**
  152. * 转换obj属性为字符串
  153. */
  154. changeObj: function() {
  155. var param = {};
  156. param["name"] = this.obj.name;
  157. param["rtcode"] = this.obj.rtcode == 0 ? '' : this.obj.rtcode;
  158. param["currentPageNo"] = this.currentPageNo;
  159. param["rowCountPerPage"] = this.rowCountPerPage;
  160. return param;
  161. },
  162. /**
  163. * 初始化选中的
  164. */
  165. initSelectedDataList: function(ids) {
  166. if (!ids || ids.length == 0) {
  167. return;
  168. }
  169. var _this = this;
  170. // 查询选中的列表
  171. space.utils.ajax({
  172. url: '@service{ name: `role_getChoolseRoleInfoApi` }@',
  173. data: {
  174. "ids": ids.join(',')
  175. },
  176. dataType: 'json',
  177. callback: function(data) {
  178. _this.selectedDataList = data.data;
  179. }
  180. })
  181. },
  182. /**
  183. * 初始化原数据集合
  184. * @param {Object} param 参数
  185. */
  186. intiDataList: function(param) {
  187. var _this = this;
  188. // 查询选中的列表
  189. space.utils.ajax({
  190. url: reqURL,
  191. data: param,
  192. dataType: 'json',
  193. callback: function(data) {
  194. var flag = false;
  195. if (data.data && data.data.length == 0) {
  196. flag = true;
  197. }
  198. if (_this.currentPageNoMore == 1) {
  199. _this.isData = flag;
  200. _this.dataList = data.data;
  201. }
  202. else {
  203. _this.dataList = _this.dataList.concat(data.data);
  204. }
  205. _this.isLoadMore = data.data.length < _this.rowCountPerPage ? false : true;
  206. }
  207. })
  208. },
  209. /**
  210. * 原数据选中
  211. */
  212. dataListSelected: function() {
  213. if (!this.selectedDataList || !this.dataList) {
  214. return;
  215. }
  216. var _this = this;
  217. // 回显选择人员
  218. _this.selectedDataList.forEach(function(selectedItem) {
  219. _this.dataList.forEach(function(item) {
  220. if (item.id == selectedItem.id) { // 对象里的唯一标识id
  221. item.selected = true; // 如果有已选的数组,显示遮罩
  222. }
  223. })
  224. })
  225. },
  226. /**
  227. * 加载更多
  228. */
  229. loadMore: function() {
  230. // 转换obj属性为字符串
  231. var param = this.changeObj();
  232. var _this = this;
  233. if (!this.isChangeConditions) {
  234. this.currentPageNoMore++;
  235. }
  236. else {
  237. this.currentPageNoMore = 1;
  238. this.isChangeConditions = false;
  239. }
  240. param["currentPageNo"] = this.currentPageNoMore;
  241. this.intiDataList(param);
  242. },
  243. /**
  244. * 查询
  245. */
  246. clickCheck: function() {
  247. var param = this.changeObj();
  248. this.currentPageNoMore = 1;
  249. this.isChangeConditions = false;
  250. this.intiDataList(param);
  251. },
  252. /**
  253. * 列表点击事件
  254. * @param {Object} id
  255. * @param {Object} count
  256. */
  257. dataListClick: function(id, count) {
  258. // 循环选中的数组,判断是否已存在元素对象,若存在,删除对象
  259. var flag = true;
  260. var _this = this;
  261. this.selectedDataList.forEach(function(item) {
  262. if (item.id == id) { // 对象里的唯一标识id
  263. _this.selectedDataList = _this.selectedDataList.filter(function(item) {
  264. return item.id != id;
  265. });
  266. flag = false;
  267. }
  268. })
  269. // 判断数量
  270. if (this.count == 1) {
  271. // 循环原数组,是否显示遮罩
  272. this.dataList.forEach(function(item) {
  273. if (item.id == id) { // 对象里的唯一标识id
  274. item.selected = !item.selected;
  275. } else {
  276. item.selected = false;
  277. }
  278. })
  279. // 若不存在,找到原数据的对象,替换到选中的数组
  280. if (flag) {
  281. var dataItem = this.dataList.filter(function(item) {
  282. return item.id == id;
  283. })
  284. this.selectedDataList = [];
  285. this.selectedDataList.push(dataItem[0]);
  286. }
  287. } else if (this.selectedDataList.length + 1 <= this.count || this.count == "*") {
  288. // 循环数组,是否显示遮罩
  289. this.cancelMask(id);
  290. // 若不存在,找到原数据的对象,添加到选中的数组中
  291. if (flag) {
  292. var dataItem = this.dataList.filter(function(item) {
  293. return item.id == id;
  294. })
  295. this.selectedDataList.push(dataItem[0]);
  296. }
  297. if (this.count == "*") {
  298. this.countTop = "不限";
  299. }
  300. } else {
  301. space.message.warning("最多只能选择" + this.selectedDataList.length + "个角色");
  302. }
  303. },
  304. // 选中的列表取消全部事件
  305. cancelAll: function() {
  306. // 取消全部遮罩
  307. this.dataList.forEach(function(item) {
  308. item.selected = false;
  309. });
  310. // 清空选中的数据
  311. this.selectedDataList = [];
  312. },
  313. // 选中列表点击取消单个事件
  314. selectedClick: function(id) {
  315. this.selectedDataList = this.selectedDataList.filter(function(item) {
  316. return item.id != id;
  317. });
  318. // 循环数组,取消遮罩
  319. this.cancelMask(id);
  320. },
  321. // 循环数组,取消单个遮罩
  322. cancelMask: function(id) {
  323. this.dataList.forEach(function(item) {
  324. if (item.id == id) { // 对象里的唯一标识id
  325. item.selected = !item.selected;
  326. }
  327. })
  328. },
  329. // 保存按钮
  330. saveBtn: function() {
  331. if (window.chooseRoleSetting.success) {
  332. window.chooseRoleSetting.success(this.selectedDataList);
  333. space.allFunction.closeDialog();
  334. }
  335. }
  336. }
  337. })
  338. </script>
  339. </html>