index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head th:include="common/common :: headVue('ES搜索服务')"></head>
  4. <style>
  5. .clearfix:before,
  6. .clearfix:after {
  7. display: table;
  8. content: "";
  9. }
  10. .clearfix:after {
  11. clear: both
  12. }
  13. /* 谷歌浏览器滚动条美化 */
  14. ::-webkit-scrollbar {
  15. width: 15px;
  16. height: 15px;
  17. }
  18. ::-webkit-scrollbar-track,
  19. ::-webkit-scrollbar-thumb {
  20. border-radius: 999px;
  21. border: 5px solid transparent;
  22. }
  23. ::-webkit-scrollbar-track {
  24. box-shadow: 1px 1px 5px rgba(143, 143, 143, 0.2) inset;
  25. }
  26. ::-webkit-scrollbar-thumb {
  27. min-height: 20px;
  28. background-clip: content-box;
  29. box-shadow: 0 0 0 5px rgba(143, 143, 143, 0.466) inset;
  30. }
  31. ::-webkit-scrollbar-corner {
  32. background: transparent;
  33. }
  34. .tabs{
  35. display: flex;
  36. }
  37. .tabsn{
  38. padding: 4px 20px;
  39. border: 1px #e3e3e3 solid;
  40. border-bottom: none;
  41. cursor: pointer;
  42. }
  43. .tabshit{
  44. background: #f5f7fa;
  45. border-bottom: #78ba27 solid 4px
  46. }
  47. sapn{
  48. color: #8c939d;
  49. font-size: 12px;
  50. overflow: hidden;
  51. text-overflow:ellipsis;
  52. white-space: nowrap;
  53. }
  54. </style>
  55. <body>
  56. <div id="app">
  57. <el-card>
  58. <div slot="header" class="clearfix">
  59. <img th:src="@{img/logo.png}" width="100" />
  60. <img th:src="@{img/baidu.png}" width="150"/>
  61. </div>
  62. <div class="tabs">
  63. <div v-for="(item,index) in tabList" @click="tabsck(item)" :class="{tabshit:item.type,tabsn:true}">
  64. {{item.name}}
  65. </div>
  66. </div>
  67. <!-- 查询表单 -->
  68. <el-form :inline="true" :model="searchForm" label-width="90px" size="small">
  69. <el-form-item>
  70. <el-input placeholder="请输入查询关键字" @keyup.enter.native="list(searchForm)" v-model="searchForm.keyword" clearable>
  71. <el-select v-model="select" slot="prepend" placeholder="请选择" style="width: 124px">
  72. <el-option v-for="item in selectlist" :label="item" :value="item"></el-option>
  73. </el-select>
  74. <el-button slot="append" icon="el-icon-search" @click="list(searchForm)"></el-button>
  75. </el-input>
  76. <el-input v-show="false" placeholder="请输入查询关键字" @keyup.enter.native="list(searchForm)" v-model="searchForm.keyword" clearable></el-input>
  77. </el-form-item>
  78. <!-- <el-form-item>-->
  79. <!-- <el-button icon="el-icon-search" plain @click="list(searchForm)">搜索</el-button>-->
  80. <!-- </el-form-item>-->
  81. <el-form-item>
  82. <!-- <el-button type="info" plain icon="el-icon-plus" @click="preAdd" :loading="genLoading">添加</el-button>-->
  83. </el-form-item>
  84. </el-form>
  85. <ol style="list-style: none">
  86. <li v-for="site in tableData">
  87. <div>
  88. <h3><a :href="site.url" target="_blank" v-html="site.title"></a></h3>
  89. <p v-html="site.content"></p>
  90. <p v-html="site.type"></p>
  91. <!-- <a :href="site.url" target="_blank">网址:{{site.url}}</a>-->
  92. <p v-html="site.date"></p>
  93. <a :href="site.url" target="_blank" style="text-decoration:none"><sapn>{{site.url}} 数据来源:{{site.source}}</sapn></a>
  94. </div>
  95. </ol>
  96. <!-- 数据表格 -->
  97. <el-table v-loading="tableLoading" :data="tableData" @selection-change="handleSelectionChange" border>
  98. <!--<el-table-column type="selection" align="center" width="55"></el-table-column>-->
  99. <!-- <el-table-column type="index" align="center" min-width="60"></el-table-column> 索引-->
  100. <!-- <el-table-column prop="title" label="标题" align="center" min-width="100" show-overflow-tooltip></el-table-column>-->
  101. <!-- <el-table-column prop="type" label="类型" align="center" min-width="100" show-overflow-tooltip></el-table-column>-->
  102. <!-- <el-table-column prop="content" label="内容" align="center" min-width="80" show-overflow-tooltip></el-table-column>-->
  103. <!-- <el-table-column prop="url" label="url" align="center" min-width="80" show-overflow-tooltip></el-table-column>-->
  104. <!-- <el-table-column prop="date" label="日期" align="center" min-width="80" show-overflow-tooltip></el-table-column>-->
  105. <!--<el-table-column prop="createTime" label="创建时间" align="center" min-width="100" show-overflow-tooltip>
  106. <template slot-scope="scope">
  107. {{ moment(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }}
  108. </template>
  109. </el-table-column>-->
  110. <!-- <el-table-column label="操作" align="center" fixed="right" min-width="60">-->
  111. <!-- <template slot-scope="scope">-->
  112. <!--&lt;!&ndash; <el-button size="mini" icon="el-icon-edit" type="primary" plain @click="preById(scope.row)" :loading="genLoading">修改</el-button>&ndash;&gt;-->
  113. <!--&lt;!&ndash; <el-button size="mini" icon="el-icon-delete" type="danger" plain @click="delById(scope.row)" :loading="genLoading">删除</el-button>&ndash;&gt;-->
  114. <!--&lt;!&ndash; <el-button size="mini" icon="el-icon-edit" type="primary" :loading="genLoading">查看</el-button>&ndash;&gt;-->
  115. <!-- </template>-->
  116. <!-- </el-table-column>-->
  117. </el-table>
  118. <div align="right" style="margin-top: 20px;">
  119. <el-pagination
  120. :current-page="searchForm.page"
  121. :page-sizes="[1, 8, 16, 32, 48]"
  122. :page-size="searchForm.rows"
  123. :total="totalCount"
  124. layout="total, sizes, prev, pager, next, jumper"
  125. @size-change="handleSizeChange"
  126. @current-change="handleCurrentChange"
  127. />
  128. </div>
  129. </el-card>
  130. <el-dialog :title="title" :visible.sync="dialogVisible" width="40%">
  131. <el-form :model="bookDto" label-width="90px" style="width: 520px;">
  132. <el-form-item label="ID">
  133. <el-input v-model="bookDto.id" disabled="true" autocomplete="off" placeholder="ID自动生成"></el-input>
  134. </el-form-item>
  135. <el-form-item label="名称">
  136. <el-input v-model="bookDto.name" autocomplete="off"></el-input>
  137. </el-form-item>
  138. <el-form-item label="描述">
  139. <el-input v-model="bookDto.desc" autocomplete="off"></el-input>
  140. </el-form-item>
  141. </el-form>
  142. <div slot="footer" class="dialog-footer">
  143. <el-button :loading="genLoading" @click="dialogVisible = false">取 消</el-button>
  144. <el-button type="primary" :loading="genLoading" @click="deal">确 定</el-button>
  145. </div>
  146. </el-dialog>
  147. </div>
  148. <script type="text/javascript" th:inline="javascript">
  149. /*<![CDATA[*/
  150. var myApp = new Vue({
  151. el: '#app',
  152. data: {
  153. // 表格加载条控制
  154. tableLoading: false,
  155. // 按钮加载条控制
  156. genLoading: false,
  157. // Table数据
  158. tableData: [],
  159. // Table数据总条数
  160. totalCount: 0,
  161. // Table选择的数据
  162. multipleSelection: [],
  163. // 查询条件
  164. searchForm: {
  165. // 当前页
  166. page: 1,
  167. // 每页条数
  168. rows: 8,
  169. // 查询关键字
  170. keyword: ''
  171. },
  172. // 表详细弹出框标题
  173. title: '添加',
  174. // 表详细弹出框是否显示
  175. dialogVisible: false,
  176. // 操作对象
  177. bookDto: {
  178. // ID
  179. id: 1,
  180. // 名称
  181. name: '',
  182. // 描述
  183. desc: ''
  184. },
  185. tabList:[
  186. {
  187. name:"内网",
  188. type:true
  189. },
  190. {
  191. name:"外网",
  192. type:false
  193. }
  194. ],
  195. selectlist:["政策","重燃","核电设备","核燃料","水电","火电","风电","光伏","储能","氢能","碳指标"],
  196. select:""
  197. },
  198. // 启动时就执行
  199. mounted: function() {
  200. // ES信息查询
  201. // this.queryES();
  202. // 列表查询(页面加载查询...)
  203. // this.list(this.searchForm);
  204. },
  205. methods: {
  206. tabsck:function(item){
  207. this.tabList.forEach((res)=>res.type=false)
  208. item.type=!item.type
  209. },
  210. // 查询ES信息
  211. queryES: function() {
  212. axios.get('/high/es').then(res => {
  213. console.log(res);
  214. }).catch(err => {
  215. console.log(err);
  216. this.$message.error('查询失败');
  217. });
  218. },
  219. // 每页条数改变
  220. handleSizeChange: function(rows) {
  221. this.searchForm.rows = rows;
  222. // console.log(this.searchForm.rows);
  223. // 刷新列表
  224. this.list(this.searchForm);
  225. },
  226. // 当前页数改变
  227. handleCurrentChange: function(page) {
  228. this.searchForm.page = page;
  229. // 刷新列表
  230. this.list(this.searchForm);
  231. },
  232. // 选择数据改变触发事件
  233. handleSelectionChange(val) {
  234. this.multipleSelection = val;
  235. },
  236. // 列表查询
  237. list: function(searchForm) {
  238. console.log(this.select)
  239. // 加载显示
  240. this.tableLoading = true;
  241. axios.get('/high/book', {
  242. params: {
  243. 'page': this.searchForm.page,
  244. 'rows': this.searchForm.rows,
  245. // 'keyword': this.searchForm.keyword
  246. 'keyword': this.searchForm.keyword+this.select
  247. }
  248. }).then(res => {
  249. // console.log(res);
  250. var data = res.data.data;
  251. this.tableData = data.data;
  252. this.totalCount = data.count;
  253. }).catch(err => {
  254. console.log(err);
  255. this.$message.error('查询失败');
  256. }).then(() => {
  257. this.tableLoading = false;
  258. });
  259. },
  260. // 添加
  261. preAdd: function() {
  262. this.genLoading = true;
  263. // this.$nextTick Dom渲染完执行
  264. this.$nextTick(() => {
  265. this.title = "添加";
  266. this.bookDto = {};
  267. this.dialogVisible = true;
  268. this.genLoading = false;
  269. });
  270. },
  271. // 预修改
  272. preById: function(row) {
  273. this.genLoading = true;
  274. this.title = "修改";
  275. this.dialogVisible = true;
  276. axios.get('/high/book/' + row.id).then(res => {
  277. // console.log(res);
  278. this.bookDto = res.data.data;
  279. }).catch(err => {
  280. console.log(err);
  281. this.$message.error('查询失败');
  282. }).then(() => {
  283. this.genLoading = false;
  284. });
  285. },
  286. // 添加或者修改
  287. deal: function() {
  288. this.genLoading = true;
  289. if (this.bookDto.id) {
  290. // ID存在修改
  291. axios.put('/high/book', this.bookDto).then(res => {
  292. if (res.data.code == 200) {
  293. this.$message({
  294. message: res.data.msg,
  295. type: 'success'
  296. });
  297. this.dialogVisible = false;
  298. // 列表查询必须慢点,ES没有事务性,查询太快,数据还没更新
  299. this.tableLoading = true;
  300. setTimeout(() => {this.list(this.searchForm);}, 1000);
  301. } else {
  302. this.$message.error('修改失败');
  303. }
  304. }).catch(err => {
  305. console.log(err);
  306. this.$message.error('修改失败');
  307. }).then(() => {
  308. this.genLoading = false;
  309. });
  310. } else {
  311. // ID不存在添加
  312. axios.post('/high/book', this.bookDto).then(res => {
  313. if (res.data.code == 200) {
  314. this.$message({
  315. message: res.data.msg,
  316. type: 'success'
  317. });
  318. this.dialogVisible = false;
  319. // 列表查询必须慢点,ES没有事务性,查询太快,数据还没更新
  320. this.tableLoading = true;
  321. setTimeout(() => {this.list(this.searchForm);}, 1000);
  322. } else {
  323. this.$message.error('添加失败');
  324. }
  325. }).catch(err => {
  326. console.log(err);
  327. this.$message.error('添加失败');
  328. }).then(() => {
  329. this.genLoading = false;
  330. });
  331. }
  332. },
  333. // 删除
  334. delById: function (row) {
  335. this.genLoading = true;
  336. this.$confirm('是否确定删除', '提示', {
  337. confirmButtonText: '确定',
  338. cancelButtonText: '取消',
  339. type: 'warning'
  340. }).then(() => {
  341. axios.delete('/high/book/' + row.id).then(res => {
  342. if (res.data.code == 200) {
  343. this.$message({
  344. message: res.data.msg,
  345. type: 'success'
  346. });
  347. // 列表查询必须慢点,ES没有事务性,查询太快,数据还没更新
  348. this.tableLoading = true;
  349. setTimeout(() => {this.list(this.searchForm);}, 1000);
  350. } else {
  351. this.$message.error('删除失败');
  352. }
  353. }).catch(err => {
  354. console.log(err);
  355. this.$message.error('删除失败');
  356. }).then(() => {
  357. this.genLoading = false;
  358. });
  359. }).catch(() => {
  360. this.genLoading = false;
  361. });
  362. }
  363. }
  364. });
  365. /*]]>*/
  366. </script>
  367. </body>
  368. </html>