lcw
This commit is contained in:
@ -37,7 +37,9 @@ const changeValue = (value) => {
|
||||
showPopup.value = true
|
||||
}
|
||||
const classIndex=ref(0)
|
||||
const handleChange = (val,index) => {
|
||||
const handleChange = (val, index) => {
|
||||
console.log(val.tqjg);
|
||||
|
||||
classIndex.value=index
|
||||
|
||||
emitter.emit('getlistData', val.tqjg)
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, toRaw, computed, watch, nextTick, onMounted,getCurrentInstance } from "vue";
|
||||
import { ref, reactive, toRaw, computed, watch, nextTick, onMounted, getCurrentInstance } from "vue";
|
||||
import formNewModel from "./formNewModel.vue"
|
||||
import emitter from "@/utils/eventBus.js";
|
||||
const { proxy } = getCurrentInstance()
|
||||
@ -40,37 +40,57 @@ const data = {
|
||||
40: "特征识别分析",
|
||||
}
|
||||
const model = ref()
|
||||
const numberData = 0
|
||||
const jx = (val) => {
|
||||
if (val) {
|
||||
const jsonObject = val;
|
||||
if (Array.isArray(jsonObject)) {
|
||||
model.value = jsonObject.reduce((acc, cur) => {
|
||||
const key = Object.keys(cur)[0];
|
||||
const prefix = key.substring(0, 2);
|
||||
if (!acc[prefix] && prefix !== '50' && prefix !== '60') {
|
||||
acc[prefix] = {
|
||||
inputs: [],
|
||||
model: {},
|
||||
value: prefix
|
||||
};
|
||||
}
|
||||
if (prefix === '50' || prefix === '60') {
|
||||
acc[10].inputs.push({ label: cur[key].name, prop: key, type: "input", width: "33%" });
|
||||
acc[10].model[key] = cur[key].content ? cur[key].content : '-';
|
||||
} else {
|
||||
acc[prefix].inputs.push({ label: cur[key].name, prop: key, type: "input", width: "33%" });
|
||||
acc[prefix].model[key] = cur[key].content == '-' || cur[key].content == '' || cur[key].content == '无' ? '/' : cur[key].content;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
} else {
|
||||
const str = JSON.parse(jsonObject);
|
||||
jx(str)
|
||||
numberData++
|
||||
if (numberData == 3) {
|
||||
numberData=0
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const json =props.listData ;
|
||||
const jsonString = JSON.parse(json);
|
||||
if (jsonString) {
|
||||
const jsonObject = jsonString;
|
||||
console.log(jsonObject);
|
||||
model.value = jsonObject.reduce((acc, cur) => {
|
||||
const key = Object.keys(cur)[0];
|
||||
const prefix = key.substring(0, 2);
|
||||
if (!acc[prefix] && prefix !== '50' && prefix !== '60') {
|
||||
acc[prefix] = {
|
||||
inputs: [],
|
||||
model: {},
|
||||
value: prefix
|
||||
};
|
||||
}
|
||||
if (prefix === '50' || prefix === '60') {
|
||||
acc[10].inputs.push({ label: cur[key].name, prop: key, type: "input", width: "33%" });
|
||||
acc[10].model[key] = cur[key].content? cur[key].content : '-';
|
||||
} else {
|
||||
acc[prefix].inputs.push({ label: cur[key].name, prop: key, type: "input", width: "33%" });
|
||||
acc[prefix].model[key] = cur[key].content=='-'||cur[key].content==''||cur[key].content=='无'? '/':cur[key].content ;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
} else {
|
||||
model.value = []
|
||||
proxy.$message({ type: "error", message: "解析失败" });
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
const json = props.listData;
|
||||
const jsonString = JSON.parse(json);
|
||||
jx(jsonString)
|
||||
})
|
||||
watch(() => props.listData, (val) => {
|
||||
if (val) {
|
||||
const json = val;
|
||||
const jsonString = JSON.parse(json);
|
||||
jx(jsonString)
|
||||
}
|
||||
},{deep:true})
|
||||
const handleClose = () => {
|
||||
emitter.emit('showDetails', true)
|
||||
}
|
||||
|
||||
@ -317,26 +317,26 @@ const getText = async (val) => {
|
||||
handleFx(obj)
|
||||
}
|
||||
function simpleExtractJSON(text) {
|
||||
// 找到第一个 [
|
||||
const startIndex = text.indexOf('[');
|
||||
if (startIndex === -1) return null;
|
||||
// 找到第一个 [
|
||||
const startIndex = text.indexOf('[');
|
||||
if (startIndex === -1) return null;
|
||||
|
||||
// 找到最后一个完整的 }
|
||||
let lastBraceIndex = text.lastIndexOf('}');
|
||||
if (lastBraceIndex === -1) return null;
|
||||
// 找到最后一个完整的 }
|
||||
let lastBraceIndex = text.lastIndexOf('}');
|
||||
if (lastBraceIndex === -1) return null;
|
||||
|
||||
// 确保 } 后面没有其他字符(除了空格和换行)
|
||||
let endIndex = lastBraceIndex + 1;
|
||||
// 确保 } 后面没有其他字符(除了空格和换行)
|
||||
let endIndex = lastBraceIndex + 1;
|
||||
|
||||
// 截取从 [ 到最后一个 } 的内容,然后加上 ]
|
||||
let jsonString = text.substring(startIndex, endIndex) + ']';
|
||||
// 截取从 [ 到最后一个 } 的内容,然后加上 ]
|
||||
let jsonString = text.substring(startIndex, endIndex) + ']';
|
||||
|
||||
try {
|
||||
return JSON.parse(jsonString);
|
||||
} catch (error) {
|
||||
console.error("简单修复失败:", error);
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(jsonString);
|
||||
} catch (error) {
|
||||
console.error("简单修复失败:", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
const handleFx = (val) => {
|
||||
ElMessageBox.prompt('请输入名称', '提示', {
|
||||
@ -349,44 +349,44 @@ const handleFx = (val) => {
|
||||
.then(({ value }) => {
|
||||
loading.value = true
|
||||
completions(val).then(res => {
|
||||
console.log(res,"分析报告数据");
|
||||
let jsonString
|
||||
let jsonMatch = res.choices[0].text.match(/\[[\s\S]*?\]/g);
|
||||
if (!jsonMatch) {
|
||||
jsonMatch = simpleExtractJSON(res.choices[0].text)
|
||||
jsonString = jsonMatch;
|
||||
} else {
|
||||
jsonString = jsonMatch[0];
|
||||
}
|
||||
if (jsonMatch) {
|
||||
const promes = {
|
||||
fxlb: selectType.value,
|
||||
fxmc: value,
|
||||
tqjg:JSON.stringify(jsonString),//提取结果
|
||||
xyjg: res.choices[0].text,
|
||||
...saveData.value
|
||||
// console.log(res,"分析报告数据");
|
||||
let jsonString
|
||||
let jsonMatch = res.choices[0].text.match(/\[[\s\S]*?\]/g);
|
||||
if (!jsonMatch) {
|
||||
jsonMatch = simpleExtractJSON(res.choices[0].text)
|
||||
jsonString = jsonMatch;
|
||||
} else {
|
||||
jsonString = jsonMatch[0];
|
||||
}
|
||||
yyfxAdd(promes).then(res => {
|
||||
proxy.$message({ type: "success", message: "添加成功" });
|
||||
emitter.emit('getYyfxSelectPage')
|
||||
emitter.emit('getlistData',JSON.stringify(jsonString))
|
||||
emitter.emit('showDetails', false)
|
||||
}).catch(err => {
|
||||
console.log(err, "xxxxx");
|
||||
proxy.$message({ type: "error", message: "添加失败" });
|
||||
})
|
||||
} else {
|
||||
proxy.$message({ type: "error", message: "解析失败,请重新上传分析" });
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err, 'vvvv');
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
if (jsonMatch) {
|
||||
const promes = {
|
||||
fxlb: selectType.value,
|
||||
fxmc: value,
|
||||
tqjg: JSON.stringify(jsonString),//提取结果
|
||||
xyjg: res.choices[0].text,
|
||||
...saveData.value
|
||||
}
|
||||
yyfxAdd(promes).then(res => {
|
||||
proxy.$message({ type: "success", message: "添加成功" });
|
||||
emitter.emit('getYyfxSelectPage')
|
||||
emitter.emit('getlistData', JSON.stringify(jsonString))
|
||||
emitter.emit('showDetails', false)
|
||||
}).catch(err => {
|
||||
console.log(err, "xxxxx");
|
||||
proxy.$message({ type: "error", message: "添加失败" });
|
||||
})
|
||||
} else {
|
||||
proxy.$message({ type: "error", message: "解析失败,请重新上传分析" });
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err, 'vvvv');
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user