提交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) => {
|
||||
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"
|
||||
);
|
||||
};
|
||||
|
||||
@ -7,11 +7,14 @@
|
||||
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"/>
|
||||
<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"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.slot">
|
||||
<view class="py-7 font-13">
|
||||
@ -20,10 +23,22 @@
|
||||
</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
|
||||
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>
|
||||
<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>
|
||||
@ -35,103 +50,112 @@
|
||||
// #ifdef MP-WEIXIN
|
||||
export default {
|
||||
options: {
|
||||
styleIsolation: 'shared',
|
||||
}
|
||||
}
|
||||
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
|
||||
labelWidth: 80,
|
||||
},
|
||||
schema: []
|
||||
})
|
||||
const defineProp = defineProps(['modelValue', 'formsProps', 'schema'])
|
||||
const emits = defineEmits(['update:modelValue', 'register'])
|
||||
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
|
||||
formModel.model = value.formModel;
|
||||
if (value.schema) {
|
||||
props.schema = value.schema
|
||||
props.schema = value.schema;
|
||||
}
|
||||
if (value.formsProps) {
|
||||
props.formsProps = 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 = {}
|
||||
let initRules: any = {};
|
||||
props.schema.forEach((item) => {
|
||||
if (item.field && item.rules) {
|
||||
for (const key in item.rules) {
|
||||
item.rules[key]['ifShow'] = item.ifShow
|
||||
item.rules[key]["ifShow"] = item.ifShow;
|
||||
}
|
||||
initRules[item.field] = {
|
||||
rules: item.rules
|
||||
}
|
||||
rules: item.rules,
|
||||
};
|
||||
} else {
|
||||
if (item.field && item.required) {
|
||||
initRules[item.field] = {
|
||||
rules: [{
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
ifShow: item.ifShow,
|
||||
errorMessage: item.label + '不能为空'
|
||||
}]
|
||||
errorMessage: item.label + "不能为空",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return initRules
|
||||
})
|
||||
|
||||
});
|
||||
return initRules;
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.formsItem:not(:last-child) {
|
||||
border-bottom: 1px solid #EFEFEF;
|
||||
border-bottom: 1px solid #efefef;
|
||||
}
|
||||
|
||||
.detailModel {
|
||||
|
||||
@ -1,20 +1,41 @@
|
||||
<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>
|
||||
<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 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"/>
|
||||
<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"/>
|
||||
<Picker
|
||||
ref="popup"
|
||||
:title="attrs.label"
|
||||
:range="range"
|
||||
:rangeKey="rangeKey"
|
||||
v-model="pickerKey"
|
||||
@ok="ok"
|
||||
@change="change"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -33,140 +54,198 @@
|
||||
* @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
|
||||
return props.modelValue;
|
||||
},
|
||||
set(value) {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
})
|
||||
const attrs: any = useAttrs()
|
||||
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
|
||||
return attrs.componentProps.range;
|
||||
} else {
|
||||
return [attrs.componentProps.range]
|
||||
return [attrs.componentProps.range];
|
||||
}
|
||||
} else {
|
||||
return []
|
||||
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 = 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
|
||||
})
|
||||
loadingShow.value = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initapi()
|
||||
initapi();
|
||||
|
||||
function open() {
|
||||
if (!attrs.componentProps.disabled) {
|
||||
if (newValue.value) {
|
||||
forEach(attrs.componentProps.range, (v, k) => {
|
||||
if (v[attrs.componentProps.savaKey] == newValue.value) {
|
||||
pickerKey.value = [k]
|
||||
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 (
|
||||
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()
|
||||
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()
|
||||
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])
|
||||
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
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pickerValue.value = newValue.value
|
||||
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 = []
|
||||
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])
|
||||
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])
|
||||
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(',')
|
||||
newValue.value = id.join(",");
|
||||
pickerValue.value = text.join(",");
|
||||
} else {
|
||||
let id = []
|
||||
let id = [];
|
||||
for (const key in changeValue) {
|
||||
id.push(attrs.componentProps.range[key][changeValue[key]])
|
||||
id.push(attrs.componentProps.range[key][changeValue[key]]);
|
||||
}
|
||||
newValue.value = id.join(',')
|
||||
pickerValue.value = id.join(',')
|
||||
newValue.value = id.join(",");
|
||||
pickerValue.value = id.join(",");
|
||||
}
|
||||
}
|
||||
if (attrs.componentProps.ok && typeof attrs.componentProps.ok === 'function') {
|
||||
attrs.componentProps.ok(changeValue, {
|
||||
if (
|
||||
attrs.componentProps.ok &&
|
||||
typeof attrs.componentProps.ok === "function"
|
||||
) {
|
||||
attrs.componentProps.ok(
|
||||
changeValue,
|
||||
{
|
||||
name: pickerValue.value,
|
||||
value: newValue.value
|
||||
}, attrs.componentProps.range)
|
||||
value: newValue.value,
|
||||
},
|
||||
attrs.componentProps.range,
|
||||
attrs
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
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();
|
||||
if (getFile.gkkRyList && getFile.gkkRyList.length > 0) {
|
||||
education.xl = map(getFile.gkkRyList, (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 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 {
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -96,8 +96,10 @@ const schema = reactive<FormsSchema[]>([
|
||||
{
|
||||
field: "zcpztime",
|
||||
label: "职称批准年月",
|
||||
component: "BasicDateTimes",
|
||||
componentProps: {},
|
||||
component: "BasicDateTime",
|
||||
componentProps: {
|
||||
mode: "year-month",
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "zczsbh",
|
||||
|
||||
@ -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",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@ -64,8 +64,10 @@ const [register, { getValue, setValue }] = useForm({
|
||||
{
|
||||
field: "zgnytime",
|
||||
label: "教师资格取得年月",
|
||||
component: "BasicDateTimes",
|
||||
componentProps: {},
|
||||
component: "BasicDateTime",
|
||||
componentProps: {
|
||||
mode: "year-month",
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "zgzctime",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user