WordTable.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <div class="WordTable" v-loading="loading">
  3. <div class="wheader">
  4. <Header />
  5. </div>
  6. <div class="main">
  7. <div class="top">
  8. <div class="left">
  9. <div class="type_dv">
  10. <span :class="[typeIndex == 0 ? 'sele' : '']" @click="cutType(0)"
  11. >音节</span
  12. >
  13. <span :class="[typeIndex == 1 ? 'sele' : '']" @click="cutType(1)"
  14. >汉字</span
  15. >
  16. <span :class="[typeIndex == 2 ? 'sele' : '']" @click="cutType(2)"
  17. >词汇</span
  18. >
  19. </div>
  20. <!-- <el-radio-group v-model="headText">
  21. <el-radio :label="1">词头</el-radio>
  22. <el-radio :label="2">文本</el-radio>
  23. </el-radio-group> -->
  24. </div>
  25. <div class="right">
  26. <div class="seek">
  27. <img src="../../assets/teacherdev/search-icon.png" alt="" />
  28. <input v-model="keyword" type="text" />
  29. </div>
  30. <div class="seekBtn" @click="page1getdata">搜索</div>
  31. </div>
  32. </div>
  33. <div class="table">
  34. <el-table
  35. :data="dataList.list"
  36. style="width: 100%"
  37. @sort-change="sort_change"
  38. ref="table"
  39. >
  40. <el-table-column prop="number" label="序号" width="48" align="center">
  41. </el-table-column>
  42. <el-table-column
  43. prop="word"
  44. :label="typeIndex == 0 ? '音节' : '汉字'"
  45. width="93"
  46. sortable
  47. >
  48. <template slot-scope="item">
  49. <span
  50. :style="{
  51. color:
  52. item.row.levelName && levelMap[item.row.levelName]
  53. ? levelMap[item.row.levelName].color
  54. : '',
  55. }"
  56. >{{ item.row.word }}</span
  57. >
  58. </template>
  59. </el-table-column>
  60. <template v-if="typeIndex != 0">
  61. <el-table-column prop="pinYin" label="拼音" width="95" sortable>
  62. </el-table-column>
  63. </template>
  64. <el-table-column prop="gradeName" label="等次" width="95" sortable>
  65. <template slot-scope="item">
  66. <span
  67. :style="{
  68. color:
  69. item.row.gradeName && levelMap[item.row.gradeName]
  70. ? levelMap[item.row.gradeName].color
  71. : '',
  72. }"
  73. >{{ item.row.gradeName }}</span
  74. >
  75. </template>
  76. </el-table-column>
  77. <el-table-column prop="levelName" label="级别" width="106" sortable>
  78. <template slot-scope="item">
  79. <span
  80. :style="{
  81. color:
  82. item.row.levelName && levelMap[item.row.levelName]
  83. ? levelMap[item.row.levelName].color
  84. : '',
  85. }"
  86. >{{ item.row.levelName }}</span
  87. >
  88. </template>
  89. </el-table-column>
  90. <el-table-column prop="freq" label="频数" width="108" sortable>
  91. </el-table-column>
  92. <el-table-column prop="textRatio" label="比例" width="110" sortable>
  93. <!-- <template slot-scope="item">
  94. <span v-if="headText == 1">{{ item.row.wordRatio }}%</span>
  95. <span v-else>{{ item.row.textRatio }}%</span>
  96. </template> -->
  97. </el-table-column>
  98. <el-table-column prop="" label="备注">
  99. <template slot-scope="item">
  100. <div style="display: flex">
  101. <span
  102. v-for="(items, i) in item.row.remarks"
  103. :key=""
  104. class="beizhu"
  105. style="margin-right: 10px"
  106. >
  107. <span
  108. style="font-size: 18px; font-weight: 400"
  109. v-html="items.word"
  110. >
  111. </span>
  112. <span
  113. :style="{
  114. color:
  115. items.levelName && levelMap[items.levelName]
  116. ? levelMap[items.levelName].color
  117. : '',
  118. }"
  119. >
  120. {{ items.levelName }}
  121. </span>
  122. <span>
  123. {{ items.freq }}
  124. </span>
  125. </span>
  126. </div>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. </div>
  131. <div class="page" v-if="dataList.list.length > 0">
  132. <el-pagination
  133. background
  134. @current-change="handleCurrentChange"
  135. :current-page="page"
  136. :page-size="pageSize"
  137. layout="prev, pager, next, jumper"
  138. :total="dataList.total"
  139. >
  140. </el-pagination>
  141. </div>
  142. </div>
  143. </div>
  144. </template>
  145. <script>
  146. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  147. //例如:import 《组件名称》from ‘《组件路径》';
  148. import Header from "@/components/Header.vue";
  149. import { postapi } from "@/api/api";
  150. import staticData from "../../common/data";
  151. export default {
  152. //import引入的组件需要注入到对象中才能使用
  153. components: {
  154. Header,
  155. },
  156. props: {},
  157. data() {
  158. //这里存放数据
  159. return {
  160. typeIndex: 0,
  161. headText: 1,
  162. keyword: "",
  163. dataList: {
  164. list: [],
  165. },
  166. page: 1,
  167. pageSize: 10,
  168. partitionKey: null,
  169. searchType: null,
  170. levelMap: null,
  171. loading: false,
  172. sortType: null,
  173. sortField: null,
  174. };
  175. },
  176. //计算属性 类似于data概念
  177. computed: {},
  178. //监控data中数据变化
  179. watch: {},
  180. //方法集合
  181. methods: {
  182. handleCurrentChange(val) {
  183. this.page = val;
  184. this.getlist();
  185. },
  186. getlist() {
  187. this.loading = true;
  188. postapi({
  189. url: "/GCLSTRCServer/tools/TS/glossary/list",
  190. data: {
  191. pageIndex: this.page,
  192. pageSize: this.pageSize,
  193. partitionKey: this.partitionKey,
  194. searchType: this.typeIndex,
  195. word: this.keyword,
  196. sortField: this.sortField,
  197. sortType: this.sortType,
  198. },
  199. })
  200. .then((res) => {
  201. let num = this.page * this.pageSize - this.pageSize + 1;
  202. res.data.result.list.forEach((item) => {
  203. item.remarks = JSON.parse(item.remarks);
  204. item.number = num;
  205. num++;
  206. });
  207. this.dataList = res.data.result;
  208. this.loading = false;
  209. })
  210. .catch((res) => {
  211. this.loading = false;
  212. });
  213. },
  214. page1getdata() {
  215. this.loading = true;
  216. this.page = 1;
  217. this.getlist();
  218. },
  219. sort_change(column, prop, order) {
  220. if (this.$refs.table) this.$refs.table.clearSort();
  221. column.column.order = column.order;
  222. if (column.prop == "pinyin") {
  223. this.sortField = "pin_yin";
  224. } else if (column.prop == "gradeName") {
  225. this.sortField = "grade_id";
  226. } else if (column.prop == "levelName") {
  227. this.sortField = "level_id";
  228. } else if (column.prop == "textRatio") {
  229. this.sortField = "text_ratio";
  230. } else {
  231. this.sortField = column.prop;
  232. }
  233. if (column.order == "descending") {
  234. this.sortType = 1;
  235. } else {
  236. this.sortType = 0;
  237. }
  238. this.getlist();
  239. },
  240. cutType(index) {
  241. this.typeIndex = index;
  242. this.page1getdata();
  243. },
  244. },
  245. //生命周期 - 创建完成(可以访问当前this实例)
  246. created() {
  247. this.partitionKey = this.$route.query.partitionKey * 1;
  248. this.levelMap = staticData.LevelMap;
  249. this.getlist();
  250. },
  251. //生命周期 - 挂载完成(可以访问DOM元素)
  252. mounted() {},
  253. //生命周期-创建之前
  254. beforeCreated() {},
  255. //生命周期-挂载之前
  256. beforeMount() {},
  257. //生命周期-更新之前
  258. beforUpdate() {},
  259. //生命周期-更新之后
  260. updated() {},
  261. //生命周期-销毁之前
  262. beforeDestory() {},
  263. //生命周期-销毁完成
  264. destoryed() {},
  265. //如果页面有keep-alive缓存功能,这个函数会触发
  266. activated() {},
  267. };
  268. </script>
  269. <style lang="scss" scoped>
  270. /* @import url(); 引入css类 */
  271. .WordTable {
  272. background: #f6f6f6;
  273. height: 100%;
  274. .wheader {
  275. background: #ffffff;
  276. }
  277. .main {
  278. width: 1200px;
  279. margin: 23px auto;
  280. .top {
  281. display: flex;
  282. justify-content: space-between;
  283. .left {
  284. display: flex;
  285. align-items: center;
  286. .type_dv {
  287. margin-right: 40px;
  288. // width: 172px;
  289. padding: 0 2px;
  290. height: 40px;
  291. background: #eeeeee;
  292. border-radius: 4px;
  293. display: flex;
  294. align-items: center;
  295. span {
  296. display: inline-block;
  297. height: 36px;
  298. width: 56px;
  299. font-weight: 400;
  300. font-size: 14px;
  301. line-height: 40px;
  302. text-align: center;
  303. color: #888888;
  304. cursor: pointer;
  305. }
  306. .sele {
  307. color: #000000;
  308. background: #ffffff;
  309. box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.08);
  310. }
  311. }
  312. }
  313. .right {
  314. display: flex;
  315. .seek {
  316. display: flex;
  317. width: 264px;
  318. height: 40px;
  319. background: #ffffff;
  320. border: 1px solid #dddddd;
  321. border-radius: 2px 0px 0px 2px;
  322. img {
  323. width: 16px;
  324. height: 16px;
  325. margin: 12px 4px 12px 12px;
  326. }
  327. input {
  328. flex: 1;
  329. border: none;
  330. outline: none;
  331. background: none;
  332. height: 40px;
  333. }
  334. }
  335. .seekBtn {
  336. width: 56px;
  337. height: 40px;
  338. background: #ffa800;
  339. border: 1px solid #ffa800;
  340. border-radius: 0px 2px 2px 0px;
  341. cursor: pointer;
  342. font-weight: 400;
  343. font-size: 16px;
  344. line-height: 40px;
  345. text-align: center;
  346. color: #ffffff;
  347. }
  348. }
  349. }
  350. .table {
  351. margin-top: 21px;
  352. }
  353. .page {
  354. margin-top: 24px;
  355. }
  356. .beizhu {
  357. height: 28px;
  358. display: inline-block;
  359. background: #f9f9f9;
  360. border-radius: 4px;
  361. display: flex;
  362. align-items: center;
  363. font-size: 12px;
  364. font-weight: 500;
  365. padding-left: 4px;
  366. padding-right: 7px;
  367. > :not(:nth-last-child(1)) {
  368. margin-right: 8px;
  369. }
  370. }
  371. }
  372. }
  373. </style>
  374. <style lang="scss">
  375. .WordTable {
  376. .table {
  377. .el-table th {
  378. background: #ffffff;
  379. padding: 7px 0;
  380. }
  381. .el-table th > .cell {
  382. display: flex;
  383. align-items: center;
  384. justify-content: space-between;
  385. font-weight: 700;
  386. color: #333333;
  387. font-size: 14px;
  388. }
  389. .el-table td {
  390. padding: 8px 0;
  391. }
  392. .el-table td > .cell {
  393. font-size: 14px;
  394. line-height: 22px;
  395. color: #333333;
  396. font-weight: 600;
  397. }
  398. }
  399. .el-radio__input.is-checked + .el-radio__label {
  400. color: #000000;
  401. }
  402. .el-radio__input.is-checked .el-radio__inner {
  403. border: 2px solid #c8c8c8;
  404. background: #1e1e1e;
  405. }
  406. .el-radio__inner::after {
  407. background: none;
  408. }
  409. .el-radio__inner {
  410. background: #c8c8c8;
  411. border: none;
  412. }
  413. .el-pagination.is-background .el-pager li:not(.disabled).active {
  414. background: #ffffff !important;
  415. color: rgba(0, 0, 0, 0.85);
  416. border: 1px solid #333333;
  417. }
  418. .el-pager {
  419. .number {
  420. background: #ffffff !important;
  421. border: 1px solid #d9d9d9;
  422. border-radius: 2px;
  423. }
  424. }
  425. .btn-prev,
  426. .btn-next {
  427. border: 1px solid #d9d9d9;
  428. border-radius: 2px;
  429. background: #ffffff !important;
  430. }
  431. }
  432. </style>