完成教师档案
This commit is contained in:
parent
333316f207
commit
b0b288bb3b
@ -37,10 +37,10 @@ const newValue = computed({
|
|||||||
const attrs: any = useAttrs()
|
const attrs: any = useAttrs()
|
||||||
|
|
||||||
function change(e: string) {
|
function change(e: string) {
|
||||||
|
newValue.value = e
|
||||||
if (attrs.componentProps.change && isFunction(attrs.componentProps.change)) {
|
if (attrs.componentProps.change && isFunction(attrs.componentProps.change)) {
|
||||||
attrs.componentProps.change(e)
|
attrs.componentProps.change(e)
|
||||||
}
|
}
|
||||||
newValue.value = e
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped></style>
|
||||||
|
|||||||
141
src/components/BasicForm/components/BasicTree.vue
Normal file
141
src/components/BasicForm/components/BasicTree.vue
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<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.join(',') }}</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>
|
||||||
|
<BasicTree ref="basicTreeRef"
|
||||||
|
:range="range"
|
||||||
|
:idKey="savaKey"
|
||||||
|
:rangeKey="rangeKey"
|
||||||
|
:title="'选择'+ attrs.label"
|
||||||
|
@confirm="confirm"
|
||||||
|
v-bind="attrs.componentProps"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import BasicTree from '@/components/BasicTree/Tree.vue';
|
||||||
|
/**
|
||||||
|
* BasicPicker 选择器
|
||||||
|
* @property title 顶部title
|
||||||
|
* @property range 渲染数据列表
|
||||||
|
* @property api 渲染数据接口
|
||||||
|
* @property param 接口参数
|
||||||
|
* @property resultKey 数据接口返回字段默认为result
|
||||||
|
* @property rangeKey 显示值的key
|
||||||
|
* @property savaKey 保存值的key
|
||||||
|
*
|
||||||
|
* @property @ok 点击确定事件
|
||||||
|
* @property @change 选择器change事件
|
||||||
|
*/
|
||||||
|
import {isFunction, map} from "lodash";
|
||||||
|
|
||||||
|
const loadingShow = ref(false)
|
||||||
|
const basicTreeRef = ref<any>(null)
|
||||||
|
const props = defineProps(['modelValue'])
|
||||||
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
const pickerValue = ref<any>([])
|
||||||
|
|
||||||
|
const newValue = computed({
|
||||||
|
get() {
|
||||||
|
return props.modelValue
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const attrs: any = useAttrs()
|
||||||
|
|
||||||
|
const rangeKey = ref(attrs.componentProps && attrs.componentProps.rangeKey || '')
|
||||||
|
const savaKey = ref(attrs.componentProps && attrs.componentProps.savaKey || '')
|
||||||
|
|
||||||
|
const range = computed({
|
||||||
|
get() {
|
||||||
|
if (attrs.componentProps && attrs.componentProps.range) {
|
||||||
|
return attrs.componentProps.range
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
attrs.componentProps.range = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initapi()
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
if (!attrs.componentProps.disabled) {
|
||||||
|
basicTreeRef.value._show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirm(value: any) {
|
||||||
|
const valueDataID = map(value, (item) => {
|
||||||
|
return item[attrs.componentProps.savaKey]
|
||||||
|
})
|
||||||
|
newValue.value = valueDataID.join(',')
|
||||||
|
|
||||||
|
if (attrs.componentProps.ok && typeof attrs.componentProps.ok === 'function') {
|
||||||
|
attrs.componentProps.ok(value, attrs.componentProps.range)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hx(rangeData: any, data: any) {
|
||||||
|
let valueList = data.split(',')
|
||||||
|
for (const key in rangeData) {
|
||||||
|
for (const vkey in valueList) {
|
||||||
|
if (rangeData[key][attrs.componentProps.savaKey] == valueList[vkey]) {
|
||||||
|
rangeData[key].checked = true;
|
||||||
|
if (!attrs.componentProps.multiple) {
|
||||||
|
pickerValue.value = []
|
||||||
|
}
|
||||||
|
pickerValue.value.push(rangeData[key][attrs.componentProps.rangeKey])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rangeData[key].children && rangeData[key].children.length > 0) {
|
||||||
|
hx(rangeData[key].children, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
range.value = rangeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
if (newValue.value || newValue.value == 0) {
|
||||||
|
if (attrs.componentProps.range && attrs.componentProps.range.length > 0) {
|
||||||
|
hx(attrs.componentProps.range, newValue.value.toString())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pickerValue.value = newValue.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
@ -39,6 +39,7 @@ const calculateYearDiff = (startDate: string) => {
|
|||||||
if (!startDate) return "";
|
if (!startDate) return "";
|
||||||
const start = dayjs(startDate);
|
const start = dayjs(startDate);
|
||||||
const now = dayjs();
|
const now = dayjs();
|
||||||
|
console.log(now.diff(start, "year"));
|
||||||
return now.diff(start, "year");
|
return now.diff(start, "year");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user