SentenceSegTemp.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <!-- -->
  2. <template>
  3. <div class="sentence-seg-temp" v-if="detail">
  4. <div class="seg-congfig">
  5. <div class="adult-book-input-item">
  6. <span
  7. class="adult-book-lable"
  8. style="line-height: 32px; margin-left: 10px"
  9. >横线长度:</span
  10. >
  11. <el-select v-model="detail.hengLeg" placeholder="请选择" size="small">
  12. <el-option
  13. v-for="item in inputLegOptions"
  14. :key="item.value"
  15. :label="item.name"
  16. :value="item.value"
  17. >
  18. </el-option>
  19. </el-select>
  20. </div>
  21. <div class="adult-book-input-item" v-if="type !== 'config_table'">
  22. <el-button type="primary" size="small" @click="setConfig" style="margin"
  23. >功能设置</el-button
  24. >
  25. <!-- <ul class="check-fn-list">
  26. <li v-if="items && items.fn_check_list.sent_check">
  27. {{ items.fn_check_list.sent_check | getFnName(fn_list) }}
  28. </li>
  29. <li v-if="items && items.fn_check_list.short_check">
  30. {{ items.fn_check_list.short_check | getFnName(fn_list) }}
  31. </li>
  32. <li v-if="items && items.fn_check_list.long_check">
  33. {{ items.fn_check_list.long_check | getFnName(fn_list) }}
  34. </li>
  35. <li v-if="items && items.fn_check_list.judge_check">
  36. {{ items.fn_check_list.judge_check | getFnName(fn_list) }}
  37. </li>
  38. <li v-if="items && items.fn_check_list.checkbox_check">
  39. {{ items.fn_check_list.checkbox_check | getFnName(fn_list) }}
  40. </li>
  41. <li v-if="items && items.fn_check_list.radio_check">
  42. {{ items.fn_check_list.radio_check | getFnName(fn_list) }}
  43. </li>
  44. <li v-if="items && items.fn_check_list.record_check">
  45. {{ items.fn_check_list.record_check | getFnName(fn_list) }}
  46. </li>
  47. </ul> -->
  48. </div>
  49. </div>
  50. <div class="adult-book-input-item">
  51. <span class="adult-book-lable">句子缩进:</span>
  52. <el-radio-group v-model="detail.textindent">
  53. <el-radio :label="true">是</el-radio>
  54. <el-radio :label="false">否</el-radio>
  55. </el-radio-group>
  56. </div>
  57. <div
  58. class="sentence-option"
  59. v-for="(dItem, dIndex) in detail.detail"
  60. :key="'items.detail' + dIndex"
  61. >
  62. <div class="adult-book-input-item adult-book-input-item-center">
  63. <span class="adult-book-lable">元素{{ dIndex + 1 }}.</span>
  64. <el-button size="small" @click="deleteElement(dIndex)"
  65. >删除元素</el-button
  66. >
  67. <el-button
  68. type="primary"
  69. size="small"
  70. icon="el-icon-top"
  71. @click="moveElement(dItem, dIndex, 'up')"
  72. >上移</el-button
  73. >
  74. <el-button
  75. type="primary"
  76. size="small"
  77. icon="el-icon-bottom"
  78. @click="moveElement(dItem, dIndex, 'down')"
  79. >下移</el-button
  80. >
  81. </div>
  82. <template>
  83. <SentenceSegwordChs
  84. :curQue="dItem"
  85. :segModel="segModel"
  86. name="元素"
  87. :type="type"
  88. />
  89. <div class="adult-book-input-item" style="margin-top: 10px">
  90. <span class="adult-book-lable">图片:</span>
  91. <Upload
  92. :changeFillId="timuchangeImage"
  93. :datafileList="dItem.img_list ? dItem.img_list : []"
  94. :filleNumber="1"
  95. :uploadType="'image'"
  96. :index="dIndex"
  97. />
  98. </div>
  99. </template>
  100. <template>
  101. <div class="adult-book-input-item adult-book-input-item-center">
  102. <span class="adult-book-lable">字体:</span>
  103. <el-radio-group
  104. v-model="dItem.config.fontFamily"
  105. @input="value => changefontFamily(value, dItem)"
  106. >
  107. <el-radio
  108. v-for="(item, index) in fontFamilyList"
  109. :key="'fontFamilyList' + index"
  110. :label="item.value"
  111. >
  112. <span>{{ item.name }}</span>
  113. </el-radio>
  114. </el-radio-group>
  115. </div>
  116. <div class="adult-book-input-item adult-book-input-item-center">
  117. <span class="adult-book-lable">字的大小:</span>
  118. <el-radio-group
  119. v-model="dItem.config.fontSize"
  120. @input="value => changefontSize(value, dItem)"
  121. >
  122. <el-radio label="12px">12px</el-radio>
  123. <el-radio label="16px">16px</el-radio>
  124. <el-radio label="20px">20px</el-radio>
  125. <el-radio label="24px">24px</el-radio>
  126. <el-radio label="28px">28px</el-radio>
  127. </el-radio-group>
  128. </div>
  129. <!-- <div class="adult-book-input-item adult-book-input-item-center">
  130. <span class="adult-book-lable">字的颜色:</span>
  131. <el-radio-group v-model="dItem.config.fontColor">
  132. <el-radio
  133. v-for="(item, index) in colorList"
  134. :key="'colorList' + index"
  135. :label="item.value"
  136. >
  137. <span
  138. :style="{
  139. backgroundColor: item.value == 'sub' ? '' : item.value,
  140. }"
  141. :class="item.value != 'sub' ? 'colorItem' : ''"
  142. >{{ item.value == "sub" ? "书的辅助色" : "" }}</span
  143. >
  144. </el-radio>
  145. </el-radio-group>
  146. </div> -->
  147. <div class="adult-book-input-item adult-book-input-item-center">
  148. <span class="adult-book-lable">设置间距:</span>
  149. <el-checkbox-group v-model="dItem.config.wordPadding">
  150. <el-checkbox
  151. v-for="(item, index) in paddingList"
  152. :key="'paddingList' + index"
  153. :label="item.value"
  154. >
  155. {{ item.name }}
  156. </el-checkbox>
  157. </el-checkbox-group>
  158. </div>
  159. <div class="adult-book-input-item">
  160. <span class="adult-book-lable">输入内容:</span>
  161. <el-radio-group v-model="dItem.config.conAlign">
  162. <el-radio label="left">左对齐</el-radio>
  163. <el-radio label="center">居中对齐</el-radio>
  164. </el-radio-group>
  165. </div>
  166. </template>
  167. </div>
  168. <el-button @click="addElement()" style="margin-bottom: 10px"
  169. >添加元素</el-button
  170. >
  171. <!-- <div class="adult-book-input-item">
  172. <span class="adult-book-lable">英文:</span>
  173. <el-input
  174. v-model="detail.en"
  175. type="textarea"
  176. placeholder="请输入英文翻译"
  177. />
  178. </div> -->
  179. <el-dialog
  180. title="功能设置"
  181. :close-on-click-modal="false"
  182. :modal-append-to-body="false"
  183. append-to-body
  184. :visible.sync="configVisible"
  185. width="80%"
  186. >
  187. <FnConfig :items="items" :config="queConfig" />
  188. <span slot="footer" class="dialog-footer">
  189. <el-button @click="configVisible = false">取 消</el-button>
  190. <el-button type="primary" @click="saveConfig">确 定</el-button>
  191. </span>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import SentenceSegwordChs from "./SentenceSegwordChs";
  197. import FnConfig from "./FnConfig.vue";
  198. import Upload from "./Upload.vue";
  199. export default {
  200. components: {
  201. SentenceSegwordChs,
  202. FnConfig,
  203. Upload
  204. },
  205. props: ["detail", "segModel", "type"],
  206. data() {
  207. return {
  208. inputLegOptions: [
  209. {
  210. name: "系统默认值",
  211. value: -1
  212. },
  213. {
  214. name: "约1个汉字的宽度",
  215. value: 1
  216. },
  217. {
  218. name: "约2个汉字的宽度",
  219. value: 2
  220. },
  221. {
  222. name: "约3个汉字的宽度",
  223. value: 3
  224. },
  225. {
  226. name: "约4个汉字的宽度",
  227. value: 4
  228. },
  229. {
  230. name: "约5个汉字的宽度",
  231. value: 5
  232. }
  233. ],
  234. colorList: [
  235. {
  236. value: "#000",
  237. name: "黑色"
  238. },
  239. {
  240. value: "sub",
  241. name: "辅助色"
  242. },
  243. {
  244. value: "#FF8730",
  245. name: "橙色"
  246. },
  247. {
  248. value: "#3CB4E7",
  249. name: "蓝色"
  250. },
  251. {
  252. value: "#ED5050",
  253. name: "浅红色"
  254. },
  255. {
  256. value: "#FF3F3F",
  257. name: "红色"
  258. }
  259. ],
  260. paddingList: [
  261. {
  262. value: "left",
  263. name: "要左边距"
  264. },
  265. {
  266. value: "right",
  267. name: "要右边距"
  268. }
  269. ],
  270. fontFamilyList: [
  271. {
  272. value: "楷体,FZJCGFKTK",
  273. name: "使用中文字体"
  274. },
  275. {
  276. value: "Sans-GBNPC",
  277. name: "使用拼音字体"
  278. },
  279. {
  280. value: "robot",
  281. name: "使用英文字体"
  282. },
  283. {
  284. value:
  285. "Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif, alabo",
  286. name: "系统字体"
  287. },
  288. {
  289. value: "math",
  290. name: "公式字体"
  291. }
  292. ],
  293. configVisible: false,
  294. items: null,
  295. queConfig: {
  296. fn_record_list: [
  297. {
  298. type: "sentence_record_mini_chs",
  299. name: "录音控件-mini",
  300. isFn: false
  301. },
  302. {
  303. type: "sentence_record_normal_chs",
  304. name: "录音控件-normal",
  305. isFn: false
  306. },
  307. {
  308. type: "sentence_record_pro_chs",
  309. name: "录音控件-pro",
  310. isFn: false
  311. },
  312. {
  313. type: "sentence_record_promax_chs",
  314. name: "录音控件-promax",
  315. isFn: false
  316. }
  317. ]
  318. }
  319. };
  320. },
  321. computed: {},
  322. watch: {},
  323. //方法集合
  324. methods: {
  325. changefontFamily(value, dItem) {
  326. // if (value == "楷体") {
  327. // dItem.config.fontSize = "16px";
  328. // } else if (value == "Sans-GBNPC") {
  329. // dItem.config.fontSize = "16px";
  330. // } else if (value == "robot") {
  331. // dItem.config.fontSize = "16px";
  332. // }
  333. if (dItem && dItem.wordsList && dItem.wordsList.length > 0) {
  334. dItem.wordsList.forEach((item, index) => {
  335. item.fontFamily = value;
  336. });
  337. }
  338. },
  339. changefontSize(value, dItem) {
  340. if (dItem && dItem.wordsList && dItem.wordsList.length > 0) {
  341. dItem.wordsList.forEach((item, index) => {
  342. item.fontSize = value;
  343. });
  344. }
  345. },
  346. addElement() {
  347. let obj = {
  348. pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
  349. sentence: "", //句子
  350. segList: [], //分词结果
  351. seg_words: "",
  352. wordsList: [],
  353. hengList: [],
  354. config: {
  355. fontSize: "20px",
  356. fontColor: "#000",
  357. fontFamily: "楷体,FZJCGFKTK",
  358. wordPadding: [],
  359. conAlign: "center"
  360. }
  361. };
  362. this.detail.detail.push(JSON.parse(JSON.stringify(obj)));
  363. },
  364. deleteElement(index) {
  365. this.detail.detail.splice(index, 1);
  366. },
  367. moveElement(dItem, index, type) {
  368. let obj = JSON.parse(JSON.stringify(dItem));
  369. if (type == "up" && index > 0) {
  370. this.detail.detail.splice(index - 1, 0, obj);
  371. this.detail.detail.splice(index + 1, 1);
  372. }
  373. if (type == "down" && index < this.detail.detail.length - 1) {
  374. this.detail.detail[index] = this.detail.detail.splice(
  375. index + 1,
  376. 1,
  377. this.detail.detail[index]
  378. )[0];
  379. }
  380. },
  381. //功能设置
  382. setConfig() {
  383. this.configVisible = true;
  384. this.items = JSON.parse(JSON.stringify(this.detail));
  385. },
  386. saveConfig() {
  387. this.configVisible = false;
  388. this.$set(this.detail, "fn_check_list", this.items.fn_check_list);
  389. },
  390. timuchangeImage(fileList, duration, index) {
  391. const articleImgList = JSON.parse(JSON.stringify(fileList));
  392. const articleImgRes = [];
  393. articleImgList.forEach(item => {
  394. if (item.response) {
  395. const obj = {
  396. name: item.name,
  397. url: item.response.file_info_list[0].file_url,
  398. file_size: item.response.file_info_list[0].file_size,
  399. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]"
  400. };
  401. articleImgRes.push(obj);
  402. }
  403. });
  404. this.detail.detail[index].img_list = JSON.parse(
  405. JSON.stringify(articleImgRes)
  406. );
  407. }
  408. },
  409. //生命周期 - 创建完成(可以访问当前this实例)
  410. created() {},
  411. //生命周期 - 挂载完成(可以访问DOM元素)
  412. mounted() {
  413. console.log(this.detail);
  414. },
  415. beforeCreate() {}, //生命周期 - 创建之前
  416. beforeMount() {}, //生命周期 - 挂载之前
  417. beforeUpdate() {}, //生命周期 - 更新之前
  418. updated() {}, //生命周期 - 更新之后
  419. beforeDestroy() {}, //生命周期 - 销毁之前
  420. destroyed() {}, //生命周期 - 销毁完成
  421. activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
  422. };
  423. </script>
  424. <style lang="scss" scoped>
  425. //@import url(); 引入公共css类
  426. .sentence-option {
  427. border: 1px #ccc solid;
  428. background: #f5f5f5;
  429. padding: 10px;
  430. margin-bottom: 10px;
  431. }
  432. .adult-book-input-item {
  433. display: flex;
  434. justify-content: flex-start;
  435. align-items: center;
  436. margin-bottom: 10px;
  437. &-center {
  438. align-items: center;
  439. }
  440. }
  441. .adult-book-lable {
  442. width: 70px;
  443. font-size: 14px;
  444. display: block;
  445. text-align: right;
  446. margin-right: 8px;
  447. line-height: 32px;
  448. &-bottom {
  449. margin-bottom: 10px;
  450. display: block;
  451. }
  452. }
  453. .el-radio-group {
  454. flex: 1;
  455. display: flex;
  456. flex-wrap: wrap;
  457. }
  458. .el-radio {
  459. display: flex;
  460. justify-content: flex-start;
  461. align-items: center;
  462. }
  463. .colorItem {
  464. width: 20px;
  465. height: 20px;
  466. border-radius: 100%;
  467. display: block;
  468. }
  469. .seg-congfig {
  470. display: flex;
  471. justify-content: space-between;
  472. }
  473. </style>