更新
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
<p>上传文件提取文本内容(支持 .png, .jpg )</p>
|
||||
<div class="container flex" style="height: 248px;">
|
||||
<div class="mr10">
|
||||
<el-upload class="upload-demo" accept=".png,.jpg,jpeg" action="abc" :auto-upload="false" :on-change="onHandleChange" :show-file-list="false">
|
||||
<el-upload :headers="headers" accept=".png,.jpg,jpeg" action="/mosty-api/mosty-base/minio/file/upload" :show-file-list="false" :on-success="handlerSuccess" :on-change="onHandleChange" >
|
||||
<el-button size="medium" type="primary">上传图片</el-button>
|
||||
</el-upload>
|
||||
<p id="file-info">{{ files.name || '未选择文件' }} </p>
|
||||
@ -69,15 +69,19 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import axios from "axios";
|
||||
import * as ocr from "@paddlejs-models/ocr";
|
||||
import { drawBox } from "@/utils/ocrUtils";
|
||||
import { nextTick,reactive, ref,getCurrentInstance, watch } from "vue";
|
||||
import { useStore } from "vuex";
|
||||
const store = useStore();
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
const content = ref('请先上传文件...')
|
||||
const fileText = ref('未选择文件')
|
||||
|
||||
@ -97,7 +101,10 @@ const textStyle = reactive({
|
||||
width: "",
|
||||
height: ""
|
||||
})
|
||||
|
||||
const headers = ref({
|
||||
Authorization: store.getters.token
|
||||
});
|
||||
const fjdz = ref('') //附件地址
|
||||
|
||||
const initDemo = () =>{
|
||||
loading.value = imgIsLoad ? false : true;
|
||||
@ -110,10 +117,9 @@ const initDemo = () =>{
|
||||
fileInput.addEventListener("change", function (e) {
|
||||
if (e.target.files.length > 0) {
|
||||
selectedFile = e.target.files[0];
|
||||
fileText.value = `已选择: ${selectedFile.name} (${(
|
||||
selectedFile.size / 1024
|
||||
).toFixed(2)} KB)`;
|
||||
fileText.value = `已选择: ${selectedFile.name} (${( selectedFile.size / 1024 ).toFixed(2)} KB)`;
|
||||
extractBtn.disabled = false;
|
||||
uploadFile(selectedFile); //上传附件
|
||||
} else {
|
||||
selectedFile = null;
|
||||
fileText.value = "未选择文件";
|
||||
@ -225,24 +231,11 @@ async function extractTextFromDocx(file) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const frashJs = async () =>{
|
||||
if(!imgIsLoad){
|
||||
try {
|
||||
await ocr.init();// 模型初始化
|
||||
imgIsLoad = true;
|
||||
proxy.$message({ type: "success", message: "加载成功" });
|
||||
} catch (err) {
|
||||
proxy.$message({ type: "error", message: "加载失败,请刷新页面" });
|
||||
imgIsLoad = false;
|
||||
}
|
||||
}
|
||||
const handlerSuccess = (file) =>{
|
||||
fjdz.value = file.data;
|
||||
}
|
||||
/**
|
||||
*@Descripttion:图片上传事件
|
||||
*@Author: PengShuai
|
||||
*@Date: 2023-12-21 10:49:36
|
||||
*/
|
||||
|
||||
/**@Descripttion:图片上传事件*/
|
||||
const onHandleChange = (file) => {
|
||||
files.value = file;
|
||||
image.value = URL.createObjectURL(file.raw);
|
||||
@ -251,6 +244,7 @@ const onHandleChange = (file) => {
|
||||
setTimeout(() => {
|
||||
getRecognize();
|
||||
}, 600);
|
||||
|
||||
}
|
||||
// 图片解析
|
||||
const getRecognize = async () => {
|
||||
@ -277,12 +271,15 @@ const changeRadio = (val) =>{
|
||||
if(!imgIsLoad) proxy.$message({ type: "error", message: "加载失败,请刷新页面" });
|
||||
}
|
||||
}
|
||||
|
||||
// 提交
|
||||
const onComfirm = () => {
|
||||
if(active.value == '文件解析'){
|
||||
let obj = { text: content.value };
|
||||
emits("change", obj);
|
||||
if(content.value == '请先上传文件...') return proxy.$message({ type: "warning", message: "请解析文件" });
|
||||
emits("change", { text: content.value,fjdz:fjdz.value });
|
||||
}else{
|
||||
emits("change", {text:texts.value.join(',\n')});
|
||||
if(texts.value.length == 0) return proxy.$message({ type: "warning", message: "请解析文件" });
|
||||
emits("change", {text:texts.value.join(',\n'),fjdz:fjdz.value});
|
||||
}
|
||||
handleClose()
|
||||
};
|
||||
@ -299,6 +296,36 @@ const handleClose = () => {
|
||||
emits("update:modelValue", false);
|
||||
};
|
||||
|
||||
// 上传附件
|
||||
const uploadFile = (file) =>{
|
||||
let formData = new FormData();
|
||||
formData.append("file", file);
|
||||
let token = localStorage.getItem('token');
|
||||
axios({
|
||||
method: 'post',
|
||||
url: '/mosty-api/mosty-base/minio/file/upload',
|
||||
data:formData,
|
||||
headers: { "Content-type": "multipart/form-data",'Authorization': token }
|
||||
}).then( (res) => {
|
||||
fjdz.value = res.data ? res.data.data : null;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 刷新js
|
||||
const frashJs = async () =>{
|
||||
if(!imgIsLoad){
|
||||
try {
|
||||
await ocr.init();// 模型初始化
|
||||
imgIsLoad = true;
|
||||
proxy.$message({ type: "success", message: "加载成功" });
|
||||
} catch (err) {
|
||||
proxy.$message({ type: "error", message: "加载失败,请刷新页面" });
|
||||
imgIsLoad = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const chooseFile = () => {
|
||||
document.getElementById("file-input").click();
|
||||
};
|
||||
|
@ -82,6 +82,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import { COMPONENT_WIDTH } from "@/constant";
|
||||
import { ref, defineProps, defineEmits, computed, watch, onMounted } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
@ -196,12 +197,13 @@ watch(
|
||||
|
||||
|
||||
const handlerSuccess = (res, file) => {
|
||||
file.url = `/mosty-api/mosty-base/minio/image/download/` + res.data;
|
||||
fileList.value.push(file);
|
||||
let arr = props.modelValue ? props.modelValue : [];
|
||||
arr.push(res.data);
|
||||
emits("update:modelValue", arr);
|
||||
emits("handleChange", props.modelValue);
|
||||
console.log(file,'===========00');
|
||||
// file.url = `/mosty-api/mosty-base/minio/image/download/` + res.data;
|
||||
// fileList.value.push(file);
|
||||
// let arr = props.modelValue ? props.modelValue : [];
|
||||
// arr.push(res.data);
|
||||
// emits("update:modelValue", arr);
|
||||
// emits("handleChange", props.modelValue);
|
||||
};
|
||||
|
||||
const handleExceed = (files, fileList) => {
|
||||
|
@ -77,10 +77,6 @@ const formData = ref([
|
||||
{ prop: "gapline", type: "slot",width:'100%' },
|
||||
{ prop: "scfj", type: "slot",width:'100%'},
|
||||
{ label: "线索内容", prop: "xsNr", type: "textarea",width:'100%'},
|
||||
{ label: "群体类型", prop: "qtlx", type: "select",options:props.dic.D_GS_XS_QTLX },
|
||||
{ label: "群体名称", prop: "qtmc", type: "input"},
|
||||
{ label: "涉及人数", prop: "sjrs", type: "inputNumber"},
|
||||
{ label: "线索报送单位", prop: "ssbmdm", type: "department"},
|
||||
]);
|
||||
const fjdz = ref()
|
||||
const listQuery = ref({}); //表单
|
||||
|
@ -45,10 +45,11 @@
|
||||
</div>
|
||||
<div class="tabBox">
|
||||
<MyTable
|
||||
:tableData="pageData.tableData"
|
||||
:tableColumn="pageData.tableColumn1"
|
||||
:tableData="pageData.tableDataR"
|
||||
:tableColumn="pageData.tableColumnR"
|
||||
:tableHeight="pageData.tableHeight"
|
||||
:key="pageData.keyCount"
|
||||
element-loading-text="模型加载中......"
|
||||
:tableConfiger="pageData.tableConfigerR"
|
||||
:controlsWidth="pageData.controlsWidthR"
|
||||
>
|
||||
@ -116,8 +117,10 @@ const queryFrom = ref({});
|
||||
const container = ref('')
|
||||
const btnLoading = ref(false)
|
||||
const prsentText = ref(null)
|
||||
const qbid = ref('') //情报id
|
||||
const pageData = reactive({
|
||||
tableData: [], //表格数据
|
||||
tableDataR: [], //表格数据
|
||||
keyCount: 0,
|
||||
tableConfiger: {
|
||||
rowHieght: 61,
|
||||
@ -143,7 +146,7 @@ const pageData = reactive({
|
||||
{ label: "要素名称", prop: "ysmc",showOverflowTooltip:true },
|
||||
{ label: "要素描述", prop: "ysms",showOverflowTooltip:true },
|
||||
],
|
||||
tableColumn1: [
|
||||
tableColumnR: [
|
||||
{ label: "线索名称", prop: "yymc",showOverflowTooltip:true },
|
||||
{ label: "线索类型", prop: "yslx",showOverflowTooltip:true },
|
||||
{ label: "指向地点", prop: "ysms",showOverflowTooltip:true },
|
||||
@ -155,8 +158,6 @@ onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 搜索
|
||||
const onSearch = (val) => {
|
||||
queryFrom.value = { ...val };
|
||||
@ -218,22 +219,16 @@ const changeSize = (val) => {
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 新增
|
||||
const addEdit = (type, row) => {
|
||||
|
||||
};
|
||||
|
||||
// 提取数据
|
||||
const getText = (val) =>{
|
||||
prsentText.value = null; //先清空
|
||||
container.value = val.text;
|
||||
let obj = {
|
||||
let obj = {
|
||||
"model": "deepseek-reasoner",
|
||||
"messages": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "# 角色定位\n你是一名资深警务人员,尤其擅长对警情、案件、线索等非结构化文本数据进行阅读理解,并从中提取各种对象特征信息进行结构化,并总结各种对象之间的关联关系。\n## - person:人物 - id:唯一值 - name:姓名 - enName:英文姓名 - nickName:绰号 - aliasName:别名 - screenName:网名 - idcard:身份证号码 - phoneNo:手机号码 - bankCard:银行卡号 - passporNumber:护照号码 - permanentResidenceAddress:户籍地址 - residenceAddress:现住地址 - jbxx:基本信息 - id:唯一值 - xsmc:线索名称 - xslx:线索类型 - qbly:情报来源 - kssj:开始时间 - jssj:结束时间 - qtlx:群体类型 - qtmc:群体名称 - sjrs:设计人数 - sbdw:送报单位## 注意点\n- 地址信息能够根据上下文信息按照省、市、县、街道/乡镇、路名分段补全并标准化。例如:四川省 成都市 高新区 桂溪街道 交子大道11号\n- 对象之间的关联关系由对象类型、对象id、关系类型、目标对象类型、目标对象id 5个属性组成。\n"
|
||||
"content": "# 角色定位\n你是一名资深警务人员,尤其擅长对警情、案件、线索等非结构化文本数据进行阅读理解,并从中提取各种对象特征信息进行结构化,并总结各种对象之间的关联关系。\n## - ryList:人物 - id:唯一值 - xm:姓名 - enName:英文姓名 - nickName:绰号 - aliasName:别名 - screenName:网名 - sfzh:身份证号码 - lxdh:手机号码 - bankCard:银行卡号 - passporNumber:护照号码 - hjdz:户籍地址 - xjzdz:现住地址 - jbxx:基本信息 - id:唯一值 - xsMc:线索名称 - xlLx:线索类型 - qbLy:情报来源 - zxkssj:开始时间 - zxjssj:结束时间 - qtlx:群体类型 - qtmc:群体名称 - sjrs:设计人数 - sbdw:送报单位## 注意点\n- 地址信息能够根据上下文信息按照省、市、县、街道/乡镇、路名分段补全并标准化。例如:四川省 成都市 高新区 桂溪街道 交子大道11号\n- 对象之间的关联关系由对象类型、对象id、关系类型、目标对象类型、目标对象id 5个属性组成。\n"
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
@ -243,24 +238,44 @@ const getText = (val) =>{
|
||||
"max_tokens": 4096,
|
||||
"stream": false
|
||||
}
|
||||
// 拼接字典
|
||||
// 线索类型:
|
||||
let xslx = '线索类型是一个字典,字典内容包括:' + (D_GS_XS_LX.value.map(item=>item.dm+':'+item.zdmc).join(','))+'\n'
|
||||
let qbLy = '情报来源是一个字典,字典内容包括:' + (D_GS_XS_LY.value.map(item=>item.dm+':'+item.zdmc).join(','))+'\n'
|
||||
let sszt = '所属专题是一个字典,字典内容包括:' + (D_BZ_SSZT.value.map(item=>item.dm+':'+item.zdmc).join(','))+'\n'
|
||||
obj.messages[0].content = obj.messages[0].content + xslx + qbLy + sszt;
|
||||
// *********************
|
||||
obj.messages[1].content = obj.messages[1].content + val.text;
|
||||
prsentText.value = obj;
|
||||
qcckPost({fjdz:val.fjdz,tjnr:val.text},'/mosty-gsxt/qbcjjl/add').then((res)=>{
|
||||
qbid.value = res || ''
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
const handleFx = () => {
|
||||
if(!prsentText.value) return proxy.$message({ type: "warning", message: "请先上传要解析的文件" });;
|
||||
btnLoading.value = true;
|
||||
pageData.tableConfigerR.loading = true;
|
||||
ParsingText( prsentText.value,(res)=>{
|
||||
pageData.tableConfigerR.loading = false;
|
||||
btnLoading.value = false;
|
||||
let content = res.data.choices[0].message.content;
|
||||
let message = null;
|
||||
try{
|
||||
message = content ? JSON.parse(content):''
|
||||
}catch(err){
|
||||
proxy.$message({ type: "danger", message: "解析异常,请重新上传解析" });;
|
||||
proxy.$message({ type: "danger", message: "解析异常,请重新上传解析" });
|
||||
}
|
||||
if(!message) return;
|
||||
console.log(message,'=================将结果');
|
||||
if(!message) return proxy.$message({ type: "danger", message: "解析异常,请重新上传解析" });
|
||||
let params = {
|
||||
qbid:qbid.value,
|
||||
...message.jbxx[0],
|
||||
ryList:message.ryList,
|
||||
}
|
||||
qcckPost(params,'/mosty-gsxt/qbcj/add').then((res)=>{
|
||||
console.log(res,'============');
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user