CheckStyle.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <div class="check-article">
  3. <div class="main">
  4. <div class="main-top">
  5. <div style="display: flex">
  6. <b>校对样式</b>
  7. </div>
  8. <!-- <div class="btn-box">
  9. <el-button type="primary" @click="savePinyin">保存</el-button>
  10. </div> -->
  11. </div>
  12. <div class="article">
  13. <div v-for="(item, index) in indexArr" :key="index + 'paragraph'" class="paragraph">
  14. <div v-for="(items, indexs) in item" :key="indexs + 'words'" class="sentence-box">
  15. <div
  16. class="sentence"
  17. :style="{
  18. marginRight: items.marginRight ? '8px' : '',
  19. color: activeIndex === index + '_' + items.sentenceIndex + '_' + items.wordIndex ? '#F2555A' : '',
  20. }"
  21. @click="selectItem(items, index)"
  22. >
  23. <span
  24. class="words"
  25. :class="[/^[0-9]*$/.test(items.text)] ? (/^[\u4e00-\u9fa5]/.test(items.text) ? 'hanzi' : 'en') : ''"
  26. >
  27. {{ items.text }}
  28. </span>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <el-dialog
  35. v-if="dialogFlag"
  36. :visible.sync="dialogFlag"
  37. :show-close="false"
  38. :close-on-click-modal="false"
  39. :modal-append-to-body="false"
  40. :modal="false"
  41. width="250px"
  42. class="login-dialog"
  43. >
  44. <div class="check-box">
  45. <div class="content">
  46. <div class="words-box">
  47. <span class="words">
  48. {{ itemActive.text }}
  49. </span>
  50. </div>
  51. </div>
  52. <el-form>
  53. <el-form-item label="字体">
  54. <el-radio-group v-model="itemActive.fontFamily">
  55. <el-radio v-for="(item, index) in fontFamilyList" :key="'fontFamilyList' + index" :label="item.value">
  56. <span>{{ item.name }}</span>
  57. </el-radio>
  58. </el-radio-group>
  59. </el-form-item>
  60. </el-form>
  61. <div class="btn-box">
  62. <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
  63. <el-button type="primary" size="small" @click="surePinyin">保存</el-button>
  64. </div>
  65. </div>
  66. </el-dialog>
  67. </div>
  68. </template>
  69. <script>
  70. // import { publicMethods, reparse } from '@/api/api';
  71. import th from 'element-ui/lib/locale/lang/th';
  72. export default {
  73. components: {},
  74. props: ['data'],
  75. data() {
  76. return {
  77. loading: false,
  78. id: '',
  79. ArticelData: null,
  80. indexArr: [], // 索引数组
  81. activeIndex: null,
  82. itemActive: null,
  83. dialogFlag: false,
  84. checkPinyinInput: '',
  85. oldInput: '',
  86. tableData: [
  87. ['ā', 'á', 'ǎ', 'à', 'a'],
  88. ['ō', 'ó', 'ǒ', 'ò', 'o'],
  89. ['ē', 'é', 'ě', 'è', 'e'],
  90. ['ī', 'í', 'ǐ', 'ì', 'i'],
  91. ['ū', 'ú', 'ǔ', 'ù', 'u'],
  92. ['ǖ', 'ǘ', 'ǚ', 'ǜ', 'ü'],
  93. ['Ā', 'Á', 'Â', 'À', 'A'],
  94. ['Ō', 'Ó', 'Ô', 'Ò', 'O'],
  95. ['Ē', 'É', 'Ê', 'È', 'E'],
  96. ['Ī', 'Í', 'Î', 'Ì', 'I'],
  97. ['Ū', 'Ú', 'Û', 'Ù', 'U'],
  98. ['n', 'ń', 'ň', 'ǹ', 'n'],
  99. ['m̄', 'ḿ', 'm', 'm̀', 'n'],
  100. ],
  101. toneList: [' ', 'ˉ', 'ˊ', 'ˇ', 'ˋ'],
  102. fontFamilyList: [
  103. {
  104. value: '楷体',
  105. name: '中文',
  106. },
  107. {
  108. value: 'Sans-GBNPC',
  109. name: '拼音',
  110. },
  111. {
  112. value: 'robot',
  113. name: '英文',
  114. },
  115. {
  116. value: 'Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif, alabo',
  117. name: '系统字体',
  118. },
  119. ],
  120. };
  121. },
  122. // 生命周期 - 创建完成(可以访问当前this实例)
  123. created() {
  124. this.getArticleData();
  125. },
  126. methods: {
  127. // 获取分析结果
  128. getArticleData() {
  129. this.loading = true;
  130. let newdata = [];
  131. this.data.detail.forEach((item) => {
  132. if (item.wordsList.length !== 0) {
  133. newdata.push(item);
  134. }
  135. });
  136. // this.ArticelData = JSON.parse(JSON.stringify(newdata));
  137. let saveArr = [];
  138. let arr = [];
  139. let saveIndex = 0;
  140. // 添加索引
  141. newdata.forEach((item, index) => {
  142. arr.push([]);
  143. item.wordsList.forEach((items, indexs) => {
  144. items.forEach((itemss, indexss) => {
  145. let obj = {
  146. text: itemss.chs,
  147. paraIndex: index,
  148. sentenceIndex: indexs,
  149. wordIndex: indexss,
  150. marginRight: true,
  151. saveIndex,
  152. fontFamily: itemss.fontFamily,
  153. };
  154. arr[index].push(obj);
  155. let saveObj = {
  156. word: itemss.chs,
  157. // pinyin_lt: itemss.pinyin_lt?itemss.pinyin_lt:''
  158. };
  159. saveArr.push(saveObj);
  160. saveIndex++;
  161. });
  162. });
  163. });
  164. this.indexArr = arr;
  165. this.ArticelData = saveArr;
  166. this.loading = false;
  167. },
  168. selectItem(item, index) {
  169. this.activeIndex = `${index}_${item.sentenceIndex}_${item.wordIndex}`;
  170. this.itemActive = item;
  171. this.dialogFlag = true;
  172. this.checkPinyinInput = '';
  173. },
  174. cancleDialog() {
  175. this.activeIndex = null;
  176. this.itemActive = null;
  177. this.checkPinyinInput = '';
  178. this.oldInput = '';
  179. this.dialogFlag = false;
  180. },
  181. surePinyin() {
  182. this.saveStyle();
  183. this.dialogFlag = false;
  184. },
  185. saveStyle() {
  186. this.$emit(
  187. 'saveStyle',
  188. this.itemActive.paraIndex,
  189. this.itemActive.sentenceIndex,
  190. this.itemActive.wordIndex,
  191. this.itemActive.fontFamily,
  192. );
  193. this.$message.success('保存成功');
  194. this.activeIndex = null;
  195. // this.itemActive = null;
  196. this.dialogFlag = false;
  197. },
  198. },
  199. };
  200. </script>
  201. <style lang="scss" scoped>
  202. .check-article {
  203. min-height: 100%;
  204. background: #f6f6f6;
  205. .wheader {
  206. background: #fff;
  207. }
  208. .el-button {
  209. padding: 5px 16px;
  210. font-size: 14px;
  211. font-weight: 400;
  212. line-height: 22px;
  213. color: #4e5969;
  214. background: #f2f3f5;
  215. border: 1px solid #f2f3f5;
  216. border-radius: 2px;
  217. &.el-button--primary {
  218. color: #fff;
  219. background: #165dff;
  220. border: 1px solid #165dff;
  221. }
  222. }
  223. .main {
  224. background: #fff;
  225. &-top {
  226. position: relative;
  227. display: flex;
  228. align-items: center;
  229. justify-content: space-between;
  230. margin-bottom: 24px;
  231. b {
  232. margin-left: 16px;
  233. font-size: 24px;
  234. font-weight: 500;
  235. line-height: 34px;
  236. color: #000;
  237. }
  238. }
  239. .go-back {
  240. display: flex;
  241. align-items: center;
  242. width: 60px;
  243. padding: 5px 8px;
  244. font-size: 14px;
  245. font-weight: 400;
  246. line-height: 22px;
  247. color: #333;
  248. cursor: pointer;
  249. background: #fff;
  250. border: 1px solid #d9d9d9;
  251. border-radius: 4px;
  252. box-shadow: 0 2px 0 0 rgba(0, 0, 0, 2%);
  253. .el-icon-arrow-left {
  254. margin-right: 8px;
  255. font-size: 16px;
  256. }
  257. }
  258. .article {
  259. padding: 8px;
  260. background: #fcfcfc;
  261. border: 1px solid rgba(0, 0, 0, 8%);
  262. border-radius: 2px;
  263. }
  264. .paragraph {
  265. display: flex;
  266. flex-flow: wrap;
  267. width: 100%;
  268. margin-bottom: 24px;
  269. text-align: center;
  270. .sentence-box {
  271. display: flex;
  272. flex-flow: wrap;
  273. float: left;
  274. .sentence {
  275. margin-top: 8px;
  276. color: #000;
  277. text-align: center;
  278. cursor: pointer;
  279. .words {
  280. display: block;
  281. font-size: 20px;
  282. font-weight: 400;
  283. line-height: 28px;
  284. }
  285. .pinyin {
  286. display: block;
  287. height: 14px;
  288. font-family: 'League';
  289. font-size: 14px;
  290. font-weight: 400;
  291. line-height: 1;
  292. }
  293. }
  294. }
  295. }
  296. }
  297. }
  298. .check-box {
  299. padding: 24px;
  300. background: #fff;
  301. border-radius: 4px;
  302. box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 25%);
  303. .content {
  304. display: flex;
  305. align-items: center;
  306. justify-content: center;
  307. .words-box {
  308. color: #000;
  309. text-align: center;
  310. .words {
  311. display: block;
  312. font-size: 28px;
  313. font-weight: 400;
  314. line-height: 40px;
  315. }
  316. .pinyin {
  317. display: block;
  318. height: 20px;
  319. font-family: 'League';
  320. font-size: 20px;
  321. font-weight: 400;
  322. line-height: 1;
  323. }
  324. }
  325. }
  326. .checkPinyinInput {
  327. margin: 16px 0 8px;
  328. }
  329. .tips {
  330. margin: 0 0 24px;
  331. font-size: 12px;
  332. font-weight: 400;
  333. line-height: 18px;
  334. color: #a0a0a0;
  335. }
  336. .btn-box {
  337. text-align: right;
  338. .el-button {
  339. padding: 2px 12px;
  340. font-size: 12px;
  341. line-height: 20px;
  342. }
  343. }
  344. }
  345. </style>
  346. <style lang="scss">
  347. .check-article {
  348. .login-dialog {
  349. .el-dialog__header {
  350. padding: 0;
  351. }
  352. .el-dialog__body {
  353. padding: 0;
  354. }
  355. .el-input__inner {
  356. text-align: center;
  357. background: #f3f3f3;
  358. }
  359. }
  360. }
  361. </style>