inspiration.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <div class="model-item-container">
  3. <div top="" class="model-item-part">
  4. <div class="progress_bar">
  5. <div class="bar_item" v-for="(item, i) in steps" :key="item.text + i">
  6. <div class="item_child">
  7. <div
  8. class="cricle c_play"
  9. :style="{
  10. backgroundColor:
  11. status.step >= i
  12. ? 'rgb(228, 242, 255)'
  13. : 'rgb(238, 238, 238)',
  14. backgroundImage: getBG(i),
  15. }"
  16. v-text="status.step < i ? i + 1 : ''"
  17. ></div>
  18. <div
  19. class="item-child-label active"
  20. style="width: 50px"
  21. v-text="item.text"
  22. ></div>
  23. </div>
  24. <div class="c_right c_right_grey"></div>
  25. </div>
  26. </div>
  27. </div>
  28. <el-form
  29. label-width="100px"
  30. v-if="status.step === 0"
  31. :model="form"
  32. label-position="left"
  33. >
  34. <el-form-item label="标题">
  35. <el-input v-model="form.title" />
  36. </el-form-item>
  37. <el-form-item label="文章长度">
  38. <div style="text-align: right; width: 100%">
  39. <el-button
  40. @click="form.long = 'short'"
  41. plain
  42. :class="{ act: form.long === 'short' }"
  43. >
  44. </el-button>
  45. <el-button
  46. @click="form.long = 'default'"
  47. plain
  48. :class="{ act: form.long === 'default' }"
  49. >
  50. </el-button>
  51. <el-button
  52. @click="form.long = 'long'"
  53. plain
  54. :class="{ act: form.long === 'long' }"
  55. >
  56. </el-button>
  57. </div>
  58. </el-form-item>
  59. <el-form-item label="摘要条数">
  60. <div style="text-align: right; width: 100%">
  61. <el-input-number v-model="form.num" :min="1" />
  62. </div>
  63. </el-form-item>
  64. </el-form>
  65. <el-form
  66. label-width="100px"
  67. v-if="status.step === 1"
  68. :model="form"
  69. label-position="top"
  70. >
  71. <el-form-item label="您可以选择/编辑摘要:">
  72. <div
  73. style="
  74. position: relative;
  75. margin-top: 1em;
  76. border: 1px solid #fff;
  77. border-radius: 4px;
  78. "
  79. :style="{ borderColor: form.radio === i ? '#3b82f6' : '#fff' }"
  80. v-for="(_, i) in form.intro_list"
  81. :key="i"
  82. >
  83. <el-icon
  84. class="select"
  85. :color="form.radio === i ? '#3b82f6' : '#333'"
  86. @click="form.radio = i"
  87. ><Check
  88. /></el-icon>
  89. <el-input v-model="form.intro_list[i]" type="textarea" :rows="6" />
  90. </div>
  91. </el-form-item>
  92. </el-form>
  93. <el-form
  94. label-width="100px"
  95. v-if="status.step === 2"
  96. :model="form"
  97. label-position="top"
  98. >
  99. <el-form-item
  100. label="您可以选择编辑/增删/重组大纲:"
  101. style="display: block"
  102. >
  103. <div
  104. class="dagang"
  105. v-for="(item, i) in form.contents_list"
  106. :key="'dg' + i"
  107. >
  108. <el-icon :size="20" class="add"><CirclePlus /></el-icon>
  109. <el-icon :size="20" class="close"><CircleClose /></el-icon>
  110. <el-input
  111. v-model="item.title"
  112. style="width: 100%"
  113. class="no_border"
  114. />
  115. </div>
  116. </el-form-item>
  117. </el-form>
  118. <div class="step4" v-if="status.step === 3">
  119. <b>标题:</b>
  120. {{ form.title }}
  121. <p
  122. style="padding: 5px 10px"
  123. v-for="(item, i) in form.contents_list"
  124. :key="item + i"
  125. v-text="item.title"
  126. ></p>
  127. </div>
  128. <div class="btn_group">
  129. <el-button
  130. type="primary"
  131. v-if="status.step > 0"
  132. plain
  133. @click="status.step--"
  134. >
  135. 上一步
  136. </el-button>
  137. <el-button type="primary" :loading="load" @click="createEdior">
  138. 下一步
  139. </el-button>
  140. <div class="bottom-content-safe-tip">
  141. <img :src="image_base64.tanhao" class="content-safe-tip-icon" />
  142. <div class="content-safe-tip-text">
  143. 声明:内容为概率模型生成,可能会产生不正确的信息,不代表我司的观点和立场
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </template>
  149. <script setup>
  150. import { ref, defineEmits } from 'vue';
  151. import { image_base64 } from './data.js';
  152. import { commit, generate_pc_get } from '@/api/aleditor.js';
  153. const emits = defineEmits(['closeType', 'setHtml', 'setImage', 'setTitle']);
  154. const steps = [
  155. {
  156. text: '标题',
  157. },
  158. {
  159. text: '摘要',
  160. },
  161. {
  162. text: '大纲',
  163. },
  164. {
  165. text: '内容',
  166. },
  167. ];
  168. const form = ref({
  169. intro_list: [],
  170. contents_list: [],
  171. title: '',
  172. title2: '',
  173. num: 1,
  174. long: 'short',
  175. radio: 0,
  176. });
  177. const load = ref(false);
  178. const status = ref({
  179. step: 0,
  180. });
  181. const getBG = i => {
  182. if (status.value.step == i) return 'url(' + image_base64.play + ')';
  183. if (status.value.step > i) return 'url(' + image_base64.duigou + ')';
  184. return undefined;
  185. };
  186. // 第一步
  187. const createEdior = () => {
  188. load.value = true;
  189. let generateType = undefined;
  190. let query_type = undefined;
  191. // 如果是大纲到内容则清空intro_list
  192. if (status.value.step === 2) form.value.intro_list = [];
  193. if (form.value.intro_list.length) {
  194. generateType = 7;
  195. query_type = 'title';
  196. } else if (!form.value.intro_list.length && form.value.long === 'short') {
  197. generateType = 8;
  198. query_type = 'all';
  199. } else {
  200. generateType = 6;
  201. query_type = 'intro';
  202. }
  203. const p = {
  204. data: {
  205. title: form.value.title,
  206. intro: form.value.intro_list.length
  207. ? form.value.intro_list[form.value.radio]
  208. : undefined,
  209. },
  210. outLineCnt: status.value.step === 1 ? 5 : undefined,
  211. domain: 'paper',
  212. generateType,
  213. intro_count: form.value.long === 'short' ? undefined : form.value.num,
  214. length: form.value.long,
  215. query_type,
  216. };
  217. status.value.step++;
  218. commit({
  219. data: p,
  220. noload: true,
  221. })
  222. .then(r => {
  223. if (!r.data) return;
  224. p.req = {
  225. doc_id: r.data.doc_id,
  226. };
  227. get(p);
  228. })
  229. .catch(() => {
  230. load.value = false;
  231. });
  232. };
  233. const get = p => {
  234. generate_pc_get({
  235. data: p,
  236. noload: true,
  237. })
  238. .then(res => {
  239. if (res.errCode !== 0 && res.data.status === 'RUNNING') {
  240. let t = setTimeout(() => {
  241. clearTimeout(t);
  242. get(p);
  243. }, 800);
  244. return;
  245. }
  246. load.value = false;
  247. if (status.value.step === 1) {
  248. const intro = res.data.result.introList.length
  249. ? res.data.result.introList
  250. : [res.data.result.intro || ''];
  251. form.value.intro_list = intro;
  252. }
  253. if (status.value.step === 2) {
  254. console.log(res.data.result.contents);
  255. form.value.contents_list = res.data.result.contents || [];
  256. }
  257. if (status.value.step === 3) {
  258. emits('setTitle', res.data.result.title);
  259. emits('setHtml', res.data.result.intro);
  260. emits('closeType');
  261. }
  262. })
  263. .catch(() => {
  264. load.value = false;
  265. });
  266. };
  267. </script>
  268. <style scoped>
  269. .model-item-container {
  270. text-align: center;
  271. -webkit-box-flex: 1;
  272. -ms-flex: 1;
  273. flex: 1;
  274. display: -webkit-box;
  275. display: -ms-flexbox;
  276. display: flex;
  277. -webkit-box-orient: vertical;
  278. -webkit-box-direction: normal;
  279. -ms-flex-direction: column;
  280. flex-direction: column;
  281. min-height: 0;
  282. width: 95%;
  283. height: 100%;
  284. }
  285. .model-item-part {
  286. -webkit-box-flex: 0;
  287. -ms-flex: none;
  288. flex: none;
  289. font-size: 14px;
  290. }
  291. .bar_item,
  292. .progress_bar {
  293. display: -webkit-box;
  294. display: -ms-flexbox;
  295. display: flex;
  296. -webkit-box-pack: justify;
  297. -ms-flex-pack: justify;
  298. justify-content: space-between;
  299. }
  300. .progress_bar {
  301. width: 100%;
  302. height: 80px;
  303. line-height: 80px;
  304. font-size: 14px;
  305. }
  306. .bar_item {
  307. width: 90px;
  308. }
  309. .item_child {
  310. display: -webkit-box;
  311. display: -ms-flexbox;
  312. display: flex;
  313. -webkit-box-align: center;
  314. -ms-flex-align: center;
  315. align-items: center;
  316. }
  317. .c_right_grey {
  318. background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNyIgaGVpZ2h0PSIxNSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNLjE1NiAxLjAxYS41NDcuNTQ3IDAgMDAwIC43NjVMNS43MzYgNy41bC01LjU4IDUuNzI0YS41NDguNTQ4IDAgMDAuMTcuODgyLjUyLjUyIDAgMDAuNTc3LS4xMTdMNi44MzcgNy45YS41NzMuNTczIDAgMDAwLS43OTlMLjkwMyAxLjAxYS41MjEuNTIxIDAgMDAtLjc0NyAweiIgZmlsbD0iI0UxRTFFMSIvPjwvc3ZnPg==);
  319. }
  320. .c_right {
  321. background-repeat: no-repeat;
  322. background-position: 50%;
  323. background-size: 29%;
  324. width: 25px;
  325. height: 100%;
  326. }
  327. .cricle {
  328. width: 25px;
  329. height: 25px;
  330. border-radius: 50%;
  331. line-height: 25px;
  332. text-align: center;
  333. color: #8e8e8e;
  334. font-size: 16px;
  335. background-repeat: no-repeat;
  336. background-position: 50%;
  337. margin-right: 5px;
  338. background-size: 40%;
  339. }
  340. .item-child-label.active {
  341. color: #4b4b4b;
  342. }
  343. .item-child-label {
  344. color: #8e8e8e;
  345. }
  346. .act {
  347. color: var(--el-button-hover-text-color);
  348. border-color: var(--el-button-hover-border-color);
  349. background-color: var(--el-button-hover-bg-color);
  350. outline: 0;
  351. }
  352. .btn_group {
  353. position: absolute;
  354. width: 100%;
  355. text-align: right;
  356. bottom: 0;
  357. padding-right: 1em;
  358. }
  359. .bottom-content-safe-tip {
  360. display: -webkit-box;
  361. display: -ms-flexbox;
  362. display: flex;
  363. padding: 15px 0;
  364. -webkit-box-pack: center;
  365. -ms-flex-pack: center;
  366. justify-content: center;
  367. width: 100%;
  368. zoom: 0.83;
  369. }
  370. .bottom-content-safe-tip .content-safe-tip-icon {
  371. width: 15px;
  372. height: 15px;
  373. margin-right: 10px;
  374. }
  375. .bottom-content-safe-tip .content-safe-tip-text {
  376. font-size: 12px;
  377. line-height: 15px;
  378. color: #cacaca;
  379. }
  380. .dagang {
  381. padding: 0 0 0 30px;
  382. position: relative;
  383. margin-bottom: 1em;
  384. }
  385. .dagang .add {
  386. position: absolute;
  387. left: 2px;
  388. top: 5px;
  389. display: none;
  390. }
  391. .dagang .close {
  392. position: absolute;
  393. right: 3px;
  394. z-index: 1;
  395. top: 5px;
  396. display: none;
  397. }
  398. .no_border .el-input__wrapper {
  399. box-shadow: none;
  400. }
  401. .dagang:hover .add,
  402. .dagang:hover .close {
  403. display: block;
  404. cursor: pointer;
  405. }
  406. .dagang:hover .no_border .el-input__wrapper {
  407. box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color))
  408. inset;
  409. }
  410. .select {
  411. position: absolute;
  412. right: 5px;
  413. top: 50%;
  414. transform: translateY(-50%);
  415. z-index: 1;
  416. cursor: pointer;
  417. }
  418. .step4 {
  419. padding: 40px;
  420. text-align: left;
  421. color: #8e8e8e;
  422. background-color: #f5f5f5;
  423. line-height: 1.1em;
  424. }
  425. .step4 * {
  426. vertical-align: middle;
  427. }
  428. </style>
  429. <style>
  430. .model-item-container .el-form-item__content {
  431. display: block;
  432. }
  433. .model-item-container .el-textarea__inner {
  434. padding-top: 1em;
  435. }
  436. </style>