maxiaoshan 3 years ago
parent
commit
be86b61feb
4 changed files with 189 additions and 73 deletions
  1. 60 22
      src/front/front.go
  2. 1 1
      src/front/user.go
  3. 6 6
      src/web/templates/detail.html
  4. 122 44
      src/web/templates/list.html

+ 60 - 22
src/front/front.go

@@ -45,6 +45,7 @@ var preKey = "ck_"
 var preErr = "err_"
 var SE = qu.SimpleEncrypt{Key: "topJYBX2019"}
 var CheckLock = &sync.Mutex{}
+var LABELER, AUDITOR, ADMIN = 1, 2, 3 //标注人员,审核人员,管理员
 
 /*
 	status
@@ -65,11 +66,13 @@ func (i *Front) ListInfo() error {
 	min := i.GetString("minval") //min max不用int类型接收,以免有默认值0
 	max := i.GetString("maxval")
 	hasno, _ := i.GetBool("hasno")
+	notag, _ := i.GetBool("notag")
 	pagenum, _ := i.GetInteger("pagenum")
-	if pagenum == 0 {
+	labeler := i.GetString("labeler")
+	if pagenum == 0 { //页码
 		pagenum = 1
 	}
-	qu.Debug("coll:", coll, "stype:", stype, "field:", field, "hasno:", hasno, "max:", max, "min:", min, "pagenum:", pagenum)
+	qu.Debug("coll:", coll, "stype:", stype, "field:", field, "hasno:", hasno, "notag:", notag, "max:", max, "min:", min, "pagenum:", pagenum, "labeler:", labeler)
 	query := map[string]interface{}{}
 	if spidercode != "" { //爬虫代码
 		query["spidercode"] = spidercode
@@ -84,11 +87,13 @@ func (i *Front) ListInfo() error {
 			query["subtype"] = subtype
 		}
 	}
+	fieldScreen := false
 	if field != "-1" && field != "" { //字段
-		query[preKey+field] = map[string]interface{}{
-			"$exists": false, //field未曾标记
+		fieldScreen = true
+		queryfield := map[string]interface{}{
+			"$exists": !hasno,
 		}
-		if field == "budget" || field == "bidamount" || field == "biddiscount" { //金额区间
+		if field == "budget" || field == "bidamount" { //金额区间
 			numMap := map[string]interface{}{}
 			if min != "" {
 				minint := qu.IntAll(min)
@@ -98,25 +103,23 @@ func (i *Front) ListInfo() error {
 				maxint := qu.IntAll(max)
 				numMap["$lte"] = maxint
 			}
-			queryArr := []interface{}{}
-			if hasno { //包含field不存在的数据
-				queryArr = append(queryArr, map[string]interface{}{
-					field: map[string]interface{}{
-						"$exists": false,
-					},
-				})
-			}
-			if len(numMap) > 0 { //给定了区间,查询此区间或者budget、bidamount不存在的数据
-				queryArr = append(queryArr, map[string]interface{}{
-					field: numMap,
-				})
-			}
-			if len(queryArr) > 0 {
-				query["$or"] = queryArr
+			if len(numMap) > 0 { //给定了区间,不再判断字段存在
+				queryfield = numMap
 			}
-		} else {
-			hasno = false
 		}
+		query[field] = queryfield
+	}
+	if fieldScreen && notag {
+		query[preKey+field] = map[string]interface{}{
+			"$exists": false,
+		}
+	} else if !fieldScreen && notag {
+		query["ck_data"] = 0
+	}
+
+	//标注人员
+	if labeler != "" {
+		query["modifyuser"] = labeler
 	}
 	qu.Debug("query:", coll, query)
 	if coll == "" {
@@ -137,10 +140,17 @@ func (i *Front) ListInfo() error {
 	i.T["max"] = max
 	i.T["min"] = min
 	i.T["hasno"] = hasno
+	i.T["notag"] = notag
 	checkedNum, allNum := GetCheckedAndAllDataInfo(query, coll) //已标和总数信息
 	i.T["checkednum"] = checkedNum
 	i.T["allnum"] = allNum
 	i.T["pagenum"] = pagenum
+	role := qu.IntAll(i.GetSession("role"))
+	i.T["role"] = role
+	i.T["labeler"] = labeler
+	if role >= AUDITOR {
+		i.T["labelers"] = GetLabeler(coll)
+	}
 	return i.Render("list.html", &i.T)
 }
 
@@ -760,6 +770,7 @@ func getDetail(id, coll string) map[string]interface{} {
 		info["href"] = "http://" + href
 	}
 	info["filetext"] = util.GetFileText(info) //获取附件信息
+	qu.Debug(info["filetext"])
 	//rep["type"] = ftype
 	rep["info"] = info
 	common, timeplace, other := setExtComMap(info) //拼装抽取common值
@@ -1555,3 +1566,30 @@ func (i *Front) Elist() error {
 	i.T["common"] = common
 	return i.Render("elist.html", &i.T)
 }
+
+//查询表中已标数据的标注人
+func GetLabeler(coll string) (labeler []string) {
+	defer qu.Catch()
+	sess := util.MgoM.GetMgoConn()
+	defer util.MgoM.DestoryMongoConn(sess)
+	it := sess.DB(util.MgoM.DbName).C(coll).Pipe([]map[string]interface{}{
+		// map[string]interface{}{
+		// 	"$match": map[string]interface{}{
+		// 		"s_province": "河南省",
+		// 	},
+		// },
+		map[string]interface{}{
+			"$group": map[string]interface{}{
+				"_id": "$modifyuser",
+			},
+		},
+	}).Iter()
+	for user := make(map[string]interface{}); it.Next(&user); {
+		if name := qu.ObjToString(user["_id"]); name != "" {
+			labeler = append(labeler, name)
+		}
+	}
+	sort.Strings(labeler)
+	qu.Debug("labeler:", labeler)
+	return
+}

+ 1 - 1
src/front/user.go

@@ -7,7 +7,6 @@ import (
 
 //登录
 func (i *Front) Login() error {
-	qu.Debug(i.Method(), i.GetSession("password"))
 	if i.Method() == "GET" {
 		return i.Render("login.html")
 	} else {
@@ -24,6 +23,7 @@ func (i *Front) Login() error {
 			i.SetSession("loginuser", username)
 			i.SetSession("username", username)
 			i.SetSession("password", password)
+			i.SetSession("role", qu.IntAll((*user)["role"]))
 			return i.Redirect("/center/list")
 		} else {
 			if username != "" {

+ 6 - 6
src/web/templates/detail.html

@@ -64,7 +64,6 @@
     </style>
     <script>
         function prettyPrint(obj) {
-            console.log(obj)
             var ENDLINE = "\n";
             var COMMA_ENDLINE = ",\n";
             var OBJ_BEGIN = "{";
@@ -75,7 +74,7 @@
 
             return (function innerPrettyPrint(obj, spaces) {
                 var type = typeof obj;
-                console.log(obj,type)
+                //console.log(obj,type)
                 if (type == "number" || type == "boolean") {
                     return obj.toString();
                 } else if (type == "string") {
@@ -127,9 +126,10 @@
             {{if .T.info.detail}}
             <div v-html="dataHtml"></div>
             {{end}}
-
+        
             {{if .T.info.filetext}}
             <br><h3>附件内容</h3>
+<!--            <div>{{.T.info.filetext}}</div>-->
             <div v-html="fileHtml"></div>
             {{end}}
         </div>
@@ -328,7 +328,7 @@
     var issave = false;
     var _id = {{.T.info._id}};
     var nextid = {{.T.nextid}};
-    console.log(nextid)
+    //console.log(nextid)
     //基本信息
     var common={{.T.common}};
     var uInput=[];
@@ -553,7 +553,7 @@
             textMap: ['','','增', '改', '删'],
             tempHtml: `{{Html (Regexp (Regexp .T.info.detail "(\\n|\\\\n)\\s+" "\n") "(`|\\n|\\\\n)+" "<br/>")}}`,
             dataHtml: `{{Html (Regexp (Regexp .T.info.detail "(\\n|\\\\n)\\s+" "\n") "(`|\\n|\\\\n)+" "<br/>")}}`,
-            fileHtml: `{{Html (Regexp (Regexp .T.info.filetext "(\\n|\\\\n)\\s+" "\n") "(`|\\n|\\\\n)+" "<br/>")}}`,
+            fileHtml: {{.T.info.filetext}}.replace(/(\\n|\\\\n)\\s+/, '\n').replace(/(`|\\n|\\\\n)+/, '<br>'),
             showPop: false,
             editData: [
                 {
@@ -995,7 +995,7 @@
                     return
                 }
                 var d= JSON.stringify(this.editData);
-                console.log(d)
+                //console.log(d)
                 var _this = this
                 $.ajax({
                     url:"/center/biaozhu",

+ 122 - 44
src/web/templates/list.html

@@ -52,6 +52,11 @@
         .import-primary{
             margin-left: 9px;
         }
+        .r-c-box {
+            display: flex;
+            flex-direction: row;
+            align-items: center;
+        }
     </style>
 </head>
  <body>
@@ -113,6 +118,9 @@
                  <div style="display: none">
                      <input type="input" name="pagenum" id="pagenum"  class="form-control" value="{{.T.pagenum}}"/>
                  </div>
+                <div style="display: none">
+                     <input type="input" name="labeler" id="labername"  class="form-control" value=""/>
+                 </div>
                  <div class="col-md-3">
                      <input type="input" name="spidercode" class="form-control" value="{{.T.spidercode}}"
                             placeholder="请输入爬虫代码"/>
@@ -128,7 +136,7 @@
                      <div class=" row-box" style="padding-left: 0">
                          <label class="checkbox-inline">类型:</label>
                          <select name="type" id="topsubtype" class="form-control">
-                             <option value="-1">全部</option>
+                             <option value="-1">请选择</option>
                              <!--<option value="trailer" {{if eq .T.type "notice"}}selected{{end}}>预告</option>
                              <option value="tender" {{if eq .T.type "tender"}}selected{{end}}>招标</option>
                              <option value="bid" {{if eq .T.type "bid"}}selected{{end}}>结果</option>-->
@@ -137,7 +145,7 @@
                      <div class="row-box">
                          <label class="checkbox-inline">字段:</label>
                          <select name="field" id="field" class="form-control">
-                             <option value="-1">全部</option>
+                             <option value="-1">请选择</option>
                              <!--<option value="trailer" {{if eq .T.type "notice"}}selected{{end}}>预告</option>
                              <option value="tender" {{if eq .T.type "tender"}}selected{{end}}>招标</option>
                              <option value="bid" {{if eq .T.type "bid"}}selected{{end}}>结果</option> -->
@@ -146,9 +154,13 @@
                                 value="{{.T.min}}" placeholder="最小值"/>
                          <input type="input" name="maxval" id="maxval" style="display:none" class="form-control"
                                 value="{{.T.max}}" placeholder="最大值"/>
-                         <div id="boexists" style="display:none;margin-left: -29px;">
+                         <div id="boexists" style="margin-left: -29px;">
                              <input id="hasno" type="checkbox" name="hasno" onclick="checkboxOnclick(this)" value={{if .T.hasno}} true {{else}} false {{end}}/>
-                             <label style="margin-left: -28px;">包含不存在</label>
+                             <label style="margin-left: -28px;">不存在</label>
+                         </div>
+                        <div id="datanotag" style="margin-left: -29px;">
+                             <input id="notag" type="checkbox" name="notag" onclick="checktagboxOnclick(this)" value={{if .T.notag}} true {{else}} false {{end}}/>
+                             <label style="margin-left: -28px;">未标注</label>
                          </div>
                      </div>
                      <!--<div class="col-md-2">
@@ -184,14 +196,23 @@
          </div>
          <hr style="border:1 double" width="100%">
          <div  class="col-md-12">
-             <div class="form-group col-md-5" style="margin-left: -15px;">
-                 <h4>
-                     已验/总数:{{.T.checkednum}}/{{.T.allnum}}
-                 </h4>
-             </div>
-             <div>
-                 <button class="btn btn-primary" style="margin-left: 17px;" onclick="updateinfo()">刷新</button>
-             </div>
+            <div class="form-group col-md-3" style="margin-left: -15px;">
+              <h4>
+                已验/总数:{{.T.checkednum}}/{{.T.allnum}}
+              </h4>
+            </div>
+            <div class="r-c-box">
+              <button class="btn btn-primary" style="margin-left: 17px;" onclick="updateinfo()">刷新</button>
+              {{if ge .T.role 2}}
+              <div class="r-c-box">
+                <label class="checkbox-inline" style="word-break: keep-all; margin: 0 20px;">人员筛选:</label>
+                <select name="type" id="labeler" onchange="changelabeler(this.value)" class="form-control">
+                   <option value="-1">请选择</option>
+                </select>
+              </div>
+              {{end}}
+            </div>
+           
          </div>
          <hr style="border:1 double" width="100%">
          <div id="spcontent" class="column">
@@ -203,9 +224,13 @@
              {{end}}
          </div>
 	</div>
-  <div style="text-align: center;">
-     <div id="pager" class="pager clearfix">
-     </div>
+  <div style="text-align: center;justify-content: flex-end;padding-right: 100px;" class="r-c-box">
+    <div id="pager" class="pager clearfix"></div>
+    <div class="pager clearfix r-c-box" style="margin-left: 16px;">
+      跳转到
+      <input type="text" id="changePage" style="width:30px;">
+      <a type="text" href="javascript:void(0);" onclick="gopage()" style="text-align:center;float: right;">GO</a>
+    </div>
   </div>
 </div>
 
@@ -213,15 +238,19 @@
 
 <script>
 var vueApp = new Vue()
+//history.replaceState('', {},location.href.replace(location.search, '') )
 $(function(){
   if({{.T.coll}} == "marked"){
     $("#markedinit").css("display","");
   }
-  //是否不存在标记
+  //不存在标记
   if( {{.T.hasno}} ){
     $("#hasno").attr("checked",true);
   }
-
+  if( {{.T.notag}} ){
+    $("#notag").attr("checked",true);
+  }
+  //数据类型
   for(i in {{.T.topsubtype}}){
     var selected = ""
     if({{.T.type}} == {{.T.topsubtype}}[i]){
@@ -229,6 +258,11 @@ $(function(){
     }
     $("#topsubtype").append("<option "+selected+" value='"+{{.T.topsubtype}}[i]+"'>"+{{.T.topsubtype}}[i]+"</option>")
   }
+  //标注人员筛选
+  for(i in {{.T.labelers}}){
+    $("#labeler").append("<option value='"+{{.T.labelers}}[i]+"'>"+{{.T.labelers}}[i]+"</option>")
+  }
+  //字段选择
   var fk = "";
   for(i in {{.T.allfield}}){
     var selected = ""
@@ -243,9 +277,22 @@ $(function(){
   if(fk=="budget"||fk=="bidamount"){
     $("#maxval").css("display","");
     $("#minval").css("display","");
-    $("#boexists").css("display","");
+    $("#boexists").css("display","none");
   }
   
+  $("#field").change(function(){
+    $("#hasno").attr("checked",false);
+    $("#notag").attr("checked",false);
+    if($(this).val()=="bidamount"||$(this).val()=="budget"){
+      $("#minval").css("display","");
+      $("#maxval").css("display","");
+      $("#boexists").css("display","none");
+    }else{
+      $("#minval").css("display","none");
+      $("#maxval").css("display","none");
+      $("#boexists").css("display","");
+    }
+  });
   $("#fromtable").on('input propertychange', function(){
     var tmpcoll = $("#fromtable").val();
     if(tmpcoll == "marked"){
@@ -257,6 +304,24 @@ $(function(){
 })
 
 
+//是否选择不存在
+function checkboxOnclick(checkbox){
+  if ( checkbox.checked == true){
+      $("#hasno").attr("value",true);
+  }else{
+      $("#hasno").attr("value",false);
+  }
+}
+
+//是否选择未标注
+function checktagboxOnclick(checkbox){
+  if ( checkbox.checked == true){
+      $("#notag").attr("value",true);
+  }else{
+      $("#notag").attr("value",false);
+  }
+}
+
 function getdetail(id) {
     $.ajax({
         url: "/center/checkid",
@@ -268,14 +333,22 @@ function getdetail(id) {
                 if(r.exists){//标注完成
                     window.open("/center/finishcheck");
                 }else if(!r.exists && r.id != id){
-                    vueApp.$confirm('此条数据正在标注,是否直接跳转到未标注数据?', {
+                  /*
+                  vueApp.$message({
+                    message: '此条数据正在标注,请选择未标注数据',
+                    type: 'danger',
+                    duration: 2000,
+                    offset: 300
+                  });
+                  */
+                  vueApp.$confirm('此条数据正在标注,是否直接跳转到未标注数据?', {
                         confirmButtonText: '确认',
                         cancelButtonText: '取消',
                         type: 'warning'
                     }).then(() => {
                         window.open("/center/detail/"+r.id+".html");
                     }).catch(() => {
-                    });
+                  });
                 }else if (!r.exists && r.id == id){
                     window.open("/center/detail/"+r.id+".html");
                 }else{
@@ -288,16 +361,6 @@ function getdetail(id) {
     })
 }
 
-
-function checkboxOnclick(checkbox){
-    if ( checkbox.checked == true){
-        console.log("true")
-        $("#hasno").attr("value",true);
-    }else{
-        $("#hasno").attr("value",false);
-    }
-}
-
 function getescount(){
   var importcoll = $("#importcoll").val();
   if(importcoll == ""){
@@ -329,7 +392,7 @@ function importbyes(count,msg,text,coll){
   }).catch(() => {
   });
 }
-
+//es导入
 function importes(estext,coll){
     showLoading()
     $.ajax({
@@ -353,7 +416,7 @@ function importes(estext,coll){
         }
     });
 }
-
+//excel导入
 function importbyexcel(){
   var importcoll = $("#importcoll").val();
   if(importcoll == ""){
@@ -408,18 +471,6 @@ hideLoading = function (){
   $('#loadingModal').modal('hide');
 }
 
-$("#field").change(function(){
-  if($(this).val()=="bidamount"||$(this).val()=="budget"){
-    $("#minval").css("display","");
-    $("#maxval").css("display","");
-    $("#boexists").css("display","");
-  }else{
-    $("#minval").css("display","none");
-    $("#maxval").css("display","none");
-    $("#boexists").css("display","none");
-  }
-});
-
 //分页
 $("#pager").zPager({
     totalData: {{.T.allnum}},//数据总条数
@@ -467,6 +518,24 @@ function alertsync() {
     }
 }
 
+//页码跳转
+function gopage(){
+  var pagenumber = $("#changePage").val();
+  var totalcount = {{.T.allnum}};
+  var pagecount = parseInt((totalcount + 50 - 1) / 50)
+  if(1 <= pagenumber && pagenumber <= pagecount){
+    submitform(pagenumber);
+  }else{
+    vueApp.$message({
+      message: '页码输入有误,请重新输入!',
+      type: 'danger',
+      duration: 2000,
+      offset: 300
+    });
+  }
+  
+}
+
 function submitform(number){
     $("#pagenum").val(number);
     $("#submitForm").trigger('click');
@@ -549,6 +618,15 @@ function cancel() {
     $("#editeuser").modal("hide");
 }
 
+function changelabeler(labeler){
+  if(labeler == "-1"){
+    return
+  }
+  $("#labername").val(labeler)
+  $("#submitForm").trigger('click');
+  //window.location.href = '/center/getlistbylabeler/?user='+labeler;
+  //window.open("/center/getlistbylabeler/?user="+labeler);
+}
 
 </script>