Bladeren bron

Merge branch 'master' of http://192.168.3.207:10080/qmx/datatag

maxiaoshan 5 jaren geleden
bovenliggende
commit
9f2f2f3ac0

+ 0 - 0
src/models/o_rules.go → src/models/rules.go


+ 115 - 0
src/models/rules_es.go

@@ -0,0 +1,115 @@
+package models
+
+
+
+type QueryObjecct struct {
+	Query struct {
+		Bool struct {
+			Must    []interface{} `json:"must,omitempty"`
+			MustNot []interface{} `json:"must_not,omitempty"`
+			Should  []interface{} `json:"should,omitempty"`
+		} `json:"bool"`
+	} `json:"query"`
+	Size int `json:"-"`
+}
+
+//通用匹配 Must
+type MustObject struct {
+	//省市县
+	AreaCityDistrict *AreaCityDistrict `json:"term,omitempty"`
+	//一级分类、二级分类
+	ToptypeSubtype *ToptypeSubtype `json:"terms,omitempty"`
+	//时间范围
+	Publishtime *Publishtime `json:"range,omitempty"`
+	//字段是或否存在
+	ExistfieldsObject *ExistfieldsObject `json:"constant_score,omitempty"`
+}
+
+//时间范围
+type Publishtime struct {
+	//查询时间
+	PublishtimeObject struct {
+		Gte int `json:"gte"`
+		Lt  int `json:"lt"`
+	} `json:"publishtime,omitempty"`
+}
+
+//省市县
+type AreaCityDistrict struct {
+	Area     string `json:"area,omitempty"`
+	City     string `json:"city,omitempty"`
+	District string `json:"district,omitempty"`
+}
+
+//一级分类、二级分类
+type ToptypeSubtype struct {
+	Toptype []string `json:"toptype,omitempty"`
+	Subtype []string `json:"subtype,omitempty"`
+}
+
+//字段存在 存在放MustNot,字符串为空忽略
+type ExistfieldsObject struct {
+	Filter struct {
+		Missing struct {
+			Field []string `json:"field,omitempty"`
+		} `json:"missing,omitempty"`
+	} `json:"filter,omitempty"`
+}
+
+//全局附加词 should
+type GlobaladdkeyObject struct {
+	MatchPhrase *MatchPhrase `json:"match_phrase,omitempty"`
+}
+
+//全局排除词 must_not
+type GlobalnotkeyObject struct {
+	MatchPhrase *MatchPhrase `json:"match_phrase,omitempty"`
+}
+
+//匹配方式
+type MatchPhrase struct {
+	Title       string `json:"title,omitempty"`
+	Detail      string `json:"detail,omitempty"`
+	Purchasing  string `json:"purchasing,omitempty"`
+	Attachments string `json:"attachments,omitempty"`
+	Projectname string `json:"projectname,omitempty"`
+}
+
+//关键词 should
+type MatchkeyObject struct {
+	MatchPhrase *MatchPhrase `json:"match_phrase"`
+}
+
+//附件词 should
+type AddkeyObject struct {
+	MatchPhrase *MatchPhrase `json:"match_phrase"`
+}
+
+//排除词 must_not
+type NotkeyObject struct {
+	MatchPhrase *MatchPhrase `json:"match_phrase"`
+}
+
+//采购单位行业 should
+type BuyerclassObject struct {
+	Terms struct {
+		Buyerclass []string `json:"buyerclass,omitempty"`
+	} `json:"terms,omitempty"`
+}
+
+//公告行业二级 should
+type SubscopeclassObject struct {
+	Terms struct {
+		Subscopeclass []string `json:"s_subscopeclass,omitempty"`
+	} `json:"terms,omitempty"`
+}
+
+//xf should
+type NewObject struct {
+	Bool struct {
+		Must    []interface{} `json:"must,omitempty"`
+		MustNot []interface{} `json:"must_not,omitempty"`
+		Should  []interface{} `json:"should,omitempty"`
+	} `json:"bool,omitempty"`
+}
+

+ 41 - 0
src/models/tag.go

@@ -0,0 +1,41 @@
+package models
+
+import "gopkg.in/mgo.v2/bson"
+
+type Tag struct {
+	Id                 bson.ObjectId `bson:"_id"`
+	Scustomername      string        `json:"s_customername" bson:"s_customername"`
+	Stagname           string        `json:"s_tagname" bson:"s_tagname"`
+	Ssalesperson       string        `json:"s_salesperson" bson:"s_salesperson"`
+	Istarttime         int           `json:"i_starttime" bson:"i_starttime"`
+	Iendtime           int           `json:"i_endtime" bson:"i_endtime"`
+	Sarea              string        `json:"s_area" bson:"s_area"`
+	Scity              string        `json:"s_city" bson:"s_city"`
+	Sdistrict          string        `json:"s_district" bson:"s_district"`
+	Sglobaladdkey      string        `json:"s_globaladdkey" bson:"s_globaladdkey"`
+	Sglobaladdkeymatch string        `json:"s_globaladdkeymatch" bson:"s_globaladdkeymatch"`
+	Sglobalnotkey      string        `json:"s_globalnotkey" bson:"s_globalnotkey"`
+	Sglobalnotkeymatch string        `json:"s_globalnotkeymatch" bson:"s_globalnotkeymatch"`
+	Orules             []struct {
+		Smatchkey      string `json:"s_matchkey" bson:"s_matchkey"`
+		Snotkey        string `json:"s_notkey" bson:"s_notkey"`
+		Snotkeymatch   string `json:"s_notkeymatch" bson:"s_notkeymatch"`
+		Saddkey        string `json:"s_addkey" bson:"s_addkey"`
+		Saddkeymatch   string `json:"s_addkeymatch" bson:"s_addkeymatch"`
+		Stoptype       string `json:"s_toptype" bson:"s_toptype"`
+		Ssubtype       string `json:"s_subtype" bson:"s_subtype"`
+		Stopscopeclass string `json:"s_topscopeclass" bson:"s_topscopeclass"`
+		Ssubscopeclass string `json:"s_subscopeclass" bson:"s_subscopeclass"`
+		Sbuyerclass    string `json:"s_buyerclass" bson:"s_buyerclass"`
+	} `json:"o_rules" bson:"s_buyerclass"`
+	Sexistfields   string `json:"s_existfields" bson:"s_existfields"`
+	Imaxnum        int    `json:"i_maxnum" bson:"i_maxnum"`
+	Iextfieldstype int    `json:"i_extfieldstype" bson:"i_extfieldstype"`
+	Sesquery       string `json:"s_esquery" bson:"s_esquery"`
+	Iesquerytype   int    `json:"i_esquerytype" bson:"i_esquerytype"`
+	Sdataid        string `json:"s_dataid" bson:"s_dataid"`
+	Icreatetime    int    `json:"i_createtime" bson:"i_createtime"`
+	Iupdatetime    int    `json:"i_updatetime" bson:"i_updatetime"`
+	Screateuser    string `json:"s_createuser" bson:"s_createuser"`
+	Supdateuser    string `json:"s_updateuser" bson:"s_updateuser"`
+}

+ 31 - 15
src/service/import_rules_service.go

@@ -5,14 +5,13 @@ import (
 	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
 	"io/ioutil"
-	qu "qfw/util"
 	"util"
 )
 
 type ImportRulesService struct {
 	*xweb.Action
-	importfile xweb.Mapper `xweb:"/service/importfile"` //导入文件excel
-
+	importfile   xweb.Mapper `xweb:"/service/importfile"`   //导入文件excel
+	esgeneration xweb.Mapper `xweb:"/service/esgeneration"` //es generation
 }
 
 func (f *ImportRulesService) Importfile() {
@@ -39,23 +38,40 @@ func (f *ImportRulesService) Importfile() {
 
 //更新xlsx db
 func updateDbXf(id string, rdata map[string]interface{}) (rid string, err error) {
-	m := util.Mgo.GetMgoConn()
-	defer m.Close()
-	var err1 error
+	var err1 bool
 	if id == "" {
 		objectId := bson.NewObjectId()
-		rdata["_id"]=objectId
+		rdata["_id"] = objectId
 		id = objectId.Hex()
-		err1 = m.DB(qu.ObjToString(util.Sysconfig["dbname"])).C("tags").Insert(rdata)
-	} else if bson.IsObjectIdHex(id){
+		err1 = util.Mgo.SaveByOriID("tags",rdata)
+	} else if bson.IsObjectIdHex(id) {
 		tmpid := bson.ObjectIdHex(id)
-		err1 = m.DB(qu.ObjToString(util.Sysconfig["dbname"])).C("tags").Update(bson.M{"_id": tmpid}, bson.M{"$set": rdata})
-	}else {
-		return "",errors.New("id err")
+		err1 = util.Mgo.Update("tags",bson.M{"_id": tmpid}, bson.M{"$set": rdata},false,false)
+	} else {
+		return "", errors.New("id err")
 	}
-	if err1 != nil {
-		return "", err1
+	if !err1  {
+		return "", errors.New("Insert or Update err")
 	} else {
-		return id, err1
+		return id, nil
+	}
+}
+
+func (f *ImportRulesService) Esgeneration() {
+	if f.Method() == "POST" {
+		_id := f.GetString("_id")
+		tmp := make(map[string]string)
+		if bson.IsObjectIdHex(_id) {
+			data, _ := util.Mgo.FindOne("tags", `{"_id":"`+_id+`"}`)
+			if nil != data && len(*data) > 0 {
+				//esstr := util.Utiltags(*data)
+				//tmp["data"] = esstr
+			} else {
+				tmp["err"] = "id no found"
+			}
+		} else {
+			tmp["err"] = "id err"
+		}
+		f.ServeJson(tmp)
 	}
 }

+ 8 - 1
src/service/privateservice.go

@@ -23,6 +23,8 @@ type Service struct {
 	//rule
 	ruleList   xweb.Mapper `xweb:"/service/rule/list"`   //规则列表
 	ruleCreate xweb.Mapper `xweb:"/service/rule/create"` //规则新建
+
+	//importfile xweb.Mapper `xweb:"/service/importfile"` //导入文件excel
 }
 
 //规则列表
@@ -61,7 +63,12 @@ func (s *Service) RuleCreate() {
 	if s.Method() == "POST" {
 
 	} else {
-		s.Render("private/rule_create.html")
+		s.T["province"] = Province
+		s.T["city"] = ProvinceCitys
+		s.T["district"] = CityDistricts
+		s.T["topType"] = InfoTypeMap
+		s.T["subType"] = InfoTypeArr
+		s.Render("private/rule_create.html", &s.T)
 	}
 }
 

+ 17 - 0
src/util/utiltag.go

@@ -0,0 +1,17 @@
+package util
+
+import (
+	"encoding/json"
+	"models"
+)
+
+func Utiltags(tag map[string]interface{}) string {
+	
+	QueryObjecct := models.QueryObjecct{}
+
+
+
+
+	esbytes, _ := json.Marshal(QueryObjecct)
+	return string(esbytes)
+}

+ 84 - 0
src/web/templates/com/header.html

@@ -50,6 +50,90 @@
     </div>  
 </div>
 
+<!-- 导入ES语句模态框 -->
+<div class="modal fade" id="modal-imp-es" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+	<div class="modal-dialog">
+		<div class="modal-content">
+			<div class="modal-header">
+				<div class="modal-header">
+					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+					<div class="edit-form">
+						<div class="edit-info">
+							<span class="glyphicon glyphicon-import" aria-hidden="true"></span>
+							<span class="info">导入ES语句</span>
+						</div>
+						<div class="col-sm-12">
+							<textarea class="form-control" id="es_json" placeholder="请输入ES语句"></textarea>
+						</div>
+					</div>
+				</div>
+				<div class="modal-footer">
+					<input type="button" disabled="true" onclick="saveEs()" class="btn btn-primary saveBtn" value="保存">
+					<input type="button" onclick="cancelModel()" class="btn btn-default" style="margin-left: 24px" value="取消">
+				</div>
+			</div>
+		</div><!-- /.modal-content -->
+	</div><!-- /.modal -->
+</div>
+
+<!-- 选择匹配方式模态框 -->
+<div class="modal fade" id="modal-select-match" tabindex="-1" role="dialog" aria-hidden="true">
+	<div class="modal-dialog">
+		<div class="modal-content">
+			<div class="modal-header">
+				<div class="modal-header">
+					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+					<div class="edit-form">
+						<div class="edit-info">
+							<span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span>
+							<span class="info">匹配方式</span>
+						</div>
+						<div class="dit-form btn-group" data-toggle="buttons" id="radioMatch">
+							<label class="btn btn-default">
+								<input type="radio" name="matchBtn" value="1">全文匹配</label>
+							<label class="btn btn-default" style="margin-left: 10px">
+								<input type="radio" name="matchBtn" value="2">标题匹配</label>
+						</div>
+					</div>
+				</div>
+				<div class="modal-footer">
+					<input type="button" onclick="saveMatch()" class="btn btn-primary saveBtn" value="保存">
+					<input type="button" onclick="cancelModel()" class="btn btn-default" style="margin-left: 24px" value="取消">
+				</div>
+			</div>
+		</div>
+	</div><!-- /.modal -->
+</div>
+
+<!-- 选择采购单位行业模态框 -->
+<div class="modal fade" id="modal-select-buyer" tabindex="-1" role="dialog" aria-hidden="true">
+	<div class="modal-dialog">
+		<div class="modal-content">
+			<div class="modal-header">
+				<div class="modal-header">
+					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+					<div class="edit-form">
+						<div class="edit-info">
+							<span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span>
+							<span class="info">采购单位行业</span>
+						</div>
+						<div class="dit-form btn-group" data-toggle="buttons" id="radioMatch">
+							<label class="btn btn-default">
+								<input type="radio" name="matchBtn" value="1">全文匹配</label>
+							<label class="btn btn-default" style="margin-left: 10px">
+								<input type="radio" name="matchBtn" value="2">标题匹配</label>
+						</div>
+					</div>
+				</div>
+				<div class="modal-footer">
+					<input type="button" onclick="saveMatch()" class="btn btn-primary saveBtn" value="保存">
+					<input type="button" onclick="cancelModel()" class="btn btn-default" style="margin-left: 24px" value="取消">
+				</div>
+			</div>
+		</div>
+	</div><!-- /.modal -->
+</div>
+
 <div id="modal-topuserinfo" class="modal fade">
   	<div class="modal-dialog">
 	    <form id="topuserform" class="form-horizontal" role="form">

+ 289 - 415
src/web/templates/private/rule_create.html

@@ -38,325 +38,238 @@
                 <div class="tab-content">
                     <div class="tab-pane active" id="tab_1">
                         <form class="form-horizontal">
-                            <fieldset data-mode="guide">
-                                <div class="box box-primary">
-                                    <div class="box-header with-border">
-                                        <i class="fa fa-tag">
-                                        </i>
-                                        <h3 class="box-title">
-                                            通用条件
-                                        </h3>
-                                    </div>
-                                    <div class="box-body">
-                                        <div class="form-group">
-                                            <label for="spiderName" class="col-sm-2 control-label">
-                                                客户名称
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <input type="text" class="form-control" name="Base.SpiderName" id="spiderName"
-                                                       placeholder="客户名称" value="">
-                                            </div>
+                            <div class="box box-primary">
+                                <div class="box-header with-border">
+                                    <i class="fa fa-tag">
+                                    </i>
+                                    <h3 class="box-title">
+                                        通用条件
+                                    </h3>
+                                </div>
+                                <div class="box-body">
+                                    <div class="form-group">
+                                        <label for="spiderName" class="col-sm-2 control-label">
+                                            客户名称
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <input type="text" class="form-control" id="cusName" placeholder="客户名称" value="">
+                                        </div>
 
-                                            <label for="spiderCode" class="col-sm-2 control-label ">
-                                                规则名称
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <input type="text" class="form-control" name="Base.SpiderCode" id="spiderCode"
-                                                       placeholder="规则名称"  value="">
-                                            </div>
+                                        <label for="spiderCode" class="col-sm-2 control-label ">
+                                            规则名称
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <input type="text" class="form-control" id="tagName" placeholder="规则名称"  value="">
                                         </div>
-                                        <div class="form-group">
-                                            <label for="spiderChannel" class="col-sm-2 control-label">
-                                                销售经理
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <input type="text" class="form-control" name="Base.SpiderChannel" id="spiderChannel"
-                                                       placeholder="销售经理" value="">
-                                            </div>
+                                    </div>
+                                    <div class="form-group">
+                                        <label for="spiderChannel" class="col-sm-2 control-label">
+                                            销售经理
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <input type="text" class="form-control" id="saleName" placeholder="销售经理" value="">
                                         </div>
-                                        <hr>
-                                        <div class="form-group">
-                                            <label for="spiderPageEncoding" class="col-sm-2 control-label ">
-                                                省
-                                            </label>
-                                            <div class="col-sm-2">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        1.
-                                                    </option>
-                                                    <option value="2">
-                                                        2.
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
-                                            <label for="spiderPageEncoding" class="col-sm-1 control-label ">
-                                                市
-                                            </label>
-                                            <div class="col-sm-2">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        1.
-                                                    </option>
-                                                    <option value="2">
-                                                        2.
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
-                                            <label for="spiderPageEncoding" class="col-sm-1 control-label ">
-                                                区/县
-                                            </label>
-                                            <div class="col-sm-2">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        1.
-                                                    </option>
-                                                    <option value="2">
-                                                        2.
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
+                                    </div>
+                                    <hr>
+                                    <div class="form-group">
+                                        <label class="col-sm-2 control-label">省</label>
+                                        <div class="col-sm-2">
+                                            <select class="form-control" id="province" onchange="selectPro(this)">
+                                                <option>请选择省份</option>
+                                            </select>
+                                        </div>
+                                        <label class="col-sm-1 control-label">市</label>
+                                        <div class="col-sm-2">
+                                            <select class="form-control" id="city" onchange="selectCity(this)">
+                                                <option>请选择城市</option>
+                                            </select>
+                                        </div>
+                                        <label class="col-sm-1 control-label">区/县</label>
+                                        <div class="col-sm-2">
+                                            <select class="form-control" id="country" onchange="selectDis(this)">
+                                                <option >请选择县区</option>
+                                            </select>
+                                        </div>
+                                    </div>
+                                    <div class="form-group">
+                                        <label for="spiderPageEncoding" class="col-sm-2 control-label ">
+                                            一级公告类别
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <select class="form-control">
+                                                <option value="1">
+                                                    1.
+                                                </option>
+                                                <option value="2">
+                                                    2.
+                                                </option>
+                                            </select>
                                         </div>
-                                        <div class="form-group">
-                                            <label for="spiderPageEncoding" class="col-sm-2 control-label ">
-                                                一级公告类型
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        1.
-                                                    </option>
-                                                    <option value="2">
-                                                        2.
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
 
-                                            <label for="spiderPageEncoding" class="col-sm-2 control-label ">
-                                                一级公告类型
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        1.
-                                                    </option>
-                                                    <option value="2">
-                                                        2.
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
+                                        <label for="spiderPageEncoding" class="col-sm-2 control-label ">
+                                            二级公告类别
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <select class="form-control">
+                                                <option value="1">
+                                                    1.
+                                                </option>
+                                                <option value="2">
+                                                    2.
+                                                </option>
+                                            </select>
                                         </div>
-                                        <div class="form-group">
-                                            <label for="starttime" class="col-sm-2 control-label ">
-                                                开始时间
-                                            </label>
-                                            <div class="col-sm-3">
-                                                  <div class="wui-content">
-                                                      <div class="wui-area">
-                                                				<wui-date 
-                                                					format="yyyy-mm-dd hh:mm:ss" 
-                                                					placeholder="请选择或输入开始日期" 
-                                                					id="date4" 
-                                                					btns="{'ok':'确定','now':'此刻'}" 
-                                                					ng-model="date4"
-                                                				>
-                                                				</wui-date>
-                                                			</div>
-                                                  </div>
-                                               <!-- <input type="text" class="form-control" name="starttime" id="starttime" placeholder="开始时间" value="">-->
-                                            </div>
-                                            <label for="endtime" class="col-sm-2 control-label ">
-                                                结束时间
-                                            </label>
-                                            <div class="col-sm-3">
-                                                  <div class="wui-content">
-                                                      <div class="wui-area">
-                                                				<wui-date 
-                                                					format="yyyy-mm-dd hh:mm:ss" 
-                                                					placeholder="请选择或输入结束日期" 
-                                                					id="date4" 
-                                                					btns="{'ok':'确定','now':'此刻'}" 
-                                                					ng-model="date5"
-                                                				>
-                                                				</wui-date>
-                                                			</div>
-                                                  </div>
-                                               <!-- <input type="text" class="form-control" name="starttime" id="endtime" placeholder="结束时间" value="">-->
-                                            </div>
+                                    </div>
+                                    <div class="form-group">
+                                        <label for="starttime" class="col-sm-2 control-label ">
+                                            开始时间
+                                        </label>
+                                        <div class="col-sm-3">
+                                              <div class="wui-content">
+                                                  <div class="wui-area">
+                                                            <wui-date
+                                                                format="yyyy-mm-dd hh:mm:ss"
+                                                                placeholder="请选择或输入开始日期"
+                                                                id="date4"
+                                                                btns="{'ok':'确定','now':'此刻'}"
+                                                                ng-model="date4"
+                                                            >
+                                                            </wui-date>
+                                                        </div>
+                                              </div>
+                                           <!-- <input type="text" class="form-control" name="starttime" id="starttime" placeholder="开始时间" value="">-->
+                                        </div>
+                                        <label for="endtime" class="col-sm-2 control-label ">
+                                            结束时间
+                                        </label>
+                                        <div class="col-sm-3">
+                                              <div class="wui-content">
+                                                  <div class="wui-area">
+                                                            <wui-date
+                                                                format="yyyy-mm-dd hh:mm:ss"
+                                                                placeholder="请选择或输入结束日期"
+                                                                id="date4"
+                                                                btns="{'ok':'确定','now':'此刻'}"
+                                                                ng-model="date5"
+                                                            >
+                                                            </wui-date>
+                                                        </div>
+                                              </div>
+                                           <!-- <input type="text" class="form-control" name="starttime" id="endtime" placeholder="结束时间" value="">-->
                                         </div>
-                                        <div class="form-group">
-                                            <label for="spiderPageEncoding" class="col-sm-2 control-label ">
-                                                字段是或否存在
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        是
-                                                    </option>
-                                                    <option value="2">
-                                                        否
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
+                                    </div>
+                                    <div class="form-group">
+                                        <label for="spiderPageEncoding" class="col-sm-2 control-label ">
+                                            字段是或否存在
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <select class="form-control">
+                                                <option value="1">
+                                                    是
+                                                </option>
+                                                <option value="2">
+                                                    否
+                                                </option>
+                                            </select>
+                                        </div>
+                                    </div>
+                                    <hr>
+                                    <div class="form-group">
+                                        <label class="col-sm-2 control-label">
+                                            全局附加词
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <input type="text" class="form-control" placeholder="***" value="">
                                         </div>
-                                        <hr>
-                                        <div class="form-group">
-                                            <label for="spiderChannel" class="col-sm-2 control-label">
-                                                全局附加词
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <input type="text" class="form-control" name="Base.SpiderChannel" id="spiderChannel"
-                                                       placeholder="***" value="">
-                                            </div>
-                                            <label for="spiderPageEncoding" class="col-sm-2 control-label ">
-                                                匹配方式
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        是
-                                                    </option>
-                                                    <option value="2">
-                                                        否
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
+                                        <label class="col-sm-2 control-label ">
+                                            匹配方式
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <select class="form-control">
+                                                <option value="1">
+                                                    是
+                                                </option>
+                                                <option value="2">
+                                                    否
+                                                </option>
+                                            </select>
                                         </div>
-                                        <div class="form-group">
-                                            <label for="spiderChannel" class="col-sm-2 control-label">
-                                                全局排除词
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <input type="text" class="form-control" name="Base.SpiderChannel" id="spiderChannel"
-                                                       placeholder="***" value="">
-                                            </div>
-                                            <label for="spiderPageEncoding" class="col-sm-2 control-label ">
-                                                匹配方式
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        
-                                                    </option>
-                                                    <option value="2">
-                                                        
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
+                                    </div>
+                                    <div class="form-group">
+                                        <label for="spiderChannel" class="col-sm-2 control-label">
+                                            全局排除词
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <input type="text" class="form-control" placeholder="***" value="">
+                                        </div>
+                                        <label for="spiderPageEncoding" class="col-sm-2 control-label ">
+                                            匹配方式
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <select class="form-control">
+                                                <option value="1">
+                                                    是
+                                                </option>
+                                                <option value="2">
+                                                    否
+                                                </option>
+                                            </select>
+                                        </div>
+                                    </div>
+                                    <hr>
+                                    <div class="form-group">
+                                        <label for="spiderChannel" class="col-sm-2 control-label">
+                                            预览数据数量
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <input type="text" class="form-control" placeholder="*" value="">
                                         </div>
-                                        <hr>
-                                        <div class="form-group">
-                                            <label for="spiderChannel" class="col-sm-2 control-label">
-                                                预览数据数量
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <input type="text" class="form-control" name="Base.SpiderChannel" id="spiderChannel"
-                                                       placeholder="*" value="">
-                                            </div>
-                                            <label for="spiderPageEncoding" class="col-sm-2 control-label ">
-                                                高级字段包
-                                            </label>
-                                            <div class="col-sm-3">
-                                                <select name="Base.SpiderPageEncoding" id="spiderPageEncoding" class="form-control">
-                                                    <option value="1">
-                                                        是
-                                                    </option>
-                                                    <option value="2">
-                                                        否
-                                                    </option>
-                                                </select>
-                                                <script>
-                                                    var sel = "";
-                                                    if (sel == "1") {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 0;
-                                                    } else {
-                                                        $("#spiderPageEncoding").get(0).selectedIndex = 1;
-                                                    }
-                                                </script>
-                                            </div>
+                                        <label for="spiderPageEncoding" class="col-sm-2 control-label ">
+                                            高级字段包
+                                        </label>
+                                        <div class="col-sm-3">
+                                            <select class="form-control">
+                                                <option value="1">
+                                                    是
+                                                </option>
+                                                <option value="2">
+                                                    否
+                                                </option>
+                                            </select>
                                         </div>
                                     </div>
                                 </div>
-                            </fieldset>
+                            </div>
                         </form>
                     </div>
                     <div class="tab-pane" id="tab_2">
-                        <table id="keywords" class="table table-bordered table-striped">
-                            <thead><tr>
-                                <th style="text-align: center"><input type="checkbox" onclick="selectrow(this)"/></th>
-                                <th style="text-align: center">编号{{.T.ischeck}}</th>
-                                <th style="text-align: center">关键词</th>
-                                <th style="text-align: center">附加词</th>
-                                <th style="text-align: center">匹配方式</th>
-                                <th style="text-align: center">排除词</th>
-                                <th style="text-align: center">匹配方式</th>
-                                <th style="text-align: center">采购单位行业</th>
-                                <th style="text-align: center">公告行业</th>
-                            </tr></thead>
-                        </table>
+                        <div class="box box-primary">
+                            <div class="box-header with-border">
+                                <i class="fa fa-bookmark">
+                                </i>
+                                <h3 class="box-title">
+                                    关键词
+                                </h3>
+                                <div style="float: right">
+                                    <a class="btn btn-default btn-sm" id="batchAssign" onclick="selectMatch()">匹配方式</a>
+                                    <a class="btn btn-default btn-sm" id="batchClose" onclick="selectBuyer()">采购单位行业</a>
+                                    <a class="btn btn-default btn-sm" id="batchClose" onclick="selectInfo()">公告行业</a>
+                                </div>
+                            </div>
+                            <table id="keywords" class="table table-bordered">
+                                <thead><tr>
+                                    <th style="text-align: center"><input type="checkbox" onclick="selectrow(this)"/></th>
+                                    <th style="text-align: center">编号{{.T.ischeck}}</th>
+                                    <th style="text-align: center">关键词</th>
+                                    <th style="text-align: center">附加词</th>
+                                    <th style="text-align: center">匹配方式</th>
+                                    <th style="text-align: center">排除词</th>
+                                    <th style="text-align: center">匹配方式</th>
+                                    <th style="text-align: center">采购单位行业</th>
+                                    <th style="text-align: center">公告行业</th>
+                                </tr></thead>
+                            </table>
+                        </div>
                     </div>
                     <div class="tab-pane" id="tab_3">
                         <table id="history" class="table table-bordered table-striped">
@@ -374,121 +287,82 @@
         </div>
     </section>
 </div>
-<!-- 导入ES语句模态框 -->
-<div class="modal fade" id="modal-imp-es" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
-    <div class="modal-dialog">
-        <div class="modal-content">
-            <div class="modal-header">
-                <div class="modal-header">
-                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
-                    <div class="edit-form">
-                        <div class="edit-info">
-                            <span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>
-                            <span class="info">导入ES语句</span>
-                        </div>
-                        <div class="col-sm-12">
-                            <textarea class="form-control" id="es_json" placeholder="请输入ES语句"></textarea>
-                        </div>
-                        <div class="col-sm-offset-2 col-sm-10" style="margin-top: 14px">
-                            <input type="button" disabled="true" onclick="saveEs()" class="btn btn-primary saveBtn" value="保存">
-                            <input type="button" onclick="cancelES()" class="btn btn-default" style="margin-left: 24px" value="取消">
-                        </div>
-                    </div>
-                </div>
-            </div>
-        </div><!-- /.modal-content -->
-    </div><!-- /.modal -->
-</div>
+
 {{include "com/dialog.html"}}
 {{include "com/footer.html"}}
 <script>
-  var app = angular.module('app',["wui.date"]);
-  console.log(app)
-  $(function () {
-      ttable=$('#rule').DataTable({
-          "paging"      : false,
-          "lengthChange": false,
-          "searching"   : false,
-          "ordering"    : false,
-          "info"        : true,
-          "autoWidth"   : false,
-          "ajax": {
-              "url": "/service/rule/reload",
-              "type": "post",
-              "data":{}
-          },
-          "language": {
-              "url": "/dist/js/dataTables.chinese.lang"
-          },
-          "columnDefs": [
-              { "orderable": false, "targets": [0,9] },
-          ],
-          "columns": [
-              { "data": "_id",render:function(val,a,row){
-                      return row.num
-                  }},
-              { "data": "s_taskname"},
-              { "data": "l_comeintime",render:function(val){
-                      var dt=new Date()
-                      dt.setTime(parseInt(val)*1000)
-                      return dt.format("yyyy-MM-dd hh:mm:ss")
-                  }},
-              { "data": "s_username"},
-              { "data": "s_descript","width":"23%"},
-              { "data": ""},
-              { "data": ""},
-              { "data": ""}
-          ]
-      });
-      ttable=$('#history').DataTable({
-          "paging"      : false,
-          "lengthChange": false,
-          "searching"   : false,
-          "ordering"    : false,
-          "info"        : true,
-          "autoWidth"   : false,
-          "ajax": {
-              "url": "",
-              "type": "post",
-              "data":{}
-          },
-          "language": {
-              "url": "/dist/js/dataTables.chinese.lang"
-          },
-          "columns": [
-              { "data": "_id",render:function(val,a,row){
-                      return row.num
-                  }},
-              { "data": "s_taskname"},
-              { "data": "l_comeintime",render:function(val){
-                      var dt=new Date()
-                      dt.setTime(parseInt(val)*1000)
-                      return dt.format("yyyy-MM-dd hh:mm:ss")
-                  }},
-              { "data": "s_username"},
-              { "data": "s_descript","width":"23%"}
-          ]
-      });
-  })
-  //导入ES
-  function importEs() {
-      $("#modal-imp-es").modal("show");
-  }
-  function cancelES(){
-      $("#modal-imp-es").modal("hide");
-  }
-  function saveEs(){
-      const $esStr = $("#es_json").val();
-      try {
-          if (typeof JSON.parse($esStr) == "object") {
-              console.log("json格式正确")
-          }
-      } catch(e) {
-          console.log(e)
-      }
-      console.log("json格式不正确")
-  }
-  
+    menuActive("/service/rule/list");
+    var app = angular.module('app',["wui.date"]);
+    let provice = {{.T.provice}}}
+    console.dir(provice);
+    $(function () {
+        $('#keywords').DataTable({
+            "paging"      : false,
+            "lengthChange": false,
+            "searching"   : false,
+            "ordering"    : false,
+            "info"        : true,
+            "autoWidth"   : false,
+            "language": {
+                "url": "/dist/js/dataTables.chinese.lang"
+            }
+        });
+        $('#history').DataTable({
+            "paging"      : false,
+            "lengthChange": false,
+            "searching"   : false,
+            "ordering"    : false,
+            "info"        : true,
+            "autoWidth"   : false,
+            "language": {
+                "url": "/dist/js/dataTables.chinese.lang"
+            }
+        });
+    });
+    function importEs() {
+        $("#modal-imp-es").modal("show");
+    }
+    function cancelModel(){
+        $("#modal-imp-es").modal("hide");
+        $("#modal-select-match").modal("hide");
+    }
+    function saveEs(){
+        const $esStr = $("#es_json").val();
+        try {
+            if (typeof JSON.parse($esStr) == "object") {
+                console.log("json格式正确")
+            }
+        } catch(e) {
+            console.log(e)
+        }
+        console.log("json格式不正确")
+    }
+
+    /**
+     * 自动加载省份
+     */
+    (function showProv() {
+        var len = provice.length;
+        for (var i = 0; i < len; i++) {
+            var provOpt = document.createElement('option');
+            provOpt.innerText = provice[i]['name'];
+            provOpt.value = i;
+            prov.appendChild(provOpt);
+        }
+    })();
+    function selectPro(obj) {
+
+    }
+    function selectMatch() {
+        $("#modal-select-match").modal("show");
+    }
+    function saveMatch() {
+
+    }
+    function selectBuyer() {
+        $("#modal-select-buyer").modal("show");
+    }
+
   //导入规则
   function importRule(){
 		var f=$("#fileframe").contents().find("input");

+ 64 - 33
src/web/templates/private/rule_list.html

@@ -17,18 +17,27 @@
     <section class="content">
         <div class="row">
             <div class="col-xs-12">
+
                 <div class="box">
                     <div class="box-body">
+                        <div style="padding-bottom:3px;float: right">
+                            <div class="col-lg-9">
+                                <input type="text" id="" name="" value="" class="form-control" placeholder="请输入搜索内容">
+                            </div>
+                            <div class="col-sm-1" style="padding-left:0px;padding-right:0px;">
+                                <button class="btn btn-default" onclick="search(0)">搜索</button>
+                            </div>
+                        </div>
                         <table id="dataTable" class="table table-bordered table-hover">
                             <thead>
                             <tr>
-                                <th>编号</th>
-                                <th>客户姓名</th>
-                                <th>规则名称</th>
-                                <th>销售经理</th>
-                                <th>创建时间</th>
-                                <th>修改时间</th>
-                                <th>操作</th>
+                                <th style="text-align: center">编号</th>
+                                <th style="text-align: center">客户姓名</th>
+                                <th style="text-align: center">规则名称</th>
+                                <th style="text-align: center">销售经理</th>
+                                <th style="text-align: center">创建时间</th>
+                                <th style="text-align: center">修改时间</th>
+                                <th style="text-align: center">操作</th>
                             </tr>
                             </thead>
                         </table>
@@ -45,45 +54,67 @@
 <script>
     menuActive("/service/rule/list")
     $(function () {
-        ttable=$('#dataTable').DataTable({
-            "paging"      : false,
+        const myTable = $('#dataTable').DataTable({
+            "paging": true,
             "lengthChange": false,
-            "searching"   : false,
-            "ordering"    : false,
-            "info"        : true,
-            "autoWidth"   : false,
+            "searching": false,
+            "ordering": false,
+            "info": true,
+            "autoWidth": true,
             "ajax": {
                 "url": "/service/rule/list",
                 "type": "post",
-                "data":{}
+                "data": {}
             },
             "language": {
                 "url": "/dist/js/dataTables.chinese.lang"
             },
+            "fnDrawCallback": function () {
+                $("ul.pagination").prepend("&nbsp;&nbsp;&nbsp;转到第 <input type='text' id='changePage'   style='width:20px;'> 页    <a type='text' href='javascript:void(0);' id='dataTable-btn' style='text-align:center'>GO</a>");
+                $('#dataTable-btn').click(function (e) {
+                    var redirectpage = 0
+                    if ($("#changePage").val() && $("#changePage").val() > 0) {
+                        var redirectpage = $("#changePage").val() - 1;
+                    }
+                    myTable.page(redirectpage).draw(false);
+                });
+                this.api().column(0).nodes().each(function(cell, i) {
+                    cell.innerHTML = i + 1;
+                });
+            },
             "columns": [
-                { "data": "_id",render:function(val,a,row){
-                        return row.num
-                    }},
-                { "data": "s_taskname"},
-                { "data": "l_comeintime",render:function(val){
-                        var dt=new Date()
-                        dt.setTime(parseInt(val)*1000)
+                {"data": null},
+                {"data": "s_customername"},
+                {"data": "s_tagname"},
+                {"data": "s_salesperson"},
+                {
+                    "data": "i_createtime", render: function (val) {
+                        var dt = new Date()
+                        dt.setTime(parseInt(val) * 1000)
                         return dt.format("yyyy-MM-dd hh:mm:ss")
-                    }},
-                { "data": "s_username"},
-                { "data": "s_descript","width":"23%"},
-                { "data":"_id","width":"25%",render:function(val,a,row,pos){
-                        tmp = '<div>'+
-                            '<a class="btn btn-sm btn-primary opr" opr="edit" row="'+pos.row+'" >编辑</a> '+
-                            '<a class="btn btn-sm btn-success opr" opr="start" onclick="start(\''+row._id+'\')">启动</a> '+
-                            '<a class="btn btn-sm btn-info opr" opr="stop" onclick="stop(\''+row._id+'\')">停止</a> '+
-                            '<a class="btn btn-sm btn-danger opr" opr="del" onclick="del(\''+val+'\')">删除</a>'+
+                    }
+                },
+                {
+                    "data": "i_updatetime", render: function (val) {
+                        var dt = new Date()
+                        dt.setTime(parseInt(val) * 1000)
+                        return dt.format("yyyy-MM-dd hh:mm:ss")
+                    }
+                },
+                {
+                    "data": "_id", "width": "25%", render: function (val, a, row, pos) {
+                        tmp = '<div>' +
+                            '<a class="btn btn-sm btn-primary opr" opr="edit" row="' + pos.row + '" >编辑</a> ' +
+                            '<a class="btn btn-sm btn-danger opr" opr="start" onclick="start(\'' + row._id + '\')">删除</a> ' +
+                            '<a class="btn btn-sm btn-info opr" opr="stop" onclick="stop(\'' + row._id + '\')">预览</a> ' +
+                            '<a class="btn btn-sm btn-success opr" opr="del" onclick="del(\'' + val + '\')">导出</a>' +
                             '</div>';
-                        return  tmp
-                    }}
+                        return tmp
+                    }
+                }
             ]
         });
-    })
+    });
     function start(_id){
         showConfirm("确定启动?", function() {
             $.ajax({