This commit is contained in:
Net 2025-06-10 23:40:49 +08:00
parent 1cc0122ae9
commit b431e1bff5
14 changed files with 766 additions and 294 deletions

View File

@ -30,3 +30,13 @@ export const jsConfirmJsDataApi = async (params: any) => {
export const jsdFindPageTaskApi = async (params: any) => {
return await get("/api/jsd/findPageTask", params);
};
export const fractionRuleApi = async () => {
return await get(
"/api/fractionRule/findAllByItemId?itemId=CDFDED2A704F46E2A4D7E8816968BD23"
);
};
export const fractionRuleApi1 = async () => {
return await get(
"/api/fractionRule/findAllByItemId?itemId=B96A0FA22C414F71A3E1CDCA7E206B10"
);
};

View File

@ -1,137 +1,161 @@
<template>
<view class="white-bg-color r-md font-14 po-re">
<uni-forms
ref="formRef"
<view class="white-bg-color r-md font-14 po-re">
<uni-forms
ref="formRef"
:model="formModel.model"
:rules="rules"
v-bind="props.formsProps"
>
<template v-for="item in props.schema" :key="item.field">
<view class="formsItem" v-if="ifShow(item, formModel.model)">
<FormsItem v-bind="item">
<template v-if="item.component && !item.slot">
<BasicComponent
v-bind="Object.assign({ ...attrs }, item, props.formsProps)"
v-model="formModel.model[item.field]"
:model="formModel.model"
:rules="rules"
v-bind="props.formsProps"
>
<template v-for="item in props.schema" :key="item.field">
<view class="formsItem" v-if="ifShow(item,formModel.model)">
<FormsItem v-bind='item'>
<template v-if="item.component&&!item.slot">
<BasicComponent v-bind='Object.assign(item,props.formsProps)'
v-model="formModel.model[item.field]" :model="formModel.model"/>
</template>
<template v-if="item.slot">
<view class="py-7 font-13">
<slot :name="item.slot" :data="formModel.model"></slot>
</view>
</template>
</FormsItem>
</view>
<view v-else-if="item.title&&ifTitleShow(item,formModel.model)" class="global-bg-color py-15">
<BasicTitle line :title="item.title" :isBorder="false" v-bind="item.componentProps"/>
</view>
<view v-else-if="item.interval" class="global-bg-color" style="height: 30rpx;"></view>
<template v-if="item.colSlot">
<slot :name="item.colSlot"></slot>
</template>
/>
</template>
</uni-forms>
</view>
<template v-if="item.slot">
<view class="py-7 font-13">
<slot :name="item.slot" :data="formModel.model"></slot>
</view>
</template>
</FormsItem>
</view>
<view
v-else-if="item.title && ifTitleShow(item, formModel.model)"
class="global-bg-color py-15"
>
<BasicTitle
line
:title="item.title"
:isBorder="false"
v-bind="item.componentProps"
/>
</view>
<view
v-else-if="item.interval"
class="global-bg-color"
style="height: 30rpx"
></view>
<template v-if="item.colSlot">
<slot :name="item.colSlot"></slot>
</template>
</template>
</uni-forms>
</view>
</template>
<script lang="ts">
// #ifdef MP-WEIXIN
export default {
options: {
styleIsolation: 'shared',
}
}
options: {
styleIsolation: "shared",
},
};
// #endif
</script>
<script setup lang="ts">
import {computed, reactive} from "vue";
import BasicComponent from './src/BasicComponent.vue'
import FormsItem from './src/FormsItem.vue'
import {ifShow, ifTitleShow} from "@/components/BasicForm/hooks/useForm";
import { computed, reactive } from "vue";
import BasicComponent from "./src/BasicComponent.vue";
import FormsItem from "./src/FormsItem.vue";
import { ifShow, ifTitleShow } from "@/components/BasicForm/hooks/useForm";
const formRef = ref<any>(null)
const formRef = ref<any>(null);
const attrs: any = useAttrs();
console.log(attrs);
const formModel = reactive({model: {}})
const formModel = reactive({ model: {} });
watch(() => defineProp.modelValue, (value) => {
formModel.model = value
})
watch(
() => defineProp.modelValue,
(value) => {
formModel.model = value;
}
);
const refreshModel = (model: any) => {
formModel.model = Object.assign({}, formModel.model, model)
}
formModel.model = Object.assign({}, formModel.model, model);
};
const props = reactive<FormOptions>({
formsProps: {
labelWidth: 80
},
schema: []
})
const defineProp = defineProps(['modelValue', 'formsProps', 'schema'])
const emits = defineEmits(['update:modelValue', 'register'])
formsProps: {
labelWidth: 80,
},
schema: [],
});
const defineProp = defineProps(["modelValue", "formsProps", "schema"]);
const emits = defineEmits(["update:modelValue", "register"]);
if (defineProp.modelValue) {
formModel.model = defineProp.modelValue
formModel.model = defineProp.modelValue;
}
if (defineProp.schema) {
props.schema = defineProp.schema
props.schema = defineProp.schema;
}
if (defineProp.formsProps) {
props.formsProps = defineProp.formsProps
props.formsProps = defineProp.formsProps;
}
function setProps(value: FormOptions) {
formModel.model = value.formModel
if (value.schema) {
props.schema = value.schema
}
if (value.formsProps) {
props.formsProps = value.formsProps
}
formModel.model = value.formModel;
if (value.schema) {
props.schema = value.schema;
}
if (value.formsProps) {
props.formsProps = value.formsProps;
}
}
const refreshProps = () => {
emits('register', setProps, formRef, formModel.model)
}
emits("register", setProps, formRef, formModel.model);
};
onMounted(() => {
formRef.value.refreshModel = refreshModel
formRef.value.refreshProps = refreshProps
emits('register', setProps, formRef, formModel.model)
})
watch(() => formModel.model, (count) => {
emits('update:modelValue', count)
emits('register', setProps, formRef, count)
}, {deep: true})
formRef.value.refreshModel = refreshModel;
formRef.value.refreshProps = refreshProps;
emits("register", setProps, formRef, formModel.model);
});
watch(
() => formModel.model,
(count) => {
emits("update:modelValue", count);
emits("register", setProps, formRef, count);
},
{ deep: true }
);
//
const rules = computed(() => {
let initRules: any = {}
props.schema.forEach((item) => {
if (item.field && item.rules) {
for (const key in item.rules) {
item.rules[key]['ifShow'] = item.ifShow
}
initRules[item.field] = {
rules: item.rules
}
} else {
if (item.field && item.required) {
initRules[item.field] = {
rules: [{
required: true,
ifShow: item.ifShow,
errorMessage: item.label + '不能为空'
}]
}
}
}
})
return initRules
})
let initRules: any = {};
props.schema.forEach((item) => {
if (item.field && item.rules) {
for (const key in item.rules) {
item.rules[key]["ifShow"] = item.ifShow;
}
initRules[item.field] = {
rules: item.rules,
};
} else {
if (item.field && item.required) {
initRules[item.field] = {
rules: [
{
required: true,
ifShow: item.ifShow,
errorMessage: item.label + "不能为空",
},
],
};
}
}
});
return initRules;
});
</script>
<style lang="scss" scoped>
.formsItem:not(:last-child) {
border-bottom: 1px solid #EFEFEF;
border-bottom: 1px solid #efefef;
}
.detailModel {

View File

@ -1,21 +1,42 @@
<template>
<view class="py-7">
<u-loading-icon :show="loadingShow" style="justify-content: start" size="20"/>
<view @click="open" class="wh-full flex-row items-center justify-between" v-if="!loadingShow">
<view class="font-13 text-ellipsis-1" v-if="pickerValue">{{ pickerValue }}</view>
<view class="font-13 color-9" v-else-if="!attrs.componentProps.disabled">
<text v-if="attrs.componentProps&&attrs.componentProps.placeholder">{{
attrs.componentProps.placeholder
}}
</text>
<text v-else>请选择{{ attrs.label }}</text>
</view>
<view v-else></view>
<uni-icons type="right" size="18" color="#999999" v-if="!attrs.componentProps.disabled"/>
</view>
<Picker ref="popup" :title="attrs.label" :range="range" :rangeKey="rangeKey" v-model="pickerKey" @ok="ok"
@change="change"/>
<view class="py-7">
<u-loading-icon
:show="loadingShow"
style="justify-content: start"
size="20"
/>
<view
@click="open"
class="wh-full flex-row items-center justify-between"
v-if="!loadingShow"
>
<view class="font-13 text-ellipsis-1" v-if="pickerValue">{{
pickerValue
}}</view>
<view class="font-13 color-9" v-else-if="!attrs.componentProps.disabled">
<text v-if="attrs.componentProps && attrs.componentProps.placeholder"
>{{ attrs.componentProps.placeholder }}
</text>
<text v-else>请选择{{ attrs.label }}</text>
</view>
<view v-else></view>
<uni-icons
type="right"
size="18"
color="#999999"
v-if="!attrs.componentProps.disabled"
/>
</view>
<Picker
ref="popup"
:title="attrs.label"
:range="range"
:rangeKey="rangeKey"
v-model="pickerKey"
@ok="ok"
@change="change"
/>
</view>
</template>
<script setup lang="ts">
@ -33,141 +54,199 @@
* @property @ok 点击确定事件
* @property @change 选择器change事件
*/
import Picker from '@/components/BasicPicker/Picker.vue'
import {forEach, isFunction} from "lodash";
import Picker from "@/components/BasicPicker/Picker.vue";
import { forEach, isFunction } from "lodash";
const popup = ref<any>(null)
const popup = ref<any>(null);
const loadingShow = ref(false)
const loadingShow = ref(false);
const props = defineProps(['modelValue'])
const emit = defineEmits(['update:modelValue'])
const props = defineProps(["modelValue"]);
const emit = defineEmits(["update:modelValue"]);
const newValue = computed({
get() {
return props.modelValue
},
set(value) {
emit('update:modelValue', value)
}
})
const attrs: any = useAttrs()
get() {
return props.modelValue;
},
set(value) {
emit("update:modelValue", value);
},
});
const attrs: any = useAttrs();
const rangeKey = ref(attrs.componentProps && attrs.componentProps.rangeKey || '')
const pickerKey = ref(attrs.componentProps && attrs.componentProps.value || [0])
const rangeKey = ref(
(attrs.componentProps && attrs.componentProps.rangeKey) || ""
);
const pickerKey = ref(
(attrs.componentProps && attrs.componentProps.value) || [0]
);
const range = computed(() => {
if (attrs.componentProps && attrs.componentProps.range) {
if (Array.isArray(attrs.componentProps.range[0])) {
return attrs.componentProps.range
} else {
return [attrs.componentProps.range]
}
if (attrs.componentProps && attrs.componentProps.range) {
if (Array.isArray(attrs.componentProps.range[0])) {
return attrs.componentProps.range;
} else {
return []
return [attrs.componentProps.range];
}
})
} else {
return [];
}
});
function initapi() {
if (attrs.componentProps.api && isFunction(attrs.componentProps.api)) {
loadingShow.value = true
attrs.componentProps.api(attrs.componentProps.param || null).then((res: any) => {
attrs.componentProps.range = res[attrs.componentProps.resultKey || 'result']
if (attrs.componentProps.request && isFunction(attrs.componentProps.request)) {
attrs.componentProps.request(attrs.componentProps.range)
}
loadingShow.value = false
})
}
if (attrs.componentProps.api && isFunction(attrs.componentProps.api)) {
loadingShow.value = true;
attrs.componentProps
.api(attrs.componentProps.param || null)
.then((res: any) => {
attrs.componentProps.range =
res[attrs.componentProps.resultKey || "result"];
if (
attrs.componentProps.request &&
isFunction(attrs.componentProps.request)
) {
attrs.componentProps.request(attrs.componentProps.range);
}
loadingShow.value = false;
});
}
}
initapi()
initapi();
function open() {
if (!attrs.componentProps.disabled) {
if (newValue.value) {
if (!attrs.componentProps.disabled) {
if (newValue.value) {
forEach(attrs.componentProps.range, (v, k) => {
if (v[attrs.componentProps.savaKey] == newValue.value) {
pickerKey.value = [k];
}
});
} else {
if (newValue.value == false || newValue.value == 0) {
forEach(attrs.componentProps.range, (v, k) => {
if (v[attrs.componentProps.savaKey] == newValue.value) {
pickerKey.value = [k]
if (
v[attrs.componentProps.savaKey].toString() ==
newValue.value.toString()
) {
pickerKey.value = [k];
}
})
} else {
if (newValue.value == false || newValue.value == 0) {
forEach(attrs.componentProps.range, (v, k) => {
if (v[attrs.componentProps.savaKey].toString() == newValue.value.toString()) {
pickerKey.value = [k]
}
})
}
});
}
if (attrs.componentProps.open && typeof attrs.componentProps.open === 'function') {
if (attrs.componentProps.open(pickerKey.value, attrs)) {
popup.value.open()
}
} else {
popup.value.open()
}
}
if (
attrs.componentProps.open &&
typeof attrs.componentProps.open === "function"
) {
const res = attrs.componentProps.open(
pickerKey.value,
attrs,
attrs.model
);
if (res) {
popup.value.open();
}
// resfalse
} else {
popup.value.open();
}
}
}
function change(e: any) {
if (attrs.componentProps.onChange && typeof attrs.componentProps.onChange === 'function') {
attrs.componentProps.onChange(e)
}
if (
attrs.componentProps.onChange &&
typeof attrs.componentProps.onChange === "function"
) {
attrs.componentProps.onChange(e);
}
}
const pickerValue = ref<any>('')
const pickerValue = ref<any>("");
watchEffect(() => {
if (newValue.value || newValue.value == 0) {
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
for (const key in attrs.componentProps.range) {
if (newValue.value == attrs.componentProps.range[key][attrs.componentProps.savaKey]) {
pickerValue.value = attrs.componentProps.range[key][attrs.componentProps.rangeKey]
if (attrs.componentProps.watch && isFunction(attrs.componentProps.watch)) {
attrs.componentProps.watch(pickerValue.value, attrs.componentProps.range[key])
}
break
}
}
} else {
pickerValue.value = newValue.value
if (newValue.value || newValue.value == 0) {
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
for (const key in attrs.componentProps.range) {
if (
newValue.value ==
attrs.componentProps.range[key][attrs.componentProps.savaKey]
) {
pickerValue.value =
attrs.componentProps.range[key][attrs.componentProps.rangeKey];
if (
attrs.componentProps.watch &&
isFunction(attrs.componentProps.watch)
) {
attrs.componentProps.watch(
pickerValue.value,
attrs.componentProps.range[key]
);
}
break;
}
}
} else {
pickerValue.value = newValue.value;
}
})
}
});
function ok(changeValue: any) {
if (attrs.componentProps) {
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
if (attrs.componentProps.savaKey) {
let id = []
let text = []
for (const key in changeValue) {
if (Array.isArray(attrs.componentProps.range[0])) {
id.push(attrs.componentProps.range[key][changeValue[key]][attrs.componentProps.savaKey])
text.push(attrs.componentProps.range[key][changeValue[key]][attrs.componentProps.rangeKey])
} else {
id.push(attrs.componentProps.range[changeValue[key]][attrs.componentProps.savaKey])
text.push(attrs.componentProps.range[changeValue[key]][attrs.componentProps.rangeKey])
}
}
newValue.value = id.join(',')
pickerValue.value = text.join(',')
} else {
let id = []
for (const key in changeValue) {
id.push(attrs.componentProps.range[key][changeValue[key]])
}
newValue.value = id.join(',')
pickerValue.value = id.join(',')
}
if (attrs.componentProps) {
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
if (attrs.componentProps.savaKey) {
let id = [];
let text = [];
for (const key in changeValue) {
if (Array.isArray(attrs.componentProps.range[0])) {
id.push(
attrs.componentProps.range[key][changeValue[key]][
attrs.componentProps.savaKey
]
);
text.push(
attrs.componentProps.range[key][changeValue[key]][
attrs.componentProps.rangeKey
]
);
} else {
id.push(
attrs.componentProps.range[changeValue[key]][
attrs.componentProps.savaKey
]
);
text.push(
attrs.componentProps.range[changeValue[key]][
attrs.componentProps.rangeKey
]
);
}
}
if (attrs.componentProps.ok && typeof attrs.componentProps.ok === 'function') {
attrs.componentProps.ok(changeValue, {
name: pickerValue.value,
value: newValue.value
}, attrs.componentProps.range)
newValue.value = id.join(",");
pickerValue.value = text.join(",");
} else {
let id = [];
for (const key in changeValue) {
id.push(attrs.componentProps.range[key][changeValue[key]]);
}
newValue.value = id.join(",");
pickerValue.value = id.join(",");
}
}
if (
attrs.componentProps.ok &&
typeof attrs.componentProps.ok === "function"
) {
attrs.componentProps.ok(
changeValue,
{
name: pickerValue.value,
value: newValue.value,
},
attrs.componentProps.range,
attrs
);
}
}
}
</script>

View File

@ -12,7 +12,7 @@
<view class="mr-2">
<uni-icons :type="leftIcon" size="20"></uni-icons>
</view>
<view>{{ attrs.label }}</view>
<view >{{ attrs.label }}</view>
</view>
<view class="flex-1 pl-10 w-full " :class="{'mt-10':labelPosition==='column'&&attrs.label}">
<slot></slot>

View File

@ -24,7 +24,7 @@
@pickend="pickend"
>
<picker-view-column v-for="(item, index) in range" :key="index">
<view class="flex-col-center" v-for="(val, i) in item" :key="i">
<view class="flex-col-center picker-item" v-for="(val, i) in item" :key="i">
{{ rangeKey ? val[rangeKey] : val }}</view
>
</picker-view-column>
@ -150,4 +150,19 @@ defineExpose({ open, close });
.picker-view {
height: 400rpx;
}
picker-view-column {
width: 100%;
}
.picker-item {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
padding: 0 10rpx;
box-sizing: border-box;
display: block !important;
text-align: center;
}
</style>

View File

@ -29,7 +29,7 @@
</view>
<template #bottom>
<view class="flex-row items-center pb-10 pt-5">
<u-button text="返回" class="ml-15 mr-7" :plain="true" @click="navigateBack"/>
<u-button text="上一步" class="ml-15 mr-7" :plain="true" @click="navigateBack"/>
<u-button text="下一步" class="mr-15 mr-7" type="primary" @click="submit"/>
</view>
</template>

View File

@ -31,7 +31,7 @@
<template #bottom>
<view class="flex-row items-center pb-10 pt-5">
<u-button
text="返回"
text="上一步"
class="ml-15 mr-7"
:plain="true"
@click="navigateBack"

View File

@ -30,7 +30,7 @@
<template #bottom>
<view class="flex-row items-center pb-10 pt-5">
<u-button
text="返回"
text="上一步"
class="ml-15 mr-7"
:plain="true"
@click="navigateBack"

View File

@ -6,11 +6,13 @@
<view class="po-re mb-15">
<BasicForm
v-model="item.value"
:schema="schema"
:schema="getSchemaForIndex(index)"
:index="index"
:key="`form-${index}-${forceUpdateKey}`"
:formsProps="{ labelWidth: 100 }"
/>
<view
@click="deleteMemberFamily(index as number, item.value)"
@click="deleteMemberFamily(index, item.value)"
class="delete-icon"
>
<BasicIcon type="clear" size="30" />
@ -30,7 +32,7 @@
<template #bottom>
<view class="flex-row items-center pb-10 pt-5">
<u-button
text="返回"
text="上一步"
class="ml-15 mr-7"
:plain="true"
@click="navigateBack"
@ -48,21 +50,89 @@
<script lang="ts" setup>
import { dicApi } from "@/api/system/dic";
import { useForm } from "@/components/BasicForm/hooks/useForm";
import { useDataStore } from "@/store/modules/data";
import { navigateTo, navigateBack } from "@/utils/uniapp";
import { navigateBack, navigateTo, showModal, showToast } from "@/utils/uniapp";
import { cloneDeep, map } from "lodash";
import { fractionRuleApi } from "@/api/base/server";
const schema = reactive<FormsSchema[]>([
//
const education = reactive<any>({
xl: [{ value: {} }],
});
//
const honorCategories = ref<any[]>([]);
//
const awardLevelsMap = reactive<Record<number, any>>({});
//
const forceUpdateKey = ref(0);
//
const baseSchema = [
{
field: "rymc",
label: "荣誉名称",
component: "BasicInput",
componentProps: {},
},
{
field: "hilb_id",
label: "荣誉类别",
component: "BasicPicker",
componentProps: {
api: fractionRuleApi,
rangeKey: "inspectStandard",
savaKey: "id",
ok: (selectedIndex: number, form: any, list: any, attrs: any) => {
const selectedCategory = list[selectedIndex];
const formIndex = attrs.index;
//
updateAwardLevels(formIndex, selectedCategory);
//
if (education.xl[formIndex].value.hjjbId) {
education.xl[formIndex].value.hjjbId = "";
}
//
forceUpdateKey.value++;
},
},
},
{
field: "hjjbId",
label: "获奖级别",
component: "BasicPicker",
componentProps: {
api: dicApi,
param: { pid: 1472324538 },
rangeKey: "dictionaryValue",
savaKey: "dictionaryCode",
range: [],
rangeKey: "name",
savaKey: "id",
open: (value: any, attrs: any, model: any) => {
const formIndex = attrs.index;
//
if (!model?.hilb_id) {
showToast({
title: "请先选择荣誉类别",
icon: "none",
});
return false;
}
//
const awardLevels = awardLevelsMap[formIndex] || [];
if (awardLevels.length === 0) {
showToast({
title: "该荣誉类别暂无获奖级别数据",
icon: "none",
});
return false;
}
return true;
},
},
},
{
@ -71,24 +141,18 @@ const schema = reactive<FormsSchema[]>([
component: "BasicInput",
componentProps: {},
},
// {
// field: "bjdw",
// label: "",
// component: "BasicInput",
// itemProps: {
// labelPosition: "top",
// },
// componentProps: {
// type: "textarea",
// rows: 3,
// },
// },
{
field: "hjtime",
label: "获奖时间",
component: "BasicDateTimes",
componentProps: {},
},
{
field: "jf",
label: "积分",
component: "BasicInput",
componentProps: {},
},
{
field: "hjfjId",
label: "上传证书",
@ -98,29 +162,101 @@ const schema = reactive<FormsSchema[]>([
},
componentProps: {},
},
]);
];
const education = reactive<any>({
xl: [{ value: {} }],
});
// schema
const getSchemaForIndex = (index: number) => {
const schema = cloneDeep(baseSchema);
function addEducation() {
education.xl.push({ value: {} });
}
//
const hjjbField = schema.find((item) => item.field === "hjjbId");
if (hjjbField) {
hjjbField.componentProps.range = awardLevelsMap[index] || [];
}
const { getFile, setFile } = useDataStore();
if (getFile.grRyList && getFile.grRyList.length > 0) {
education.xl = map(getFile.grRyList, (item) => {
return { value: item };
return schema;
};
//
const updateAwardLevels = (formIndex: number, category: any) => {
if (category?.ruleItemList && category.ruleItemList.length > 0) {
awardLevelsMap[formIndex] = category.ruleItemList;
} else {
awardLevelsMap[formIndex] = [];
}
};
//
const initHonorCategories = async () => {
try {
const result = await fractionRuleApi();
honorCategories.value = result.result || result || [];
} catch (error) {
console.error("获取荣誉类别数据失败:", error);
}
};
//
const initEchoData = async () => {
await initHonorCategories();
//
education.xl.forEach((formItem: any, index: number) => {
if (formItem.value?.hilb_id) {
const category = honorCategories.value.find(
(cat: any) => cat.id === formItem.value.hilb_id
);
if (category) {
//
updateAwardLevels(index, category);
} else {
console.log(`未找到荣誉类别 ID: ${formItem.value.hilb_id}`);
}
} else {
console.log(`表单项 ${index} 没有荣誉类别 ID`);
}
});
//
forceUpdateKey.value++;
};
//
function addEducation() {
const newIndex = education.xl.length;
education.xl.push({ value: {} });
//
awardLevelsMap[newIndex] = [];
}
//
function deleteMemberFamily(index: number, item: any) {
const list = cloneDeep(education.xl);
list.splice(index, 1);
education.xl = list;
//
delete awardLevelsMap[index];
// awardLevelsMap
const newAwardLevelsMap: Record<number, any[]> = {};
education.xl.forEach((_: any, i: number) => {
if (i < index) {
newAwardLevelsMap[i] = awardLevelsMap[i] || [];
} else if (i > index) {
newAwardLevelsMap[i - 1] = awardLevelsMap[i] || [];
}
});
//
education.xl.splice(index, 1);
// awardLevelsMap
Object.keys(awardLevelsMap).forEach(
(key: string) => delete awardLevelsMap[Number(key)]
);
Object.assign(awardLevelsMap, newAwardLevelsMap);
}
//
function submit() {
setFile({
...getFile,
@ -130,7 +266,31 @@ function submit() {
});
navigateTo("/pages/view/hr/teacherProfile/PublicClassAwards");
}
//
const { getFile, setFile } = useDataStore();
//
if (getFile.grRyList && getFile.grRyList.length > 0) {
education.xl = map(getFile.grRyList, (item) => {
return { value: item };
});
}
//
onMounted(() => {
if (getFile.grRyList && getFile.grRyList.length > 0) {
//
nextTick(() => {
initEchoData();
});
} else {
//
initHonorCategories();
}
});
</script>
<style>
.delete-icon {
position: absolute;

View File

@ -6,11 +6,13 @@
<view class="po-re mb-15">
<BasicForm
v-model="item.value"
:schema="schema"
:schema="getSchemaForIndex(index)"
:index="index"
:key="`form-${index}-${forceUpdateKey}`"
:formsProps="{ labelWidth: 100 }"
/>
<view
@click="deleteMemberFamily(index as number, item.value)"
@click="deleteMemberFamily(index, item.value)"
class="delete-icon"
>
<BasicIcon type="clear" size="30" />
@ -30,7 +32,7 @@
<template #bottom>
<view class="flex-row items-center pb-10 pt-5">
<u-button
text="返回"
text="上一步"
class="ml-15 mr-7"
:plain="true"
@click="navigateBack"
@ -47,23 +49,93 @@
</template>
<script lang="ts" setup>
import { fractionRuleApi1 } from "@/api/base/server";
import { dicApi } from "@/api/system/dic";
import { useForm } from "@/components/BasicForm/hooks/useForm";
import Template from "@/components/BasicQrcode/_template/template.vue";
import { useDataStore } from "@/store/modules/data";
import { navigateTo, navigateBack } from "@/utils/uniapp";
import { navigateBack, navigateTo, showToast } from "@/utils/uniapp";
import { cloneDeep, map } from "lodash";
const schema = reactive<FormsSchema[]>([
//
const education = reactive<any>({
xl: [{ value: {} }],
});
//
const honorCategories = ref<any[]>([]);
//
const awardLevelsMap = reactive<Record<number, any>>({});
//
const forceUpdateKey = ref(0);
//
const baseSchema = [
{
field: "rymc",
label: "荣誉名称",
component: "BasicInput",
componentProps: {},
},
{
field: "hilb_id",
label: "荣誉类别",
component: "BasicPicker",
componentProps: {
api: fractionRuleApi1,
rangeKey: "inspectStandard",
savaKey: "id",
ok: (selectedIndex: number, form: any, list: any, attrs: any) => {
const selectedCategory = list[selectedIndex];
const formIndex = attrs.index;
//
updateAwardLevels(formIndex, selectedCategory);
//
if (education.xl[formIndex].value.xm) {
education.xl[formIndex].value.xm = "";
}
//
forceUpdateKey.value++;
},
},
},
{
field: "xm",
label: "获奖级别",
component: "BasicPicker",
componentProps: {
api: dicApi,
param: { pid: 1472324538 },
rangeKey: "dictionaryValue",
savaKey: "dictionaryCode",
range: [],
rangeKey: "name",
savaKey: "id",
open: (value: any, attrs: any, model: any) => {
const formIndex = attrs.index;
//
if (!model?.hilb_id) {
showToast({
title: "请先选择荣誉类别",
icon: "none",
});
return false;
}
//
const awardLevels = awardLevelsMap[formIndex] || [];
if (awardLevels.length === 0) {
showToast({
title: "该荣誉类别暂无获奖级别数据",
icon: "none",
});
return false;
}
return true;
},
},
},
{
@ -78,6 +150,12 @@ const schema = reactive<FormsSchema[]>([
component: "BasicDateTimes",
componentProps: {},
},
{
field: "jf",
label: "积分",
component: "BasicInput",
componentProps: {},
},
{
field: "hjfjId",
label: "上传证书",
@ -88,29 +166,99 @@ const schema = reactive<FormsSchema[]>([
},
componentProps: {},
},
]);
];
const education = reactive<any>({
xl: [{ value: {} }],
});
// schema
const getSchemaForIndex = (index: number) => {
const schema = cloneDeep(baseSchema);
//
const hjjbField = schema.find((item) => item.field === "xm");
if (hjjbField) {
hjjbField.componentProps.range = awardLevelsMap[index] || [];
}
return schema;
};
function addEducation() {
education.xl.push({ value: {} });
}
//
const updateAwardLevels = (formIndex: number, category: any) => {
if (category?.ruleItemList && category.ruleItemList.length > 0) {
awardLevelsMap[formIndex] = category.ruleItemList;
} else {
awardLevelsMap[formIndex] = [];
}
};
const { getFile, setFile } = useDataStore();
if (getFile.gkkRyList && getFile.gkkRyList.length > 0) {
education.xl = map(getFile.gkkRyList, (item) => {
return { value: item };
//
const initHonorCategories = async () => {
try {
const result = await fractionRuleApi1();
honorCategories.value = result.result || result || [];
} catch (error) {
console.error("获取荣誉类别数据失败:", error);
}
};
//
const initEchoData = async () => {
await initHonorCategories();
//
education.xl.forEach((formItem: any, index: number) => {
if (formItem.value?.hilb_id) {
const category = honorCategories.value.find(
(cat: any) => cat.id === formItem.value.hilb_id
);
if (category) {
//
updateAwardLevels(index, category);
} else {
console.log(`未找到荣誉类别 ID: ${formItem.value.hilb_id}`);
}
}
});
//
forceUpdateKey.value++;
};
//
function addEducation() {
const newIndex = education.xl.length;
education.xl.push({ value: {} });
//
awardLevelsMap[newIndex] = [];
}
//
function deleteMemberFamily(index: number, item: any) {
const list = cloneDeep(education.xl);
list.splice(index, 1);
education.xl = list;
//
delete awardLevelsMap[index];
// awardLevelsMap
const newAwardLevelsMap: Record<number, any[]> = {};
education.xl.forEach((_: any, i: number) => {
if (i < index) {
newAwardLevelsMap[i] = awardLevelsMap[i] || [];
} else if (i > index) {
newAwardLevelsMap[i - 1] = awardLevelsMap[i] || [];
}
});
//
education.xl.splice(index, 1);
// awardLevelsMap
Object.keys(awardLevelsMap).forEach(
(key: string) => delete awardLevelsMap[Number(key)]
);
Object.assign(awardLevelsMap, newAwardLevelsMap);
}
//
function submit() {
setFile({
...getFile,
@ -120,6 +268,29 @@ function submit() {
});
navigateTo("/pages/view/hr/teacherProfile/RecordMaterials");
}
//
const { getFile, setFile } = useDataStore();
//
if (getFile.gkkRyList && getFile.gkkRyList.length > 0) {
education.xl = map(getFile.gkkRyList, (item) => {
return { value: item };
});
}
//
onMounted(() => {
if (getFile.gkkRyList && getFile.gkkRyList.length > 0) {
//
nextTick(() => {
initEchoData();
});
} else {
//
initHonorCategories();
}
});
</script>
<style>
.delete-icon {

View File

@ -7,7 +7,7 @@
<template #bottom>
<view class="flex-row items-center pb-10 pt-5">
<u-button
text="返回"
text="上一步"
class="ml-15 mr-7"
:plain="true"
@click="navigateBack"

View File

@ -96,8 +96,10 @@ const schema = reactive<FormsSchema[]>([
{
field: "zcpztime",
label: "职称批准年月",
component: "BasicDateTimes",
componentProps: {},
component: "BasicDateTime",
componentProps: {
mode: "year-month",
},
},
{
field: "zczsbh",

View File

@ -55,8 +55,17 @@ const [register, { getValue, setValue }] = useForm({
{
field: "qtzw",
label: "其他职务",
component: "BasicInput",
componentProps: {},
component: "BasicCheckbox",
itemProps: {
labelPosition: "top",
},
componentProps: {
api: dicApi,
multiple: true,
param: { pid: 246682695 },
rangeKey: "dictionaryValue",
savaKey: "dictionaryCode",
},
},
{
field: "zrxk",
@ -73,9 +82,9 @@ const [register, { getValue, setValue }] = useForm({
label: "主任班级",
component: "BasicPicker",
componentProps: {
api: kmFindAllApi,
rangeKey: "kmmc",
savaKey: "id",
api: findAllNjBjTree,
rangeKey: "title",
savaKey: "key",
},
},
{
@ -93,9 +102,9 @@ const [register, { getValue, setValue }] = useForm({
label: "兼任班级",
component: "BasicPicker",
componentProps: {
api: kmFindAllApi,
rangeKey: "kmmc",
savaKey: "id",
api: findAllNjBjTree,
rangeKey: "title",
savaKey: "key",
},
},
{

View File

@ -64,8 +64,10 @@ const [register, { getValue, setValue }] = useForm({
{
field: "zgnytime",
label: "教师资格取得年月",
component: "BasicDateTimes",
componentProps: {},
component: "BasicDateTime",
componentProps: {
mode: "year-month",
},
},
{
field: "zgzctime",