| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <html>
- <head>
- <style>
- body{
- background-color: #fff;
- }
- .space-select-image ul, .space-select-tag{
- flex-wrap: wrap;
- justify-content: start;
- }
- .space-select-image li{
- margin: 22px 0 6px;
- width: 19%;
- }
- .space-select-tag span{
- margin: 15px 6px 3px;
- }
- .empty{
- height: 0;
- }
- .space-select-tag span:first-child{
- margin-left: 6px;
- }
- .space-select{
- margin: 0 6px;
- }
- .space-select-image-choice .space-select-image-wrap{
- margin: 0 auto;
- }
- </style>
- </head>
- <body>
- <div id="space-content">
- <div class="content-wrap">
- <van-nav-bar title="查看全部" left-text="取消" @click-left="space.plugin.layer.close();" right-text="清空所有" @click-right="removeAll"></van-nav-bar>
- <div class="space-select">
- <div class="space-select-image" v-if="initData.show == 'image'">
- <ul>
-
- <li v-for="(item,index) in initData.selectData" :key="item.id">
- <div class="space-select-image-wrap">
- <van-image :src="item.icon">
- <template v-slot:error>{{item.name}}</template>
- </van-image>
- <van-icon name="clear" class="space-select-image-close" @click="removeSingle(item.id)"></van-icon>
- </div>
- <p>{{item.name}}</p>
- </li>
-
- <!-- <li class="space-select-image-choice" @click="predefineFun" v-if="initData.predefine">
- <div class="space-select-image-wrap">
- <van-icon name="plus" ></van-icon>
- </div>
- </li>
- <li class="space-select-image-choice" @click="initData.method" v-if="initData.method">
- <div class="space-select-image-wrap">
- <van-icon name="plus" ></van-icon>
- </div>
- </li> -->
- </ul>
- </div>
- <div class="space-select-tag" v-if="initData.show != 'image'">
-
- <van-tag closeable size="large" color="#eaf2fd" text-color="#5094f2" @close="removeSingle(item.id)" v-for="(item,index) in initData.selectData" :key="item.id">
- {{item.name}}
- </van-tag>
-
- <!-- <span class="space-select-tag-choice" @click="predefineFun" v-if="initData.predefine">
- <van-icon name="plus" ></van-icon>
- 选择
- </span>
- <span class="space-select-tag-choice" @click="initData.method" v-if="initData.method">
- <van-icon name="plus" ></van-icon>
- 选择
- </span> -->
- </div>
- </div>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- space.vue = new Vue({
- el: space.appContent,
- data: function() {
- return {
- initData: {},
- }
- },
- methods: {
- // v-model数组合并去重
- uniqFun: function (valueAry) {
- var that = this;
- // 数组合并
- that.initData.selectData = that.initData.selectData.concat(valueAry);
- var newJson = []; //盛放去重后数据的新数组
- for( var item1 of that.initData.selectData){ //循环json数组对象的内容
- var flag = true; //建立标记,判断数据是否重复,true为不重复
-
- for( var item2 of newJson){ //循环新数组的内容
- if(item1.id==item2.id){ //让json数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
- flag = false;
- }
- }
- if(flag){ //判断是否重复
- newJson.push(item1); //不重复的放入新数组。 新数组的内容会继续进行上边的循环。
- }
- }
- that.initData.selectData = newJson;
- that.initData.callback({
- "selectData": that.initData.selectData
- })
- },
- predefineFun: function(){
- var that = this;
- var dataSize2 = that.initData.datasize || "9999";
- if (!space.utils.isNumberAsObject(dataSize2)) {
- dataSize2 = "9999";
- }
- if(that.initData.selectData) {
- var choosableSize = parseInt(dataSize2) - that.initData.selectData.length;
- if(choosableSize <= 0) {
- space.message.warning("数据已达上限");
- return;
- }
- dataSize2 = choosableSize;
- }
-
- if(this.initData.predefine == "person"){
- top.space.plugin.personChoose({
- datasize: dataSize2
- }, function (valueAry) {
- that.uniqFun(valueAry);
- });
- } else if(this.initData.predefine == "department"){
- top.space.plugin.departmentChoose({
- datasize: dataSize2
- }, function(valueAry) {
- that.uniqFun(valueAry);
- });
- } else if(this.initData.predefine == "post"){
- top.space.plugin.postChoose({
- datasize: dataSize2
- }, function(valueAry) {
- that.uniqFun(valueAry);
- });
- } else{
- top.space.plugin.roleChoose({
- datasize: dataSize2
- }, function(valueAry) {
- that.uniqFun(valueAry);
- });
- };
-
- },
- removeSingle: function(id) {
- this.initData.selectData = this.initData.selectData.filter(function(item){
- return item.id != id;
- });
- this.initData.callback({
- "selectData": this.initData.selectData
- })
- },
- removeAll: function() {
- this.initData.selectData = [];
- space.plugin.layer.close();
- this.initData.callback({
- "selectData": this.initData.selectData
- });
- }
- },
- });
- function layReady(data) {
- space.vue.$data.initData = data;
-
- // console.log(data);
- // data.callback({"msg": "啦啦啦"});
- }
- </script>
-
- </html>
|