123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943 |
- <template>
- <div class="WordTable" v-loading="loading">
- <div class="wheader">
- <Header />
- </div>
- <div class="main">
- <div class="top">
- <div class="left">
- <div class="type_dv">
- <div class="sele">
- <span :class="[typeIndex == 0 ? 'sele' : '']" @click="cutType(0)"
- >音节</span
- >
- <span :class="[typeIndex == 1 ? 'sele' : '']" @click="cutType(1)"
- >汉字</span
- >
- <span :class="[typeIndex == 2 ? 'sele' : '']" @click="cutType(2)"
- >词汇</span
- >
- </div>
- <div class="down" @click="download">
- <img src="../../assets/teacherdev/dowload-text.png" alt="" /><span
- >下载</span
- >
- </div>
- </div>
- <!-- <el-radio-group v-model="headText">
- <el-radio :label="1">词头</el-radio>
- <el-radio :label="2">文本</el-radio>
- </el-radio-group> -->
- </div>
- <div class="right">
- <el-cascader
- v-model="leve"
- :options="leveList"
- @change="page1getdata"
- style="width: 140px; margin-right: 24px"
- ></el-cascader>
- <div class="seek">
- <img src="../../assets/teacherdev/search-icon.png" alt="" />
- <input v-model="keyword" type="text" />
- </div>
- <div class="seekBtn" @click="page1getdata">搜索</div>
- </div>
- </div>
- <div class="table">
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <th
- v-for="(item, i) in tableHeader"
- :key="i"
- :style="{ width: item.width }"
- :class="[
- i == tableHeader.length - 1 ? 'bz' : '',
- item.name == '级别' ? 'jb' : '',
- ]"
- v-if="
- (item.name == '拼音' && typeIndex != 0) || item.name != '拼音'
- "
- >
- <div>
- <span>
- {{
- item.name == "音节"
- ? typeIndex == 0
- ? "音节"
- : "汉字"
- : item.name
- }}
- </span>
- <template v-if="item.sortShow">
- <div :class="['sort']">
- <div>
- <img
- v-if="item.sort != 'up'"
- @click="SortEvent('up', item.name, item.sortName)"
- src="../../assets/teacherdev/sort-up.png"
- alt=""
- />
- <img
- v-if="item.sort == 'up'"
- @click="SortEvent('up', item.name, item.sortName)"
- src="../../assets/teacherdev/sort-sele-up.png"
- alt=""
- />
- </div>
- <div>
- <img
- v-if="item.sort != 'down'"
- @click="SortEvent('down', item.name, item.sortName)"
- src="../../assets/teacherdev/sort-down.png"
- alt=""
- />
- <img
- v-if="item.sort == 'down'"
- @click="SortEvent('down', item.name, item.sortName)"
- src="../../assets/teacherdev/sort-sele-down.png"
- alt=""
- />
- </div>
- </div>
- </template>
- </div>
- </th>
- </tr>
- <tr v-for="(item, index) in dataList.list" :key="index + 'td'">
- <td class="sort-td">{{ item.number }}</td>
- <td :class="['sort-td', typeIndex == 0 ? 'pinyin' : 'hanzi']">
- <span
- :style="{
- fontFamily: typeIndex != 0 ? '楷体' : '',
- fontWeight: '400',
- fontSize: '18px',
- color:
- item.levelName && levelMap[item.levelName]
- ? levelMap[item.levelName].color
- : '',
- }"
- >{{ item.word }}</span
- >
- </td>
- <td
- class="sort-td"
- v-if="typeIndex != 0"
- style="font-family: GB-PINYINOK-B"
- >
- {{ item.pinYin }}
- </td>
- <td class="sort-td">
- <span
- :style="{
- fontFamily: '楷体',
- fontSize: '16px',
- color:
- item.gradeName && levelMap[item.gradeName]
- ? levelMap[item.gradeName].color
- : '',
- }"
- >{{ item.gradeName }}</span
- >
- </td>
- <td class="sort-td jb" style="text-align: right">
- <span
- :style="{
- fontFamily: '楷体',
- fontSize: '16px',
- color:
- item.levelName && levelMap[item.levelName]
- ? levelMap[item.levelName].color
- : '',
- }"
- >{{ item.levelName }}</span
- >
- </td>
- <td
- class="sort-td"
- style="cursor: pointer; fontsize: 16px"
- @click="
- backHighlight(
- item,
- levelMap[item.levelName].color,
- 'all',
- index
- )
- "
- >
- {{ item.freq }}
- </td>
- <td class="sort-td">{{ item.textRatio }}%</td>
- <td>
- <div style="display: flex; flex-wrap: wrap">
- <span
- @click="
- backHighlight(
- items,
- levelMap[item.levelName].color,
- 'one',
- index
- )
- "
- v-for="(items, i) in item.remarks"
- :key=""
- class="beizhu"
- :style="{
- marginRight: '10px',
- cursor: 'pointer',
- borderColor:
- items.levelName && levelMap[items.levelName]
- ? levelMap[items.levelName].color + '16'
- : '',
- background:
- items.levelName && levelMap[items.levelName]
- ? levelMap[items.levelName].color + '50'
- : '',
- }"
- >
- <span v-html="items.word" style="font-family: '楷体'"> </span>
- <span
- :style="{
- fontFamily: '楷体',
- color:
- items.levelName && levelMap[items.levelName]
- ? levelMap[items.levelName].color
- : '',
- }"
- >
- {{ items.levelName }}
- </span>
- <!--
- style="font-size: 12px"
- -->
- <span>
- {{ items.freq }}
- </span>
- </span>
- </div>
- </td>
- </tr>
- </table>
- <template v-if="dataList.list.length == 0">
- <div class="no_data">暂无数据</div>
- </template>
- <!-- <el-table
- :data="dataList.list"
- style="width: 100%"
- @sort-change="sort_change"
- ref="table"
- :sort-orders="['levelName']"
- sortable="custom"
- >
- <el-table-column prop="number" label="序号" width="48" align="center">
- </el-table-column>
- <el-table-column
- prop="word"
- :label="typeIndex == 0 ? '音节' : '汉字'"
- width="93"
- sortable
- >
- <template slot-scope="item">
- <span
- :style="{
- color:
- item.row.levelName && levelMap[item.row.levelName]
- ? levelMap[item.row.levelName].color
- : '',
- }"
- >{{ item.row.word }}</span
- >
- </template>
- </el-table-column>
- <template v-if="typeIndex != 0">
- <el-table-column prop="pinYin" label="拼音" width="95" sortable>
- </el-table-column>
- </template>
- <el-table-column prop="gradeName" label="等次" width="95" sortable>
- <template slot-scope="item">
- <span
- :style="{
- color:
- item.row.gradeName && levelMap[item.row.gradeName]
- ? levelMap[item.row.gradeName].color
- : '',
- }"
- >{{ item.row.gradeName }}</span
- >
- </template>
- </el-table-column>
- <el-table-column prop="levelName" label="级别" width="106" sortable>
- <template slot-scope="item">
- <span
- :style="{
- color:
- item.row.levelName && levelMap[item.row.levelName]
- ? levelMap[item.row.levelName].color
- : '',
- }"
- >{{ item.row.levelName }}</span
- >
- </template>
- </el-table-column>
- <el-table-column prop="freq" label="频数" width="108" sortable>
- </el-table-column>
- <el-table-column prop="textRatio" label="比例" width="110" sortable>
- </el-table-column>
- <el-table-column prop="" label="备注">
- <template slot-scope="item">
- <div style="display: flex">
- <span
- v-for="(items, i) in item.row.remarks"
- :key=""
- class="beizhu"
- style="margin-right: 10px"
- >
- <span
- style="font-size: 18px; font-weight: 400"
- v-html="items.word"
- >
- </span>
- <span
- :style="{
- color:
- items.levelName && levelMap[items.levelName]
- ? levelMap[items.levelName].color
- : '',
- }"
- >
- {{ items.levelName }}
- </span>
- <span>
- {{ items.freq }}
- </span>
- </span>
- </div>
- </template>
- </el-table-column>
- </el-table> -->
- </div>
- <div class="page" v-if="dataList.list.length > 0">
- <el-pagination
- background
- @current-change="handleCurrentChange"
- :current-page="page"
- :page-size="pageSize"
- layout="prev, pager, next, jumper"
- :total="dataList.total"
- >
- </el-pagination>
- </div>
- </div>
- </div>
- </template>
- <script>
- //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
- //例如:import 《组件名称》from ‘《组件路径》';
- import Header from "@/components/Header.vue";
- import { postapi } from "@/api/api";
- import staticData from "../../common/data";
- import { json2excel } from "@/utils/setMethods";
- export default {
- //import引入的组件需要注入到对象中才能使用
- components: {
- Header,
- },
- props: {},
- data() {
- //这里存放数据
- return {
- typeIndex: 0,
- headText: 1,
- keyword: "",
- leve: null,
- leveList: [
- {
- value: null,
- label: "全部",
- },
- {
- value: 1,
- label: "初等",
- children: [
- { value: "100,101,102", label: "全部" },
- { value: "100", label: "1级" },
- { value: "101", label: "2级" },
- { value: "102", label: "3级" },
- ],
- },
- {
- value: 2,
- label: "中等",
- children: [
- { value: "103,104,105", label: "全部" },
- { value: "103", label: "4级" },
- { value: "104", label: "5级" },
- { value: "105", label: "6级" },
- ],
- },
- {
- value: 3,
- label: "高等",
- children: [{ value: "106", label: "7-9级" }],
- },
- {
- value: 107,
- label: "超纲",
- children: [{ value: "107", label: "超纲" }],
- },
- {
- value: 108,
- label: "专有",
- children: [{ value: "108", label: "专有" }],
- },
- {
- value: 109,
- label: "其它",
- children: [{ value: "109", label: "其它" }],
- },
- ],
- tableHeader: [
- {
- name: "序号",
- sortShow: false,
- width: "48px",
- },
- {
- name: "音节",
- sortShow: true,
- sort: "",
- width: "93px",
- sortName: "word",
- },
- {
- name: "拼音",
- sortShow: true,
- sort: "",
- width: "95px",
- sortName: "pin_yin",
- },
- {
- name: "等次",
- sortShow: true,
- sort: "",
- width: "95px",
- sortName: "grade_id",
- },
- {
- name: "级别",
- sortShow: true,
- sort: "down",
- width: "150px",
- sortName: "level_id",
- },
- {
- name: "频数",
- sortShow: true,
- sort: "",
- width: "88px",
- sortName: "freq",
- },
- {
- name: "比例",
- sortShow: true,
- sort: "",
- width: "90px",
- sortName: "word_ratio",
- },
- {
- name: "备注",
- sortShow: false,
- sort: "",
- width: "",
- sortName: "",
- },
- ],
- dataList: {
- list: [],
- },
- page: 1,
- pageSize: 10,
- partitionKey: null,
- searchType: null,
- levelMap: null,
- loading: false,
- sortType: 0,
- sortField: "level_id",
- routerData: null,
- };
- },
- //计算属性 类似于data概念
- computed: {},
- //监控data中数据变化
- watch: {},
- //方法集合
- methods: {
- // 下载
- download() {
- let data = JSON.parse(JSON.stringify(this.dataList.list));
- data.forEach((item) => {
- item.textRatio = item.textRatio + "%";
- let str = "";
- // 处理备注
- item.remarks.forEach((items) => {
- let node = document.createElement("span");
- node.innerHTML = items.word;
- str +=
- node.innerText +
- " " +
- items.levelName +
- " " +
- items.freq +
- " ";
- });
- item.remarksTxt = str;
- });
- let tHeader = [];
- let filterVal = [];
- this.tableHeader.forEach((item) => {
- tHeader.push(item.name);
- });
- if (this.typeIndex == 0) {
- tHeader.splice(2, 1);
- filterVal = [
- "number",
- "word",
- "gradeName",
- "levelName",
- "freq",
- "textRatio",
- "remarksTxt",
- ];
- } else {
- tHeader[1] = "汉字";
- filterVal = [
- "number",
- "word",
- "pinYin",
- "gradeName",
- "levelName",
- "freq",
- "textRatio",
- "remarksTxt",
- ];
- }
- var excelDatas = [
- {
- tHeader: tHeader,
- filterVal: filterVal, // 表一的数据字段
- tableDatas: data, // 表一的整体json数据
- sheetName: "sheet1", // 表一的sheet名字
- },
- ];
- //引入的函数
- json2excel(excelDatas, "词表", true, "xlsx");
- },
- // 返回并高亮对应数据
- backHighlight(item, color, type, index) {
- let data = JSON.parse(JSON.stringify(this.routerData));
- let arr = [];
- if (type == "all") {
- if (this.typeIndex == 0) {
- item.remarks.forEach((items) => {
- arr.push(items.word);
- });
- } else {
- arr.push(this.dataList.list[index].word);
- }
- } else {
- if (this.typeIndex == 0) {
- arr.push(item.word);
- } else {
- arr.push(this.dataList.list[index].word);
- }
- }
- data.remarks = JSON.stringify(arr);
- data.color = color;
- data.leftNavIndex = this.typeIndex;
- sessionStorage.setItem("tablehighlight", true);
- window.open(
- this.$router.resolve({
- path: "/textanalysis/Result",
- query: data,
- }).href,
- "_blank"
- );
- },
- handleCurrentChange(val) {
- this.page = val;
- this.getlist();
- },
- getlist() {
- this.loading = true;
- postapi({
- url: "/GCLSTCServer/tools/TS/glossary/list",
- data: {
- pageIndex: this.page,
- pageSize: this.pageSize,
- partitionKey: this.partitionKey,
- searchType: this.typeIndex,
- word: this.keyword,
- sortField: this.sortField,
- sortType: this.sortType,
- levels: this.leve ? this.leve[1] : null,
- },
- })
- .then((res) => {
- let num = this.page * this.pageSize - this.pageSize + 1;
- res.data.result.list.forEach((item) => {
- item.remarks = JSON.parse(item.remarks);
- item.number = num;
- num++;
- });
- this.dataList = res.data.result;
- this.loading = false;
- })
- .catch((res) => {
- this.loading = false;
- });
- },
- page1getdata() {
- this.loading = true;
- this.page = 1;
- this.getlist();
- },
- SortEvent(type, name, sortName) {
- let sort = "";
- this.tableHeader.forEach((item) => {
- if (item.name == name) {
- if (!item.sort || item.sort == "up") {
- item.sort = "down";
- sort = "down";
- } else if (item.sort == "down") {
- item.sort = "up";
- sort = "up";
- }
- } else {
- item.sort = "";
- }
- });
- if (sort == "down") {
- this.sortType = 1;
- } else {
- this.sortType = 0;
- }
- this.sortField = sortName;
- this.getlist();
- },
- sort_change(column, prop, order) {
- if (this.$refs.table) this.$refs.table.clearSort();
- column.column.order = column.order;
- if (column.prop == "pinyin") {
- this.sortField = "pin_yin";
- } else if (column.prop == "gradeName") {
- this.sortField = "grade_id";
- } else if (column.prop == "levelName") {
- this.sortField = "level_id";
- } else if (column.prop == "textRatio") {
- this.sortField = "text_ratio";
- } else {
- this.sortField = column.prop;
- }
- if (column.order == "descending") {
- this.sortType = 1;
- } else {
- this.sortType = 0;
- }
- this.getlist();
- },
- cutType(index) {
- this.typeIndex = index;
- this.page1getdata();
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {
- this.routerData = JSON.parse(JSON.stringify(this.$route.query));
- this.partitionKey = this.$route.query.partitionKey * 1;
- this.levelMap = staticData.LevelMap;
- this.getlist();
- },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- //生命周期-创建之前
- beforeCreated() {},
- //生命周期-挂载之前
- beforeMount() {},
- //生命周期-更新之前
- beforUpdate() {},
- //生命周期-更新之后
- updated() {},
- //生命周期-销毁之前
- beforeDestory() {},
- //生命周期-销毁完成
- destoryed() {},
- //如果页面有keep-alive缓存功能,这个函数会触发
- activated() {},
- };
- </script>
- <style lang="scss" scoped>
- /* @import url(); 引入css类 */
- .WordTable {
- background: #f6f6f6;
- min-height: 100%;
- .wheader {
- background: #ffffff;
- }
- .main {
- width: 1200px;
- margin: 23px auto;
- .top {
- display: flex;
- justify-content: space-between;
- .left {
- display: flex;
- align-items: center;
- .type_dv {
- margin-right: 40px;
- display: flex;
- > .sele {
- padding: 0 2px;
- height: 40px;
- background: #eeeeee;
- border-radius: 4px;
- display: flex;
- align-items: center;
- span {
- display: inline-block;
- height: 36px;
- width: 56px;
- font-weight: 400;
- font-size: 14px;
- line-height: 40px;
- text-align: center;
- color: #888888;
- cursor: pointer;
- }
- .sele {
- color: #000000;
- background: #ffffff;
- box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.08);
- }
- }
- > .down {
- cursor: pointer;
- font-weight: 400;
- font-size: 14px;
- line-height: 22px;
- color: #000000;
- display: flex;
- align-items: center;
- margin-left: 24px;
- img {
- margin-right: 4px;
- width: 24px;
- height: 24px;
- }
- }
- }
- }
- .right {
- display: flex;
- align-items: center;
- .seek {
- display: flex;
- width: 264px;
- height: 40px;
- background: #ffffff;
- border: 1px solid #dddddd;
- border-radius: 2px 0px 0px 2px;
- img {
- width: 16px;
- height: 16px;
- margin: 12px 4px 12px 12px;
- }
- input {
- flex: 1;
- border: none;
- outline: none;
- background: none;
- height: 40px;
- }
- }
- .seekBtn {
- width: 56px;
- height: 40px;
- background: #ffa800;
- border: 1px solid #ffa800;
- border-radius: 0px 2px 2px 0px;
- cursor: pointer;
- font-weight: 400;
- font-size: 16px;
- line-height: 40px;
- text-align: center;
- color: #ffffff;
- }
- }
- }
- .table {
- margin-top: 21px;
- .no_data {
- background: #ffffff;
- text-align: center;
- height: 60px;
- line-height: 60px;
- color: #909399;
- }
- table {
- width: 100%;
- border-collapse: collapse;
- background: #ffffff;
- .pinyin {
- font-family: "GB-PINYINOK-B";
- }
- .hanzi {
- text-align: left !important;
- }
- .jb {
- > div {
- justify-content: flex-end !important;
- .sort {
- margin-left: 10px;
- }
- }
- }
- th {
- background: #ffffff;
- .bz {
- flex: 1;
- }
- > div {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 8px;
- height: 48px;
- .sort {
- cursor: pointer;
- > div {
- img {
- width: 11px;
- height: 11px;
- }
- }
- > :nth-child(1) {
- > img {
- position: relative;
- top: 3px;
- }
- }
- > :nth-child(2) {
- > img {
- position: relative;
- bottom: 7px;
- }
- }
- }
- }
- }
- td {
- height: 40px;
- line-height: 40px;
- text-align: left;
- border-bottom: 1px solid #eeeeee;
- font-weight: 400;
- font-size: 14px;
- }
- .sort-td {
- padding: 0 9px;
- text-align: center;
- }
- }
- }
- .page {
- margin-top: 24px;
- }
- .beizhu {
- margin-top: 8px;
- margin-bottom: 8px;
- height: 28px;
- display: inline-block;
- border: 1px solid;
- // background: #f9f9f9;
- border-radius: 4px;
- display: flex;
- align-items: center;
- font-size: 16px;
- font-weight: 500;
- padding-left: 4px;
- padding-right: 7px;
- > :not(:nth-last-child(1)) {
- margin-right: 8px;
- }
- }
- }
- }
- </style>
- <style lang="scss">
- .WordTable {
- .table {
- .el-table th {
- background: #ffffff;
- padding: 7px 0;
- }
- .el-table th > .cell {
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-weight: 700;
- color: #333333;
- font-size: 14px;
- }
- .el-table td {
- padding: 8px 0;
- }
- .el-table td > .cell {
- font-size: 14px;
- line-height: 22px;
- color: #333333;
- font-weight: 600;
- }
- }
- .el-radio__input.is-checked + .el-radio__label {
- color: #000000;
- }
- .el-radio__input.is-checked .el-radio__inner {
- border: 2px solid #c8c8c8;
- background: #1e1e1e;
- }
- .el-radio__inner::after {
- background: none;
- }
- .el-radio__inner {
- background: #c8c8c8;
- border: none;
- }
- .el-pagination.is-background .el-pager li:not(.disabled).active {
- background: #ffffff !important;
- color: rgba(0, 0, 0, 0.85);
- border: 1px solid #333333;
- }
- .el-pager {
- .number {
- background: #ffffff !important;
- border: 1px solid #d9d9d9;
- border-radius: 2px;
- }
- }
- .btn-prev,
- .btn-next {
- border: 1px solid #d9d9d9;
- border-radius: 2px;
- background: #ffffff !important;
- }
- }
- </style>
|