SegwordConfig.vue 9.2 KB

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