import OSticky from '@/components/o-sticky' import { configUnit } from '@/constant' import request from '@/helpers/request' import { verifiyNumberInteger } from '@/helpers/toolsValidate' import { Button, Cell, CellGroup, Field, Popover, showToast } from 'vant' import { defineComponent, onMounted, reactive, shallowRef, Teleport } from 'vue' import styles from '../index.module.less' export const actions = [ { text: '元', value: 'MONEY' }, { text: '%', value: 'PERCENTAGE' } ] export default defineComponent({ name: 'range-model', setup() { const statusList = reactive({ show1: false, show2: false }) const beforeData: any = shallowRef({}) // 储存原始数据 const forms = reactive({} as any) const getDetails = async () => { try { const { data } = await request.get('/api-school/schoolParamConfig/queryByParamNameList', { params: { // schoolId: '', paramNames: 'scope_of_attendance,sign_in_attendance,sign_in_attendance_type,sign_out_attendance,sign_out_attendance_type' } }) console.log(data, 'data') const rows = data || [] rows.forEach((row: any) => { forms[row.paramName] = row.paramValue }) beforeData.value = { ...forms } } catch { // } } // 数组进行对比 const dataCompare = (beforeData: any, afterData: any) => { const changeDate: any = [] for (const key in beforeData) { if (beforeData[key] != afterData[key]) { changeDate.push({ paramName: key, paramValue: afterData[key] }) } } return changeDate || [] } // 修改 const onSubmit = async () => { if (!forms['scope_of_attendance']) { showToast('请输入考勤定位范围') return } if (!forms['sign_in_attendance']) { showToast('请输入签到扣减金额') return } if (forms['sign_in_attendance'] > 100 && forms['sign_in_attendance_type'] === 'PERCENTAGE') { showToast('签到扣减金额输入有误') return } if (!forms['sign_out_attendance']) { showToast('请输入签退扣减金额') return } if ( forms['sign_out_attendance'] > 100 && forms['sign_out_attendance_type'] === 'PERCENTAGE' ) { showToast('签退扣减金额输入有误') return } try { const submitData = dataCompare(beforeData.value, forms) if (submitData.length > 0) { await request.post('/api-school/schoolParamConfig/update', { hideLoading: false, data: { configs: [...submitData], group: 'ATTENDANCE' } }) } setTimeout(() => { showToast('保存成功') }, 200) } catch { // } } onMounted(() => { getDetails() }) const onFormatterInt = (val: any) => { if (val && val >= 0) { return verifiyNumberInteger(val) } else { return '' } } return () => (
{{ title: () =>
考勤定位范围
}}
{{ title: () => (
签到、签退地点须在学校定位点 {{ extra: () => }} 以内
) }}
{{ title: () => (
签到地点在考勤定位范围之外时,扣减当日训练补助
) }}
{{ title: () => (
单次扣减金额: {{ extra: () => ( { forms['sign_in_attendance_type'] = val.value }} > {{ reference: () => (
{configUnit[forms['sign_in_attendance_type']]}
) }}
) }}
) }}
{{ title: () => (
签退地点在考勤定位范围之外时,扣减当日训练补助
) }}
{{ title: () => (
单次扣减金额: {{ extra: () => ( { forms['sign_out_attendance_type'] = val.value }} > {{ reference: () => (
{configUnit[forms['sign_out_attendance_type']]}
) }}
) }}
) }}
) } })