DialogWrap.vue 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721
  1. <template>
  2. <div class="dialog-flex-wrap" :data-chat="dialogId">
  3. <div class="dialog-flex" ref="dialogScroll">
  4. <div class="section-open" v-if="open">
  5. <header class="dialog-header">
  6. <a-avatar shape="circle" :size="28">
  7. <img alt="avatar" src="/src/assets/slider/logo.jpg" />
  8. </a-avatar>
  9. </header>
  10. <footer class="dialog-footer">
  11. <p>{{ open }}</p>
  12. </footer>
  13. </div>
  14. <Suggestion :suggestions="suggestions" :readonly="readonly" />
  15. <div class="dialog-list" v-if="dialogList.length > 0">
  16. <div
  17. :class="['dialog-item', isSetting ? '' : 'dialog-absolute', 'dialog-item-' + key]"
  18. v-for="(item, key) in dialogList"
  19. :key="item.client_gen_id"
  20. :data-item-index="key"
  21. :data-item-key="item.client_gen_id"
  22. >
  23. <div class="dialog-header header-question" v-if="item?.question">
  24. <!-- <div class="user-name" style="background-color: rgb(255, 110, 110)">
  25. {{ userName.slice(0, 1) }}
  26. </div> -->
  27. <ClientUserAvatar />
  28. </div>
  29. <div class="dialog-footer" v-if="item?.question">
  30. <Question :question="item.question" :index="key" :chat_id="dialogId" :chat_type="type" :agentId="agentId" />
  31. </div>
  32. <!-- 如果是代码则不显示头像 -->
  33. <div class="dialog-header header-answer" :class="{ 'has-code': item.code || item.sql }" v-if="item?.capacity">
  34. <img alt="avatar" src="/src/assets/slider/logo.jpg" width="28" />
  35. </div>
  36. <!-- 处理python代码和SQL代码 -->
  37. <div class="dialog-code-footer" v-if="item.code || item.sql">
  38. <CodeDisplay v-if="item.code" type="python" :code="item.code" :index="key" />
  39. <CodeDisplay v-if="item.sql" type="sql" :code="item.sql" :index="key" />
  40. </div>
  41. <div
  42. class="dialog-footer"
  43. v-else-if="item?.capacity"
  44. :style="{ display: dialogConfig.type === 'paper' ? 'inline-block' : 'block' }"
  45. >
  46. <div
  47. v-if="type === 'knowledge'"
  48. @click="openCapacity(key)"
  49. :class="[readonly || item.capacity.status === 'loading' ? 'disabled' : '']"
  50. >
  51. <a-spin :size="18" v-if="item.capacity.status === 'loading'" />
  52. <icon-check-circle-fill :size="18" v-else />
  53. <span>{{ item.capacity.status === 'loading' ? '小数正在检索' : '查看检索信息' }}</span>
  54. <!-- <b>{{ item.capacity.text }}</b> -->
  55. <icon-caret-right size="18" v-if="item.capacity.status === 'loaded' && !menuList[key]?.open" />
  56. <icon-caret-down size="18" v-if="item.capacity.status === 'loaded' && menuList[key]?.open" />
  57. </div>
  58. <div
  59. v-else
  60. v-show="item.capacity.status === 'loading'"
  61. :class="[readonly || item.capacity.status === 'loading' ? 'disabled' : '']"
  62. >
  63. <a-spin :size="18" />
  64. <span v-if="type !== 'document_report'">{{
  65. type === 'excel' ? '正在为您合并...' : '正在为您搜索答案...'
  66. }}</span>
  67. <span v-if="type === 'document_report'">{{ document_report_system_message }}</span>
  68. </div>
  69. <section v-if="type === 'knowledge' && item.capacity.status === 'loaded'" v-show="menuList[key].open">
  70. <div v-if="item.capacity.data.list">
  71. <p v-for="(item, key) in item.capacity.data.list" :key="key">
  72. <a-typography-paragraph :ellipsis="{ rows: 1, css: true }" :style="{ flex: 1, margin: '0' }">
  73. {{ item }}
  74. </a-typography-paragraph>
  75. </p>
  76. </div>
  77. <div v-if="item.capacity.data.documents">
  78. <div v-for="(document, documentKey) in item.capacity.data.documents" :key="documentKey">
  79. <div @click="openDocument(key, documentKey)" :class="[readonly ? 'disabled' : '']">
  80. <span>{{ document.type }}</span>
  81. <a-typography-paragraph :ellipsis="{ rows: 1, css: true }" :style="{ flex: 1, margin: '0' }">
  82. <span>{{ document.title }}</span>
  83. </a-typography-paragraph>
  84. <span>
  85. <em v-for="(item, documentIndex) in document.list" :key="documentIndex">{{ item.title }}</em>
  86. </span>
  87. <icon-caret-down size="12" v-if="documentKey === menuList[key].documentOpenIndex" />
  88. <icon-caret-right size="12" v-else />
  89. </div>
  90. <div v-show="documentKey === menuList[key].documentOpenIndex">
  91. <p v-for="(item, index) in document.list" :key="index">
  92. <span>{{ item.title }}</span>
  93. <a-typography-paragraph :ellipsis="{ rows: 3, css: true }" :style="{ flex: 1, margin: '0' }">
  94. <span style="color: rgba(153, 153, 153, 1); font-size: 12px">{{ item.content }}</span>
  95. </a-typography-paragraph>
  96. </p>
  97. </div>
  98. </div>
  99. </div>
  100. </section>
  101. <p v-if="type === 'knowledge' && item.answer" style="margin-top: 10px; font-size: 18px; font-weight: bold">
  102. 答案生成结果
  103. </p>
  104. <p v-if="item.answer" :style="{ 'margin-top': type === 'knowledge' ? '12px' : '0' }">
  105. <span v-if="type === 'paper'" class="paper-wrap">
  106. <img src="@/assets/question/word.svg" />
  107. <span>
  108. <b>黄冈试卷考试题</b>
  109. <em>DOCX,13.19KB</em>
  110. </span>
  111. </span>
  112. <Answer
  113. v-else
  114. :answer="item.answer"
  115. :index="key"
  116. :chat_id="dialogId"
  117. :chat_type="type"
  118. :agentId="agentId"
  119. :special_4_refference="item.fullRefference"
  120. :special_4_image="item.fullImageUrls"
  121. />
  122. </p>
  123. </div>
  124. <div class="dialog-footer" v-else>
  125. <Answer
  126. :answer="item.answer"
  127. :index="key"
  128. :chat_id="dialogId"
  129. :chat_type="type"
  130. :agentId="agentId"
  131. :special_4_refference="item.fullRefference"
  132. :special_4_image="item.fullImageUrls"
  133. />
  134. </div>
  135. <!-- 处理来源 -->
  136. <div
  137. v-if="(type === 'knowledge' || type === 'knowledgeQuiz') && item.reference && item.reference.length > 0"
  138. class="knowledge-wrap"
  139. >
  140. <header>
  141. <p>来源</p>
  142. <!-- TODO详情暂时注释 -->
  143. <p @click="checkAllReference(item)">查看全部关联 ></p>
  144. </header>
  145. <section>
  146. <DocRefItem
  147. v-for="(knowledge, knowledgeIndex) in item.reference.slice(0, 3)"
  148. :key="knowledgeIndex"
  149. :knowledge="knowledge"
  150. :knowledgeIndex="knowledgeIndex"
  151. @go-document="goKnowledge($event, item)"
  152. />
  153. </section>
  154. </div>
  155. <!-- 如果有图片 -->
  156. <div v-if="item?.image_url" style="margin-left: 50px">
  157. <a-image width="500" :src="item?.image_url" />
  158. </div>
  159. <div v-if="item.file" class="paper-wrap" @click="downloadFile(item.file.file_url)">
  160. <img v-if="item.file.file_type === 'excel'" src="@/assets/question/excel.svg" />
  161. <img v-if="item.file.file_type === 'word'" src="@/assets/question/word.svg" />
  162. <span>
  163. <b>{{ item.file.file_name }}</b>
  164. </span>
  165. <icon-download style="margin-right: 24px; font-size: 32px" />
  166. </div>
  167. <div class="dialog-other" v-if="item?.other">
  168. <p v-if="isSetting">
  169. <img src="@/assets/icons/check.png" width="16" />
  170. <span>{{ item.other.token }}</span>
  171. </p>
  172. <p v-else></p>
  173. <div v-if="chat_type !== 'huitu'">
  174. <a-tooltip content="重新生成">
  175. <p @click="reQuestion(item.question)" :class="[readonly ? 'disabled' : '']">
  176. <img src="@/assets/icons/refresh.png" width="15" />
  177. </p>
  178. </a-tooltip>
  179. <a-tooltip content="复制">
  180. <p @click="copyAnswer(item.answer)" :class="[readonly ? 'disabled' : '']">
  181. <img src="@/assets/icons/copy.png" width="15" />
  182. </p>
  183. </a-tooltip>
  184. <a-tooltip content="收藏">
  185. <p @click="saveAnswer(key)" :class="[readonly ? 'disabled' : '']" v-if="!isSetting">
  186. <img src="@/assets/icons/star-full.png" width="15" v-if="menuList[key]?.save" />
  187. <img src="@/assets/icons/star.png" width="15" v-else />
  188. </p>
  189. </a-tooltip>
  190. <a-tooltip content="点赞">
  191. <p :class="[readonly ? 'disabled' : '']" v-if="!isSetting">
  192. <img src="@/assets/icons/thumb-up.png" width="15" />
  193. </p>
  194. </a-tooltip>
  195. <a-tooltip content="反馈">
  196. <p @click="feedbackAnswer" :class="[readonly ? 'disabled' : '']" v-if="!isSetting">
  197. <img src="@/assets/icons/thumb-down.png" width="15" />
  198. </p>
  199. </a-tooltip>
  200. <a-tooltip content="分享">
  201. <p :class="[readonly ? 'disabled' : '']" v-if="!isSetting">
  202. <img src="@/assets/icons/share.png" width="15" />
  203. </p>
  204. </a-tooltip>
  205. </div>
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. <!-- <div v-show="readonly" @click="stopWriting" class="dialog-writing-button">
  211. <icon-record-stop :size="20" style="margin-right: 4px" />停止生成
  212. </div> -->
  213. <dialog-feedback :showFeedback="showFeedback" @handleCancel="handleCancel" @handleOk="handleOk" v-if="!isSetting" />
  214. </div>
  215. </template>
  216. <script>
  217. import DialogFeedback from './DialogFeedback.vue';
  218. import { defineComponent, ref, onBeforeUnmount, onMounted, reactive, nextTick, inject } from 'vue';
  219. import formatAnwserString from './answer-effect/format-anwser-string';
  220. import initTempHistory, { getChatIdFromUrl } from './answer-effect/temp-history';
  221. // import { getDocumentUrl } from '../ajax/document';
  222. import Question from './dialog-wrap/Question.vue';
  223. import Suggestion from './dialog-wrap/Suggestion.vue';
  224. import ClientUserAvatar from './dialog-wrap/ClientUserAvatar.vue';
  225. import Answer from './dialog-wrap/Answer.vue';
  226. import { huituSetTempImageIndex } from './dialog-wrap/temp-image';
  227. import generateClientUniqueId from './dialog-wrap/generate-client-unique-id';
  228. import formatDialogItem from './dialog-wrap/format-dialog-item';
  229. import DocRefItem from './dialog-wrap/DocRefItem.vue';
  230. import CodeDisplay from './dialog-wrap/CodeDisplay.vue';
  231. import { useImageUploadStatus } from '../store/index';
  232. import { formatCodePython, formatCodeSql } from './dialog-wrap/format-code-string';
  233. import formatFieldDownloadUrl from './dialog-wrap/format-field-download-url';
  234. export default defineComponent({
  235. components: {
  236. DialogFeedback,
  237. Suggestion,
  238. ClientUserAvatar,
  239. Question,
  240. Answer,
  241. DocRefItem,
  242. CodeDisplay
  243. },
  244. props: ['open', 'suggestions', 'isSetting', 'readonly', 'type', 'list', 'agentId', 'dialogId', 'reference'],
  245. setup(props, { emit }) {
  246. // 图片上传的状态
  247. const imageUploadStatus = useImageUploadStatus();
  248. const knowledgeList = ref([[{}]]);
  249. const DOCUMENT_RESULT = {};
  250. const getHTML = (string) => {
  251. return formatAnwserString(string);
  252. };
  253. const replaceCode = (text, index) => {
  254. const icon = ` <span class="circle" data-list-index="${index || 0}"></span>`;
  255. return text.replace(/##\d\$\$/g, icon);
  256. };
  257. const { helper, ajax } = inject('$global');
  258. // const userName = ref(helper.read("userName") || "");
  259. /**
  260. * 此数据定义,仅用于暂时隐藏 重新生成、复制、收藏、点赞、反馈、分享 按钮
  261. * 如果这些按钮需要显示,则可将此定义移除,同时移除 对应的 v-if
  262. */
  263. const show_info_btns = ref(false);
  264. const chat_type = props.type; // 对话的类型
  265. // 系统消息
  266. const document_report_system_message = ref('');
  267. /**
  268. * 初始化临时历史记录
  269. * 在对话过程中,消息记录是一条一条的呈现
  270. * 而在历史记录面板中,一个对话框中可能有多条对话,一次性直接加载
  271. */
  272. const tempHistory = initTempHistory();
  273. const list =
  274. (props.list &&
  275. Array.isArray(props.list) &&
  276. props.list.map((item, index) => {
  277. return formatDialogItem(item, index);
  278. })) ||
  279. [];
  280. const dialogList = reactive(list || []);
  281. const randomKey = ref(0);
  282. const showFeedback = ref(false);
  283. const menuList = reactive([]);
  284. let dialogIndex = dialogList.length;
  285. const dialogScroll = ref('');
  286. const dialogConfig = ref({});
  287. const scrollToEnd = async () => {
  288. await nextTick();
  289. if (dialogScroll.value) {
  290. dialogScroll.value.scrollTop = dialogScroll.value.scrollHeight;
  291. }
  292. };
  293. let answerInterval = null;
  294. const stopWriting = () => {
  295. window.clearInterval(answerInterval);
  296. emit('set-readonly', false);
  297. if (dialogList[dialogIndex]) {
  298. dialogList[dialogIndex].other = {
  299. token: '4.0s | Tokens'
  300. };
  301. }
  302. scrollToEnd();
  303. dialogIndex += 1;
  304. };
  305. const addData = (data) => {
  306. dialogList.splice(dialogIndex, 1, data);
  307. randomKey.value = Math.random();
  308. scrollToEnd();
  309. };
  310. const saveAnswer = (index) => {
  311. if (!props.readonly) {
  312. menuList[index].save = !menuList[index].save;
  313. }
  314. };
  315. const openCapacity = (index) => {
  316. if (!props.readonly) {
  317. menuList[index].open = !menuList[index].open;
  318. }
  319. };
  320. const feedbackAnswer = () => {
  321. if (!props.readonly) {
  322. showFeedback.value = true;
  323. }
  324. };
  325. const handleOk = () => {
  326. showFeedback.value = false;
  327. };
  328. const handleCancel = () => {
  329. showFeedback.value = false;
  330. };
  331. // const selectSuggestion = (text) => {
  332. // if (!props.readonly) {
  333. // }
  334. // };
  335. const copyAnswer = (text) => {
  336. if (!props.readonly) {
  337. helper.copyText(text, '复制成功');
  338. }
  339. };
  340. const reQuestion = (text) => {
  341. if (!props.readonly) {
  342. setTimeout(() => {
  343. helper.$bus.emit('send-message', text);
  344. }, 200);
  345. }
  346. };
  347. const openDocument = (index, documentIndex) => {
  348. if (menuList[index].documentOpenIndex === documentIndex) {
  349. menuList[index].documentOpenIndex = -1;
  350. } else {
  351. menuList[index].documentOpenIndex = documentIndex;
  352. }
  353. };
  354. const goKnowledge = (knowledge, fullRef) => {
  355. let targetDocument = { ...knowledge, ...fullRef.fullRefference, question: fullRef.question };
  356. emit('go-document', targetDocument);
  357. };
  358. const checkAllReference = (fullRef) => {
  359. const knowledge = fullRef.reference[0];
  360. goKnowledge(knowledge, fullRef);
  361. };
  362. // // 点击文档,打开新页面
  363. // const openDocuementPage = (knowledge) => {
  364. // const doc_name = knowledge.doc_name;
  365. // const doc_id = knowledge.id;
  366. // // const pdf_url = `http://192.168.20.119:11080/v1/document/get/${doc_id}`;
  367. // const pdf_url = getDocumentUrl(doc_id);
  368. // window.open(pdf_url);
  369. // }
  370. const addLoading = (data) => {
  371. const mockData = DOCUMENT_RESULT;
  372. data.capacity = {
  373. type: mockData.type,
  374. text: mockData.text,
  375. status: 'loading',
  376. data: null
  377. };
  378. menuList[dialogIndex] = {
  379. save: false,
  380. open: false,
  381. documentOpenIndex: -1
  382. };
  383. addData(data);
  384. return data;
  385. };
  386. const loadingData = ref(null);
  387. const isLoaded = ref(false);
  388. const answerData = ref('');
  389. const answerReference = ref([]);
  390. const fullRefference = reactive({
  391. full_ref: {}
  392. });
  393. const fullImageUrls = reactive({
  394. url: []
  395. });
  396. const imageUrl = ref(undefined);
  397. const answerFile = ref(undefined);
  398. const answerCode = ref(undefined);
  399. const answerSql = ref(undefined);
  400. const addQuestion = (question, file = null) => {
  401. let result = {
  402. question,
  403. capacity: null,
  404. answer: '',
  405. other: null,
  406. file: null
  407. };
  408. addData(result);
  409. return result;
  410. };
  411. const addAnswer = (data) => {
  412. data.answer = answerData.value;
  413. data.reference = answerReference.value;
  414. data.fullRefference = fullRefference.full_ref; // 完整的引用数据
  415. data.fullImageUrls = fullImageUrls.url; // 图片地址数据
  416. data.image_url = imageUrl.value;
  417. data.code = answerCode.value;
  418. data.file = answerFile.value;
  419. data.sql = answerSql.value;
  420. // 客户端生成的唯一的key
  421. data.client_gen_id = generateClientUniqueId(JSON.stringify(data));
  422. addData(data);
  423. };
  424. const answerLoaded = () => {
  425. isLoaded.value = true;
  426. emit('set-readonly', true);
  427. loadingData.value.capacity = DOCUMENT_RESULT;
  428. addAnswer(loadingData.value);
  429. };
  430. const downloadFile = (url) => {
  431. let file_url = url.replace('/./', '/');
  432. // file_url = file_url.replace('//', '/');
  433. window.open(file_url, '_blank');
  434. };
  435. onBeforeUnmount(() => {
  436. helper.$bus.off('send-message');
  437. helper.$bus.off('clear-message');
  438. helper.$bus.off('stop-writing');
  439. helper.webSocket?.close();
  440. });
  441. onMounted(() => {
  442. scrollToEnd();
  443. /**
  444. * TODO: 只允许保存一条消息,避免出现多条消息同时发送的情况
  445. * 当网络状况不佳,用户发送第一条数据时,socket还未连接成功,紧接着又发送第二条数据,第三条数据....
  446. * 此时,消息队列里将会有多条数据等待发送
  447. * 当socket连接成功后,遍历消息队列里的数据,会将这多条数据一同发送,此时就会出现异常情况。
  448. */
  449. let msg_list = [];
  450. function createSocket() {
  451. const token = helper.read('token');
  452. const p_type = props.type;
  453. // 如果是智能数据,则拿缓存里的数据开启对话
  454. if (helper.read('sendData') && helper.read('sendData').agent_id == 'basic_excel_talk') {
  455. const data = helper.read('sendData');
  456. helper.webSocket = ajax.message.create(token, data.agent_id, data.chat_id, p_type);
  457. // 创建对话之后清空缓存
  458. helper.write('sendData', {});
  459. } else {
  460. helper.webSocket = ajax.message.create(token, props.agentId, props.dialogId, p_type);
  461. }
  462. // 监听socket开启事件
  463. // 当socket开启后,遍历消息,并发送
  464. helper.webSocket.onopen = function (event) {
  465. msg_list.forEach((item) => {
  466. helper.webSocket.send(item);
  467. });
  468. // 所有消息发送完成后,清空消息队列
  469. msg_list = [];
  470. };
  471. }
  472. // 发送socket数据
  473. function sendSocketMsg(dt) {
  474. // 判断socket是否开启
  475. // 如果开启,则直接发送,如果没有开启,则将数据推入消息队列
  476. if (helper.webSocket.readyState === 0) {
  477. msg_list.push(dt);
  478. }
  479. if (helper.webSocket.readyState === 1) {
  480. helper.webSocket.send(dt);
  481. }
  482. if (helper.webSocket.readyState === 2) {
  483. // 正在关闭
  484. console.log('web socket正在关闭');
  485. }
  486. if (helper.webSocket.readyState === 3) {
  487. msg_list.push(dt);
  488. // 已关闭: 重新开启socket
  489. createSocket();
  490. }
  491. }
  492. // 创建socket链接
  493. createSocket();
  494. // let temp_step_msg = '';
  495. /**
  496. * 当 websocket 返回的消息 type=stream 时
  497. * 消息内容是一个字一个字返回的,此时,前端需要将返回的消息进行拼接,以显示完整的消息内容
  498. * 当 type=stream 消息开始时,temp_stream_msg = temp_stream_msg + new_message,
  499. * 并在界面上显示 temp_stream_msg 对应的值
  500. * 当 type=stream 类型的消息结束时,应清空 temp_stream_msg 数据内容
  501. * 以便下一次 type=stream 的消息来临时继续重新拼接
  502. */
  503. let temp_stream_msg = '';
  504. const download_server = window.ASSETS_BASE_URL;
  505. /**
  506. * 处理socket数据
  507. */
  508. function handleSocketMessage(evt_dt, cur_chat_id) {
  509. let res_data = null;
  510. try {
  511. res_data = JSON.parse(evt_dt);
  512. } catch (err) {
  513. console.log(err);
  514. }
  515. if (!res_data) {
  516. return;
  517. }
  518. const { type, reference, step_message, files } = res_data;
  519. const msg_type = type; // 返回的消息类型
  520. const chat_type = props.type; // 对话的类型
  521. let { message } = res_data;
  522. if (!loadingData.value) return;
  523. if (msg_type === 'stream') {
  524. // 没解析完就一直loading
  525. if (step_message == '文件上传完成,开始解析') {
  526. emit('changeParse', true);
  527. }
  528. if (step_message == '文件解析完成') {
  529. emit('changeParse', false);
  530. }
  531. if (files && files.length > 0) {
  532. const file_name = files[0].file_name;
  533. const file_info_arr = file_name.split('.');
  534. const end_fix = file_info_arr[file_info_arr.length - 1];
  535. const file_info = {
  536. file_name: files[0].file_name,
  537. file_url: files[0].file_url
  538. };
  539. // 理论上报表合并,只能是 excel
  540. // if(chat_type === 'excel'){
  541. // file_info.file_type = 'excel'
  542. // }
  543. if (end_fix === 'xlsx') {
  544. file_info.file_type = 'excel';
  545. }
  546. if (end_fix === 'docx') {
  547. file_info.file_type = 'word';
  548. }
  549. loadingData.value.file = file_info;
  550. answerFile.value = file_info;
  551. addData(loadingData.value);
  552. } else {
  553. // if(step_message){
  554. // answerData.value = answerData.value + getHTML(step_message) + "</br>";
  555. // }else{
  556. // answerData.value = answerData.value + message
  557. // }
  558. if (step_message) {
  559. temp_stream_msg = temp_stream_msg + step_message;
  560. // temp_stream_msg = '';
  561. answerData.value = getHTML(temp_stream_msg);
  562. } else {
  563. temp_stream_msg = temp_stream_msg + message;
  564. // temp_step_msg = '';
  565. answerData.value = getHTML(temp_stream_msg);
  566. }
  567. // answerData.value += step_message ? getHTML(step_message) + "</br>" : message
  568. if (answerData.value && !isLoaded.value) {
  569. answerLoaded();
  570. }
  571. addAnswer(loadingData.value);
  572. }
  573. } else {
  574. // 当 type 不是 stream 时,及时清理此值
  575. // 避免下一次拼接时,与前一次拼接冲突
  576. temp_stream_msg = '';
  577. }
  578. if (msg_type === 'message') {
  579. // 获取此时的聊天临时聊天记录中的序号
  580. const cur_index = tempHistory.getChatIndex(cur_chat_id);
  581. message = replaceCode(message, cur_index);
  582. answerData.value = getHTML(message);
  583. answerReference.value = [];
  584. fullRefference.full_ref = reference; // 完整引用数据
  585. // 如有文档引用处理接收到的新消息和引用
  586. if (reference && reference.doc_aggs && reference.doc_aggs.length > 0) {
  587. answerReference.value = reference.doc_aggs.map((item) => {
  588. return {
  589. id: item.doc_id,
  590. doc_name: item.doc_name,
  591. page: 0,
  592. content_ltks: [reference.chunks.find((chunk) => chunk.doc_id == item.doc_id).content_ltks]
  593. };
  594. });
  595. }
  596. // 智能数据
  597. if (chat_type == 'smartData') {
  598. answerData.value = '正在处理中...';
  599. // 以下是智能数据对话的变量
  600. const { image_url, excel_url, excel_name, code, sql } = JSON.parse(evt_dt);
  601. // const port = window.location.port ? `:${window.location.port}` : '';
  602. // 如果有图片或excel,则更新图片或excel地址
  603. if (image_url) {
  604. imageUrl.value = `${download_server}${image_url}`;
  605. }
  606. if (excel_url) {
  607. const file = {
  608. file_type: 'excel',
  609. file_url: `${download_server}${excel_url}`,
  610. file_name: `${excel_name}.xlsx` || '点击下载'
  611. };
  612. answerFile.value = file;
  613. }
  614. if (code) {
  615. const python_code = formatCodePython(code);
  616. answerCode.value = python_code;
  617. }
  618. if (sql) {
  619. const sql_code = formatCodeSql(sql);
  620. answerSql.value = sql_code;
  621. }
  622. }
  623. if (chat_type === 'document_report') {
  624. if (res_data.download_url) {
  625. // const file_url = res_data.download_url;
  626. // const file_url_arr = decodeURIComponent(file_url).split('/');
  627. // const file_name = file_url_arr[file_url_arr.length - 1]
  628. // const file = {
  629. // file_type: 'word',
  630. // // file_url: `http://${window.location.hostname}${port}${file_url}`,
  631. // file_url: res_data.download_url,
  632. // file_name: `${file_name}.docx` || '点击下载',
  633. // }
  634. const file = formatFieldDownloadUrl(res_data.download_url);
  635. answerFile.value = file;
  636. }
  637. }
  638. // 出题
  639. if (chat_type == 'question') {
  640. const { file_url, file_name } = JSON.parse(evt_dt);
  641. // const port = window.location.port ? `:${window.location.port}` : '';
  642. if (file_url) {
  643. const file = {
  644. file_type: 'word',
  645. file_url: `${download_server}${file_url}`,
  646. file_name: `${file_name}.docx` || '点击下载'
  647. };
  648. answerFile.value = file;
  649. }
  650. }
  651. if (answerData.value && !isLoaded.value) {
  652. answerLoaded();
  653. }
  654. addAnswer(loadingData.value);
  655. }
  656. if (msg_type === 'system') {
  657. if (chat_type === 'document_report') {
  658. document_report_system_message.value = res_data.message;
  659. }
  660. }
  661. if (msg_type === 'close') {
  662. // let temp_step_msg = '';
  663. // let temp_stream_msg = '';
  664. /**
  665. * 在小数绘图对话结束时
  666. * 存在一个字段数据
  667. */
  668. if (chat_type === 'huitu') {
  669. // 获取此时的聊天临时聊天记录中的序号
  670. const cur_index = tempHistory.getChatIndex(cur_chat_id);
  671. message = replaceCode(message, cur_index);
  672. answerData.value = getHTML(message);
  673. // 小数绘图
  674. if (res_data.message_files) {
  675. const arr = [];
  676. if (Array.isArray(res_data.message_files)) {
  677. res_data.message_files.forEach((item, index) => {
  678. arr.push(item);
  679. });
  680. fullImageUrls.url = arr;
  681. } else {
  682. fullImageUrls.url = arr;
  683. }
  684. }
  685. answerLoaded();
  686. stopWriting();
  687. answerData.value = '';
  688. isLoaded.value = false;
  689. } else if (chat_type === 'excel') {
  690. // 报表合并
  691. answerLoaded();
  692. answerData.value = getHTML(message);
  693. addAnswer(loadingData.value);
  694. answerData.value = getHTML(message);
  695. stopWriting();
  696. } else {
  697. if (!answerData.value) {
  698. answerLoaded();
  699. answerData.value = getHTML(message);
  700. addAnswer(loadingData.value);
  701. }
  702. stopWriting();
  703. answerData.value = '';
  704. isLoaded.value = false;
  705. }
  706. }
  707. }
  708. helper.webSocket.onmessage = (event) => {
  709. const evt_dt = event.data;
  710. /**
  711. * 例如:ws://localhost/api/chat/ws/42e4fcdc9bea11efac300242ac160006/765f672c700f49b79a473fc906fe388c?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyIiwidXNlcl9pZCI6MjEsImV4cCI6MTczMjQzNzkzNH0.7SPOZpnaTUu2KPzWIJrhhkRehjePeuL8TABo7rNgnCY
  712. */
  713. const socket_url = event.target.url; // socket连接地址
  714. const cur_chat_id = getChatIdFromUrl(socket_url);
  715. // setTempHistory(event);
  716. tempHistory.setHistory(event);
  717. // 处理socket数据
  718. handleSocketMessage(evt_dt, cur_chat_id);
  719. };
  720. /**
  721. * 所有数据的发送,统一走到这里
  722. * 通过websocket进行发送
  723. */
  724. helper.$bus.on('send-message', (value) => {
  725. // console.log(value, '会话的内容');
  726. /**
  727. * 当消息发送时,及时清理stream的拼接值
  728. * 避免本次发送,返回的stream数据与前一次返回的stream数据冲突
  729. */
  730. temp_stream_msg = '';
  731. dialogConfig.value = helper.dialogConfig;
  732. const chat_type = props.type; // 对话的类型
  733. const question = chat_type === 'report' ? value.inputs.report_name : value;
  734. const data = addQuestion(question);
  735. loadingData.value = addLoading(data);
  736. let sendData = {
  737. message: value
  738. };
  739. if (chat_type === 'report') {
  740. sendData = value;
  741. }
  742. if (chat_type === 'wendangzhineng') {
  743. const msgObj = value;
  744. const question = msgObj.message;
  745. const data = addQuestion(question);
  746. loadingData.value = addLoading(data);
  747. // 文档智能
  748. sendData = value;
  749. }
  750. if (chat_type === 'excel') {
  751. sendData = value;
  752. }
  753. if (chat_type === 'doc') {
  754. sendData.doc_ids = [helper.read('docId')];
  755. }
  756. // 小数绘图
  757. if (chat_type === 'huitu') {
  758. const img_file = helper.read('sendData');
  759. if (img_file) {
  760. const upload_file_id = img_file.upload_file_id;
  761. if (upload_file_id) {
  762. sendData = {
  763. message: value,
  764. upload_file_id: upload_file_id
  765. };
  766. setTimeout(() => {
  767. // 文字消息上传成功
  768. imageUploadStatus.messageFinish();
  769. // 记录此时页面中的问题记录
  770. huituSetTempImageIndex(dialogList.length);
  771. helper.write('sendData', {});
  772. });
  773. }
  774. } else {
  775. sendData = {
  776. message: value
  777. };
  778. }
  779. }
  780. if (chat_type === 'document_report') {
  781. const docReport = helper.read('sendData');
  782. if (docReport) {
  783. const upload_files = docReport.upload_files;
  784. sendData = {
  785. title: value,
  786. upload_files: docReport.upload_files,
  787. workflow: docReport.workflow
  788. };
  789. setTimeout(() => {
  790. // // 文字消息上传成功
  791. // imageUploadStatus.messageFinish();
  792. // // 记录此时页面中的问题记录
  793. // huituSetTempImageIndex(dialogList.length);
  794. helper.write('sendData', {});
  795. });
  796. } else {
  797. console.log('无数据信息');
  798. sendData = {
  799. message: value
  800. };
  801. }
  802. }
  803. const dt = JSON.stringify(sendData);
  804. // 发送socket数据
  805. sendSocketMsg(dt);
  806. });
  807. helper.$bus.on('clear-message', () => {
  808. dialogList.splice(0);
  809. });
  810. helper.$bus.on('stop-writing', () => {
  811. stopWriting();
  812. });
  813. });
  814. /**
  815. * 检查对话数据记录中是否存在代码(python或者SQL)
  816. * 在 智能数据 显示代码时,不用显示用户头像
  817. **/
  818. const chatItemHasCode = (item) => {
  819. if (item) {
  820. if (item.code || item.sql) {
  821. console.log('有代码');
  822. return true;
  823. }
  824. }
  825. console.log('无代码');
  826. return false;
  827. };
  828. return {
  829. dialogId: props.dialogId,
  830. goKnowledge,
  831. randomKey,
  832. showFeedback,
  833. copyAnswer,
  834. dialogList,
  835. getHTML,
  836. // selectSuggestion,
  837. dialogScroll,
  838. reQuestion,
  839. menuList,
  840. saveAnswer,
  841. openCapacity,
  842. feedbackAnswer,
  843. handleOk,
  844. handleCancel,
  845. stopWriting,
  846. knowledgeList,
  847. dialogConfig,
  848. // userName,
  849. downloadFile,
  850. openDocument,
  851. // openDocuementPage,
  852. show_info_btns,
  853. checkAllReference,
  854. chatItemHasCode,
  855. document_report_system_message
  856. };
  857. }
  858. });
  859. </script>
  860. <style>
  861. .dialog-header {
  862. display: flex;
  863. align-items: center;
  864. .dialog-span {
  865. color: rgba(51, 51, 51, 1);
  866. font-size: 14px;
  867. font-weight: bold;
  868. }
  869. }
  870. /* 如果有代码,则不显示头像 */
  871. .dialog-header.header-answer.has-code {
  872. display: none;
  873. }
  874. </style>
  875. <style scoped>
  876. /* .user-name {
  877. width: 28px;
  878. height: 28px;
  879. border-radius: 14px;
  880. display: flex;
  881. align-items: center;
  882. justify-content: center;
  883. color: #fff;
  884. } */
  885. .paper-download {
  886. padding-left: 50px;
  887. > span {
  888. width: 26px;
  889. height: 26px;
  890. border-radius: 3px;
  891. cursor: pointer;
  892. display: flex;
  893. align-items: center;
  894. justify-content: center;
  895. &:hover {
  896. background: rgba(150, 171, 185, 0.2);
  897. }
  898. }
  899. }
  900. .paper-wrap {
  901. display: flex;
  902. align-items: center;
  903. margin-bottom: 10px;
  904. cursor: pointer;
  905. background-color: #f5f7fe;
  906. border-radius: 16px;
  907. padding: 6px;
  908. margin-left: 50px;
  909. > img {
  910. width: 50px;
  911. margin: 8px 6px;
  912. }
  913. > span {
  914. flex: 1;
  915. white-space: nowrap;
  916. overflow: hidden;
  917. text-overflow: ellipsis;
  918. > b {
  919. white-space: nowrap;
  920. overflow: hidden;
  921. text-overflow: ellipsis;
  922. display: block;
  923. width: 100%;
  924. }
  925. > em {
  926. font-style: normal;
  927. }
  928. }
  929. }
  930. .knowledge-detail {
  931. width: 320px;
  932. padding-top: 20px;
  933. .knowledge-content {
  934. height: 300px;
  935. overflow-y: auto;
  936. line-height: 30px;
  937. }
  938. .knowledge-footer {
  939. border-top: 1px solid rgba(229, 229, 229, 1);
  940. margin-top: 20px;
  941. padding-top: 20px;
  942. display: flex;
  943. justify-content: space-between;
  944. align-items: center;
  945. p {
  946. &:nth-child(1) {
  947. opacity: 0.8;
  948. }
  949. &:nth-child(2) {
  950. flex: 1;
  951. display: flex;
  952. justify-content: left;
  953. margin: 0 30px;
  954. > span {
  955. margin: 0 5px;
  956. cursor: pointer;
  957. &:hover,
  958. &.active {
  959. color: #00aea3;
  960. }
  961. }
  962. }
  963. &:nth-child(3) {
  964. font-weight: bold;
  965. cursor: pointer;
  966. &:hover {
  967. color: #00aea3;
  968. }
  969. }
  970. }
  971. }
  972. }
  973. .knowledge-wrap {
  974. padding: 10px 0 20px 50px;
  975. > header {
  976. display: flex;
  977. justify-content: space-between;
  978. > p {
  979. &:nth-child(1) {
  980. color: #7f7f7f;
  981. font-weight: bold;
  982. }
  983. &:nth-child(2) {
  984. cursor: pointer;
  985. &:hover {
  986. color: #00aea3;
  987. }
  988. }
  989. }
  990. }
  991. > section {
  992. > div {
  993. > div {
  994. height: 40px;
  995. display: inline-flex;
  996. align-items: center;
  997. > span {
  998. &:nth-child(1) {
  999. display: inline-block;
  1000. background-color: rgba(0, 174, 163, 0.2);
  1001. color: #00aea3;
  1002. padding: 1px 5px;
  1003. border-radius: 2px;
  1004. margin-right: 5px;
  1005. font-size: 12px;
  1006. }
  1007. &:nth-child(2) {
  1008. cursor: pointer;
  1009. &:hover {
  1010. color: #00aea3;
  1011. }
  1012. }
  1013. }
  1014. }
  1015. }
  1016. }
  1017. }
  1018. .dialog-absolute {
  1019. .dialog-header {
  1020. position: absolute;
  1021. &:nth-child(1) {
  1022. transform: translateY(10px);
  1023. }
  1024. &:nth-child(3) {
  1025. transform: translateY(16px);
  1026. }
  1027. }
  1028. .dialog-footer {
  1029. margin-left: 50px;
  1030. &:nth-child(2) {
  1031. margin-left: 50px;
  1032. padding-left: 0;
  1033. }
  1034. }
  1035. .dialog-code-footer {
  1036. border-radius: 12px;
  1037. background-color: rgba(245, 247, 254, 1);
  1038. padding: 12px 16px;
  1039. /* margin: 16px 0; */
  1040. margin: 16px 0 16px 50px;
  1041. }
  1042. /* .dialog-code-footer {
  1043. border-radius: 12px;
  1044. font-size: 14px;
  1045. background-color: #32333c;
  1046. color: #BCBDC3;
  1047. margin: 16px 0;
  1048. margin-left: 50px;
  1049. .dialog-code-footer-title {
  1050. font-size: 16px;
  1051. font-weight: 500;
  1052. width: 100%;
  1053. color: #BCBDC3;
  1054. }
  1055. &:nth-child(2) {
  1056. background-color: rgba(0, 0, 0, 0);
  1057. margin: 0;
  1058. }
  1059. >p {
  1060. font-size: 14px;
  1061. }
  1062. >div {
  1063. font-size: 14px;
  1064. padding: 4px 8px;
  1065. border-radius: 4px;
  1066. align-items: center;
  1067. cursor: pointer;
  1068. &.disabled {
  1069. cursor: not-allowed;
  1070. }
  1071. >b {
  1072. margin-right: 8px;
  1073. }
  1074. }
  1075. >section {
  1076. padding: 0 16px;
  1077. background-color: #ffffff;
  1078. border-radius: 12px;
  1079. margin-top: 16px;
  1080. >p {
  1081. display: inline-block;
  1082. color: rgba(16, 16, 16, 1);
  1083. font-size: 12px;
  1084. margin-top: 16px;
  1085. width: 100%;
  1086. }
  1087. >div {
  1088. margin-top: 4px;
  1089. overflow: hidden;
  1090. margin-bottom: 16px;
  1091. display: inline-block;
  1092. width: 100%;
  1093. >div {
  1094. margin-top: 8px;
  1095. >div {
  1096. &:nth-child(1) {
  1097. border-radius: 4px;
  1098. color: rgba(16, 16, 16, 1);
  1099. font-size: 12px;
  1100. height: 24px;
  1101. border: 1px solid rgba(229, 229, 229, 1);
  1102. display: flex;
  1103. justify-content: center;
  1104. align-items: center;
  1105. padding-right: 8px;
  1106. cursor: pointer;
  1107. &.disabled {
  1108. cursor: not-allowed;
  1109. }
  1110. &:hover {
  1111. background: rgba(229, 229, 229, 0.2);
  1112. }
  1113. >span {
  1114. &:nth-child(1) {
  1115. background-color: rgba(0, 174, 163, 0.2);
  1116. color: #00aea3;
  1117. font-size: 12px;
  1118. border: 1px solid rgba(64, 95, 234, 0.13);
  1119. padding: 0 4px;
  1120. margin: 0 4px 0 0;
  1121. }
  1122. &:nth-child(3) {
  1123. color: #00aea3;
  1124. font-size: 12px;
  1125. em {
  1126. padding: 0 4px;
  1127. font-style: normal;
  1128. border-left: 1px solid rgba(64, 95, 234, 1);
  1129. font-weight: bold;
  1130. &:nth-child(1) {
  1131. border: none;
  1132. }
  1133. }
  1134. }
  1135. }
  1136. }
  1137. &:nth-child(2) {
  1138. >p {
  1139. margin: 8px 0;
  1140. display: flex;
  1141. >span {
  1142. transform: translateY(2px);
  1143. color: #00aea3;
  1144. font-weight: bold;
  1145. font-size: 12px;
  1146. margin-right: 8px;
  1147. }
  1148. }
  1149. }
  1150. }
  1151. }
  1152. >p {
  1153. float: left;
  1154. width: 48%;
  1155. border-radius: 4px;
  1156. background-color: rgba(245, 247, 254, 1);
  1157. color: rgba(16, 16, 16, 1);
  1158. font-size: 12px;
  1159. margin-top: 8px;
  1160. height: 36px;
  1161. line-height: 36px;
  1162. padding: 0 8px;
  1163. display: flex;
  1164. align-items: center;
  1165. &:nth-child(odd) {
  1166. margin-right: 4%;
  1167. }
  1168. }
  1169. }
  1170. }
  1171. } */
  1172. }
  1173. .dialog-flex-wrap {
  1174. position: relative;
  1175. flex: 1;
  1176. margin-top: 16px;
  1177. height: 100%;
  1178. }
  1179. .dialog-flex {
  1180. position: absolute;
  1181. left: 0;
  1182. top: 0;
  1183. right: 0;
  1184. bottom: 0;
  1185. overflow-y: auto;
  1186. overflow-x: hidden;
  1187. padding-right: 32px;
  1188. }
  1189. .section-open {
  1190. margin-top: 12px;
  1191. }
  1192. .dialog-file {
  1193. width: 421px;
  1194. height: 48px;
  1195. border-radius: 12px;
  1196. background-color: rgba(255, 255, 255, 1);
  1197. color: rgba(16, 16, 16, 1);
  1198. font-size: 14px;
  1199. border: 1px solid rgba(229, 229, 229, 1);
  1200. display: flex;
  1201. align-items: center;
  1202. margin-bottom: 16px;
  1203. padding: 0 8px;
  1204. }
  1205. .dialog-footer {
  1206. border-radius: 12px;
  1207. background-color: rgba(245, 247, 254, 1);
  1208. padding: 12px 16px;
  1209. margin: 16px 0;
  1210. &:nth-child(2) {
  1211. background-color: rgba(0, 0, 0, 0);
  1212. margin: 0;
  1213. }
  1214. > p {
  1215. color: rgba(16, 16, 16, 1);
  1216. font-size: 14px;
  1217. }
  1218. > div {
  1219. border: 1px solid rgba(64, 95, 234, 0.42);
  1220. background-color: rgba(255, 255, 255, 1);
  1221. color: rgba(16, 16, 16, 1);
  1222. font-size: 14px;
  1223. display: inline-flex;
  1224. padding: 4px 8px;
  1225. border-radius: 4px;
  1226. align-items: center;
  1227. cursor: pointer;
  1228. height: 30px;
  1229. &.disabled {
  1230. cursor: not-allowed;
  1231. }
  1232. &:hover {
  1233. background: rgb(245, 247, 254, 0.4);
  1234. }
  1235. > span {
  1236. margin: 0 8px;
  1237. }
  1238. > b {
  1239. margin-right: 8px;
  1240. }
  1241. }
  1242. > section {
  1243. padding: 0 16px;
  1244. background-color: #ffffff;
  1245. border-radius: 12px;
  1246. margin-top: 16px;
  1247. > p {
  1248. display: inline-block;
  1249. color: rgba(16, 16, 16, 1);
  1250. font-size: 12px;
  1251. margin-top: 16px;
  1252. width: 100%;
  1253. }
  1254. > div {
  1255. margin-top: 4px;
  1256. overflow: hidden;
  1257. margin-bottom: 16px;
  1258. display: inline-block;
  1259. width: 100%;
  1260. > div {
  1261. margin-top: 8px;
  1262. > div {
  1263. &:nth-child(1) {
  1264. border-radius: 4px;
  1265. color: rgba(16, 16, 16, 1);
  1266. font-size: 12px;
  1267. height: 24px;
  1268. border: 1px solid rgba(229, 229, 229, 1);
  1269. display: flex;
  1270. justify-content: center;
  1271. align-items: center;
  1272. padding-right: 8px;
  1273. cursor: pointer;
  1274. &.disabled {
  1275. cursor: not-allowed;
  1276. }
  1277. &:hover {
  1278. background: rgba(229, 229, 229, 0.2);
  1279. }
  1280. > span {
  1281. &:nth-child(1) {
  1282. background-color: rgba(0, 174, 163, 0.2);
  1283. color: #00aea3;
  1284. font-size: 12px;
  1285. border: 1px solid rgba(64, 95, 234, 0.13);
  1286. padding: 0 4px;
  1287. margin: 0 4px 0 0;
  1288. }
  1289. &:nth-child(3) {
  1290. color: #00aea3;
  1291. font-size: 12px;
  1292. em {
  1293. padding: 0 4px;
  1294. font-style: normal;
  1295. border-left: 1px solid rgba(64, 95, 234, 1);
  1296. font-weight: bold;
  1297. &:nth-child(1) {
  1298. border: none;
  1299. }
  1300. }
  1301. }
  1302. }
  1303. }
  1304. &:nth-child(2) {
  1305. > p {
  1306. margin: 8px 0;
  1307. display: flex;
  1308. > span {
  1309. transform: translateY(2px);
  1310. color: #00aea3;
  1311. font-weight: bold;
  1312. font-size: 12px;
  1313. margin-right: 8px;
  1314. }
  1315. }
  1316. }
  1317. }
  1318. }
  1319. > p {
  1320. float: left;
  1321. width: 48%;
  1322. border-radius: 4px;
  1323. background-color: rgba(245, 247, 254, 1);
  1324. color: rgba(16, 16, 16, 1);
  1325. font-size: 12px;
  1326. margin-top: 8px;
  1327. height: 36px;
  1328. line-height: 36px;
  1329. padding: 0 8px;
  1330. display: flex;
  1331. align-items: center;
  1332. &:nth-child(odd) {
  1333. margin-right: 4%;
  1334. }
  1335. }
  1336. }
  1337. }
  1338. }
  1339. /**
  1340. .section-suggestions {
  1341. margin: 12px 0 20px;
  1342. .section-suggestion {
  1343. width: 380px;
  1344. height: 40px;
  1345. line-height: 40px;
  1346. border: 1px solid #e5e5e5;
  1347. border-radius: 12px;
  1348. padding: 0 8px;
  1349. display: flex;
  1350. align-items: center;
  1351. justify-content: space-between;
  1352. cursor: pointer;
  1353. margin-top: 8px;
  1354. &.disabled {
  1355. cursor: not-allowed;
  1356. }
  1357. &:hover {
  1358. background: rgb(245, 247, 254);
  1359. }
  1360. }
  1361. }
  1362. */
  1363. .dialog-other {
  1364. margin-bottom: 16px;
  1365. display: flex;
  1366. align-items: center;
  1367. justify-content: space-between;
  1368. > p {
  1369. display: flex;
  1370. align-items: center;
  1371. span {
  1372. margin-left: 8px;
  1373. color: rgba(16, 16, 16, 1);
  1374. font-size: 12px;
  1375. }
  1376. }
  1377. > div {
  1378. display: flex;
  1379. p {
  1380. display: flex;
  1381. align-items: center;
  1382. justify-content: center;
  1383. width: 30px;
  1384. height: 30px;
  1385. border-radius: 15px;
  1386. border: 1px solid rgba(229, 229, 229, 1);
  1387. margin-left: 8px;
  1388. cursor: pointer;
  1389. &.disabled {
  1390. cursor: not-allowed;
  1391. }
  1392. &:hover {
  1393. background-color: rgba(245, 247, 254, 1);
  1394. }
  1395. }
  1396. }
  1397. }
  1398. .feedback-title {
  1399. color: rgba(102, 102, 102, 1);
  1400. font-size: 12px;
  1401. margin: 0 0 8px 4px;
  1402. }
  1403. .feedback-content {
  1404. margin-bottom: 16px;
  1405. }
  1406. .dialog-writing-button {
  1407. position: absolute;
  1408. bottom: -30px;
  1409. left: 50%;
  1410. transform: translateX(-50%);
  1411. text-align: center;
  1412. width: 106px;
  1413. height: 34px;
  1414. line-height: 34px;
  1415. border-radius: 4px;
  1416. background-color: rgba(255, 255, 255, 1);
  1417. color: rgba(16, 16, 16, 1);
  1418. font-size: 14px;
  1419. border: 1px solid rgba(229, 229, 229, 1);
  1420. display: flex;
  1421. align-items: center;
  1422. justify-content: center;
  1423. cursor: pointer;
  1424. z-index: 10;
  1425. &:hover {
  1426. background: rgb(245, 247, 254);
  1427. }
  1428. }
  1429. </style>
  1430. <style>
  1431. .circle {
  1432. width: 13px;
  1433. height: 13px;
  1434. margin-left: 4px;
  1435. border-radius: 50%;
  1436. cursor: pointer;
  1437. display: inline-block;
  1438. border: 1px solid #888;
  1439. }
  1440. .circle::before {
  1441. content: '!';
  1442. font-size: 12px;
  1443. color: #000;
  1444. line-height: 12px;
  1445. text-align: center;
  1446. display: block;
  1447. }
  1448. </style>