1003810210_edit.jsp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <html>
  2. <head>
  3. <style>
  4. body{
  5. background-color: #fff;
  6. }
  7. .space-select-image ul, .space-select-tag{
  8. flex-wrap: wrap;
  9. justify-content: start;
  10. }
  11. .space-select-image li{
  12. margin: 22px 0 6px;
  13. width: 19%;
  14. }
  15. .space-select-tag span{
  16. margin: 15px 6px 3px;
  17. }
  18. .empty{
  19. height: 0;
  20. }
  21. .space-select-tag span:first-child{
  22. margin-left: 6px;
  23. }
  24. .space-select{
  25. margin: 0 6px;
  26. }
  27. .space-select-image-choice .space-select-image-wrap{
  28. margin: 0 auto;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div id="space-content">
  34. <div class="content-wrap">
  35. <van-nav-bar title="查看全部" left-text="取消" @click-left="space.plugin.layer.close();" right-text="清空所有" @click-right="removeAll"></van-nav-bar>
  36. <div class="space-select">
  37. <div class="space-select-image" v-if="initData.show == 'image'">
  38. <ul>
  39. <li v-for="(item,index) in initData.selectData" :key="item.id">
  40. <div class="space-select-image-wrap">
  41. <van-image :src="item.icon">
  42. <template v-slot:error>{{item.name}}</template>
  43. </van-image>
  44. <van-icon name="clear" class="space-select-image-close" @click="removeSingle(item.id)"></van-icon>
  45. </div>
  46. <p>{{item.name}}</p>
  47. </li>
  48. <!-- <li class="space-select-image-choice" @click="predefineFun" v-if="initData.predefine">
  49. <div class="space-select-image-wrap">
  50. <van-icon name="plus" ></van-icon>
  51. </div>
  52. </li>
  53. <li class="space-select-image-choice" @click="initData.method" v-if="initData.method">
  54. <div class="space-select-image-wrap">
  55. <van-icon name="plus" ></van-icon>
  56. </div>
  57. </li> -->
  58. </ul>
  59. </div>
  60. <div class="space-select-tag" v-if="initData.show != 'image'">
  61. <van-tag closeable size="large" color="#eaf2fd" text-color="#5094f2" @close="removeSingle(item.id)" v-for="(item,index) in initData.selectData" :key="item.id">
  62. {{item.name}}
  63. </van-tag>
  64. <!-- <span class="space-select-tag-choice" @click="predefineFun" v-if="initData.predefine">
  65. <van-icon name="plus" ></van-icon>
  66. 选择
  67. </span>
  68. <span class="space-select-tag-choice" @click="initData.method" v-if="initData.method">
  69. <van-icon name="plus" ></van-icon>
  70. 选择
  71. </span> -->
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </body>
  77. <script type="text/javascript">
  78. space.vue = new Vue({
  79. el: space.appContent,
  80. data: function() {
  81. return {
  82. initData: {},
  83. }
  84. },
  85. methods: {
  86. // v-model数组合并去重
  87. uniqFun: function (valueAry) {
  88. var that = this;
  89. // 数组合并
  90. that.initData.selectData = that.initData.selectData.concat(valueAry);
  91. var newJson = []; //盛放去重后数据的新数组
  92. for( var item1 of that.initData.selectData){ //循环json数组对象的内容
  93. var flag = true; //建立标记,判断数据是否重复,true为不重复
  94. for( var item2 of newJson){ //循环新数组的内容
  95. if(item1.id==item2.id){ //让json数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  96. flag = false;
  97. }
  98. }
  99. if(flag){ //判断是否重复
  100. newJson.push(item1); //不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  101. }
  102. }
  103. that.initData.selectData = newJson;
  104. that.initData.callback({
  105. "selectData": that.initData.selectData
  106. })
  107. },
  108. predefineFun: function(){
  109. var that = this;
  110. var dataSize2 = that.initData.datasize || "9999";
  111. if (!space.utils.isNumberAsObject(dataSize2)) {
  112. dataSize2 = "9999";
  113. }
  114. if(that.initData.selectData) {
  115. var choosableSize = parseInt(dataSize2) - that.initData.selectData.length;
  116. if(choosableSize <= 0) {
  117. space.message.warning("数据已达上限");
  118. return;
  119. }
  120. dataSize2 = choosableSize;
  121. }
  122. if(this.initData.predefine == "person"){
  123. top.space.plugin.personChoose({
  124. datasize: dataSize2
  125. }, function (valueAry) {
  126. that.uniqFun(valueAry);
  127. });
  128. } else if(this.initData.predefine == "department"){
  129. top.space.plugin.departmentChoose({
  130. datasize: dataSize2
  131. }, function(valueAry) {
  132. that.uniqFun(valueAry);
  133. });
  134. } else if(this.initData.predefine == "post"){
  135. top.space.plugin.postChoose({
  136. datasize: dataSize2
  137. }, function(valueAry) {
  138. that.uniqFun(valueAry);
  139. });
  140. } else{
  141. top.space.plugin.roleChoose({
  142. datasize: dataSize2
  143. }, function(valueAry) {
  144. that.uniqFun(valueAry);
  145. });
  146. };
  147. },
  148. removeSingle: function(id) {
  149. this.initData.selectData = this.initData.selectData.filter(function(item){
  150. return item.id != id;
  151. });
  152. this.initData.callback({
  153. "selectData": this.initData.selectData
  154. })
  155. },
  156. removeAll: function() {
  157. this.initData.selectData = [];
  158. space.plugin.layer.close();
  159. this.initData.callback({
  160. "selectData": this.initData.selectData
  161. });
  162. }
  163. },
  164. });
  165. function layReady(data) {
  166. space.vue.$data.initData = data;
  167. // console.log(data);
  168. // data.callback({"msg": "啦啦啦"});
  169. }
  170. </script>
  171. </html>