Jianghan преди 3 години
родител
ревизия
7703c4981d
променени са 6 файла, в които са добавени 216 реда и са изтрити 52 реда
  1. 1 1
      src/front/front.go
  2. 185 32
      src/front/remark.go
  3. 2 1
      src/util/config.go
  4. 5 0
      src/util/util.go
  5. 20 15
      src/web/templates/project/remark_detail.html
  6. 3 3
      src/web/templates/project/remark_list.html

+ 1 - 1
src/front/front.go

@@ -86,7 +86,7 @@ type Front struct {
 	//check
 
 	remarkList   xweb.Mapper `xweb:"/front/user/remark/list"`
-	remarkDetail xweb.Mapper `xweb:"/center/detail/(.*).html"`
+	remarkDetail xweb.Mapper `xweb:"/front/user/remark/detail"`
 }
 
 func (f *Front) Index() {

+ 185 - 32
src/front/remark.go

@@ -3,6 +3,7 @@ package front
 import (
 	"fmt"
 	"go.mongodb.org/mongo-driver/bson"
+	"math"
 	mgo "mongodb"
 	qu "qfw/util"
 	"sort"
@@ -25,10 +26,11 @@ func (f *Front) RemarkList() {
 		query := map[string]interface{}{"s_usertaskid": tid}
 		if search != "" {
 			query["$or"] = []interface{}{
-				bson.M{"s_name": bson.M{"$regex": search}},
+				bson.M{"v_baseinfo.title": bson.M{"$regex": search}},
 			}
 		}
-		info, _ := util.Mgo.Find(sourceinfo, query, `{"_id": 1}`, nil, false, start, limit)
+		field := map[string]interface{}{"title": 1, "v_baseinfo": 1, "b_istag": 1}
+		info, _ := util.Mgo.Find(sourceinfo, query, `{"_id": 1}`, field, false, start, limit)
 		count := util.Mgo.Count(sourceinfo, query)
 		qu.Debug(query, sourceinfo, count)
 		f.ServeJson(map[string]interface{}{
@@ -45,7 +47,10 @@ func (f *Front) RemarkList() {
 	}
 }
 
-func (f *Front) RemarkDetail(id, coll string) {
+func (f *Front) RemarkDetail() {
+	id := f.GetString("gid")
+	coll := f.GetString("s_sourceinfo")
+	qu.Debug("------------", id, coll)
 	rep := getDetail(id, coll)          //获取本条公告的信息
 	f.T["otherInfo"] = rep["otherInfo"] //展示关联公告信息
 	f.T["moreInfo"] = rep["moreInfo"]   //更多关联公告信息
@@ -58,22 +63,19 @@ func (f *Front) RemarkDetail(id, coll string) {
 	f.T["timeplace"] = rep["timeplace"]
 	f.T["purchasinglist"] = rep["purchasinglist"]
 	f.T["other"] = rep["other"]
-
 	f.T["PurchasinglistField"] = util.PurchasinglistField
 	f.T["WinnerorderField"] = util.WinnerorderField
 	f.T["PackageField"] = util.PackageField
 	f.T["topsubtype"] = util.TopSubStypeArr2
-	f.T[preKey+"purchasinglist"] = rep[preKey+"purchasinglist"]
-	f.T[preKey+"package"] = rep[preKey+"package"]
-	f.T[preKey+"winnerorder"] = rep[preKey+"winnerorder"]
+	f.T["ck_purchasinglist"] = rep["ck_purchasinglist"]
+	f.T["ck_package"] = rep["ck_package"]
+	f.T["ck_winnerorder"] = rep["ck_winnerorder"]
 	f.T["worder_new"] = rep["worder_new"]
 	f.T["pcl_new"] = rep["pcl_new"]
 	f.T["pkg_new"] = rep["pkg_new"]
-	f.T["nextid"] = GetNextDataId(id, coll, query)              //下一条id
-	checkedNum, allNum := GetCheckedAndAllDataInfo(query, coll) //已标和总数信息
-	f.T["checkednum"] = checkedNum
-	f.T["allnum"] = allNum
-	f.T["fields"] = util.Config.Fields
+	f.T["nextid"] = GetNextDataId(id, coll) //下一条id
+	f.T["fields"] = map[string]bool{"projectname": true}
+	_ = f.Render("project/remark_detail.html", &f.T)
 }
 
 func getDetail(id, coll string) map[string]interface{} {
@@ -94,35 +96,34 @@ func getDetail(id, coll string) map[string]interface{} {
 	rep["common"] = common
 	rep["timeplace"] = timeplace
 	rep["other"] = other
-	packs, packskey, pkg_new := setPaceMap(baseInfo, bzInfo) //拼装子包信息
+	packs, packskey, pkg_new := setPaceMap(baseInfo) //拼装子包信息
 	rep["packs"] = packs
 	rep["packskey"] = packskey
 	rep["pkg_new"] = pkg_new
-
-	purchasinglist, isNewStatus := setPurchasingMap(baseInfo, bzInfo) //标的物
+	purchasinglist, isNewStatus := setPurchasingMap(baseInfo) //标的物
 	rep["purchasinglist"] = purchasinglist
 	rep["pcl_new"] = isNewStatus
-	worder, worder_new := setWorderMap(info) //中标候选人
+	worder, worder_new := setWorderMap(baseInfo) //中标候选人
 	rep["worder"] = worder
 	rep["worder_new"] = worder_new
-	otherInfo, moreInfo := setOtherInfo(info) //处理公告关联信息
+	otherInfo, moreInfo := setOtherInfo(baseInfo) //处理公告关联信息
 	rep["otherInfo"] = otherInfo
 	rep["moreInfo"] = moreInfo
 	//
-	if info[preKey+"purchasinglist"] != nil {
-		rep[preKey+"purchasinglist"] = "1"
+	if bzInfo["purchasinglist"] != nil {
+		rep["ck_purchasinglist"] = "1"
 	} else {
-		rep[preKey+"purchasinglist"] = "-1"
+		rep["ck_purchasinglist"] = "-1"
 	}
-	if info[preKey+"package"] != nil {
-		rep[preKey+"package"] = "1"
+	if bzInfo["package"] != nil {
+		rep["ck_package"] = "1"
 	} else {
-		rep[preKey+"package"] = "-1"
+		rep["ck_package"] = "-1"
 	}
-	if info[preKey+"winnerorder"] != nil {
-		rep[preKey+"winnerorder"] = "1"
+	if bzInfo["winnerorder"] != nil {
+		rep["ck_winnerorder"] = "1"
 	} else {
-		rep[preKey+"winnerorder"] = "-1"
+		rep["ck_winnerorder"] = "-1"
 	}
 	return rep
 }
@@ -212,10 +213,10 @@ func setExtComMap(info, bzInfo map[string]interface{}) ([]interface{}, []interfa
 }
 
 //拼装子包信息
-func setPaceMap(info, bzInfo map[string]interface{}) ([]map[string]interface{}, []string, []bool) {
+func setPaceMap(info map[string]interface{}) ([]map[string]interface{}, []string, []bool) {
 	var confpack []interface{}
 	confpack, _ = util.BiaoZhu["package"].([]interface{})
-	bzpack := bzInfo["package"].(map[string]interface{})
+	//bzpack := bzInfo["package"].(map[string]interface{})
 	packs := map[string]map[string]interface{}{}
 	var sortpackskey []string
 	isNewPkg := map[string]bool{} //记录子包是否是新增的
@@ -225,8 +226,7 @@ func setPaceMap(info, bzInfo map[string]interface{}) ([]map[string]interface{},
 				//isNew, _ := tmppack["ck_isnew"].(bool)
 				isNew := false
 				status := "-1"
-				bzp := bzpack[k].(map[string]interface{})
-				if bzp["tag"] != nil {
+				if tmppack["package_son"] != nil {
 					status = "1"
 				}
 				isNewPkg[k] = isNew
@@ -309,7 +309,7 @@ func setPaceMap(info, bzInfo map[string]interface{}) ([]map[string]interface{},
 }
 
 //拼装标的物
-func setPurchasingMap(info, bzinfo map[string]interface{}) ([]interface{}, []map[string]interface{}) {
+func setPurchasingMap(info map[string]interface{}) ([]interface{}, []map[string]interface{}) {
 	purchasinglist, _ := util.BiaoZhu["purchasinglist"].([]interface{})
 	var purchasinglists []interface{}
 	//isNewPcl := []bool{} //记录子包是否是新增的
@@ -320,7 +320,7 @@ func setPurchasingMap(info, bzinfo map[string]interface{}) ([]interface{}, []map
 				//isNew, _ := pcl["ck_isnew"].(bool)
 				isNew := false
 				status := "-1"
-				if pcl["ck_purchasinglist"] != nil {
+				if pcl["purchasinglist_son"] != nil {
 					status = "1"
 				}
 				//isNewPcl = append(isNewPcl, isNew)
@@ -351,3 +351,156 @@ func setPurchasingMap(info, bzinfo map[string]interface{}) ([]interface{}, []map
 	}
 	return purchasinglists, isNewAndStatus
 }
+
+//拼装中标候选人
+func setWorderMap(info map[string]interface{}) ([]interface{}, []map[string]interface{}) {
+	//基本参数--中标候选人
+	winnerorder, _ := util.BiaoZhu["winnerorder"].([]interface{})
+	worders := []interface{}{}
+	isNewAndStatus := []map[string]interface{}{}
+	if tmpwds, ok := info["winnerorder"].([]interface{}); ok {
+		for _, v := range tmpwds {
+			if wd, ok := v.(map[string]interface{}); ok {
+				//isNew, _ := wd["ck_isnew"].(bool)
+				isNew := false
+				status := "-1"
+				if wd["winnerorder_son"] != nil {
+					status = "1"
+				}
+				isNewAndStatus = append(isNewAndStatus, map[string]interface{}{"isnew": isNew, "status": status})
+				wds := []interface{}{}
+				for _, cp := range winnerorder {
+					cp, _ := cp.(map[string]interface{})
+					value := wd[qu.ObjToString(cp["key"])]
+					if value == nil {
+						value = ""
+					}
+					tp := map[string]interface{}{
+						"key":      cp["key"],
+						"descript": cp["descript"],
+						"value":    value,
+						"status":   status,
+					}
+					wds = append(wds, tp)
+				}
+				worders = append(worders, wds)
+			}
+		}
+	}
+	return worders, isNewAndStatus
+}
+
+//获取公告关联信息
+func setOtherInfo(info map[string]interface{}) (result, moreArr []map[string]interface{}) {
+	if otherInfo, ok := info["info"].([]interface{}); ok && len(otherInfo) > 0 {
+		//中标,成交、合同、招标(不含变更)
+		/*
+			[
+				{},
+				{},
+			]
+		*/
+		zbArr := []map[string]interface{}{}
+		cjArr := []map[string]interface{}{}
+		htArr := []map[string]interface{}{}
+		zbbArr := []map[string]interface{}{}
+		for _, tmp := range otherInfo {
+			tmpInfo := tmp.(map[string]interface{})
+			tmpInfo["detail"] = qu.ObjToString(tmpInfo["title"]) + "</br>" + qu.ObjToString(tmpInfo["title"])
+			toptype := tmpInfo["toptype"]
+			subtype := tmpInfo["subtype"]
+			ptime := ""
+			tmpPtime := qu.Int64All(tmpInfo["publishtime"])
+			if tmpPtime > 0 {
+				ptime = qu.FormatDateByInt64(&tmpPtime, qu.Date_Full_Layout)
+			}
+			tmpInfo["publishtime_str"] = ptime
+			if subtype == "中标" {
+				zbArr = append(zbArr, tmpInfo)
+			} else if subtype == "成交" {
+				cjArr = append(cjArr, tmpInfo)
+			} else if subtype == "合同" {
+				htArr = append(htArr, tmpInfo)
+			} else if toptype == "招标" && subtype != "变更" {
+				zbbArr = append(zbbArr, tmpInfo)
+			} else { //标注页不展示的信息,更多中展示
+				moreArr = append(moreArr, map[string]interface{}{
+					"publishtime": tmpInfo["publishtime_str"],
+					"subtype":     subtype,
+					"title":       tmpInfo["title"],
+					"href":        util.GetJyHref(qu.ObjToString(tmpInfo["id"])),
+				})
+			}
+		}
+		publishtime := qu.Float64All(info["publishtime"])
+		//中标信息
+		if zbLen := len(zbArr); zbLen > 0 {
+			rzb := DealData(zbLen, publishtime, zbArr, &moreArr)
+			result = append(result, rzb)
+		}
+		//成交
+		if cjLen := len(cjArr); cjLen > 0 {
+			rcj := DealData(cjLen, publishtime, cjArr, &moreArr)
+			result = append(result, rcj)
+		}
+		//合同
+		if htLen := len(htArr); htLen > 0 {
+			rht := DealData(htLen, publishtime, htArr, &moreArr)
+			result = append(result, rht)
+		}
+		result = append(result, zbbArr...)
+	}
+	return
+}
+
+func DealData(tmpLen int, publishtime float64, tmp []map[string]interface{}, moreArr *[]map[string]interface{}) (resultTmp map[string]interface{}) {
+	if tmpLen == 1 || publishtime <= 0 { //相同类型只有一条或者原公告发布时间异常取第一条公告
+		resultTmp = tmp[0]
+		for _, t := range tmp[1:] { //将过滤掉的数据加入到更多中
+			*moreArr = append(*moreArr, map[string]interface{}{
+				"publishtime": t["publishtime_str"],
+				"subtype":     t["subtype"],
+				"title":       t["title"],
+				"href":        util.GetJyHref(qu.ObjToString(t["id"])),
+			})
+		}
+		return
+	} else {
+		diff := float64(0) //记录差值
+		index := 0
+		for i, zb := range tmp {
+			pTmp := qu.Float64All(zb["publishtime"])
+			diffTmp := math.Abs(publishtime - pTmp) //绝对值
+			if i == 0 {
+				diff = diffTmp
+			} else if diffTmp < diff { //记录较小差值的数据索引位置
+				diff = diffTmp
+				index = i
+			} else { //将过滤掉的数据加入到更多中
+				*moreArr = append(*moreArr, map[string]interface{}{
+					"publishtime": zb["publishtime_str"],
+					"subtype":     zb["subtype"],
+					"title":       zb["title"],
+					"href":        util.GetJyHref(qu.ObjToString(zb["id"])),
+				})
+			}
+		}
+		resultTmp = tmp[index]
+	}
+	return
+}
+
+//获取当前数据下一条的id
+func GetNextDataId(id, coll string) string {
+	nextIdQuery := map[string]interface{}{
+		"_id": map[string]interface{}{
+			"$gt": mgo.StringTOBsonId(id),
+		},
+	}
+
+	one, _ := util.Mgo.Find(coll, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
+	if one != nil && len(*one) == 1 {
+		return mgo.BsonIdToSId((*one)[0]["_id"])
+	}
+	return id
+}

+ 2 - 1
src/util/config.go

@@ -52,6 +52,7 @@ var (
 
 var SE = qu.SimpleEncrypt{Key: "topJYBX2019"}
 
+const JYHREFPRE = "https://www.jianyu360.cn/article/content/"
 const BIDDINGSTARTID = "5a862f0640d2d9bbe88e3cec"
 const PROJECTCOLLNAME = "f_project"
 const TASKCOLLNAME = "f_task"
@@ -175,7 +176,7 @@ func InitConfig() {
 		WinnerorderField = append(WinnerorderField, map[string]string{key: descript})
 	}
 	//公告类型
-	types := Sysconfig[""].(map[string]interface{})
+	types := Sysconfig["topsubtype"].(map[string]interface{})
 	for top, v := range types {
 		tmp := v.([]interface{})
 		for _, sub := range tmp {

+ 5 - 0
src/util/util.go

@@ -2,6 +2,7 @@ package util
 
 import (
 	"net/http"
+	"qfw/util"
 	"strconv"
 )
 
@@ -33,3 +34,7 @@ func GetPostForm(r *http.Request) map[string]interface{} {
 	}
 	return val
 }
+
+func GetJyHref(id string) string {
+	return JYHREFPRE + util.CommonEncodeArticle("content", id) + ".html"
+}

+ 20 - 15
src/web/templates/project/remark_detail.html

@@ -399,23 +399,27 @@
 </main>
 
 </body>
+
 <script>
     var allCheckFields = {{ .T.fields }}          //本次需标注的所有字段
+    var moreInfo = {{ .T.moreInfo }}            // 更多关联信息
+    var otherInfo = {{ .T.otherInfo }}          //公告关联信息
     // 页面数据
     var pageDataMap = {
         '原文': {
             title: '{{.T.info.title}}',
             href: '{{.T.info.href}}',
-            html: '{{Html (Regexp (Regexp .T.info.detail "(\\\\n|\\\\\\\\n)\\\\s+" "\\n") "(`|\\\\n|\\\\\\\\n)+" "<br/>")}}',
-        '附件':{
+            // html: '{{Html (Regexp (Regexp .T.info.detail "(\\n|\\\\n)\\s+" "\n") "(`|\\n|\\\\n)+" "<br/>")}}',
+            html: '{{ .T.info.detail }}',
+        },
+        '附件': {
             title: '附件内容',
             href: '',
-            html:{{if .T.info.filetext}}{{.T.info.filetext}}.replace(/(\\n|\\\\n)\\s+/, '\n').replace(/(`|\\n|\\\\n)+/, '<br>'){{else}}``{{end}} }
-      }
-    // 更多关联信息
-    var moreInfo = {{ .T.moreInfo }}
-    //公告关联信息
-    var otherInfo = {{ .T.otherInfo }}
+            // html:{{if .T.info.filetext}}{{.T.info.filetext}}.replace(/(\\n|\\\\n)\\s+/, '\n').replace(/(`|\\n|\\\\n)+/, '<br>'){{else}}``{{end}} }
+            html: '{{ .T.info.filetext }}',
+        },
+    }
+
     //快捷键
     $(document).keydown(function (event) {
         if (!event.shiftKey) {
@@ -742,7 +746,8 @@
                 index: 0
             },
             textMap: ['', '', '增', '改', '删'],
-            pageHtml: `{{Html (Regexp (Regexp .T.info.detail "(\\\\n|\\\\\\\\n)\\\\s+" "\\n") "(\`|\\\\n|\\\\\\\\n)+" "<br/>")}}`,
+            // pageHtml: `{{Html (Regexp (Regexp .T.info.detail "(\\n|\\\\n)\\s+" "\n") "(`|\\n|\\\\n)+" "<br/>")}}`,
+            pageHtml: '{{ .T.info.detail }}',
             showPop: false,
             editData:[{
               title: '基本字段',
@@ -774,23 +779,23 @@
               key: 'purchasinglist',
               //checkType: {{.T.ck_pclisext}},
               content: pcl_content,
-              checkAllTag: {{ .T.ck_pclistag }},
-              status: {{ .T.ck_purchasinglist }},
+              // checkAllTag: {{ .T.ck_pclistag }},
+              // status: {{ .T.ck_purchasinglist }},
               }, {
               title: '多包信息',
               show:false,
               showCheck: true,
               key: 'package',
-              checkType: {{.T.ck_pkgisext}},
-              status:{{ .T.ck_package }},
+              // checkType: {{.T.ck_pkgisext}},
+              // status:{{ .T.ck_package }},
               content: p_content
               }, {
               title: '中标候选人信息',
               show: false,
               showCheck: true,
               key: 'winnerorder',
-              checkType: {{.T.ck_wodrisext}},
-              status:{{ .T.ck_winnerorder }},
+              // checkType: {{.T.ck_wodrisext}},
+              // status:{{ .T.ck_winnerorder }},
               content: c_content
               }, {
               title: '其余信息',

+ 3 - 3
src/web/templates/project/remark_list.html

@@ -93,9 +93,9 @@
                 {"data": "v_baseinfo.title", render: function (val, index, row) {
                         let tmp;
                         if (row["re_data"] === 1) {
-                            tmp = '<a style="display: inline-block;cursor:pointer;font-size:16px;color: green" onclick="skipDetail(\'' + row._id + '\')">' + val + '</a>'
+                            tmp = '<a style="display: inline-block;cursor:pointer;font-size:16px;color: green" target="_blank" href="/front/user/remark/detail/?gid=' + row._id + '&s_sourceinfo='+sourceinfo+'">' + val + '</a>'
                         } else {
-                            tmp = '<a style="display: inline-block;cursor:pointer;font-size:16px;color: #428bca" onclick="skipDetail(\'' + row._id + '\')">' + val + '</a>'
+                            tmp = '<a style="display: inline-block;cursor:pointer;font-size:16px;color: #428bca" target="_blank" href="/front/user/remark/detail/?gid=' + row._id + '&s_sourceinfo='+sourceinfo+'">' + val + '</a>'
                         }
                         return tmp
                     }}
@@ -113,6 +113,6 @@
     });
 
     function skipDetail(id) {
-        window.open("/project/remark_detail/"+id+"/"+sourceinfo+".html");
+        window.open("/front/user/remark/detail/"+sourceinfo+"/"+id+".html");
     }
 </script>