main
han 5 months ago
parent 2d327401c7
commit 0b767f0d66
  1. 2
      src/assets/styles/v-layout.scss
  2. 63
      src/components/FileUpload/index.vue
  3. 224
      src/components/FileUpload1/index.vue
  4. 38
      src/views/pages/AI-Document-Correction/dialog.vue
  5. 30
      src/views/pages/AI-Document-Writing/dialog.vue

@ -152,7 +152,7 @@ $--base-super-radius: 24px;
.el-form-item.v-item-inline {
display: flex;
align-items: center;
.el-form-item__label {
float: none;

@ -1,38 +1,37 @@
<template>
<div class="upload-file">
<el-upload
multiple
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:limit="limit"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:show-file-list="false"
:headers="headers"
class="upload-file-uploader"
ref="fileUpload"
multiple
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:limit="limit"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:show-file-list="false"
:headers="headers"
class="upload-file-uploader"
ref="fileUpload"
>
<!-- 上传按钮 -->
<i class="el-icon-document"></i>上传资料
<!-- &lt;!&ndash; 上传提示 &ndash;&gt;-->
<!-- <div class="el-upload__tip" slot="tip" v-if="showTip">-->
<!-- 请上传-->
<!-- <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>-->
<!-- <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>-->
<!-- 的文件-->
<!-- </div>-->
<!-- &lt;!&ndash; 上传提示 &ndash;&gt;-->
<!-- <div class="el-upload__tip" slot="tip" v-if="showTip">-->
<!-- 请上传-->
<!-- <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>-->
<!-- <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>-->
<!-- 的文件-->
<!-- </div>-->
</el-upload>
<!-- 文件列表 -->
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
<el-link :href="`${file.url}`" :underline="false" target="_blank">
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content row"
v-for="(file, index) in fileList">
<span class="el-icon-document"> {{ file.name }} </span>
</el-link>
<div class="ele-upload-list__item-content-action">
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
<i class="el-icon-delete" @click="handleDelete(index)"></i>
</div>
</li>
</transition-group>
@ -40,7 +39,7 @@
</template>
<script>
import { getAccessToken } from "@/utils/auth";
import {getAccessToken} from "@/utils/auth";
export default {
name: "FileUpload",
@ -74,7 +73,7 @@ export default {
uploadList: [],
baseUrl: process.env.VUE_APP_BASE_API,
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/Unify-chat/uploadFile", //
headers: { Authorization: "Bearer " + getAccessToken() }, //
headers: {Authorization: "Bearer " + getAccessToken()}, //
fileList: [],
};
},
@ -88,7 +87,7 @@ export default {
//
this.fileList = list.map(item => {
if (typeof item === "string") {
item = { name: item, url: item };
item = {name: item, url: item};
}
item.uid = item.uid || new Date().getTime() + temp++;
return item;
@ -150,10 +149,10 @@ export default {
},
//
handleUploadSuccess(res, file) {
console.log('res',res,file)
console.log('res', res, file)
if (res.code === 0) {
// edit by
this.uploadList.push({ name: file.name, url: res.data });
this.uploadList.push({name: file.name, url: res.data});
this.uploadedSuccessfully();
} else {
this.number--;
@ -203,18 +202,22 @@ export default {
.upload-file-uploader {
margin-bottom: 5px;
}
.upload-file-list .el-upload-list__item {
border: 1px solid #e4e7ed;
background-color: #fff;
padding: 0 10px;
line-height: 2;
margin-bottom: 10px;
position: relative;
}
.upload-file-list .ele-upload-list__item-content {
display: flex;
justify-content: space-between;
justify-content: space-between !important;
align-items: center;
color: inherit;
}
.ele-upload-list__item-content-action .el-link {
margin-right: 10px;
}

@ -0,0 +1,224 @@
<template>
<div class="upload-file">
<el-upload
multiple
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:limit="limit"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:show-file-list="false"
:headers="headers"
class="upload-file-uploader"
ref="fileUpload"
>
<!-- 上传按钮 -->
<i class="el-icon-document"></i>上传资料
<!-- &lt;!&ndash; 上传提示 &ndash;&gt;-->
<!-- <div class="el-upload__tip" slot="tip" v-if="showTip">-->
<!-- 请上传-->
<!-- <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>-->
<!-- <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>-->
<!-- 的文件-->
<!-- </div>-->
</el-upload>
<!-- 文件列表 -->
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content row"
v-for="(file, index) in fileList">
<span class="el-icon-document"> {{ file.name }} </span>
<div class="ele-upload-list__item-content-action">
<i class="el-icon-delete" @click="handleDelete(index)"></i>
</div>
</li>
</transition-group>
</div>
</template>
<script>
import {getAccessToken} from "@/utils/auth";
export default {
name: "FileUpload",
props: {
//
value: [String, Object, Array],
//
limit: {
type: Number,
default: 5,
},
// (MB)
fileSize: {
type: Number,
default: 5,
},
// , ['png', 'jpg', 'jpeg']
fileType: {
type: Array,
default: () => ["doc", "xls", "ppt", "txt", "pdf"],
},
//
isShowTip: {
type: Boolean,
default: true
}
},
data() {
return {
number: 0,
uploadList: [],
baseUrl: process.env.VUE_APP_BASE_API,
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/Unify-chat/uploadFile", //
headers: {Authorization: "Bearer " + getAccessToken()}, //
fileList: [],
};
},
watch: {
value: {
handler(val) {
if (val) {
let temp = 1;
//
const list = Array.isArray(val) ? val : this.value.split(',');
//
this.fileList = list.map(item => {
if (typeof item === "string") {
item = {name: item, url: item};
}
item.uid = item.uid || new Date().getTime() + temp++;
return item;
});
} else {
this.fileList = [];
return [];
}
},
deep: true,
immediate: true
}
},
computed: {
//
showTip() {
return this.isShowTip && (this.fileType || this.fileSize);
},
},
methods: {
//
handleBeforeUpload(file) {
//
if (this.fileType) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
}
const isTypeOk = this.fileType.some((type) => {
if (file.type.indexOf(type) > -1) return true;
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
return false;
});
if (!isTypeOk) {
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
return false;
}
}
//
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
return false;
}
}
this.$modal.loading("正在上传文件,请稍候...");
this.number++;
return true;
},
//
handleExceed() {
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
},
//
handleUploadError(err) {
this.$modal.msgError("上传图片失败,请重试");
this.$modal.closeLoading()
},
//
handleUploadSuccess(res, file) {
console.log('res', res, file)
if (res.code === 0) {
// edit by
this.uploadList.push({name: file.name, url: res.data});
this.uploadedSuccessfully();
} else {
this.number--;
this.$modal.closeLoading();
this.$modal.msgError(res.msg);
this.$refs.fileUpload.handleRemove(file);
this.uploadedSuccessfully();
}
},
//
handleDelete(index) {
this.fileList.splice(index, 1);
this.$emit("input", this.listToString(this.fileList));
},
//
uploadedSuccessfully() {
if (this.number > 0 && this.uploadList.length === this.number) {
this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = [];
this.number = 0;
this.$emit("input", this.listToString(this.fileList));
this.$modal.closeLoading();
}
},
//
getFileName(name) {
if (name.lastIndexOf("/") > -1) {
return name.slice(name.lastIndexOf("/") + 1);
} else {
return "";
}
},
//
listToString(list, separator) {
let strs = "";
separator = separator || ",";
for (let i in list) {
strs += list[i].url + separator;
}
return strs != '' ? strs.substr(0, strs.length - 1) : '';
}
}
};
</script>
<style scoped lang="scss">
.upload-file-uploader {
margin-bottom: 5px;
}
.upload-file-list .el-upload-list__item {
background-color: #fff;
padding: 0 10px;
line-height: 2;
margin-bottom: 10px;
position: relative;
}
.upload-file-list .ele-upload-list__item-content {
display: flex;
justify-content: space-between !important;
align-items: center;
color: inherit;
}
.ele-upload-list__item-content-action .el-link {
margin-right: 10px;
}
</style>

@ -8,7 +8,7 @@
<div class="ai-edit-left col m-r-large v-overflow-y" v-loading="generatedLoading"
element-loading-text="请稍后,正文生成中...">
<div class="ai-show-btn show" @click="showPage=!showPage"><i class="el-icon-arrow-right"></i></div>
<ckeditor :editor="editor" v-model="editorData" :config="editorConfig" style="height:500px" />
<ckeditor :editor="editor" v-model="editorData" :config="editorConfig" style="height:500px"/>
<div class="v-edit-tool">
<div class="v-edit-tool-item down" @click="downLoadDoc"><i class="iconfont icon-down"></i></div>
<div class="v-edit-tool-item refresh" @click="refreshDoc"><i class="iconfont icon-refresh"></i></div>
@ -63,7 +63,7 @@
:disabled="generatedLoading"
resize="none"></el-input>
</el-form-item>
<el-form-item label="内容篇幅" class="v-item-inline">
<el-form-item label="内容篇幅" class="v-item-inline flex-align-center">
<el-radio-group v-model="form.length" class="v-radio-group" :disabled="generatedLoading">
<el-radio :label="0">短篇</el-radio>
<el-radio :label="1">中篇</el-radio>
@ -72,7 +72,7 @@
</el-form-item>
<el-form-item label="参考资料" class="v-item-inline">
<div class="text-right color-primary">
<FileUpload ref="upload" :limit="1" :fileType="['png', 'jpg', 'jpeg', 'text']"
<FileUpload ref="upload" :limit="1" :file-type="['png', 'jpg', 'jpeg', 'doc','docx']"
@input="handleReferenceChange">
<i class="el-icon-document"></i>上传资料
</FileUpload>
@ -80,7 +80,7 @@
</el-form-item>
<el-form-item label="仿写资料" class="v-item-inline">
<div class="text-right color-primary">
<FileUpload ref="upload" :limit="1" :fileType="['png', 'jpg', 'jpeg', 'text']"
<FileUpload ref="upload1" :limit="1" :file-type="['png', 'jpg', 'jpeg', 'doc','docx']"
@input="handleImitationChange">
<i class="el-icon-document"></i>上传资料
</FileUpload>
@ -88,7 +88,7 @@
</el-form-item>
</el-form>
<!-- skType 1深度思考 2普通问答 -->
<div class="ai-ecode-content" v-if="skType==1&&thinkStart">
<div class="ai-ecode-content" v-if="skType==1">
<div class="ai-ecode-msg">
<div class="ai-ecode-msg-title"><img src="@/assets/ai-images/aie.png" class="ai-ecode-msg-title-img"/>
<div class="ai-ecode-msg-title-txt" v-if="thinkState">已深度思考,耗时{{ thinkTimes }}</div>
@ -113,7 +113,10 @@
<script>
import FileUpload from '@/components/FileUpload'
import FileUpload1 from '@/components/FileUpload1'
import * as AiApi from '@/api/ai-api'
const {
GeneralHtmlSupport,
HtmlComment,
@ -184,18 +187,18 @@ const {
Base64UploadAdapter,
} = CKEDITOR;
const { FormatPainter } = CKEDITOR_PREMIUM_FEATURES;
const {FormatPainter} = CKEDITOR_PREMIUM_FEATURES;
export default {
name: 'DocumentCorrectionDialog',
components: { FileUpload},
components: {FileUpload,FileUpload1},
data() {
return {
editor: ClassicEditor,
editorData: "<h1 style='color:red'>asdf</h1>",
editorConfig: {
licenseKey:"eyJhbGciOiJFUzI1NiJ9.eyJleHAiOjE3ODAwMTI3OTksImp0aSI6IjIzOThmNWExLTU5NGItNDVmNC04YjZiLTYxY2M0MWQ5YzE0YiIsInVzYWdlRW5kcG9pbnQiOiJodHRwczovL3Byb3h5LWV2ZW50LmNrZWRpdG9yLmNvbSIsImRpc3RyaWJ1dGlvbkNoYW5uZWwiOlsiY2xvdWQiLCJkcnVwYWwiXSwiZmVhdHVyZXMiOlsiRFJVUCIsIkUyUCIsIkUyVyJdLCJ2YyI6IjY4OTc5NjhlIn0.-YzAWQBdSXs9w0xLPLc4v2T2wVUnMShOBNMXceWayj4oXbfVEsMokgHHr_4zHTtoQbCbc3pWMxR5iSYaY8Xhtw",
licenseKey: "eyJhbGciOiJFUzI1NiJ9.eyJleHAiOjE3NDk2ODYzOTksImp0aSI6ImFlNDIyNDQ4LTZlMzYtNDU3Mi05N2FhLWViNDEyZGY3NjYxZCIsInVzYWdlRW5kcG9pbnQiOiJodHRwczovL3Byb3h5LWV2ZW50LmNrZWRpdG9yLmNvbSIsImRpc3RyaWJ1dGlvbkNoYW5uZWwiOlsiY2xvdWQiLCJkcnVwYWwiLCJzaCJdLCJ3aGl0ZUxhYmVsIjp0cnVlLCJsaWNlbnNlVHlwZSI6InRyaWFsIiwiZmVhdHVyZXMiOlsiKiJdLCJ2YyI6IjQ2NTY4ZTczIn0.tle2DeT9IWKLaVnhU0-EST0NhqhkHPxsUl5g1i0wiFmC1rjT9uwxSGnMZdd-CsLC5o_0n-B2PXAYeZFjkXfECw",
placeholder: "请输入内容",
language: 'zh-cn',
@ -338,22 +341,23 @@ export default {
reasoningContent: '',
}
},
mounted() {
let params
console.log(this.$route.params.data)
if (this.$route.params.data) {
params = this.$route.params.data
localStorage.setItem('fileData', params);
} else {
params = localStorage.getItem('fileData')
}
this.form.type = params.type
this.form.docType = params.docType
this.form.title = params.title
this.form.keywords = params.keywords
this.form.first = params.first
this.form.first = params.second
this.getModellist()
this.getDocumentType()
},
@ -405,7 +409,7 @@ export default {
children: children
}
})
//this.generateDoc()
//this.generateDoc()
} catch (err) {
} finally {
}
@ -443,20 +447,23 @@ export default {
let child = model.children.find((item, index) => {
return item.value == val[1]
})
this.thinkState=true
this.skType = child.skType
},
/** 获取 公文列表 */
onCreated(editor) {
this.editor = Object.seal(editor) // Object.seal()
},
handleReferenceChange(file) {
handleReferenceChange(file) {console.log(file)
this.form.referenceDocumentId = file
},
handleImitationChange(file) {
console.log(file)
this.form.imitationDocumentId = file
},
/** 生成 公文 */
async generateDoc() {
try {
await this.$refs['formRef'].validate()
this.generatedContent = '';
@ -481,10 +488,14 @@ export default {
let docType = this.DocumentType.find((item) => {
return item.value == this.form.docType
})
let subType = this.typeList.find((item) => {
return item.value == this.form.subType
})
try {
const params = {
docType: docType.label, // /
subType: this.form.subType,//
subType:subType.label ,//
title: this.form.title, //
keywords: this.form.keywords, //
userRole: this.form.userRole, //
@ -495,6 +506,7 @@ export default {
referenceDocumentId: this.form.referenceDocumentId,//
imitationDocumentId: this.form.imitationDocumentId,//仿
};
console.log(params)
this.eventSource = await AiApi.chatStream(params);
this.eventSource.onmessage = (event) => {

@ -31,7 +31,7 @@
</div>
<div class="btn">
<el-button size="mini" type="primary" round @click="acceptAllError">全部接受</el-button>
<!-- <el-button plain size="mini" round>重新检查</el-button>-->
<!-- <el-button plain size="mini" round>重新检查</el-button>-->
</div>
</div>
<div class="v-overflow-y" style="height: calc(100vh - 200px);">
@ -114,6 +114,7 @@ export default {
editor.destroy()
},
mounted() {
console.log(localStorage.getItem('fileId'))
if (this.$route.params.fileId) {
this.fileId = this.$route.params.fileId
localStorage.setItem('fileId', this.fileId);
@ -156,7 +157,7 @@ export default {
this.errorListOld = res.data.errorContents
this.errorList.forEach((item, index, arr) => {
if (index == 0) {
this.changeDocumentClass(item.errorType,item.errorName)
this.changeDocumentClass(item.errorType, item.errorName)
}
})
this.errorTypes.push({errorType: "全部错误", count: res.data.errorContents.length},)
@ -168,7 +169,7 @@ export default {
}
},
/** 改变样式 */
changeDocumentClass(type,errorName){
changeDocumentClass(type, errorName) {
switch (type) {
case '严重错误':
this.DocumentContent = this.DocumentContent.replace(errorName, `<s style="color:#F5384A">${errorName}</s>`)
@ -180,7 +181,7 @@ export default {
this.DocumentContent = this.DocumentContent.replace(errorName, `<s style="color:#B179F2">${errorName}</s>`)
break;
case '标点错误':
this.DocumentContent = this.DocumentContent.replace(errorName, `<s style="color:#1060FF">${ierrorName}</s>`)
this.DocumentContent = this.DocumentContent.replace(errorName, `<s style="color:#1060FF">${errorName}</s>`)
break;
}
},
@ -222,15 +223,17 @@ export default {
this.editor = Object.seal(editor) // Object.seal()
},
/** 接受单错误 */
acceptError(index,val) {
acceptError(index, val) {
this.DocumentContent = this.DocumentContent.replace(val.errorName, `${val.correctName}`)
if(this.DocumentContent.includes(val.errorName)){
this.changeDocumentClass(val.errorType,val.errorName)
}else{
if (this.DocumentContent.includes(val.errorName)) {
this.changeDocumentClass(val.errorType, val.errorName)
} else {
this.changeErrorType(val.errorType)
this.errorList.splice(index, 1);
this.errorActive = 0
this.changeDocumentClass(this.errorList[this.errorActive].errorType,this.errorList[this.errorActive].errorName)
if (this.errorList.length > 0) {
this.changeDocumentClass(this.errorList[this.errorActive].errorType, this.errorList[this.errorActive].errorName)
}
}
},
/** 接受所有错误 */
@ -242,15 +245,20 @@ export default {
this.DocumentContent = this.DocumentContent.replace('</s></span>', '')
}
this.errorList.forEach((item, index, arr) => {
this.changeErrorType(item.errorType)
this.DocumentContent = this.DocumentContent.replace(item.errorName, item.correctName)
})
this.errorList=[]
},
/** 忽略错误 */
ignoreError(index, row) {
this.errorList.splice(index, 1);
this.changeErrorType(row.errorType)
this.errorActive = 0
this.changeDocumentClass(this.errorList[this.errorActive].errorType,this.errorList[this.errorActive].errorName)
if (this.errorList.length > 0) {
this.changeDocumentClass(this.errorList[this.errorActive].errorType, this.errorList[this.errorActive].errorName)
}
},
/** 改变 错误类型数值 */
changeErrorType(val) {
@ -291,7 +299,7 @@ export default {
// BlobURL
URL.revokeObjectURL(downloadLink.href);
},
gotoBack(){
gotoBack() {
this.$router.push('/DocumentWritingIndex');
}
}

Loading…
Cancel
Save