提交1
This commit is contained in:
parent
1cc0122ae9
commit
b431e1bff5
@ -30,3 +30,13 @@ export const jsConfirmJsDataApi = async (params: any) => {
|
|||||||
export const jsdFindPageTaskApi = async (params: any) => {
|
export const jsdFindPageTaskApi = async (params: any) => {
|
||||||
return await get("/api/jsd/findPageTask", params);
|
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"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,137 +1,161 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="white-bg-color r-md font-14 po-re">
|
<view class="white-bg-color r-md font-14 po-re">
|
||||||
<uni-forms
|
<uni-forms
|
||||||
ref="formRef"
|
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"
|
: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>
|
</template>
|
||||||
</uni-forms>
|
<template v-if="item.slot">
|
||||||
</view>
|
<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>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
export default {
|
export default {
|
||||||
options: {
|
options: {
|
||||||
styleIsolation: 'shared',
|
styleIsolation: "shared",
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
// #endif
|
// #endif
|
||||||
</script>
|
</script>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {computed, reactive} from "vue";
|
import { computed, reactive } from "vue";
|
||||||
import BasicComponent from './src/BasicComponent.vue'
|
import BasicComponent from "./src/BasicComponent.vue";
|
||||||
import FormsItem from './src/FormsItem.vue'
|
import FormsItem from "./src/FormsItem.vue";
|
||||||
import {ifShow, ifTitleShow} from "@/components/BasicForm/hooks/useForm";
|
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) => {
|
watch(
|
||||||
formModel.model = value
|
() => defineProp.modelValue,
|
||||||
})
|
(value) => {
|
||||||
|
formModel.model = value;
|
||||||
|
}
|
||||||
|
);
|
||||||
const refreshModel = (model: any) => {
|
const refreshModel = (model: any) => {
|
||||||
formModel.model = Object.assign({}, formModel.model, model)
|
formModel.model = Object.assign({}, formModel.model, model);
|
||||||
}
|
};
|
||||||
|
|
||||||
const props = reactive<FormOptions>({
|
const props = reactive<FormOptions>({
|
||||||
formsProps: {
|
formsProps: {
|
||||||
labelWidth: 80
|
labelWidth: 80,
|
||||||
},
|
},
|
||||||
schema: []
|
schema: [],
|
||||||
})
|
});
|
||||||
const defineProp = defineProps(['modelValue', 'formsProps', 'schema'])
|
const defineProp = defineProps(["modelValue", "formsProps", "schema"]);
|
||||||
const emits = defineEmits(['update:modelValue', 'register'])
|
const emits = defineEmits(["update:modelValue", "register"]);
|
||||||
|
|
||||||
if (defineProp.modelValue) {
|
if (defineProp.modelValue) {
|
||||||
formModel.model = defineProp.modelValue
|
formModel.model = defineProp.modelValue;
|
||||||
}
|
}
|
||||||
if (defineProp.schema) {
|
if (defineProp.schema) {
|
||||||
props.schema = defineProp.schema
|
props.schema = defineProp.schema;
|
||||||
}
|
}
|
||||||
if (defineProp.formsProps) {
|
if (defineProp.formsProps) {
|
||||||
props.formsProps = defineProp.formsProps
|
props.formsProps = defineProp.formsProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProps(value: FormOptions) {
|
function setProps(value: FormOptions) {
|
||||||
formModel.model = value.formModel
|
formModel.model = value.formModel;
|
||||||
if (value.schema) {
|
if (value.schema) {
|
||||||
props.schema = value.schema
|
props.schema = value.schema;
|
||||||
}
|
}
|
||||||
if (value.formsProps) {
|
if (value.formsProps) {
|
||||||
props.formsProps = value.formsProps
|
props.formsProps = value.formsProps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const refreshProps = () => {
|
const refreshProps = () => {
|
||||||
emits('register', setProps, formRef, formModel.model)
|
emits("register", setProps, formRef, formModel.model);
|
||||||
}
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
formRef.value.refreshModel = refreshModel
|
formRef.value.refreshModel = refreshModel;
|
||||||
formRef.value.refreshProps = refreshProps
|
formRef.value.refreshProps = refreshProps;
|
||||||
emits('register', setProps, formRef, formModel.model)
|
emits("register", setProps, formRef, formModel.model);
|
||||||
})
|
});
|
||||||
|
|
||||||
watch(() => formModel.model, (count) => {
|
|
||||||
emits('update:modelValue', count)
|
|
||||||
emits('register', setProps, formRef, count)
|
|
||||||
}, {deep: true})
|
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => formModel.model,
|
||||||
|
(count) => {
|
||||||
|
emits("update:modelValue", count);
|
||||||
|
emits("register", setProps, formRef, count);
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
//表单验证处理方法
|
//表单验证处理方法
|
||||||
const rules = computed(() => {
|
const rules = computed(() => {
|
||||||
let initRules: any = {}
|
let initRules: any = {};
|
||||||
props.schema.forEach((item) => {
|
props.schema.forEach((item) => {
|
||||||
if (item.field && item.rules) {
|
if (item.field && item.rules) {
|
||||||
for (const key in item.rules) {
|
for (const key in item.rules) {
|
||||||
item.rules[key]['ifShow'] = item.ifShow
|
item.rules[key]["ifShow"] = item.ifShow;
|
||||||
}
|
}
|
||||||
initRules[item.field] = {
|
initRules[item.field] = {
|
||||||
rules: item.rules
|
rules: item.rules,
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
if (item.field && item.required) {
|
if (item.field && item.required) {
|
||||||
initRules[item.field] = {
|
initRules[item.field] = {
|
||||||
rules: [{
|
rules: [
|
||||||
required: true,
|
{
|
||||||
ifShow: item.ifShow,
|
required: true,
|
||||||
errorMessage: item.label + '不能为空'
|
ifShow: item.ifShow,
|
||||||
}]
|
errorMessage: item.label + "不能为空",
|
||||||
}
|
},
|
||||||
}
|
],
|
||||||
}
|
};
|
||||||
})
|
}
|
||||||
return initRules
|
}
|
||||||
})
|
});
|
||||||
|
return initRules;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.formsItem:not(:last-child) {
|
.formsItem:not(:last-child) {
|
||||||
border-bottom: 1px solid #EFEFEF;
|
border-bottom: 1px solid #efefef;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detailModel {
|
.detailModel {
|
||||||
|
|||||||
@ -1,21 +1,42 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="py-7">
|
<view class="py-7">
|
||||||
<u-loading-icon :show="loadingShow" style="justify-content: start" size="20"/>
|
<u-loading-icon
|
||||||
<view @click="open" class="wh-full flex-row items-center justify-between" v-if="!loadingShow">
|
:show="loadingShow"
|
||||||
<view class="font-13 text-ellipsis-1" v-if="pickerValue">{{ pickerValue }}</view>
|
style="justify-content: start"
|
||||||
<view class="font-13 color-9" v-else-if="!attrs.componentProps.disabled">
|
size="20"
|
||||||
<text v-if="attrs.componentProps&&attrs.componentProps.placeholder">{{
|
/>
|
||||||
attrs.componentProps.placeholder
|
<view
|
||||||
}}
|
@click="open"
|
||||||
</text>
|
class="wh-full flex-row items-center justify-between"
|
||||||
<text v-else>请选择{{ attrs.label }}</text>
|
v-if="!loadingShow"
|
||||||
</view>
|
>
|
||||||
<view v-else>无</view>
|
<view class="font-13 text-ellipsis-1" v-if="pickerValue">{{
|
||||||
<uni-icons type="right" size="18" color="#999999" v-if="!attrs.componentProps.disabled"/>
|
pickerValue
|
||||||
</view>
|
}}</view>
|
||||||
<Picker ref="popup" :title="attrs.label" :range="range" :rangeKey="rangeKey" v-model="pickerKey" @ok="ok"
|
<view class="font-13 color-9" v-else-if="!attrs.componentProps.disabled">
|
||||||
@change="change"/>
|
<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>
|
</view>
|
||||||
|
<Picker
|
||||||
|
ref="popup"
|
||||||
|
:title="attrs.label"
|
||||||
|
:range="range"
|
||||||
|
:rangeKey="rangeKey"
|
||||||
|
v-model="pickerKey"
|
||||||
|
@ok="ok"
|
||||||
|
@change="change"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -33,141 +54,199 @@
|
|||||||
* @property @ok 点击确定事件
|
* @property @ok 点击确定事件
|
||||||
* @property @change 选择器change事件
|
* @property @change 选择器change事件
|
||||||
*/
|
*/
|
||||||
import Picker from '@/components/BasicPicker/Picker.vue'
|
import Picker from "@/components/BasicPicker/Picker.vue";
|
||||||
import {forEach, isFunction} from "lodash";
|
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 props = defineProps(["modelValue"]);
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(["update:modelValue"]);
|
||||||
const newValue = computed({
|
const newValue = computed({
|
||||||
get() {
|
get() {
|
||||||
return props.modelValue
|
return props.modelValue;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
emit('update:modelValue', value)
|
emit("update:modelValue", value);
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
const attrs: any = useAttrs()
|
const attrs: any = useAttrs();
|
||||||
|
|
||||||
const rangeKey = ref(attrs.componentProps && attrs.componentProps.rangeKey || '')
|
const rangeKey = ref(
|
||||||
const pickerKey = ref(attrs.componentProps && attrs.componentProps.value || [0])
|
(attrs.componentProps && attrs.componentProps.rangeKey) || ""
|
||||||
|
);
|
||||||
|
const pickerKey = ref(
|
||||||
|
(attrs.componentProps && attrs.componentProps.value) || [0]
|
||||||
|
);
|
||||||
|
|
||||||
const range = computed(() => {
|
const range = computed(() => {
|
||||||
if (attrs.componentProps && attrs.componentProps.range) {
|
if (attrs.componentProps && attrs.componentProps.range) {
|
||||||
if (Array.isArray(attrs.componentProps.range[0])) {
|
if (Array.isArray(attrs.componentProps.range[0])) {
|
||||||
return attrs.componentProps.range
|
return attrs.componentProps.range;
|
||||||
} else {
|
|
||||||
return [attrs.componentProps.range]
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return []
|
return [attrs.componentProps.range];
|
||||||
}
|
}
|
||||||
})
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function initapi() {
|
function initapi() {
|
||||||
if (attrs.componentProps.api && isFunction(attrs.componentProps.api)) {
|
if (attrs.componentProps.api && isFunction(attrs.componentProps.api)) {
|
||||||
loadingShow.value = true
|
loadingShow.value = true;
|
||||||
attrs.componentProps.api(attrs.componentProps.param || null).then((res: any) => {
|
attrs.componentProps
|
||||||
attrs.componentProps.range = res[attrs.componentProps.resultKey || 'result']
|
.api(attrs.componentProps.param || null)
|
||||||
if (attrs.componentProps.request && isFunction(attrs.componentProps.request)) {
|
.then((res: any) => {
|
||||||
attrs.componentProps.request(attrs.componentProps.range)
|
attrs.componentProps.range =
|
||||||
}
|
res[attrs.componentProps.resultKey || "result"];
|
||||||
loadingShow.value = false
|
if (
|
||||||
})
|
attrs.componentProps.request &&
|
||||||
}
|
isFunction(attrs.componentProps.request)
|
||||||
|
) {
|
||||||
|
attrs.componentProps.request(attrs.componentProps.range);
|
||||||
|
}
|
||||||
|
loadingShow.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initapi()
|
initapi();
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
if (!attrs.componentProps.disabled) {
|
if (!attrs.componentProps.disabled) {
|
||||||
if (newValue.value) {
|
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) => {
|
forEach(attrs.componentProps.range, (v, k) => {
|
||||||
if (v[attrs.componentProps.savaKey] == newValue.value) {
|
if (
|
||||||
pickerKey.value = [k]
|
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();
|
||||||
|
}
|
||||||
|
// 如果res为false,不执行任何操作,不打开弹窗
|
||||||
|
} else {
|
||||||
|
popup.value.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function change(e: any) {
|
function change(e: any) {
|
||||||
if (attrs.componentProps.onChange && typeof attrs.componentProps.onChange === 'function') {
|
if (
|
||||||
attrs.componentProps.onChange(e)
|
attrs.componentProps.onChange &&
|
||||||
}
|
typeof attrs.componentProps.onChange === "function"
|
||||||
|
) {
|
||||||
|
attrs.componentProps.onChange(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pickerValue = ref<any>('')
|
const pickerValue = ref<any>("");
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (newValue.value || newValue.value == 0) {
|
if (newValue.value || newValue.value == 0) {
|
||||||
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
|
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
|
||||||
for (const key in attrs.componentProps.range) {
|
for (const key in attrs.componentProps.range) {
|
||||||
if (newValue.value == attrs.componentProps.range[key][attrs.componentProps.savaKey]) {
|
if (
|
||||||
pickerValue.value = attrs.componentProps.range[key][attrs.componentProps.rangeKey]
|
newValue.value ==
|
||||||
if (attrs.componentProps.watch && isFunction(attrs.componentProps.watch)) {
|
attrs.componentProps.range[key][attrs.componentProps.savaKey]
|
||||||
attrs.componentProps.watch(pickerValue.value, attrs.componentProps.range[key])
|
) {
|
||||||
}
|
pickerValue.value =
|
||||||
break
|
attrs.componentProps.range[key][attrs.componentProps.rangeKey];
|
||||||
}
|
if (
|
||||||
}
|
attrs.componentProps.watch &&
|
||||||
} else {
|
isFunction(attrs.componentProps.watch)
|
||||||
pickerValue.value = newValue.value
|
) {
|
||||||
|
attrs.componentProps.watch(
|
||||||
|
pickerValue.value,
|
||||||
|
attrs.componentProps.range[key]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pickerValue.value = newValue.value;
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function ok(changeValue: any) {
|
function ok(changeValue: any) {
|
||||||
if (attrs.componentProps) {
|
if (attrs.componentProps) {
|
||||||
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
|
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
|
||||||
if (attrs.componentProps.savaKey) {
|
if (attrs.componentProps.savaKey) {
|
||||||
let id = []
|
let id = [];
|
||||||
let text = []
|
let text = [];
|
||||||
for (const key in changeValue) {
|
for (const key in changeValue) {
|
||||||
if (Array.isArray(attrs.componentProps.range[0])) {
|
if (Array.isArray(attrs.componentProps.range[0])) {
|
||||||
id.push(attrs.componentProps.range[key][changeValue[key]][attrs.componentProps.savaKey])
|
id.push(
|
||||||
text.push(attrs.componentProps.range[key][changeValue[key]][attrs.componentProps.rangeKey])
|
attrs.componentProps.range[key][changeValue[key]][
|
||||||
} else {
|
attrs.componentProps.savaKey
|
||||||
id.push(attrs.componentProps.range[changeValue[key]][attrs.componentProps.savaKey])
|
]
|
||||||
text.push(attrs.componentProps.range[changeValue[key]][attrs.componentProps.rangeKey])
|
);
|
||||||
}
|
text.push(
|
||||||
}
|
attrs.componentProps.range[key][changeValue[key]][
|
||||||
newValue.value = id.join(',')
|
attrs.componentProps.rangeKey
|
||||||
pickerValue.value = text.join(',')
|
]
|
||||||
} else {
|
);
|
||||||
let id = []
|
} else {
|
||||||
for (const key in changeValue) {
|
id.push(
|
||||||
id.push(attrs.componentProps.range[key][changeValue[key]])
|
attrs.componentProps.range[changeValue[key]][
|
||||||
}
|
attrs.componentProps.savaKey
|
||||||
newValue.value = id.join(',')
|
]
|
||||||
pickerValue.value = id.join(',')
|
);
|
||||||
}
|
text.push(
|
||||||
|
attrs.componentProps.range[changeValue[key]][
|
||||||
|
attrs.componentProps.rangeKey
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (attrs.componentProps.ok && typeof attrs.componentProps.ok === 'function') {
|
newValue.value = id.join(",");
|
||||||
attrs.componentProps.ok(changeValue, {
|
pickerValue.value = text.join(",");
|
||||||
name: pickerValue.value,
|
} else {
|
||||||
value: newValue.value
|
let id = [];
|
||||||
}, attrs.componentProps.range)
|
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>
|
</script>
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<view class="mr-2">
|
<view class="mr-2">
|
||||||
<uni-icons :type="leftIcon" size="20"></uni-icons>
|
<uni-icons :type="leftIcon" size="20"></uni-icons>
|
||||||
</view>
|
</view>
|
||||||
<view>{{ attrs.label }}</view>
|
<view >{{ attrs.label }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-1 pl-10 w-full " :class="{'mt-10':labelPosition==='column'&&attrs.label}">
|
<view class="flex-1 pl-10 w-full " :class="{'mt-10':labelPosition==='column'&&attrs.label}">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
@pickend="pickend"
|
@pickend="pickend"
|
||||||
>
|
>
|
||||||
<picker-view-column v-for="(item, index) in range" :key="index">
|
<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
|
{{ rangeKey ? val[rangeKey] : val }}</view
|
||||||
>
|
>
|
||||||
</picker-view-column>
|
</picker-view-column>
|
||||||
@ -150,4 +150,19 @@ defineExpose({ open, close });
|
|||||||
.picker-view {
|
.picker-view {
|
||||||
height: 400rpx;
|
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>
|
</style>
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<template #bottom>
|
<template #bottom>
|
||||||
<view class="flex-row items-center pb-10 pt-5">
|
<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"/>
|
<u-button text="下一步" class="mr-15 mr-7" type="primary" @click="submit"/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
<template #bottom>
|
<template #bottom>
|
||||||
<view class="flex-row items-center pb-10 pt-5">
|
<view class="flex-row items-center pb-10 pt-5">
|
||||||
<u-button
|
<u-button
|
||||||
text="返回"
|
text="上一步"
|
||||||
class="ml-15 mr-7"
|
class="ml-15 mr-7"
|
||||||
:plain="true"
|
:plain="true"
|
||||||
@click="navigateBack"
|
@click="navigateBack"
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
<template #bottom>
|
<template #bottom>
|
||||||
<view class="flex-row items-center pb-10 pt-5">
|
<view class="flex-row items-center pb-10 pt-5">
|
||||||
<u-button
|
<u-button
|
||||||
text="返回"
|
text="上一步"
|
||||||
class="ml-15 mr-7"
|
class="ml-15 mr-7"
|
||||||
:plain="true"
|
:plain="true"
|
||||||
@click="navigateBack"
|
@click="navigateBack"
|
||||||
|
|||||||
@ -6,11 +6,13 @@
|
|||||||
<view class="po-re mb-15">
|
<view class="po-re mb-15">
|
||||||
<BasicForm
|
<BasicForm
|
||||||
v-model="item.value"
|
v-model="item.value"
|
||||||
:schema="schema"
|
:schema="getSchemaForIndex(index)"
|
||||||
|
:index="index"
|
||||||
|
:key="`form-${index}-${forceUpdateKey}`"
|
||||||
:formsProps="{ labelWidth: 100 }"
|
:formsProps="{ labelWidth: 100 }"
|
||||||
/>
|
/>
|
||||||
<view
|
<view
|
||||||
@click="deleteMemberFamily(index as number, item.value)"
|
@click="deleteMemberFamily(index, item.value)"
|
||||||
class="delete-icon"
|
class="delete-icon"
|
||||||
>
|
>
|
||||||
<BasicIcon type="clear" size="30" />
|
<BasicIcon type="clear" size="30" />
|
||||||
@ -30,7 +32,7 @@
|
|||||||
<template #bottom>
|
<template #bottom>
|
||||||
<view class="flex-row items-center pb-10 pt-5">
|
<view class="flex-row items-center pb-10 pt-5">
|
||||||
<u-button
|
<u-button
|
||||||
text="返回"
|
text="上一步"
|
||||||
class="ml-15 mr-7"
|
class="ml-15 mr-7"
|
||||||
:plain="true"
|
:plain="true"
|
||||||
@click="navigateBack"
|
@click="navigateBack"
|
||||||
@ -48,21 +50,89 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { dicApi } from "@/api/system/dic";
|
import { dicApi } from "@/api/system/dic";
|
||||||
import { useForm } from "@/components/BasicForm/hooks/useForm";
|
|
||||||
import { useDataStore } from "@/store/modules/data";
|
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 { 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",
|
field: "hjjbId",
|
||||||
label: "获奖级别",
|
label: "获奖级别",
|
||||||
component: "BasicPicker",
|
component: "BasicPicker",
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: dicApi,
|
range: [],
|
||||||
param: { pid: 1472324538 },
|
rangeKey: "name",
|
||||||
rangeKey: "dictionaryValue",
|
savaKey: "id",
|
||||||
savaKey: "dictionaryCode",
|
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",
|
component: "BasicInput",
|
||||||
componentProps: {},
|
componentProps: {},
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// field: "bjdw",
|
|
||||||
// label: "获奖内容",
|
|
||||||
// component: "BasicInput",
|
|
||||||
// itemProps: {
|
|
||||||
// labelPosition: "top",
|
|
||||||
// },
|
|
||||||
// componentProps: {
|
|
||||||
// type: "textarea",
|
|
||||||
// rows: 3,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
field: "hjtime",
|
field: "hjtime",
|
||||||
label: "获奖时间",
|
label: "获奖时间",
|
||||||
component: "BasicDateTimes",
|
component: "BasicDateTimes",
|
||||||
componentProps: {},
|
componentProps: {},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: "jf",
|
||||||
|
label: "积分",
|
||||||
|
component: "BasicInput",
|
||||||
|
componentProps: {},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: "hjfjId",
|
field: "hjfjId",
|
||||||
label: "上传证书",
|
label: "上传证书",
|
||||||
@ -98,29 +162,101 @@ const schema = reactive<FormsSchema[]>([
|
|||||||
},
|
},
|
||||||
componentProps: {},
|
componentProps: {},
|
||||||
},
|
},
|
||||||
]);
|
];
|
||||||
|
|
||||||
const education = reactive<any>({
|
// 为每个表单项生成动态的schema
|
||||||
xl: [{ value: {} }],
|
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();
|
return schema;
|
||||||
if (getFile.grRyList && getFile.grRyList.length > 0) {
|
};
|
||||||
education.xl = map(getFile.grRyList, (item) => {
|
|
||||||
return { value: item };
|
// 更新指定表单项的获奖级别选项
|
||||||
|
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) {
|
function deleteMemberFamily(index: number, item: any) {
|
||||||
const list = cloneDeep(education.xl);
|
// 删除对应的获奖级别数据
|
||||||
list.splice(index, 1);
|
delete awardLevelsMap[index];
|
||||||
education.xl = list;
|
|
||||||
|
// 重新整理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() {
|
function submit() {
|
||||||
setFile({
|
setFile({
|
||||||
...getFile,
|
...getFile,
|
||||||
@ -130,7 +266,31 @@ function submit() {
|
|||||||
});
|
});
|
||||||
navigateTo("/pages/view/hr/teacherProfile/PublicClassAwards");
|
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>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.delete-icon {
|
.delete-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@ -6,11 +6,13 @@
|
|||||||
<view class="po-re mb-15">
|
<view class="po-re mb-15">
|
||||||
<BasicForm
|
<BasicForm
|
||||||
v-model="item.value"
|
v-model="item.value"
|
||||||
:schema="schema"
|
:schema="getSchemaForIndex(index)"
|
||||||
|
:index="index"
|
||||||
|
:key="`form-${index}-${forceUpdateKey}`"
|
||||||
:formsProps="{ labelWidth: 100 }"
|
:formsProps="{ labelWidth: 100 }"
|
||||||
/>
|
/>
|
||||||
<view
|
<view
|
||||||
@click="deleteMemberFamily(index as number, item.value)"
|
@click="deleteMemberFamily(index, item.value)"
|
||||||
class="delete-icon"
|
class="delete-icon"
|
||||||
>
|
>
|
||||||
<BasicIcon type="clear" size="30" />
|
<BasicIcon type="clear" size="30" />
|
||||||
@ -30,7 +32,7 @@
|
|||||||
<template #bottom>
|
<template #bottom>
|
||||||
<view class="flex-row items-center pb-10 pt-5">
|
<view class="flex-row items-center pb-10 pt-5">
|
||||||
<u-button
|
<u-button
|
||||||
text="返回"
|
text="上一步"
|
||||||
class="ml-15 mr-7"
|
class="ml-15 mr-7"
|
||||||
:plain="true"
|
:plain="true"
|
||||||
@click="navigateBack"
|
@click="navigateBack"
|
||||||
@ -47,23 +49,93 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { fractionRuleApi1 } from "@/api/base/server";
|
||||||
import { dicApi } from "@/api/system/dic";
|
import { dicApi } from "@/api/system/dic";
|
||||||
import { useForm } from "@/components/BasicForm/hooks/useForm";
|
|
||||||
import Template from "@/components/BasicQrcode/_template/template.vue";
|
import Template from "@/components/BasicQrcode/_template/template.vue";
|
||||||
import { useDataStore } from "@/store/modules/data";
|
import { useDataStore } from "@/store/modules/data";
|
||||||
import { navigateTo, navigateBack } from "@/utils/uniapp";
|
import { navigateBack, navigateTo, showToast } from "@/utils/uniapp";
|
||||||
import { cloneDeep, map } from "lodash";
|
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",
|
field: "xm",
|
||||||
label: "获奖级别",
|
label: "获奖级别",
|
||||||
component: "BasicPicker",
|
component: "BasicPicker",
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: dicApi,
|
range: [],
|
||||||
param: { pid: 1472324538 },
|
rangeKey: "name",
|
||||||
rangeKey: "dictionaryValue",
|
savaKey: "id",
|
||||||
savaKey: "dictionaryCode",
|
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",
|
component: "BasicDateTimes",
|
||||||
componentProps: {},
|
componentProps: {},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: "jf",
|
||||||
|
label: "积分",
|
||||||
|
component: "BasicInput",
|
||||||
|
componentProps: {},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: "hjfjId",
|
field: "hjfjId",
|
||||||
label: "上传证书",
|
label: "上传证书",
|
||||||
@ -88,29 +166,99 @@ const schema = reactive<FormsSchema[]>([
|
|||||||
},
|
},
|
||||||
componentProps: {},
|
componentProps: {},
|
||||||
},
|
},
|
||||||
]);
|
];
|
||||||
|
|
||||||
const education = reactive<any>({
|
// 为每个表单项生成动态的schema
|
||||||
xl: [{ value: {} }],
|
const getSchemaForIndex = (index: number) => {
|
||||||
});
|
const schema = cloneDeep(baseSchema);
|
||||||
|
|
||||||
function addEducation() {
|
// 更新获奖级别的选项数据
|
||||||
education.xl.push({ value: {} });
|
const hjjbField = schema.find((item) => item.field === "xm");
|
||||||
}
|
if (hjjbField) {
|
||||||
|
hjjbField.componentProps.range = awardLevelsMap[index] || [];
|
||||||
|
}
|
||||||
|
|
||||||
const { getFile, setFile } = useDataStore();
|
return schema;
|
||||||
if (getFile.gkkRyList && getFile.gkkRyList.length > 0) {
|
};
|
||||||
education.xl = map(getFile.gkkRyList, (item) => {
|
|
||||||
return { value: item };
|
// 更新指定表单项的获奖级别选项
|
||||||
|
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 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) {
|
function deleteMemberFamily(index: number, item: any) {
|
||||||
const list = cloneDeep(education.xl);
|
// 删除对应的获奖级别数据
|
||||||
list.splice(index, 1);
|
delete awardLevelsMap[index];
|
||||||
education.xl = list;
|
|
||||||
|
// 重新整理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() {
|
function submit() {
|
||||||
setFile({
|
setFile({
|
||||||
...getFile,
|
...getFile,
|
||||||
@ -120,6 +268,29 @@ function submit() {
|
|||||||
});
|
});
|
||||||
navigateTo("/pages/view/hr/teacherProfile/RecordMaterials");
|
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>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.delete-icon {
|
.delete-icon {
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<template #bottom>
|
<template #bottom>
|
||||||
<view class="flex-row items-center pb-10 pt-5">
|
<view class="flex-row items-center pb-10 pt-5">
|
||||||
<u-button
|
<u-button
|
||||||
text="返回"
|
text="上一步"
|
||||||
class="ml-15 mr-7"
|
class="ml-15 mr-7"
|
||||||
:plain="true"
|
:plain="true"
|
||||||
@click="navigateBack"
|
@click="navigateBack"
|
||||||
|
|||||||
@ -96,8 +96,10 @@ const schema = reactive<FormsSchema[]>([
|
|||||||
{
|
{
|
||||||
field: "zcpztime",
|
field: "zcpztime",
|
||||||
label: "职称批准年月",
|
label: "职称批准年月",
|
||||||
component: "BasicDateTimes",
|
component: "BasicDateTime",
|
||||||
componentProps: {},
|
componentProps: {
|
||||||
|
mode: "year-month",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "zczsbh",
|
field: "zczsbh",
|
||||||
|
|||||||
@ -55,8 +55,17 @@ const [register, { getValue, setValue }] = useForm({
|
|||||||
{
|
{
|
||||||
field: "qtzw",
|
field: "qtzw",
|
||||||
label: "其他职务",
|
label: "其他职务",
|
||||||
component: "BasicInput",
|
component: "BasicCheckbox",
|
||||||
componentProps: {},
|
itemProps: {
|
||||||
|
labelPosition: "top",
|
||||||
|
},
|
||||||
|
componentProps: {
|
||||||
|
api: dicApi,
|
||||||
|
multiple: true,
|
||||||
|
param: { pid: 246682695 },
|
||||||
|
rangeKey: "dictionaryValue",
|
||||||
|
savaKey: "dictionaryCode",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "zrxk",
|
field: "zrxk",
|
||||||
@ -73,9 +82,9 @@ const [register, { getValue, setValue }] = useForm({
|
|||||||
label: "主任班级",
|
label: "主任班级",
|
||||||
component: "BasicPicker",
|
component: "BasicPicker",
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: kmFindAllApi,
|
api: findAllNjBjTree,
|
||||||
rangeKey: "kmmc",
|
rangeKey: "title",
|
||||||
savaKey: "id",
|
savaKey: "key",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -93,9 +102,9 @@ const [register, { getValue, setValue }] = useForm({
|
|||||||
label: "兼任班级",
|
label: "兼任班级",
|
||||||
component: "BasicPicker",
|
component: "BasicPicker",
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: kmFindAllApi,
|
api: findAllNjBjTree,
|
||||||
rangeKey: "kmmc",
|
rangeKey: "title",
|
||||||
savaKey: "id",
|
savaKey: "key",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -64,8 +64,10 @@ const [register, { getValue, setValue }] = useForm({
|
|||||||
{
|
{
|
||||||
field: "zgnytime",
|
field: "zgnytime",
|
||||||
label: "教师资格取得年月",
|
label: "教师资格取得年月",
|
||||||
component: "BasicDateTimes",
|
component: "BasicDateTime",
|
||||||
componentProps: {},
|
componentProps: {
|
||||||
|
mode: "year-month",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "zgzctime",
|
field: "zgzctime",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user