123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- {{include "com/inc.html"}}
- <!-- Main Header -->
- {{include "com/header.html"}}
- <!-- Left side column. 权限菜单 -->
- {{include "com/menu.html"}}
- <style>
- /* 方法1:设置textarea合适的宽高 */
- #jsonTextarea {
- float: left;
- margin-right: 20px;
- width: 40%;
- height: 70vh;
- outline: none;
- padding: 5px;
- }
- /* 方法2:自定义高亮样式 */
- #jsonPre {
- float: left;
- width: 40%;
- height: 70vh;
- outline: 1px solid #ccc;
- padding: 5px;
- overflow: scroll;
- }
- </style>
- <div class="content-wrapper">
- <section class="content-header">
- <h1>
- {{if ne .T.bid ""}}
- 修复数据
- {{else}}
- 新增数据
- {{end}}
- </h1>
- <ol class="breadcrumb">
- <li><a href="#"><i class="fa fa-dashboard"></i> 爬虫数据维护</a></li>
- <li><a href="/lua/spiderwarn"> 异常数据管理</a></li>
- <li><a href="#">数据维护</a></li>
- </ol>
- </section>
- <!-- Main content -->
- <section class="content">
- <div class="nav-tabs-custom">
- <ul class="nav nav-tabs edit-step">
- {{if ne .T.bid ""}}
- <button class="btn btn-primary btn-sm" style="float: right;margin-top: 7px;margin-right: 10px" onclick="updateOrSave(1)"><i class="fa fa-fw fa-file-text fa-lg"></i>修复更新</button>
- <button class="btn btn-primary btn-sm" style="float: right;margin-top: 7px;margin-right: 10px" onclick="updateOrSave(2)"><i class="fa fa-fw fa-file-text fa-lg"></i>无需更新</button>
- {{else}}
- <button class="btn btn-primary btn-sm" style="float: right;margin-top: 7px;margin-right: 10px" onclick="updateOrSave(3)"><i class="fa fa-fw fa-file-text fa-lg"></i>修复发布</button>
- <button class="btn btn-primary btn-sm" style="float: right;margin-top: 7px;margin-right: 10px" onclick="updateOrSave(4)"><i class="fa fa-fw fa-file-text fa-lg"></i>直接发布</button>
- <button class="btn btn-primary btn-sm" style="float: right;margin-top: 7px;margin-right: 10px" onclick="updateOrSave(2)"><i class="fa fa-fw fa-file-text fa-lg"></i>无需发布</button>
- {{end}}
- </ul>
- <div class="box-body">
- <div class="form-group">
- <div class="col-sm-3">
- <input type="text" class="form-control" id="reasons" placeholder="请输入更新原因" required>
- </div>
- </div>
- </div>
- <form class="form-horizontal">
- <div class="box-body">
- <textarea id="jsonTextarea" style="width: 100%;height: 300px"></textarea>
- </div>
- <div class="box-body">
- <label class="col-sm-2 control-left"><span style="color:red;">* </span>请填写detail</label>
- <textarea id="jsonDetail" style="width: 100%;height: 300px;padding: 5px"></textarea>
- <label class="col-sm-2 control-left"><span style="color:red;">* </span>请填写contenthtml</label>
- <textarea id="jsonContentHtml" style="width: 100%;height: 300px;padding: 5px"></textarea>
- </div>
- <div class="box-body" id="summaryDiv">
- <label class="col-sm-2 control-left">请填写summary</label>
- <textarea id="summary" style="width: 100%;height: 200px;padding: 5px"></textarea>
- </div>
- </form>
- </div>
- </section>
- </div>
- {{include "com/footer.html"}}
- <script>
- menuActive("spiderwarn");
- var edit_data = {{.T.data}}
- var edit_contentHtml = {{.T.contenthtml}}
- var edit_detail = {{.T.detail}}
- var edit_summary = {{.T.summary}}
- var bid = {{.T.bid}}
- var edit_data_tmp = {{.T.data}}//记录汇总数据
- edit_data_tmp["detail"] = edit_detail
- edit_data_tmp["contenthtml"] = edit_contentHtml
- edit_data_tmp["summary"] = edit_summary
- function parse(str) {
- return JSON.stringify(str, null, "\t")
- }
- $('#jsonTextarea').val(parse(edit_data)); //其他属性
- $('#jsonDetail').val(edit_detail); //其他属性
- $('#jsonContentHtml').val(edit_contentHtml); //其他属性
- $('#summary').val(edit_summary);
- function updateOrSave(stype){
- /*
- * stype:
- * 1:修复更新
- * 2:无需更新
- * 3:修复发布
- * 4:直接发布
- * */
- if (stype == 1 || stype == 3){
- var reason=$("#reasons").val()
- if (reason=="") {
- showMsg("请填写更新数据原因")
- return;
- }
- }
- var data = JSON.parse($("#jsonTextarea").val())
- // 字段非空校验
- if (checkAddDict(data)) {
- let msg = "title,site,spidercode\nhref,channel,toptype\nsubtype,area\n非空必填信息,请补充完善信息"
- showMsg(msg)
- return;
- }
- var detail = $("#jsonDetail").val()
- var tmp_detail = ''+detail
- if (tmp_detail=="") {
- showMsg("请填写detail")
- return;
- }
- var tmp_content = $("#jsonContentHtml").val()
- if (tmp_content=="") {
- showMsg("请填写contenthtml")
- return;
- }
- // 判断除detail、contenthtml、summary外字段是否修改
- var modifyinfo = {}
- var update = {}
- // 修改
- for (var editDataKey in edit_data) {
- if (typeof edit_data[editDataKey] == "object") {
- if (JSON.stringify(data[editDataKey]) != JSON.stringify(edit_data[editDataKey])) {
- modifyinfo[editDataKey] = "剑鱼维护"
- update[editDataKey] = data[editDataKey]
- edit_data_tmp[editDataKey] = data[editDataKey]
- }
- }else {
- if (data[editDataKey] != edit_data[editDataKey]) {
- modifyinfo[editDataKey] = "剑鱼维护"
- update[editDataKey] = data[editDataKey]
- edit_data_tmp[editDataKey] = data[editDataKey]
- }
- }
- }
- //新增
- for (var dataKey in data) {
- if (edit_data[dataKey] == undefined) {
- modifyinfo[dataKey] = "剑鱼维护"
- update[dataKey] = data[dataKey]
- edit_data_tmp[dataKey] = data[dataKey]
- }
- }
- //判断detail、contenthtml、summary是否修改
- if (edit_detail != tmp_detail) {
- modifyinfo["detail"] = "剑鱼维护"
- update["detail"] = tmp_detail
- edit_data_tmp["detail"] = tmp_detail
- }
- if (edit_contentHtml.replace(/(\s|\t|\n)/g,'') != tmp_content.replace(/(\s|\t|\n)/g,'')) {
- modifyinfo["contenthtml"] = "剑鱼维护"
- update["contenthtml"] = tmp_content
- edit_data_tmp["contenthtml"] = tmp_content
- }
- var tmp_summary = $('#summary').val();
- if (edit_summary != tmp_summary) {
- modifyinfo["summary"] = "剑鱼维护"
- update["summary"] = tmp_summary
- edit_data_tmp["summary"] = tmp_summary
- }
- if (stype ==3 || stype ==4){//修复发布、直接发布 save
- update = edit_data_tmp
- }
- var str = ""
- if (Object.keys(update).length == 0 && stype != 2) {
- str = "没有修改任何字段信息!"
- showTip(str)
- return
- }else {
- if(Object.keys(modifyinfo).length == 0){
- str = "确定操作?"
- if (stype ==3){
- showTip("没有修改任何字段信息!")
- return
- }
- }else{
- if (stype ==2){
- showTip("请选择修复更新!")
- return
- }
- str = "确定修改以下字段信息?" + "<br>"
- for (const modifyinfoKey in modifyinfo) {
- str = str + modifyinfoKey + ","
- }
- }
- }
- // console.log("---",update)
- // console.log("---",modifyinfo)
- showConfirm(str, function() {
- $.ajax({
- url: "/lua/spiersave",
- type: 'POST',
- data: {
- "update": JSON.stringify(update),
- "modifyinfo": JSON.stringify(modifyinfo),
- "bid": bid,
- "id": {{.T.id}},
- "reasons": reason,
- "stype": stype
- },
- success: function (r) {
- if (r.success) {
- showMsg("保存成功",function (){
- window.location.href="/lua/spiderwarn"
- })
- } else {
- showTip(r.rep);
- }
- }
- })
- });
- }
- function checkAddDict(data) {
- if (data["title"]==""||data["site"]==""||data["spidercode"]==""||
- data["href"]==""||data["channel"]==""|| data["toptype"]==""||
- data["subtype"]==""|| data["area"]==""){
- return true
- }
- return false
- }
- </script>
|