brainstorming.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div class="model-item-container">
  3. <br />
  4. <el-form label-width="100px" :model="form" label-position="top">
  5. <el-form-item label="请输入主题/话题/问题">
  6. <el-input
  7. v-model="form.title"
  8. type="textarea"
  9. :rows="5"
  10. maxlength="1000"
  11. show-word-limit
  12. placeholder="如:列出5种吃了不长胖的食物"
  13. />
  14. </el-form-item>
  15. </el-form>
  16. <el-form>
  17. <el-form-item label="文案条数">
  18. <div style="text-align: right; width: 100%">
  19. <el-input-number v-model="form.num" :min="1" />
  20. </div>
  21. </el-form-item>
  22. </el-form>
  23. <div class="btn_group">
  24. <el-button
  25. type="primary"
  26. style="width: 100%"
  27. @click="create"
  28. :loading="load"
  29. >生成内容</el-button
  30. >
  31. <div class="bottom-content-safe-tip">
  32. <img :src="image_base64.tanhao" class="content-safe-tip-icon" />
  33. <div class="content-safe-tip-text">
  34. 声明:内容为概率模型生成,可能会产生不正确的信息,不代表我司的观点和立场
  35. </div>
  36. </div>
  37. </div>
  38. <template v-if="form.list.length">
  39. <div class="item" v-for="(item, i) in form.list" :key="i">
  40. <div class="content" v-text="item.text"></div>
  41. <div class="btn_div">
  42. <el-tooltip effect="dark" content="左侧导入" placement="top">
  43. <el-icon
  44. @click="() => inputText(item.text)"
  45. style="
  46. left: 50;
  47. top: 50%;
  48. transform: translate(-50%, -50%);
  49. cursor: pointer;
  50. "
  51. color="#cacaca"
  52. ><DArrowLeft
  53. /></el-icon>
  54. </el-tooltip>
  55. </div>
  56. <div class="btn_div">
  57. <el-tooltip effect="dark" content="复制" placement="top">
  58. <el-icon
  59. style="
  60. left: 50;
  61. top: 50%;
  62. transform: translate(-50%, -50%);
  63. cursor: pointer;
  64. "
  65. @click="() => copyurl(item.text)"
  66. color="#cacaca"
  67. ><CopyDocument
  68. /></el-icon>
  69. </el-tooltip>
  70. </div>
  71. </div>
  72. </template>
  73. </div>
  74. </template>
  75. <script setup>
  76. import { copyurl } from '@/utils/tool.js';
  77. import { ref, defineEmits } from 'vue';
  78. import { image_base64 } from './data.js';
  79. import { advertisement, generate_pc_get } from '@/api/aleditor.js';
  80. const emits = defineEmits(['closeType', 'setHtml', 'getImage']);
  81. const load = ref(false);
  82. const form = ref({
  83. title: '',
  84. num: 1,
  85. list: [],
  86. });
  87. const inputText = text => {
  88. emits('setHtml', text);
  89. };
  90. const create = () => {
  91. load.value = true;
  92. const p = {
  93. count: form.value.num,
  94. data: {
  95. content: form.value.title,
  96. occupation: form.value.career,
  97. type: form.value.type,
  98. },
  99. generateType: 24,
  100. length:
  101. form.value.long === 'short'
  102. ? 200
  103. : form.value.long === 'default'
  104. ? 400
  105. : 800,
  106. noblock: true,
  107. query_type: 'dialog',
  108. };
  109. advertisement({
  110. data: p,
  111. noload: true,
  112. }).then(r => {
  113. if (r.errCode !== 0) return (load.value = false);
  114. p.req = { doc_id: r.data.doc_id };
  115. get(p);
  116. });
  117. };
  118. const get = p => {
  119. generate_pc_get({
  120. data: p,
  121. noload: true,
  122. })
  123. .then(res => {
  124. load.value = false;
  125. if (res.errCode !== 0 && res.data.status === 'RUNNING') {
  126. let t = setTimeout(() => {
  127. get(p);
  128. clearTimeout(t);
  129. }, 200);
  130. return;
  131. }
  132. const list = res.data.result.content;
  133. const l = [];
  134. for (let i = 0; i < list.length; i++) {
  135. const v = list[i];
  136. l.push({
  137. text: v,
  138. });
  139. }
  140. form.value.list.push(...l);
  141. })
  142. .catch(() => {
  143. load.value = false;
  144. });
  145. };
  146. </script>
  147. <style scoped>
  148. .model-item-container {
  149. text-align: center;
  150. -webkit-box-flex: 1;
  151. -ms-flex: 1;
  152. flex: 1;
  153. display: -webkit-box;
  154. display: -ms-flexbox;
  155. display: flex;
  156. -webkit-box-orient: vertical;
  157. -webkit-box-direction: normal;
  158. -ms-flex-direction: column;
  159. flex-direction: column;
  160. min-height: 0;
  161. width: 95%;
  162. height: 100%;
  163. }
  164. .act {
  165. color: var(--el-button-hover-text-color);
  166. border-color: var(--el-button-hover-border-color);
  167. background-color: var(--el-button-hover-bg-color);
  168. outline: 0;
  169. }
  170. .btn_group {
  171. padding-right: 1em;
  172. }
  173. .bottom-content-safe-tip {
  174. display: -webkit-box;
  175. display: -ms-flexbox;
  176. display: flex;
  177. padding: 15px 0;
  178. -webkit-box-pack: center;
  179. -ms-flex-pack: center;
  180. justify-content: center;
  181. width: 100%;
  182. zoom: 0.83;
  183. }
  184. .bottom-content-safe-tip .content-safe-tip-icon {
  185. width: 15px;
  186. height: 15px;
  187. margin-right: 10px;
  188. }
  189. .bottom-content-safe-tip .content-safe-tip-text {
  190. font-size: 12px;
  191. line-height: 15px;
  192. color: #cacaca;
  193. }
  194. .item {
  195. width: 100%;
  196. -webkit-box-sizing: border-box;
  197. box-sizing: border-box;
  198. margin-bottom: 20px;
  199. text-align: left;
  200. position: relative;
  201. padding: 10px 10px 10px 0;
  202. display: flex;
  203. -webkit-box-align: center;
  204. -ms-flex-align: center;
  205. align-items: center;
  206. border-bottom: 1px solid #eee;
  207. }
  208. .content {
  209. -webkit-box-flex: 1;
  210. -ms-flex: 1;
  211. flex: 1;
  212. outline: none;
  213. line-height: 28px;
  214. text-align: justify;
  215. overflow-y: auto;
  216. }
  217. .hover_class,
  218. .item:hover {
  219. background-color: #f5f5f5;
  220. border-bottom: 1px solid #f8f8f8;
  221. }
  222. .btn_div {
  223. height: 30px;
  224. width: 30px;
  225. position: relative;
  226. }
  227. </style>