SentenceSegTemp.vue 13 KB

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