SegwordConfig.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <!-- -->
  2. <template>
  3. <div class="seg-word-config">
  4. <div
  5. class="adult-book-input-item"
  6. v-if="
  7. curQue &&
  8. type != 'sentence_segtemp_chs' &&
  9. type != 'sort_chs' &&
  10. type != 'sentence_listen_read_chs'
  11. "
  12. style="margin-top: 10px"
  13. >
  14. <span class="adult-book-lable">字的大小:</span>
  15. <el-radio-group
  16. v-model="curQue.resetFontsize"
  17. @input="changeResetFontsize"
  18. >
  19. <el-radio label="12px">12px</el-radio>
  20. <el-radio label="16px">16px</el-radio>
  21. <el-radio label="20px">20px</el-radio>
  22. <el-radio label="24px">24px</el-radio>
  23. <el-radio label="28px">28px</el-radio>
  24. </el-radio-group>
  25. </div>
  26. <div
  27. class="adult-book-input-item"
  28. v-if="
  29. curQue &&
  30. type != 'sentence_segtemp_chs' &&
  31. type != 'sort_chs' &&
  32. type != 'sentence_listen_read_chs'
  33. "
  34. >
  35. <span class="adult-book-lable">字体:</span>
  36. <el-radio-group
  37. v-model="curQue.resetFontfamily"
  38. @input="changeResetFontfamily"
  39. >
  40. <el-radio
  41. v-for="(item, index) in fontFamilyList"
  42. :key="'fontFamilyList' + index"
  43. :label="item.value"
  44. >
  45. <span>{{ item.name }}</span>
  46. </el-radio>
  47. </el-radio-group>
  48. </div>
  49. <el-table :data="data" border style="width: 75%">
  50. <el-table-column prop="chs" label="词" width="120">
  51. <template slot-scope="scope">
  52. <div class="adult-book-input-item">
  53. <el-input
  54. size="small"
  55. v-model="scope.row.chs"
  56. placeholder="请输入词"
  57. @blur="onBlur(scope.row, 'chs')"
  58. ></el-input>
  59. </div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="拼音" width="220">
  63. <template slot-scope="scope">
  64. <div class="adult-book-input-item">
  65. <el-input
  66. size="small"
  67. v-model="scope.row.pinyin"
  68. placeholder="请输入拼音"
  69. @blur="onBlur(scope.row, 'pinyin')"
  70. style="margin-right: 10px"
  71. ></el-input>
  72. <el-button size="small" @click="_createWordPinyin(scope.row)"
  73. >生成拼音</el-button
  74. >
  75. </div>
  76. </template>
  77. </el-table-column>
  78. <el-table-column
  79. label="配置"
  80. v-if="
  81. type != 'sort_chs' &&
  82. type != 'sentence_listen_read_chs'
  83. "
  84. >
  85. <template slot-scope="scope">
  86. <div class="adult-book-input-item">
  87. <span class="adult-book-lable">字的大小:</span>
  88. <el-radio-group v-model="scope.row.fontSize">
  89. <el-radio label="12px">12px</el-radio>
  90. <el-radio label="16px">16px</el-radio>
  91. <el-radio label="20px">20px</el-radio>
  92. <el-radio label="24px">24px</el-radio>
  93. <el-radio label="28px">28px</el-radio>
  94. </el-radio-group>
  95. </div>
  96. <!-- <div class="adult-book-input-item">
  97. <span class="adult-book-lable">字的颜色:</span>
  98. <el-radio-group v-model="scope.row.fontColor">
  99. <el-radio
  100. v-for="(item, index) in colorList"
  101. :key="'colorList' + index"
  102. :label="item.value"
  103. >
  104. <span
  105. :style="{
  106. backgroundColor: item.value == 'sub' ? '' : item.value,
  107. }"
  108. :class="item.value != 'sub' ? 'colorItem' : ''"
  109. >{{ item.value == "sub" ? "书的辅助色" : "" }}</span
  110. >
  111. </el-radio>
  112. </el-radio-group>
  113. </div> -->
  114. <div class="adult-book-input-item">
  115. <span class="adult-book-lable">字体:</span>
  116. <el-radio-group v-model="scope.row.fontFamily">
  117. <el-radio
  118. v-for="(item, index) in fontFamilyList"
  119. :key="'fontFamilyList' + index"
  120. :label="item.value"
  121. >
  122. <span>{{ item.name }}</span>
  123. </el-radio>
  124. </el-radio-group>
  125. </div>
  126. <div class="adult-book-input-item">
  127. <span class="adult-book-lable">设置下划线:</span>
  128. <el-checkbox v-model="scope.row.underLine">显示下划线</el-checkbox>
  129. </div>
  130. <div
  131. class="adult-book-input-item"
  132. v-if="
  133. type != 'sentence_segtemp_chs' &&
  134. type != 'dialogue_answer_chs' &&
  135. type != 'sentence_input_chs' &&
  136. type != 'sentence_judge_chs' &&
  137. type != 'sentence_record_chs' &&
  138. type != 'sentence_input_record_chs' &&
  139. type != 'sentence_listen_read_chs'
  140. "
  141. >
  142. <span class="adult-book-lable">设置间距:</span>
  143. <el-checkbox-group v-model="scope.row.wordPadding">
  144. <el-checkbox
  145. v-for="(item, index) in paddingList"
  146. :key="'colorList' + index"
  147. :label="item.value"
  148. >
  149. {{ item.name }}
  150. </el-checkbox>
  151. </el-checkbox-group>
  152. </div>
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. </div>
  157. </template>
  158. <script>
  159. import "@/utils/pinyin_dict_withtone";
  160. import "@/utils/pinyinUtil";
  161. export default {
  162. components: {},
  163. props: ["data", "type", "curQue"],
  164. data() {
  165. return {
  166. colorList: [
  167. {
  168. value: "#000",
  169. name: "黑色",
  170. },
  171. {
  172. value: "sub",
  173. name: "主题色",
  174. },
  175. ],
  176. paddingList: [
  177. {
  178. value: "left",
  179. name: "要左边距",
  180. },
  181. {
  182. value: "right",
  183. name: "要右边距",
  184. },
  185. ],
  186. fontFamilyList: [
  187. {
  188. value: "FZJCGFKTK",
  189. name: "使用中文字体",
  190. },
  191. {
  192. value: "Sans-GBNPC",
  193. name: "使用拼音字体",
  194. },
  195. {
  196. value: "robot",
  197. name: "使用英文字体",
  198. },
  199. {
  200. value: "Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif",
  201. name: "系统字体",
  202. },
  203. ],
  204. };
  205. },
  206. computed: {},
  207. watch: {},
  208. //方法集合
  209. methods: {
  210. onBlur(item, field) {
  211. item[field] = item[field] ? item[field].trim() : "";
  212. },
  213. _createWordPinyin(item) {
  214. let result = pinyinUtil.getPinyin(item.chs);
  215. item.pinyin = result;
  216. },
  217. changeResetFontsize(value) {
  218. this.data.forEach((item) => {
  219. item.fontSize = value;
  220. });
  221. },
  222. changeResetFontfamily(value) {
  223. this.data.forEach((item) => {
  224. item.fontFamily = value;
  225. });
  226. },
  227. },
  228. //生命周期 - 创建完成(可以访问当前this实例)
  229. created() {},
  230. //生命周期 - 挂载完成(可以访问DOM元素)
  231. mounted() {
  232. if (this.curQue) {
  233. if (!this.curQue.hasOwnProperty("resetFontsize")) {
  234. this.$set(this.curQue, "resetFontsize", "");
  235. }
  236. if (!this.curQue.hasOwnProperty("resetFontfamily")) {
  237. this.$set(this.curQue, "resetFontfamily", "FZJCGFKTK");
  238. }
  239. }
  240. },
  241. beforeCreate() {}, //生命周期 - 创建之前
  242. beforeMount() {}, //生命周期 - 挂载之前
  243. beforeUpdate() {}, //生命周期 - 更新之前
  244. updated() {}, //生命周期 - 更新之后
  245. beforeDestroy() {}, //生命周期 - 销毁之前
  246. destroyed() {}, //生命周期 - 销毁完成
  247. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  248. };
  249. </script>
  250. <style lang='scss' scoped>
  251. //@import url(); 引入公共css类
  252. .adult-book-input-item {
  253. display: flex;
  254. justify-content: flex-start;
  255. align-items: flex-start;
  256. margin-bottom: 10px;
  257. }
  258. .adult-book-lable {
  259. width: 80px;
  260. font-size: 14px;
  261. display: block;
  262. text-align: right;
  263. margin-right: 8px;
  264. font-weight: bold;
  265. &-bottom {
  266. margin-bottom: 10px;
  267. display: block;
  268. }
  269. }
  270. .el-radio-group {
  271. flex: 1;
  272. display: flex;
  273. flex-wrap: wrap;
  274. margin-top: 5px;
  275. }
  276. .el-radio {
  277. display: flex;
  278. justify-content: flex-start;
  279. align-items: center;
  280. margin-bottom: 6px;
  281. }
  282. .colorItem {
  283. width: 20px;
  284. height: 20px;
  285. border-radius: 100%;
  286. display: block;
  287. }
  288. </style>