瀏覽代碼

提交多选逻辑

wenmenghao321 2 年之前
父節點
當前提交
811f67d834

+ 27 - 12
src/jfw/modules/app/src/web/templates/dataExport/dataExport.html

@@ -458,7 +458,7 @@
                 <div class="box">
                     <div class="head"><p>关键词匹配方式</p><img src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/dataExport/images/icon_delete_gray@2x.png?v={{Msg "seo" "version"}}" alt="" @click.stop="dialog_show=false"></div>
                     <div class="content">
-                        <div class="item" v-for="(item,index) in list"><p :class="{'active':item.val}">{item.name}</p><i :class="item.val?'check':'nocheck'" @click.stop="choose(item,index)"></i></div>
+                        <div class="item" v-for="(item,index) in list"><p :class="{'active_':item.val}">{item.name}</p><i :class="item.val?'check':'nocheck'" @click.stop="choose(item,index)"></i></div>
                     </div>
                     <div class="foot">
                         <div class="reset_btn" @click.stop="reset">重置</div>
@@ -1134,15 +1134,17 @@
                     }
                     if(ele=='正文'){
                        
-                        new_selectType_list.push('all')
+                        new_selectType_list.push('title')
+                        new_selectType_list.push('detail')
                     }
 
                      if(ele=='附件'){
-                        new_selectType_list.push('accessory')
+                        new_selectType_list.push('filetext')
 
                     }
                     if(ele=='项目名称/标的物'){
-                        new_selectType_list.push('subject')
+                        new_selectType_list.push('purchasing')
+                        new_selectType_list.push('projectname.pname')
 
                     }
 
@@ -1167,15 +1169,17 @@
                     }
                     if(ele=='正文'){
                        
-                        new_selectType_list.push('all')
+                        new_selectType_list.push('title')
+                        new_selectType_list.push('detail')
                     }
 
                      if(ele=='附件'){
-                        new_selectType_list.push('accessory')
+                        new_selectType_list.push('filetext')
 
                     }
                     if(ele=='项目名称/标的物'){
-                        new_selectType_list.push('subject')
+                        new_selectType_list.push('purchasing')
+                        new_selectType_list.push('projectname.pname')
 
                     }
 
@@ -1366,7 +1370,7 @@
         methods: {
             open_(str){
                 this.list=[
-                    {name:'标题',val:true},
+                    {name:'标题',val:false},
                     {name:'正文',val:false},
                     {name:'附件',val:false},
                     {name:'项目名称/标的物',val:false}
@@ -1394,10 +1398,21 @@
                 this.dialog_show=true
             },
             choose(item){
-                if(item.name=='标题'){
-                    return
+                //至少有一个选项
+                let chooselist=[]
+                this.list.forEach(function(ele){
+                    if(ele.val){
+                        chooselist.push(ele.val)
+                    }
+                })
+                if(chooselist.length<2){
+                    if(item.val==false){
+                        item.val=!item.val
+                    }
+                }else{
+                    item.val=!item.val    
                 }
-                item.val=!item.val
+                   
             },
             reset(){
                 this.list=[
@@ -1422,7 +1437,7 @@
                     $(".resetOne").css('display', 'flex');
                 }
                 $('.match').html(choose_str);
-                localStorage.export_selectType = choose_str;
+                localStorage.export_selectType = choose_str; //储存汉字提交时再转换为标识字段
                 this.dialog_show=false
             }
     

+ 110 - 0
src/web/staticres/wx_dataExport/css/dataExport.css

@@ -342,4 +342,114 @@ html .match_way .box .box_bd .weui-check:checked + .weui-icon-checked:before {
   font-size: .36rem;
   font-weight: 500;
   color: #2ABED1;
+}
+#checkbox_dialog .mask{
+  position: fixed;
+  z-index: 1000;
+  top: 0;
+  right: 0;
+  left: 0;
+  bottom: 0;
+  background: rgba(0,0,0,.6);
+}
+#checkbox_dialog .mask .box{
+  width: 100%;
+  position: absolute;
+  bottom: 0;
+  left: 0;
+  padding: 0 0.32rem 0.84rem 0.32rem;
+  box-sizing: border-box;
+  border-radius: 0.2rem 0.2rem 0 0;
+  background-color: #fff;
+}
+#checkbox_dialog .mask .box .head{
+ height: 1.28rem;
+ padding-top: 0.44rem;
+ box-sizing: border-box;
+}
+#checkbox_dialog .head p{
+font-size: 0.4rem;
+font-weight: 500;
+color: #171826;
+float: left;
+}
+#checkbox_dialog .head img{
+  float: right;
+  width: 0.4rem;
+  margin-top: 0.1rem;
+}
+#checkbox_dialog .content .item{
+  width: 100%;
+  height: 0.88rem;
+
+}
+#checkbox_dialog .content .item p{
+font-size: 0.28rem;
+line-height: 0.88rem;
+font-weight: 500;
+color: #5F5E64;
+float: left;
+}
+#checkbox_dialog .content .item .check,.nocheck{
+  display: inline-block;
+    vertical-align: middle;
+    font: normal normal normal 14px/1 weui;
+    font-size: inherit;
+    text-rendering: auto;
+    -webkit-font-smoothing: antialiased;
+    float: right;
+    margin-top: 0.2rem;
+}
+#checkbox_dialog .content .item .nocheck::before{
+  content: "\EA01";
+  color: rgba(0,0,0,.3);
+  font-size: 0.44rem;
+  display: block;
+  margin: 0;
+  
+}
+#checkbox_dialog .content .item .check::before{
+  color: #2CB7CA;
+  content: "\EA06";
+  font-size: 0.44rem;
+  display: block;
+  margin: 0;
+  
+}
+#checkbox_dialog .content .item .active_{
+  color: #2ABED1 !important;
+}
+#checkbox_dialog .foot{
+  width: 100%;
+  height: 1rem;
+
+}
+#checkbox_dialog .foot .reset_btn{
+  width: 3.3rem;
+height: 0.8rem;
+background: #EDEFF2;
+border-radius: 0.08rem;
+text-align: center;
+line-height: 0.8rem;
+font-size: 0.32rem;
+font-family: PingFang SC-Medium, PingFang SC;
+font-weight: 500;
+color: #5F5E64;
+float: left;
+margin-top: 0.2rem;
+}
+#checkbox_dialog .foot .ok_btn{
+  width: 3.3rem;
+height: 0.8rem;
+background: #2ABED1;
+border-radius: 0.08rem;
+text-align: center;
+line-height: 0.8rem;
+font-size: 0.32rem;
+font-family: PingFang SC-Medium, PingFang SC;
+font-weight: 500;
+color: #F7F9FA;
+float: right;
+margin-top: 0.2rem;
+
 }

+ 192 - 24
src/web/templates/weixin/dataExport/dataExport.html

@@ -15,6 +15,7 @@
     <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/wx_dataExport/css/weui.min.css">
     <script src="{{Msg "seo" "cdn"}}/wx_dataExport/js/rem.js?v={{Msg "seo" "version"}}"></script>
   <script src="https://cdn-common.jianyu360.com/cdn/lib/jquery/3.6.0/jquery.min.js"></script>
+  <script src="//cdn-common.jianyu360.com/cdn/lib/vue/2.6.14/vue.min.js"></script>
   <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/swiper/swiper.min.css?v={{Msg "seo" "version"}}">
   <script src="{{Msg "seo" "cdn"}}/swiper/swiper.min.js?v={{Msg "seo" "version"}}"></script>
 
@@ -321,7 +322,7 @@
 						</li>
                        <li class="list-item"><a href="JavaScript:;">
                            <strong class="label" style="width: 2.2rem;min-width: 8em;">关键词匹配方式</strong>
-                           <span class="match content">标题匹配</span>
+                           <span class="match content">标题</span>
                            <i class="iconfont icon-arrow"></i>
                        </a></li>
 
@@ -475,6 +476,22 @@
             </div>
         </div>
     </div>
+    <!-- 多选弹框 -->
+    <div id="checkbox_dialog">
+        <div class="mask" v-show="dialog_show">
+            <div class="box">
+                <div class="head"><p>关键词匹配方式</p><img src="{{Msg "seo" "cdn"}}/wx_dataExport/images/icon_delete_gray@2x.png?v={{Msg "seo" "version"}}" alt="" @click.stop="dialog_show=false"></div>
+                <div class="content">
+                    <div class="item" v-for="(item,index) in list"><p :class="{'active_':item.val}">{item.name}</p><i :class="item.val?'check':'nocheck'" @click.stop="choose(item,index)"></i></div>
+                </div>
+                <div class="foot">
+                    <div class="reset_btn" @click.stop="reset">重置</div>
+                    <div class="ok_btn" @click.stop="ok">确认</div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <!-- 弹框结束 -->
 <script>
     // 数据包默认选中企业需请求默认企业接口
     try {
@@ -510,14 +527,17 @@
         });
         //
         $('.match').click(function () {
-            $('.match_way').slideDown('slow');
-            var selectType = $(this).text();
-            $(".read").each(function () {
-                var p = $(this).children().text();
-                if(p === selectType){
-                    $(this).next().find("input:radio").prop("checked", true);
-                }
-            });
+             //单选原有逻辑
+            // $('.match_way').slideDown('slow');
+            // var selectType = $(this).text();
+            // $(".read").each(function () {
+            //     var p = $(this).children().text();
+            //     if(p === selectType){
+            //         $(this).next().find("input:radio").prop("checked", true);
+            //     }
+            // });
+           var selectType = $(this).text();
+           checkboxVm.open_(selectType)
         });
 
         $(".helpwhat").on("click",function(){
@@ -788,13 +808,13 @@
         //关键词选择方式
         if(localStorage.export_selectType!==""&&localStorage.export_selectType!==undefined){
             var selectType = localStorage.export_selectType;
-            var type = "";
-            if(selectType === "title"){
-                type = "按标题匹配";
-            }else if (selectType === "all"){
-                type = "按全文匹配";
-            }
-            $(".match").text(type);
+            // var type = "";
+            // if(selectType === "title"){
+            //     type = "按标题匹配";
+            // }else if (selectType === "all"){
+            //     type = "按全文匹配";
+            // }
+            $(".match").text(selectType);
             $(".confirm").hide();
             $(".resetOne").css('display','flex');
         }
@@ -1116,15 +1136,69 @@
                 winner = localStorage.winner;
             }
             if(localStorage.export_selectType!==undefined&&localStorage.export_selectType!==""){
-                selectType = localStorage.export_selectType;
+                // selectType = localStorage.export_selectType;  单选逻辑
+                // 多选
+                var selectType_str = localStorage.export_selectType;
+                var selectType_list =selectType_str.split(',');
+                var new_selectType_list = [];
+                selectType_list.forEach(function(ele){
+                    if(ele=='标题'){
+                        new_selectType_list.push('title')
+                    }
+                    if(ele=='正文'){
+                       
+                        new_selectType_list.push('title')
+                        new_selectType_list.push('detail')
+                    }
+
+                     if(ele=='附件'){
+                        new_selectType_list.push('filetext')
+
+                    }
+                    if(ele=='项目名称/标的物'){
+                        new_selectType_list.push('purchasing')
+                        new_selectType_list.push('projectname.pname')
+
+                    }
+
+                })
+                selectType = new_selectType_list.join(',')
             }else{
+                // 单选逻辑
+                // var type = $(".match").text();
+                // if(type === "按标题匹配"){
+                //     selectType = "title";
+                // }else if(type === "按全文匹配"){
+                //     selectType = "all";
+                // }
+                // localStorage.export_selectType = selectType;
+                // 多选
                 var type = $(".match").text();
-                if(type === "按标题匹配"){
-                    selectType = "title";
-                }else if(type === "按全文匹配"){
-                    selectType = "all";
-                }
-                localStorage.export_selectType = selectType;
+                localStorage.export_selectType = type;   
+                var selectType_list =type.split(',');
+                var new_selectType_list = [];
+                selectType_list.forEach(function(ele){
+                    if(ele=='标题'){
+                        new_selectType_list.push('title')
+                    }
+                    if(ele=='正文'){
+                       
+                        new_selectType_list.push('title')
+                        new_selectType_list.push('detail')
+                    }
+
+                     if(ele=='附件'){
+                        new_selectType_list.push('filetext')
+
+                    }
+                    if(ele=='项目名称/标的物'){
+                        new_selectType_list.push('purchasing')
+                        new_selectType_list.push('projectname.pname')
+
+                    }
+
+                })
+                selectType = new_selectType_list.join(',')
             }
 			if(localStorage.comeinfrom!==undefined&&localStorage.comeinfrom!==""){
 				comeinfrom = localStorage.comeinfrom;
@@ -1197,7 +1271,7 @@
             $("#subType").text("");
             $("#winner").text("");
             $("#buyer").text("");
-            $(".match").text("标题匹配");
+            $(".match").text("标题");
             //
             $(".chooseTime ul li").removeClass('active');
             $(".chooseTime ul li:eq(0)").addClass('active');
@@ -1284,6 +1358,100 @@
             n = n.toString();
             return n[1] ? n : '0' + n
         }
+        var checkboxVm=new Vue({
+        el: '#checkbox_dialog',
+        delimiters: ['{', '}'],
+        data: function () {
+            return {
+                dialog_show:false,
+                list:[
+                    {name:'标题',val:true},
+                    {name:'正文',val:false},
+                    {name:'附件',val:false},
+                    {name:'项目名称/标的物',val:false}
+                ]
+            }
+        },
+        created() {
+     
+        },
+        mounted() {
+        },
+        methods: {
+            open_(str){
+                this.list=[
+                    {name:'标题',val:true},
+                    {name:'正文',val:false},
+                    {name:'附件',val:false},
+                    {name:'项目名称/标的物',val:false}
+                ]
+                let this_=this
+                let list =str.split(',')
+                list.forEach(function(ele){
+                    if(ele=='标题'){
+                        this_.list[0].val=true
+                    }
+                    if(ele=='正文'){
+                       
+                        this_.list[1].val=true
+                    }
+
+                     if(ele=='附件'){
+                        this_.list[2].val=true
+
+                    }
+                    if(ele=='项目名称/标的物'){
+                        this_.list[3].val=true
+
+                    }
+                })
+                this.dialog_show=true
+            },
+            choose(item){
+                //至少有一个选项
+                let chooselist=[]
+                this.list.forEach(function(ele){
+                    if(ele.val){
+                        chooselist.push(ele.val)
+                    }
+                })
+                if(chooselist.length<2){
+                    if(item.val==false){
+                        item.val=!item.val
+                    }
+                }else{
+                    item.val=!item.val    
+                }
+            },
+            reset(){
+                this.list=[
+                    {name:'标题',val:true},
+                    {name:'正文',val:false},
+                    {name:'附件',val:false},
+                    {name:'项目名称/标的物',val:false}
+                ]
+            },
+            ok(){
+                let list =this.list
+                let choose=[]
+                list.forEach(function(ele) {
+                    if(ele.val){
+                        choose.push(ele.name)
+                    }  
+                });
+                let choose_str=choose.join(',')
+                console.log(choose_str)
+                if(choose_str!=='标题'){
+                    $(".confirm").hide();
+                    $(".resetOne").css('display', 'flex');
+                }
+                $('.match').html(choose_str);
+                localStorage.export_selectType = choose_str; //储存汉字提交时再转换为标识字段
+                this.dialog_show=false
+            }
+    
+        }
+      })
     })
 </script>
 	{{include "/common/baiducc.html"}}