Browse Source

Merge pull request 'feat: 添加 unitId 属性到多个组件,确保在步骤中正确传递机组信息' (#73) from cjl-new into master

Reviewed-on: http://120.26.116.243:3000/root/alert-front/pulls/73
pull/75/head
chenjiale 1 month ago
parent
commit
815531f8a5
  1. 6
      src/views/model/list/CreateModel.vue
  2. 5
      src/views/model/list/ModelCard.vue
  3. 11
      src/views/model/list/index.vue
  4. 6
      src/views/model/list/step/Step3.vue
  5. 22
      src/views/model/train/index.vue

6
src/views/model/list/CreateModel.vue

@ -23,6 +23,9 @@ export default defineComponent({
systemId: {
type: Number,
},
unitId: {
type: Number,
},
},
setup(props) {
const current = ref(0)
@ -50,6 +53,7 @@ export default defineComponent({
current.value++
step2Data.value = step2Values
step2Values.systemId = props.systemId
step2Values.unitId = props.unitId
console.log(step2Values)
state.initStep3 = true
}
@ -115,6 +119,8 @@ export default defineComponent({
v-show="current === 2"
v-if="initStep3"
:before-data="step2Data"
:system-id="systemId"
:unit-id="unitId"
@prev="handleStepPrev"
@next="handleStep3Next"
/>

5
src/views/model/list/ModelCard.vue

@ -21,6 +21,9 @@ const props = defineProps({
systemId: {
type: Number,
},
unitId: {
type: Number,
},
})
const [registerDraw, { openDrawer }] = useDrawer()
@ -159,7 +162,7 @@ async function confirmDelete(id: number | string) {
<Icon icon="ic:sharp-add" :size="80" color="#a7a9a7" />
</Card>
</div>
<CreateModel :system-id="systemId" @register="registerDraw" />
<CreateModel :system-id="systemId" :unit-id="unitId" @register="registerDraw" />
</div>
</template>

11
src/views/model/list/index.vue

@ -8,10 +8,12 @@ import { PageWrapper } from '@/components/Page'
const loading = ref(true)
const selectData = ref(null)
const systemId = ref(null)
const unitId = ref(null)
function handleOptionSelected(values) {
selectData.value = values
systemId.value = values.system
unitId.value = values.unit
}
setTimeout(() => {
@ -31,6 +33,7 @@ export default defineComponent({
handleOptionSelected,
selectData,
systemId,
unitId,
}
},
})
@ -40,7 +43,13 @@ export default defineComponent({
<PageWrapper content-full-height>
<a-card>
<UnitSelect @option-selected="handleOptionSelected" />
<ModelCard :loading="loading" :system-id="systemId" :select-data="selectData" class="enter-y" />
<ModelCard
:loading="loading"
:system-id="systemId"
:unit-id="unitId"
:select-data="selectData"
class="enter-y"
/>
</a-card>
</PageWrapper>
</template>

6
src/views/model/list/step/Step3.vue

@ -26,6 +26,9 @@ export default defineComponent({
systemId: {
type: Number,
},
unitId: {
type: Number,
},
},
emits: ['next', 'prev'],
setup(props, { emit }) {
@ -80,6 +83,9 @@ export default defineComponent({
}
})
const modelInfo = toRaw(props.beforeData) || {}
// unit carriesid from selector (unitId is explicitly provided)
if (props.unitId !== undefined && props.unitId !== null)
modelInfo.unit = props.unitId
modelInfo.pointInfo = pointInfo
setProps({
submitButtonOptions: {

22
src/views/model/train/index.vue

@ -3,7 +3,7 @@ import type { ComponentPublicInstance } from 'vue'
import type { Dayjs } from 'dayjs'
import { debounce } from 'lodash-es'
import dayjs from 'dayjs'
import { computed, defineComponent, onMounted, ref, toRaw, watch } from 'vue'
import { computed, defineComponent, onMounted, ref, toRaw } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import {
Button,
@ -160,21 +160,13 @@ export default defineComponent({
scroll: { y: 300 },
})
const updatePrincipalFromTrainTime = (trainTimeList: any[]) => {
if (!Array.isArray(trainTimeList) || !model.value)
return
// principal is the sum of mode for each trainTime entry
model.value.principal = trainTimeList.reduce((sum, item) => {
const effectiveSampleCount = computed(() => {
const list = model.value?.trainTime || []
return list.reduce((sum: number, item: any) => {
const modeVal = Number(item?.mode)
return sum + (Number.isFinite(modeVal) ? modeVal : 0)
}, 0)
}
watch(
() => model.value?.trainTime,
newTrainTime => updatePrincipalFromTrainTime(newTrainTime as any[]),
{ deep: true, immediate: true },
)
})
const activeKey = ref('1')
type RangeValue = [Dayjs, Dayjs]
@ -392,6 +384,7 @@ export default defineComponent({
isInitBrush.value = false
return
}
console.log(isInitBrush.value,model.value?.version)
if (!isInitBrush.value && model.value?.version != 'v-test')
return
@ -1054,6 +1047,7 @@ export default defineComponent({
goAssessReport,
showTrainActions,
canEditModel,
effectiveSampleCount,
}
},
})
@ -1151,7 +1145,7 @@ export default defineComponent({
}}
</a-descriptions-item>
<a-descriptions-item label="有效样本数">
{{ model?.principal }}
{{ effectiveSampleCount }}
</a-descriptions-item>
</a-descriptions>
</a-card>

Loading…
Cancel
Save