short_video.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="short_video">
  3. <div style="padding: 25px 25px 0 25px">
  4. <el-table
  5. border
  6. header-row-class-name="head"
  7. :data="tableData"
  8. style="width: 100%"
  9. >
  10. <el-table-column prop="title" label="主题/产品" width="280">
  11. <template #default="scope">
  12. <div
  13. contenteditable
  14. class="input"
  15. v-text="scope.row.title"
  16. @input="e => setText(scope, 'title', e)"
  17. ></div>
  18. </template>
  19. </el-table-column>
  20. <el-table-column prop="desc" label="描述">
  21. <template #default="scope">
  22. <div
  23. contenteditable
  24. class="input"
  25. v-text="scope.row.desc"
  26. @input="e => setText(scope, 'desc', e)"
  27. ></div>
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="" label="">
  31. <template #default="scope">
  32. <el-button
  33. :icon="CircleClose"
  34. type="primary"
  35. link
  36. @click="() => deltable(scope)"
  37. >
  38. 删除
  39. </el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <br />
  44. <el-button :icon="CirclePlus" type="primary" link @click="addtable">
  45. 添加
  46. </el-button>
  47. <br />
  48. <el-form>
  49. <el-form-item label="文章长度">
  50. <div style="text-align: right; width: 100%">
  51. <el-button
  52. @click="long = 'short'"
  53. plain
  54. :class="{ act: long === 'short' }"
  55. >
  56. </el-button>
  57. <el-button
  58. @click="long = 'default'"
  59. plain
  60. :class="{ act: long === 'default' }"
  61. >
  62. </el-button>
  63. <el-button
  64. @click="long = 'long'"
  65. plain
  66. :class="{ act: long === 'long' }"
  67. >
  68. </el-button>
  69. </div>
  70. </el-form-item>
  71. </el-form>
  72. <div class="btn_group">
  73. <el-button type="primary" style="width: 100%" @click="create"
  74. >生成内容</el-button
  75. >
  76. <div class="bottom-content-safe-tip">
  77. <img :src="image_base64.tanhao" class="content-safe-tip-icon" />
  78. <div class="content-safe-tip-text">
  79. 声明:内容为概率模型生成,可能会产生不正确的信息,不代表我司的观点和立场
  80. </div>
  81. </div>
  82. </div>
  83. <template v-if="list.length">
  84. <div class="item" v-for="(item, i) in list" :key="i">
  85. <div class="content" v-text="item.text"></div>
  86. <div class="btn_div">
  87. <el-tooltip effect="dark" content="左侧导入" placement="top">
  88. <el-icon
  89. @click="() => inputText(item.text)"
  90. style="
  91. left: 50;
  92. top: 50%;
  93. transform: translate(-50%, -50%);
  94. cursor: pointer;
  95. "
  96. color="#cacaca"
  97. >
  98. <DArrowLeft />
  99. </el-icon>
  100. </el-tooltip>
  101. </div>
  102. <div class="btn_div">
  103. <el-tooltip effect="dark" content="复制" placement="top">
  104. <el-icon
  105. style="
  106. left: 50;
  107. top: 50%;
  108. transform: translate(-50%, -50%);
  109. cursor: pointer;
  110. "
  111. @click="() => copyurl(item.text)"
  112. color="#cacaca"
  113. >
  114. <CopyDocument />
  115. </el-icon>
  116. </el-tooltip>
  117. </div>
  118. </div>
  119. </template>
  120. </div>
  121. </div>
  122. </template>
  123. <script setup>
  124. import { copyurl } from '@/utils/tool.js';
  125. import { image_base64 } from './data.js';
  126. import { CircleClose, CirclePlus } from '@element-plus/icons-vue';
  127. import { ref, defineEmits } from 'vue';
  128. import { ElMessage } from 'element-plus';
  129. import { advertisement, generate_pc_get } from '@/api/aleditor.js';
  130. const emits = defineEmits(['closeType', 'setHtml', 'getImage']);
  131. const long = ref('short');
  132. const load = ref(false);
  133. const tableData = ref([
  134. {
  135. title: ' ',
  136. desc: ' ',
  137. },
  138. ]);
  139. const list = ref([]);
  140. const inputText = text => {
  141. emits('setHtml', text);
  142. };
  143. const addtable = () => {
  144. tableData.value.push({
  145. title: ' ',
  146. desc: ' ',
  147. });
  148. };
  149. const deltable = scope => {
  150. if (tableData.value.length <= 1)
  151. return ElMessage.error('至少需要一个或以上内容');
  152. tableData.value.splice(scope.$index, 1);
  153. };
  154. const setText = (scope, key, e) => {
  155. tableData.value[scope.$index][key] = e.target.innerText;
  156. };
  157. const create = () => {
  158. load.value = true;
  159. const p = {
  160. count: 5,
  161. data: {
  162. others: tableData.value.map(v => {
  163. return {
  164. name: v.title,
  165. desc: v.desc,
  166. };
  167. }),
  168. },
  169. generateType: 33,
  170. length:
  171. long.value === 'short' ? 400 : long.value === 'default' ? 600 : 1000,
  172. noblock: true,
  173. query_type: 'koubo_multi',
  174. docId: localStorage.getItem('fileId') || undefined,
  175. };
  176. advertisement({
  177. data: p,
  178. noload: true,
  179. }).then(r => {
  180. if (r.errCode !== 0) return (load.value = false);
  181. p.req = { doc_id: r.data.doc_id };
  182. get(p);
  183. });
  184. };
  185. const get = p => {
  186. generate_pc_get({
  187. data: p,
  188. noload: true,
  189. })
  190. .then(res => {
  191. load.value = false;
  192. if (res.errCode !== 0 && res.data.status === 'RUNNING') {
  193. let t = setTimeout(() => {
  194. get(p);
  195. clearTimeout(t);
  196. }, 200);
  197. return;
  198. }
  199. const list = res.data.result.content;
  200. const l = [];
  201. for (let i = 0; i < list.length; i++) {
  202. const v = list[i];
  203. l.push({
  204. text: v,
  205. });
  206. }
  207. list.value.push(...l);
  208. })
  209. .catch(() => {
  210. load.value = false;
  211. });
  212. };
  213. </script>
  214. <style>
  215. .short_video .head,
  216. .short_video .el-table th.el-table__cell {
  217. background-color: #fafafa;
  218. color: #111;
  219. font-weight: 400;
  220. }
  221. .short_video .el-table .el-table__cell {
  222. padding: 0;
  223. }
  224. .short_video .input,
  225. .short_video .el-table .cell {
  226. height: 45px;
  227. line-height: 45px;
  228. outline: none;
  229. }
  230. </style>
  231. <style scoped>
  232. .act {
  233. color: var(--el-button-hover-text-color);
  234. border-color: var(--el-button-hover-border-color);
  235. background-color: var(--el-button-hover-bg-color);
  236. outline: 0;
  237. }
  238. .btn_group {
  239. padding-right: 1em;
  240. }
  241. .bottom-content-safe-tip {
  242. display: -webkit-box;
  243. display: -ms-flexbox;
  244. display: flex;
  245. padding: 15px 0;
  246. -webkit-box-pack: center;
  247. -ms-flex-pack: center;
  248. justify-content: center;
  249. width: 100%;
  250. zoom: 0.83;
  251. }
  252. .bottom-content-safe-tip .content-safe-tip-icon {
  253. width: 15px;
  254. height: 15px;
  255. margin-right: 10px;
  256. }
  257. .bottom-content-safe-tip .content-safe-tip-text {
  258. font-size: 12px;
  259. line-height: 15px;
  260. color: #cacaca;
  261. }
  262. .item {
  263. width: 100%;
  264. min-height: 45px;
  265. -webkit-box-sizing: border-box;
  266. box-sizing: border-box;
  267. margin-bottom: 20px;
  268. text-align: left;
  269. position: relative;
  270. padding: 10px 10px 10px 0;
  271. display: flex;
  272. -webkit-box-align: center;
  273. -ms-flex-align: center;
  274. align-items: center;
  275. border-bottom: 1px solid #eee;
  276. }
  277. .content {
  278. -webkit-box-flex: 1;
  279. -ms-flex: 1;
  280. flex: 1;
  281. outline: none;
  282. line-height: 28px;
  283. text-align: justify;
  284. overflow-y: auto;
  285. }
  286. .hover_class,
  287. .item:hover {
  288. background-color: #f5f5f5;
  289. border-bottom: 1px solid #f8f8f8;
  290. }
  291. .btn_div {
  292. height: 30px;
  293. width: 30px;
  294. position: relative;
  295. }
  296. </style>