WordTable.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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. <el-cascader
  27. v-model="leve"
  28. :options="leveList"
  29. @change="page1getdata"
  30. style="width: 140px; margin-right: 24px"
  31. ></el-cascader>
  32. <div class="seek">
  33. <img src="../../assets/teacherdev/search-icon.png" alt="" />
  34. <input v-model="keyword" type="text" />
  35. </div>
  36. <div class="seekBtn" @click="page1getdata">搜索</div>
  37. </div>
  38. </div>
  39. <div class="table">
  40. <table border="0" cellspacing="0" cellpadding="0">
  41. <tr>
  42. <th
  43. v-for="(item, i) in tableHeader"
  44. :key="i"
  45. :style="{ width: item.width }"
  46. :class="[i == tableHeader.length - 1 ? 'bz' : '']"
  47. v-if="
  48. (item.name == '拼音' && typeIndex != 0) || item.name != '拼音'
  49. "
  50. >
  51. <div>
  52. <span>
  53. {{
  54. item.name == "音节"
  55. ? typeIndex == 0
  56. ? "音节"
  57. : "汉字"
  58. : item.name
  59. }}
  60. </span>
  61. <template v-if="item.sortShow">
  62. <div class="sort">
  63. <div>
  64. <img
  65. v-if="item.sort != 'up'"
  66. @click="SortEvent('up', item.name, item.sortName)"
  67. src="../../assets/teacherdev/sort-up.png"
  68. alt=""
  69. />
  70. <img
  71. v-if="item.sort == 'up'"
  72. @click="SortEvent('up', item.name, item.sortName)"
  73. src="../../assets/teacherdev/sort-sele-up.png"
  74. alt=""
  75. />
  76. </div>
  77. <div>
  78. <img
  79. v-if="item.sort != 'down'"
  80. @click="SortEvent('down', item.name, item.sortName)"
  81. src="../../assets/teacherdev/sort-down.png"
  82. alt=""
  83. />
  84. <img
  85. v-if="item.sort == 'down'"
  86. @click="SortEvent('down', item.name, item.sortName)"
  87. src="../../assets/teacherdev/sort-sele-down.png"
  88. alt=""
  89. />
  90. </div>
  91. </div>
  92. </template>
  93. </div>
  94. </th>
  95. </tr>
  96. <tr v-for="(item, i) in dataList.list" :key="i + 'td'">
  97. <td class="sort-td">{{ item.number }}</td>
  98. <td :class="['sort-td', typeIndex == 0 ? 'pinyin' : '']">
  99. <span
  100. :style="{
  101. color:
  102. item.levelName && levelMap[item.levelName]
  103. ? levelMap[item.levelName].color
  104. : '',
  105. }"
  106. >{{ item.word }}</span
  107. >
  108. </td>
  109. <td
  110. class="sort-td"
  111. v-if="typeIndex != 0"
  112. style="font-family: GB-PINYINOK-B"
  113. >
  114. {{ item.pinYin }}
  115. </td>
  116. <td class="sort-td">
  117. <span
  118. :style="{
  119. color:
  120. item.gradeName && levelMap[item.gradeName]
  121. ? levelMap[item.gradeName].color
  122. : '',
  123. }"
  124. >{{ item.gradeName }}</span
  125. >
  126. </td>
  127. <td class="sort-td">
  128. <span
  129. :style="{
  130. color:
  131. item.levelName && levelMap[item.levelName]
  132. ? levelMap[item.levelName].color
  133. : '',
  134. }"
  135. >{{ item.levelName }}</span
  136. >
  137. </td>
  138. <td
  139. class="sort-td"
  140. style="cursor: pointer"
  141. @click="
  142. backHighlight(item, levelMap[item.levelName].color, 'all')
  143. "
  144. >
  145. {{ item.freq }}
  146. </td>
  147. <td class="sort-td">{{ item.textRatio }}%</td>
  148. <td>
  149. <div style="display: flex; flex-wrap: wrap">
  150. <span
  151. @click="
  152. backHighlight(items, levelMap[item.levelName].color, 'one')
  153. "
  154. v-for="(items, i) in item.remarks"
  155. :key=""
  156. class="beizhu"
  157. :style="{
  158. marginRight: '10px',
  159. cursor: 'pointer',
  160. borderColor:
  161. items.levelName && levelMap[items.levelName]
  162. ? levelMap[items.levelName].color
  163. : '',
  164. background:
  165. items.levelName && levelMap[items.levelName]
  166. ? levelMap[items.levelName].color + '08'
  167. : '',
  168. }"
  169. >
  170. <span
  171. style="font-size: 18px; font-weight: 400"
  172. v-html="items.word"
  173. >
  174. </span>
  175. <span
  176. :style="{
  177. color:
  178. items.levelName && levelMap[items.levelName]
  179. ? levelMap[items.levelName].color
  180. : '',
  181. }"
  182. >
  183. {{ items.levelName }}
  184. </span>
  185. <span>
  186. {{ items.freq }}
  187. </span>
  188. </span>
  189. </div>
  190. </td>
  191. </tr>
  192. </table>
  193. <template v-if="dataList.list.length == 0">
  194. <div class="no_data">暂无数据</div>
  195. </template>
  196. <!-- <el-table
  197. :data="dataList.list"
  198. style="width: 100%"
  199. @sort-change="sort_change"
  200. ref="table"
  201. :sort-orders="['levelName']"
  202. sortable="custom"
  203. >
  204. <el-table-column prop="number" label="序号" width="48" align="center">
  205. </el-table-column>
  206. <el-table-column
  207. prop="word"
  208. :label="typeIndex == 0 ? '音节' : '汉字'"
  209. width="93"
  210. sortable
  211. >
  212. <template slot-scope="item">
  213. <span
  214. :style="{
  215. color:
  216. item.row.levelName && levelMap[item.row.levelName]
  217. ? levelMap[item.row.levelName].color
  218. : '',
  219. }"
  220. >{{ item.row.word }}</span
  221. >
  222. </template>
  223. </el-table-column>
  224. <template v-if="typeIndex != 0">
  225. <el-table-column prop="pinYin" label="拼音" width="95" sortable>
  226. </el-table-column>
  227. </template>
  228. <el-table-column prop="gradeName" label="等次" width="95" sortable>
  229. <template slot-scope="item">
  230. <span
  231. :style="{
  232. color:
  233. item.row.gradeName && levelMap[item.row.gradeName]
  234. ? levelMap[item.row.gradeName].color
  235. : '',
  236. }"
  237. >{{ item.row.gradeName }}</span
  238. >
  239. </template>
  240. </el-table-column>
  241. <el-table-column prop="levelName" label="级别" width="106" sortable>
  242. <template slot-scope="item">
  243. <span
  244. :style="{
  245. color:
  246. item.row.levelName && levelMap[item.row.levelName]
  247. ? levelMap[item.row.levelName].color
  248. : '',
  249. }"
  250. >{{ item.row.levelName }}</span
  251. >
  252. </template>
  253. </el-table-column>
  254. <el-table-column prop="freq" label="频数" width="108" sortable>
  255. </el-table-column>
  256. <el-table-column prop="textRatio" label="比例" width="110" sortable>
  257. </el-table-column>
  258. <el-table-column prop="" label="备注">
  259. <template slot-scope="item">
  260. <div style="display: flex">
  261. <span
  262. v-for="(items, i) in item.row.remarks"
  263. :key=""
  264. class="beizhu"
  265. style="margin-right: 10px"
  266. >
  267. <span
  268. style="font-size: 18px; font-weight: 400"
  269. v-html="items.word"
  270. >
  271. </span>
  272. <span
  273. :style="{
  274. color:
  275. items.levelName && levelMap[items.levelName]
  276. ? levelMap[items.levelName].color
  277. : '',
  278. }"
  279. >
  280. {{ items.levelName }}
  281. </span>
  282. <span>
  283. {{ items.freq }}
  284. </span>
  285. </span>
  286. </div>
  287. </template>
  288. </el-table-column>
  289. </el-table> -->
  290. </div>
  291. <div class="page" v-if="dataList.list.length > 0">
  292. <el-pagination
  293. background
  294. @current-change="handleCurrentChange"
  295. :current-page="page"
  296. :page-size="pageSize"
  297. layout="prev, pager, next, jumper"
  298. :total="dataList.total"
  299. >
  300. </el-pagination>
  301. </div>
  302. </div>
  303. </div>
  304. </template>
  305. <script>
  306. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  307. //例如:import 《组件名称》from ‘《组件路径》';
  308. import Header from "@/components/Header.vue";
  309. import { postapi } from "@/api/api";
  310. import staticData from "../../common/data";
  311. export default {
  312. //import引入的组件需要注入到对象中才能使用
  313. components: {
  314. Header,
  315. },
  316. props: {},
  317. data() {
  318. //这里存放数据
  319. return {
  320. typeIndex: 0,
  321. headText: 1,
  322. keyword: "",
  323. leve: null,
  324. leveList: [
  325. {
  326. value: null,
  327. label: "全部",
  328. },
  329. {
  330. value: 1,
  331. label: "初等",
  332. children: [
  333. { value: "100,101,102", label: "全部" },
  334. { value: "100", label: "1级" },
  335. { value: "101", label: "2级" },
  336. { value: "102", label: "3级" },
  337. ],
  338. },
  339. {
  340. value: 2,
  341. label: "中等",
  342. children: [
  343. { value: "103,104,105", label: "全部" },
  344. { value: "103", label: "4级" },
  345. { value: "104", label: "5级" },
  346. { value: "105", label: "6级" },
  347. ],
  348. },
  349. {
  350. value: 3,
  351. label: "高等",
  352. children: [{ value: "106", label: "7-9级" }],
  353. },
  354. {
  355. value: 107,
  356. label: "超纲",
  357. children: [{ value: "107", label: "超纲" }],
  358. },
  359. {
  360. value: 108,
  361. label: "专有",
  362. children: [{ value: "108", label: "专有" }],
  363. },
  364. {
  365. value: 109,
  366. label: "其它",
  367. children: [{ value: "109", label: "其它" }],
  368. },
  369. ],
  370. tableHeader: [
  371. {
  372. name: "序号",
  373. sortShow: false,
  374. width: "48px",
  375. },
  376. {
  377. name: "音节",
  378. sortShow: true,
  379. sort: "",
  380. width: "93px",
  381. sortName: "word",
  382. },
  383. {
  384. name: "拼音",
  385. sortShow: true,
  386. sort: "",
  387. width: "95px",
  388. sortName: "pin_yin",
  389. },
  390. {
  391. name: "等次",
  392. sortShow: true,
  393. sort: "",
  394. width: "95px",
  395. sortName: "grade_id",
  396. },
  397. {
  398. name: "级别",
  399. sortShow: true,
  400. sort: "down",
  401. width: "120px",
  402. sortName: "level_id",
  403. },
  404. {
  405. name: "频数",
  406. sortShow: true,
  407. sort: "",
  408. width: "88px",
  409. sortName: "freq",
  410. },
  411. {
  412. name: "比例",
  413. sortShow: true,
  414. sort: "",
  415. width: "90px",
  416. sortName: "word_ratio",
  417. },
  418. {
  419. name: "备注",
  420. sortShow: false,
  421. sort: "",
  422. width: "",
  423. sortName: "",
  424. },
  425. ],
  426. dataList: {
  427. list: [],
  428. },
  429. page: 1,
  430. pageSize: 10,
  431. partitionKey: null,
  432. searchType: null,
  433. levelMap: null,
  434. loading: false,
  435. sortType: 0,
  436. sortField: "level_id",
  437. routerData: null,
  438. };
  439. },
  440. //计算属性 类似于data概念
  441. computed: {},
  442. //监控data中数据变化
  443. watch: {},
  444. //方法集合
  445. methods: {
  446. // 返回并高亮对应数据
  447. backHighlight(item, color, type) {
  448. let data = JSON.parse(JSON.stringify(this.routerData));
  449. let arr = [];
  450. if (type == "all") {
  451. item.remarks.forEach((items) => {
  452. arr.push(items.word);
  453. });
  454. } else {
  455. arr.push(item.word);
  456. }
  457. data.remarks = JSON.stringify(arr);
  458. data.color = color;
  459. sessionStorage.setItem("tablehighlight", true);
  460. this.$router.push({
  461. path: "/textanalysis/Result",
  462. query: data,
  463. });
  464. },
  465. handleCurrentChange(val) {
  466. this.page = val;
  467. this.getlist();
  468. },
  469. getlist() {
  470. this.loading = true;
  471. postapi({
  472. url: "/GCLSTCServer/tools/TS/glossary/list",
  473. data: {
  474. pageIndex: this.page,
  475. pageSize: this.pageSize,
  476. partitionKey: this.partitionKey,
  477. searchType: this.typeIndex,
  478. word: this.keyword,
  479. sortField: this.sortField,
  480. sortType: this.sortType,
  481. levels: this.leve ? this.leve[1] : null,
  482. },
  483. })
  484. .then((res) => {
  485. let num = this.page * this.pageSize - this.pageSize + 1;
  486. res.data.result.list.forEach((item) => {
  487. item.remarks = JSON.parse(item.remarks);
  488. item.number = num;
  489. num++;
  490. });
  491. this.dataList = res.data.result;
  492. this.loading = false;
  493. })
  494. .catch((res) => {
  495. this.loading = false;
  496. });
  497. },
  498. page1getdata() {
  499. this.loading = true;
  500. this.page = 1;
  501. this.getlist();
  502. },
  503. SortEvent(type, name, sortName) {
  504. let sort = "";
  505. this.tableHeader.forEach((item) => {
  506. if (item.name == name) {
  507. if (!item.sort || item.sort == "up") {
  508. item.sort = "down";
  509. sort = "down";
  510. } else if (item.sort == "down") {
  511. item.sort = "up";
  512. sort = "up";
  513. }
  514. } else {
  515. item.sort = "";
  516. }
  517. });
  518. if (sort == "down") {
  519. this.sortType = 1;
  520. } else {
  521. this.sortType = 0;
  522. }
  523. this.sortField = sortName;
  524. this.getlist();
  525. },
  526. sort_change(column, prop, order) {
  527. if (this.$refs.table) this.$refs.table.clearSort();
  528. column.column.order = column.order;
  529. if (column.prop == "pinyin") {
  530. this.sortField = "pin_yin";
  531. } else if (column.prop == "gradeName") {
  532. this.sortField = "grade_id";
  533. } else if (column.prop == "levelName") {
  534. this.sortField = "level_id";
  535. } else if (column.prop == "textRatio") {
  536. this.sortField = "text_ratio";
  537. } else {
  538. this.sortField = column.prop;
  539. }
  540. if (column.order == "descending") {
  541. this.sortType = 1;
  542. } else {
  543. this.sortType = 0;
  544. }
  545. this.getlist();
  546. },
  547. cutType(index) {
  548. this.typeIndex = index;
  549. this.page1getdata();
  550. },
  551. },
  552. //生命周期 - 创建完成(可以访问当前this实例)
  553. created() {
  554. this.routerData = JSON.parse(JSON.stringify(this.$route.query));
  555. this.partitionKey = this.$route.query.partitionKey * 1;
  556. this.levelMap = staticData.LevelMap;
  557. this.getlist();
  558. },
  559. //生命周期 - 挂载完成(可以访问DOM元素)
  560. mounted() {},
  561. //生命周期-创建之前
  562. beforeCreated() {},
  563. //生命周期-挂载之前
  564. beforeMount() {},
  565. //生命周期-更新之前
  566. beforUpdate() {},
  567. //生命周期-更新之后
  568. updated() {},
  569. //生命周期-销毁之前
  570. beforeDestory() {},
  571. //生命周期-销毁完成
  572. destoryed() {},
  573. //如果页面有keep-alive缓存功能,这个函数会触发
  574. activated() {},
  575. };
  576. </script>
  577. <style lang="scss" scoped>
  578. /* @import url(); 引入css类 */
  579. .WordTable {
  580. background: #f6f6f6;
  581. min-height: 100%;
  582. .wheader {
  583. background: #ffffff;
  584. }
  585. .main {
  586. width: 1200px;
  587. margin: 23px auto;
  588. .top {
  589. display: flex;
  590. justify-content: space-between;
  591. .left {
  592. display: flex;
  593. align-items: center;
  594. .type_dv {
  595. margin-right: 40px;
  596. // width: 172px;
  597. padding: 0 2px;
  598. height: 40px;
  599. background: #eeeeee;
  600. border-radius: 4px;
  601. display: flex;
  602. align-items: center;
  603. span {
  604. display: inline-block;
  605. height: 36px;
  606. width: 56px;
  607. font-weight: 400;
  608. font-size: 14px;
  609. line-height: 40px;
  610. text-align: center;
  611. color: #888888;
  612. cursor: pointer;
  613. }
  614. .sele {
  615. color: #000000;
  616. background: #ffffff;
  617. box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.08);
  618. }
  619. }
  620. }
  621. .right {
  622. display: flex;
  623. align-items: center;
  624. .seek {
  625. display: flex;
  626. width: 264px;
  627. height: 40px;
  628. background: #ffffff;
  629. border: 1px solid #dddddd;
  630. border-radius: 2px 0px 0px 2px;
  631. img {
  632. width: 16px;
  633. height: 16px;
  634. margin: 12px 4px 12px 12px;
  635. }
  636. input {
  637. flex: 1;
  638. border: none;
  639. outline: none;
  640. background: none;
  641. height: 40px;
  642. }
  643. }
  644. .seekBtn {
  645. width: 56px;
  646. height: 40px;
  647. background: #ffa800;
  648. border: 1px solid #ffa800;
  649. border-radius: 0px 2px 2px 0px;
  650. cursor: pointer;
  651. font-weight: 400;
  652. font-size: 16px;
  653. line-height: 40px;
  654. text-align: center;
  655. color: #ffffff;
  656. }
  657. }
  658. }
  659. .table {
  660. margin-top: 21px;
  661. .no_data {
  662. background: #ffffff;
  663. text-align: center;
  664. height: 60px;
  665. line-height: 60px;
  666. color: #909399;
  667. }
  668. table {
  669. width: 100%;
  670. border-collapse: collapse;
  671. background: #ffffff;
  672. .pinyin {
  673. font-family: "GB-PINYINOK-B";
  674. }
  675. th {
  676. background: #ffffff;
  677. .bz {
  678. flex: 1;
  679. }
  680. > div {
  681. display: flex;
  682. align-items: center;
  683. justify-content: space-between;
  684. padding: 0 8px;
  685. height: 48px;
  686. .sort {
  687. cursor: pointer;
  688. > div {
  689. img {
  690. width: 11px;
  691. height: 11px;
  692. }
  693. }
  694. > :nth-child(1) {
  695. > img {
  696. position: relative;
  697. top: 3px;
  698. }
  699. }
  700. > :nth-child(2) {
  701. > img {
  702. position: relative;
  703. bottom: 7px;
  704. }
  705. }
  706. }
  707. }
  708. }
  709. td {
  710. height: 40px;
  711. line-height: 40px;
  712. text-align: left;
  713. border-bottom: 1px solid #eeeeee;
  714. font-weight: 400;
  715. font-size: 14px;
  716. }
  717. .sort-td {
  718. padding: 0 9px;
  719. text-align: center;
  720. }
  721. }
  722. }
  723. .page {
  724. margin-top: 24px;
  725. }
  726. .beizhu {
  727. margin-top: 8px;
  728. margin-bottom: 8px;
  729. height: 28px;
  730. display: inline-block;
  731. border: 1px solid;
  732. // background: #f9f9f9;
  733. border-radius: 4px;
  734. display: flex;
  735. align-items: center;
  736. font-size: 12px;
  737. font-weight: 500;
  738. padding-left: 4px;
  739. padding-right: 7px;
  740. > :not(:nth-last-child(1)) {
  741. margin-right: 8px;
  742. }
  743. }
  744. }
  745. }
  746. </style>
  747. <style lang="scss">
  748. .WordTable {
  749. .table {
  750. .el-table th {
  751. background: #ffffff;
  752. padding: 7px 0;
  753. }
  754. .el-table th > .cell {
  755. display: flex;
  756. align-items: center;
  757. justify-content: space-between;
  758. font-weight: 700;
  759. color: #333333;
  760. font-size: 14px;
  761. }
  762. .el-table td {
  763. padding: 8px 0;
  764. }
  765. .el-table td > .cell {
  766. font-size: 14px;
  767. line-height: 22px;
  768. color: #333333;
  769. font-weight: 600;
  770. }
  771. }
  772. .el-radio__input.is-checked + .el-radio__label {
  773. color: #000000;
  774. }
  775. .el-radio__input.is-checked .el-radio__inner {
  776. border: 2px solid #c8c8c8;
  777. background: #1e1e1e;
  778. }
  779. .el-radio__inner::after {
  780. background: none;
  781. }
  782. .el-radio__inner {
  783. background: #c8c8c8;
  784. border: none;
  785. }
  786. .el-pagination.is-background .el-pager li:not(.disabled).active {
  787. background: #ffffff !important;
  788. color: rgba(0, 0, 0, 0.85);
  789. border: 1px solid #333333;
  790. }
  791. .el-pager {
  792. .number {
  793. background: #ffffff !important;
  794. border: 1px solid #d9d9d9;
  795. border-radius: 2px;
  796. }
  797. }
  798. .btn-prev,
  799. .btn-next {
  800. border: 1px solid #d9d9d9;
  801. border-radius: 2px;
  802. background: #ffffff !important;
  803. }
  804. }
  805. </style>