1001710521_edit.jsp 9.6 KB

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