lcw
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user