list.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>信息抽查</title>
  6. <link href="/css/bootstrap.min.css" rel="stylesheet">
  7. <link href="/css/page.css" rel="stylesheet">
  8. <script src="/js/jquery.js"></script>
  9. <script src="/js/bootstrap.min.js"></script>
  10. <script src="/js/util.js"></script>
  11. <script src="/js/vue.min.js"></script>
  12. <script src="/js/index.js"></script>
  13. <script src="/js/jquery-page.js"></script>
  14. <link rel="stylesheet" href="/css/index.css">
  15. <style>
  16. .form-horizontal {
  17. min-height: 40px;
  18. margin-top: 20px;
  19. }
  20. .row-box label {
  21. white-space: nowrap;
  22. }
  23. .row-box select {
  24. width: 100px;
  25. }
  26. .row-box input {
  27. margin-left: 15px;
  28. width: 5em;
  29. }
  30. .row-box + .row-box {
  31. margin-left: 15px;
  32. }
  33. .row-box + button {
  34. margin-left: 15px;
  35. }
  36. .row-box {
  37. display: flex;
  38. flex-direction: row;
  39. align-items: center;
  40. }
  41. .checkbox-inline{
  42. margin-left: -11px;
  43. }
  44. .import-primary{
  45. margin-left: 9px;
  46. }
  47. .r-c-box {
  48. display: flex;
  49. flex-direction: row;
  50. align-items: center;
  51. }
  52. </style>
  53. </head>
  54. <body>
  55. <!-- 模态框(Modal) -->
  56. <div class="modal fade" id="editeuser" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  57. <div class="modal-dialog">
  58. <div class="modal-content">
  59. <div class="modal-header">
  60. <div class="modal-header">
  61. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  62. <div class="edit-form">
  63. <div class="edit-info">
  64. <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
  65. <span class="info">信息修改<span>
  66. </div>
  67. <form class="form-horizontal" role="form">
  68. <div class="form-group">
  69. <label for="username" class="col-sm-2 control-label">用户名:</label>
  70. <div class="col-sm-10">
  71. <input type="text" readonly="readonly" value='{{session "username"}}' class="form-control" id="username">
  72. </div>
  73. </div>
  74. <div class="form-group password">
  75. <label for="password" class="col-sm-2 control-label">密码:</label>
  76. <div class="col-sm-10">
  77. <input type="text" class="form-control" id="password" value='{{session "password"}}'>
  78. </div>
  79. <span class="passwordEdit hide check">密码不能为空</span>
  80. </div>
  81. <div class="form-group">
  82. <div class="col-sm-offset-2 col-sm-10">
  83. <input type="button" onclick="saveuser()" class="btn btn-primary" value="保存">
  84. <input type="button" onclick="cancel()" class="btn btn-default" value="取消">
  85. </div>
  86. </div>
  87. </form>
  88. </div>
  89. </div>
  90. </div>
  91. </div><!-- /.modal-content -->
  92. </div><!-- /.modal -->
  93. </div>
  94. <div>
  95. <div class="modal fade" id="loadingModal" backdrop="static" keyboard="false">
  96. <div style="width: 200px;height:100px; z-index: 20000; position: absolute; text-align: center; left: 50%; top: 50%;margin-left:-100px;margin-top:-10px">
  97. <div class="progress progress-striped active"
  98. style="margin-bottom: 0;height:50px; text-align:center;line-height: 50px;font-size:large;">
  99. 数据加载中,请稍候......    
  100. </div>
  101. </div>
  102. </div>
  103. <div style="background-color: #3c8dbc;text-align: right;">
  104. <div style="text-align: right;text-align: right;" class="glyphicon glyphicon-user"></div>
  105. <h3 onclick="editeuser()" style=" cursor:pointer;color: #FFFFFF;margin-top: 10px;margin-right: 15px;display: -webkit-inline-box;">{{session "loginuser"}}</h3>
  106. </div>
  107. <div class="col-md-12" style="border-right: 1px double #EEEEEE;">
  108. <div style="padding:10px 0px 0px 0px">
  109. <form action="/center/list" class="form-horizontal" role="form">
  110. <div style="display: none">
  111. <input type="input" name="pagenum" id="pagenum" class="form-control" value="{{.T.pagenum}}"/>
  112. </div>
  113. <div style="display: none">
  114. <input type="input" name="labeler" id="labername" class="form-control" value=""/>
  115. </div>
  116. <div class="col-md-3">
  117. <input type="input" name="spidercode" class="form-control" value="{{.T.spidercode}}"
  118. placeholder="请输入爬虫代码"/>
  119. </div>
  120. <div class="col-md-1" style="padding-left: 0;">
  121. <input type="input" name="db" disabled class="form-control" value="{{.T.dbname}}"
  122. placeholder="请输入库名"/>
  123. </div>
  124. <div class="col-md-1" style="padding-left: 0">
  125. <input type="input" name="coll" id="fromtable" class="form-control" value='{{if ne .T.coll ""}}{{.T.coll}}{{else}}{{.T.fromtable}}{{end}}' placeholder="请输入表名"/>
  126. </div>
  127. <div class="col-md-7 row-box" style="padding-left: 0">
  128. <div class=" row-box" style="padding-left: 0">
  129. <label class="checkbox-inline">类型:</label>
  130. <select name="type" id="topsubtype" class="form-control">
  131. <option value="-1">请选择</option>
  132. <!--<option value="trailer" {{if eq .T.type "notice"}}selected{{end}}>预告</option>
  133. <option value="tender" {{if eq .T.type "tender"}}selected{{end}}>招标</option>
  134. <option value="bid" {{if eq .T.type "bid"}}selected{{end}}>结果</option>-->
  135. </select>
  136. </div>
  137. <div class="row-box">
  138. <label class="checkbox-inline">字段:</label>
  139. <select name="field" id="field" class="form-control">
  140. <option value="-1">请选择</option>
  141. <!--<option value="trailer" {{if eq .T.type "notice"}}selected{{end}}>预告</option>
  142. <option value="tender" {{if eq .T.type "tender"}}selected{{end}}>招标</option>
  143. <option value="bid" {{if eq .T.type "bid"}}selected{{end}}>结果</option> -->
  144. </select>
  145. <input type="input" name="minval" id="minval" style="display:none" class="form-control"
  146. value="{{.T.min}}" placeholder="最小值"/>
  147. <input type="input" name="maxval" id="maxval" style="display:none" class="form-control"
  148. value="{{.T.max}}" placeholder="最大值"/>
  149. <div id="boexists" style="margin-left: -29px;">
  150. <input id="hasno" type="checkbox" name="hasno" onclick="checkboxOnclick(this)" value={{if .T.hasno}} true {{else}} false {{end}}/>
  151. <label style="margin-left: -28px;">不存在</label>
  152. </div>
  153. <div id="datanotag" style="margin-left: -29px;">
  154. <input id="notag" type="checkbox" name="notag" onclick="checktagboxOnclick(this)" value={{if .T.notag}} true {{else}} false {{end}}/>
  155. <label style="margin-left: -28px;">未标注</label>
  156. </div>
  157. </div>
  158. <!--<div class="col-md-2">
  159. <label class="checkbox-inline">
  160. <input type="checkbox" name="ispackage" value="1">分包数据
  161. </label>
  162. </div>-->
  163. <button type="submit" style="display: none" class="btn btn-primary" id="submitForm"></button>
  164. <div class="btn btn-primary" style="margin-left: 15px" onclick="alertsync()">查看</div>
  165. <div id="markedinit" class="btn btn-primary" style="margin-left: 15px;display:none;" onclick="markedinit()">初始化marked</div>
  166. <!-- <div class="btn btn-primary" style="margin-left: 15px" onclick="syncmarked()">同步</div>-->
  167. </div>
  168. </form>
  169. </div>
  170. <div class="col-md-12">
  171. <div class="form-group col-md-5" style="padding-left: 0">
  172. <textarea class="form-control" name="descript" id="es"></textarea>
  173. </div>
  174. <div class="form-group col-md-6" style="margin-top: 10px;margin-left: -14px;">
  175. <div class="col-md-3" style="padding-left: 0">
  176. <input type="input" id="importcoll" class="form-control" value="" placeholder="库表名"/>
  177. </div>
  178. <button class="btn btn-primary import-primary" onclick='getescount()'>
  179. Es导入数据
  180. </button>
  181. <button class="btn btn-primary import-primary" onclick='importbyexcel()'>
  182. 导入Excel
  183. </button>
  184. </div>
  185. <iframe srcdoc="<form id='uploadform' method='post' enctype='multipart/form-data' action='/center/importbyexcel'><input type='file' name='xlsx' /><input type='input' id='excelcoll' name='excelcoll' /></form>"
  186. height=0 scrolling=no class="hide" id="fileframe">
  187. </iframe>
  188. </div>
  189. <hr style="border:1 double" width="100%">
  190. <div class="col-md-12">
  191. <div class="form-group col-md-3" style="margin-left: -15px;">
  192. <h4>
  193. 已验/总数:{{.T.checkednum}}/{{.T.allnum}}
  194. </h4>
  195. </div>
  196. <div class="r-c-box">
  197. <button class="btn btn-primary" style="margin-left: 17px;" onclick="updateinfo()">刷新</button>
  198. {{if ge .T.role 2}}
  199. <div class="r-c-box">
  200. <label class="checkbox-inline" style="word-break: keep-all; margin: 0 20px;">人员筛选:</label>
  201. <select name="type" id="labeler" onchange="changelabeler(this.value)" class="form-control">
  202. <option value="-1">请选择</option>
  203. </select>
  204. </div>
  205. {{end}}
  206. <button class="btn btn-primary" style="margin-left: 50px;" onclick="skipReview()">数据质检</button>
  207. </div>
  208. </div>
  209. <hr style="border:1 double" width="100%">
  210. <div id="spcontent" class="column">
  211. {{range $k,$v:=.T.list}}
  212. <div>
  213. <span style="font-size:18px"><script>document.write({{ $v }}["num"])</script>:</span>&nbsp;
  214. <div onclick="getdetail({{$v._id}})" style="display: inline-block;cursor:pointer;font-size:18px;color:{{if $v.checked}}green{{else}}#428bca{{end}}">{{$v.title}}</div>
  215. </div>
  216. {{end}}
  217. </div>
  218. </div>
  219. <div style="text-align: center;justify-content: flex-end;padding-right: 100px;" class="r-c-box">
  220. <div id="pager" class="pager clearfix"></div>
  221. <div class="pager clearfix r-c-box" style="margin-left: 16px;">
  222. 跳转到
  223. <input type="text" id="changePage" style="width:30px;">
  224. <a type="text" href="javascript:void(0);" onclick="gopage()" style="text-align:center;float: right;">GO</a>
  225. </div>
  226. </div>
  227. </div>
  228. </body>
  229. <script>
  230. var vueApp = new Vue()
  231. //history.replaceState('', {},location.href.replace(location.search, '') )
  232. $(function(){
  233. if({{.T.coll}} == "marked"){
  234. $("#markedinit").css("display","");
  235. }
  236. //不存在标记
  237. if( {{.T.hasno}} ){
  238. $("#hasno").attr("checked",true);
  239. }
  240. if( {{.T.notag}} ){
  241. $("#notag").attr("checked",true);
  242. }
  243. //数据类型
  244. for(i in {{.T.topsubtype}}){
  245. var selected = ""
  246. if({{.T.type}} == {{.T.topsubtype}}[i]){
  247. selected = "selected"
  248. }
  249. $("#topsubtype").append("<option "+selected+" value='"+{{.T.topsubtype}}[i]+"'>"+{{.T.topsubtype}}[i]+"</option>")
  250. }
  251. //标注人员筛选
  252. for(i in {{.T.labelers}}){
  253. var selected = ""
  254. console.log({{.T.labeler}},"----",{{.T.labelers}}[i])
  255. if({{.T.labeler}} == {{.T.labelers}}[i]){
  256. selected = "selected"
  257. }
  258. $("#labeler").append("<option "+selected+" value='"+{{.T.labelers}}[i]+"'>"+{{.T.labelers}}[i]+"</option>")
  259. }
  260. //字段选择
  261. var fk = "";
  262. for(i in {{.T.allfield}}){
  263. var selected = ""
  264. for(key in {{.T.allfield}}[i]){
  265. if({{.T.field}} == key){
  266. selected = "selected"
  267. fk = key
  268. }
  269. $("#field").append("<option " +selected+" value='"+key+"'>"+{{.T.allfield}}[i][key]+"</option>")
  270. }
  271. }
  272. if(fk=="budget"||fk=="bidamount"){
  273. $("#maxval").css("display","");
  274. $("#minval").css("display","");
  275. $("#boexists").css("display","none");
  276. }
  277. $("#field").change(function(){
  278. $("#hasno").attr("checked",false);
  279. $("#notag").attr("checked",false);
  280. if($(this).val()=="bidamount"||$(this).val()=="budget"){
  281. $("#minval").css("display","");
  282. $("#maxval").css("display","");
  283. $("#boexists").css("display","none");
  284. }else{
  285. $("#minval").css("display","none");
  286. $("#maxval").css("display","none");
  287. $("#boexists").css("display","");
  288. }
  289. });
  290. $("#fromtable").on('input propertychange', function(){
  291. var tmpcoll = $("#fromtable").val();
  292. if(tmpcoll == "marked"){
  293. $("#markedinit").css("display","");
  294. }else{
  295. $("#markedinit").css("display","none");
  296. }
  297. });
  298. })
  299. //是否选择不存在
  300. function checkboxOnclick(checkbox){
  301. if ( checkbox.checked == true){
  302. $("#hasno").attr("value",true);
  303. }else{
  304. $("#hasno").attr("value",false);
  305. }
  306. }
  307. //是否选择未标注
  308. function checktagboxOnclick(checkbox){
  309. if ( checkbox.checked == true){
  310. $("#notag").attr("value",true);
  311. }else{
  312. $("#notag").attr("value",false);
  313. }
  314. }
  315. function getdetail(id) {
  316. $.ajax({
  317. url: "/center/checkid",
  318. type: "post",
  319. data: {"id":id},
  320. async: false,
  321. success: function (r) {
  322. if(r && r.msg == ""){
  323. if(r.exists){//标注完成
  324. window.open("/center/finishcheck");
  325. }else if(!r.exists && r.id != id){
  326. /*
  327. vueApp.$message({
  328. message: '此条数据正在标注,请选择未标注数据',
  329. type: 'danger',
  330. duration: 2000,
  331. offset: 300
  332. });
  333. */
  334. vueApp.$confirm('此条数据正在标注,是否直接跳转到未标注数据?', {
  335. confirmButtonText: '确认',
  336. cancelButtonText: '取消',
  337. type: 'warning'
  338. }).then(() => {
  339. window.open("/center/detail/"+r.id+".html");
  340. }).catch(() => {
  341. });
  342. }else if (!r.exists && r.id == id){
  343. window.open("/center/detail/"+r.id+".html");
  344. }else{
  345. alert("标注出错!")
  346. }
  347. }else{
  348. alert("标注出错!"+r.msg)
  349. }
  350. }
  351. })
  352. }
  353. function getescount(){
  354. var importcoll = $("#importcoll").val();
  355. if(importcoll == ""){
  356. alert("请输入导入表!")
  357. return
  358. }
  359. var estext = $("#es").val()
  360. if(estext==""){
  361. alert("请输入es查询语句!")
  362. return
  363. }
  364. $.ajax({
  365. url:"/center/getescount",
  366. method:"post",
  367. data: {"estext":estext},
  368. success:function(res){
  369. importbyes(res.count,res.msg,estext,importcoll)
  370. }
  371. });
  372. }
  373. function importbyes(count,msg,text,coll){
  374. vueApp.$confirm('es查询数据量:'+count, msg, {
  375. confirmButtonText: '确认导入',
  376. cancelButtonText: '取消',
  377. type: 'warning'
  378. }).then(() => {
  379. importes(text,coll)
  380. }).catch(() => {
  381. });
  382. }
  383. //es导入
  384. function importes(estext,coll){
  385. showLoading()
  386. $.ajax({
  387. url: "/center/importbyes",
  388. method: "post",
  389. data: {"estext": estext, "coll": coll},
  390. success: function (r) {
  391. hideLoading()
  392. if(r){
  393. alert(r.msg)
  394. }else{
  395. alert("导入失败")
  396. }
  397. // if (res && res.success) {
  398. // alert("数据导入成功")
  399. // //setTimeout(alert("数据导入成功"),200)
  400. // } else {
  401. // alert(res.msg)
  402. // //setTimeout(alert(res.msg),200)
  403. // }
  404. }
  405. });
  406. }
  407. //excel导入
  408. function importbyexcel(){
  409. var importcoll = $("#importcoll").val();
  410. if(importcoll == ""){
  411. alert("请输入导入表!")
  412. return
  413. }
  414. $("#excelcoll").val(importcoll);
  415. $("#fileframe").contents().find("#excelcoll").val(importcoll);
  416. var f=$("#fileframe").contents().find("input");
  417. f.get(0).click();
  418. f.change(function() {
  419. var val = $(this).val() ? $(this).val() : "";
  420. if (val.indexOf(".xlsx") < 0) {
  421. showMsg("文件格式非法",
  422. function() {});
  423. } else {
  424. $(this).parent().submit();
  425. showLoading()
  426. var ret = setInterval(function () {
  427. var f = $(window.frames[0].document).find("form");
  428. if (f.length == 0) {
  429. hideLoading()
  430. var b = $(window.frames[0].document).find("body").text();
  431. if (b) {
  432. var r = JSON.parse(b)
  433. if(r){
  434. console.log(r.msg)
  435. alert(r.msg)
  436. }else{
  437. alert("导入失败")
  438. }
  439. // if (r && r.success) {
  440. // alert("数据导入成功")
  441. // } else {
  442. // alert(r.msg)
  443. // }
  444. }
  445. $(window.frames[0].document).find("body").append("<form id='uploadform' method='post' enctype='multipart/form-data' action='/center/importbyexcel'><input type='file' name='xlsx' /><input type='input' id='excelcoll' name='excelcoll' /></form>");
  446. }
  447. },
  448. 500)
  449. }
  450. })
  451. }
  452. //展示loading框
  453. showLoading = function (){
  454. $('#loadingModal').modal({backdrop: 'static', keyboard: false});
  455. }
  456. //隐藏掉loading框
  457. hideLoading = function (){
  458. $('#loadingModal').modal('hide');
  459. }
  460. //分页
  461. $("#pager").zPager({
  462. totalData: {{.T.allnum}},//数据总条数
  463. current: {{.T.pagenum}},
  464. pageData: 50,//每页数据条数
  465. //htmlBox: $('#wraper'),
  466. btnShow: true,
  467. ajaxSetData: false
  468. });
  469. function currentPage(currentPage, type){
  470. /*
  471. 触发页码数位置: Page/js/jquery.z-pager.js 64行
  472. */
  473. console.log("当前页码数:" + currentPage);
  474. }
  475. function alertsync() {
  476. var coll = $("#fromtable").val();
  477. if(confirm("请先同步"+coll+"表中数据。如需同步,请点确定;否则,请取消,直接查看数据。"+"\n"+"(通过ES/Excel导入数据,无需同步)")){
  478. if(coll == "marked"){
  479. alert("marked表无需同步");
  480. return
  481. }
  482. showLoading();
  483. $.ajax({
  484. url:"/center/syncmarked",
  485. type:"post",
  486. async:false,
  487. data:{"coll":coll},
  488. success:function (r) {
  489. if(r){
  490. console.log(r.msg);
  491. alert(r.msg);
  492. hideLoading();
  493. if(r.flag){
  494. $("#submitForm").trigger('click');
  495. }
  496. }else{
  497. hideLoading()
  498. }
  499. }
  500. })
  501. }else{
  502. $("#submitForm").trigger('click');
  503. }
  504. }
  505. //页码跳转
  506. function gopage(){
  507. var pagenumber = $("#changePage").val();
  508. var totalcount = {{.T.allnum}};
  509. var pagecount = parseInt((totalcount + 50 - 1) / 50)
  510. if(1 <= pagenumber && pagenumber <= pagecount){
  511. submitform(pagenumber);
  512. }else{
  513. vueApp.$message({
  514. message: '页码输入有误,请重新输入!',
  515. type: 'danger',
  516. duration: 2000,
  517. offset: 300
  518. });
  519. }
  520. }
  521. function submitform(number){
  522. $("#pagenum").val(number);
  523. $("#submitForm").trigger('click');
  524. }
  525. function updateinfo(){
  526. $("#submitForm").trigger('click');
  527. }
  528. //同步marked表中的数据
  529. function syncmarked() {
  530. var coll = $("#fromtable").val();
  531. if(confirm("确定同步"+coll+"表中数据?")){
  532. if(coll == "marked"){
  533. alert("marked表无需同步");
  534. return
  535. }
  536. $.ajax({
  537. url:"/center/syncmarked",
  538. type:"post",
  539. data:{"coll":coll},
  540. success:function (r) {
  541. if(r){
  542. console.log(r.msg)
  543. alert(r.msg)
  544. }
  545. }
  546. })
  547. }
  548. }
  549. function markedinit(){
  550. vueApp.$confirm('确定初始化marked表中ck_data标记?', {
  551. confirmButtonText: '确认',
  552. cancelButtonText: '取消',
  553. type: 'warning'
  554. }).then(() => {
  555. $.ajax({
  556. url: "/center/markedinit",
  557. type: "post",
  558. success: function (r) {
  559. if(r&&r.success){
  560. alert("初始化成功");
  561. }else{
  562. alert("初始化失败");
  563. }
  564. }
  565. })
  566. }).catch(() => {
  567. });
  568. }
  569. function saveuser() {
  570. var username = $("#username").val();
  571. var password = $("#password").val();
  572. if(username!=""&&password!=""){
  573. $.ajax({
  574. url: "/center/saveuser",
  575. type: "post",
  576. data: {"username":username,"password":password},
  577. success: function (r) {
  578. if(r&&r.flag){
  579. alert("更新成功");
  580. $("#editeuser").modal("hide");
  581. }else{
  582. alert("更新失败");
  583. }
  584. }
  585. })
  586. }else{
  587. alert("用户或密码不能为空!")
  588. }
  589. }
  590. function editeuser() {
  591. $("#editeuser").modal("show");
  592. }
  593. function cancel() {
  594. $("#editeuser").modal("hide");
  595. }
  596. function changelabeler(labeler){
  597. if(labeler == "-1"){
  598. return
  599. }
  600. $("#labername").val(labeler)
  601. $("#submitForm").trigger('click');
  602. //window.location.href = '/center/getlistbylabeler/?user='+labeler;
  603. //window.open("/center/getlistbylabeler/?user="+labeler);
  604. }
  605. function skipReview() {
  606. window.location.href="/center/review"
  607. }
  608. </script>
  609. </html>