Commit 3e67bc30 by yancanhua

feat: 是否显示无此结构优化

1 parent 38c3f9a3
Pipeline #157 for 3e67bc30 failed in 0 seconds
...@@ -36,13 +36,10 @@ type InspectionColumnRow = InspectionNode & { ...@@ -36,13 +36,10 @@ type InspectionColumnRow = InspectionNode & {
/** 叶子列(含展示用 value 等扩展字段) */ /** 叶子列(含展示用 value 等扩展字段) */
const columnsList = ref<InspectionColumnRow[]>([]); const columnsList = ref<InspectionColumnRow[]>([]);
const resultStatus = ref(false);
const form = ref({}); const form = ref({});
const rules = ref({}); const rules = ref({});
//是否支持"无此结构":0-否,1-是
const allowNoStructure = ref(false);
// 加载中 // 加载中
const pageLoading = ref(false); const pageLoading = ref(false);
...@@ -50,12 +47,9 @@ watch(() => props.leafNodes, (nodes) => { ...@@ -50,12 +47,9 @@ watch(() => props.leafNodes, (nodes) => {
pageLoading.value = true; pageLoading.value = true;
columnsList.value = (nodes || []).map((item) => ({ columnsList.value = (nodes || []).map((item) => ({
...item, ...item,
resultStatus: item?.inspectionResultVO?.resultStatus == 3 ? true : false,
value: getValueText(item), value: getValueText(item),
})) as InspectionColumnRow[]; })) as InspectionColumnRow[];
if (columnsList.value && columnsList.value.length) {
allowNoStructure.value = columnsList?.value?.[0]?.allowNoStructure == 1;
}
resultStatus.value = false
setTimeout(() => { setTimeout(() => {
pageLoading.value = false; pageLoading.value = false;
}, 1200); }, 1200);
...@@ -171,7 +165,7 @@ function setSubmitData() { ...@@ -171,7 +165,7 @@ function setSubmitData() {
if (item.itemType == 2 && dataList.length) { if (item.itemType == 2 && dataList.length) {
allowNoStatus = 2; allowNoStatus = 2;
} }
if (resultStatus.value) { if (item.allowNoStructure == 1 && item.resultStatus) {
allowNoStatus = 3; allowNoStatus = 3;
} }
// 每项都入列,便于大项/二级切换时静默保存仍能带上当前 Tab 全部叶子(未填则为空 data,仍会走保存接口) // 每项都入列,便于大项/二级切换时静默保存仍能带上当前 Tab 全部叶子(未填则为空 data,仍会走保存接口)
...@@ -260,6 +254,14 @@ async function getCarTypeListData() { ...@@ -260,6 +254,14 @@ async function getCarTypeListData() {
} }
} }
function getLeft(nodeName: string) {
let leftPx = 86;
if (nodeName.length > 4) {
leftPx = leftPx + ((nodeName.length - 4) * 12);
}
return leftPx;
}
defineExpose({ defineExpose({
validate, validate,
saveData, saveData,
...@@ -277,19 +279,22 @@ defineExpose({ ...@@ -277,19 +279,22 @@ defineExpose({
<div v-if="!pageLoading"> <div v-if="!pageLoading">
<van-form ref="customizeFormRef" :model="form" :rules="rules"> <van-form ref="customizeFormRef" :model="form" :rules="rules">
<div v-if="allowNoStructure" class="formTitle">
<div @click="resultStatus = !resultStatus">
<van-icon v-if="!resultStatus" color="#666666" name="circle" size="14" />
<van-icon v-if="resultStatus" color="#185EFE" name="checked" size="14" />
<span class="radioText">无此结构</span>
</div>
</div>
<div v-for="(item, index) in columnsList" :key="index" class="customizeList" :class="{ <div v-for="(item, index) in columnsList" :key="index" class="customizeList" :class="{
'border-bottom': index < columnsList.length - 1 && item.interactionType != 'image_upload', 'border-bottom': index < columnsList.length - 1 && item.interactionType != 'image_upload',
'customizeList50': setImgWidth(item) 'customizeList50': setImgWidth(item)
}"> }">
<!-- 是否支持"无此结构":0-否,1-是 -->
<div v-if="item.allowNoStructure" class="formTitle"
:style="{ left: getLeft(item.nodeName) + 'px' }">
<div @click="item.resultStatus = !item.resultStatus">
<van-icon v-if="!item.resultStatus" color="#666666" name="circle" size="14" />
<van-icon v-if="item.resultStatus" color="#185EFE" name="checked" size="14" />
<span class="radioText">无此结构</span>
</div>
</div>
<!-- 文本输入框 --> <!-- 文本输入框 -->
<div v-if="item.interactionType == 'text_input'"> <div v-if="item.interactionType == 'text_input'">
<van-field type="textarea" rows="1" v-model="item.value" clearable :label="item.nodeName" <van-field type="textarea" rows="1" v-model="item.value" clearable :label="item.nodeName"
...@@ -314,7 +319,7 @@ defineExpose({ ...@@ -314,7 +319,7 @@ defineExpose({
:min="getValidationRules(item).min || 0" :placeholder="item.placeholder" :min="getValidationRules(item).min || 0" :placeholder="item.placeholder"
:required="item.required === 1" step="0.01" type="number" :required="item.required === 1" step="0.01" type="number"
@input="(e) => { item.value = parseFloat(item.value)?.toFixed(getValidationRules(item).decimalDigits || 2) || '' }" @input="(e) => { item.value = parseFloat(item.value)?.toFixed(getValidationRules(item).decimalDigits || 2) || '' }"
input-align="right" label-width="120px" autosize > input-align="right" label-width="120px" autosize>
<template v-if="item.suffix" #right-icon> <template v-if="item.suffix" #right-icon>
<span>{{ item.suffix }}</span> <span>{{ item.suffix }}</span>
</template> </template>
...@@ -362,11 +367,11 @@ defineExpose({ ...@@ -362,11 +367,11 @@ defineExpose({
<style lang="scss" scoped> <style lang="scss" scoped>
.formTitle { .formTitle {
float: left;
display: flex; display: flex;
width: 100%;
padding: 0 12px;
background: #fff; background: #fff;
position: absolute;
top: 18px;
left: 86px;
} }
.radioText { .radioText {
...@@ -378,6 +383,7 @@ defineExpose({ ...@@ -378,6 +383,7 @@ defineExpose({
.customizeList { .customizeList {
float: left; float: left;
width: 100%; width: 100%;
position: relative;
} }
.customizeList50 { .customizeList50 {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!