|
@@ -1,14 +1,104 @@
|
|
import OSticky from '@/components/o-sticky'
|
|
import OSticky from '@/components/o-sticky'
|
|
-import { Button, Cell, CellGroup, Field, Popover } from 'vant'
|
|
|
|
-import { defineComponent, reactive, Teleport } from 'vue'
|
|
|
|
|
|
+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'
|
|
import styles from '../index.module.less'
|
|
|
|
|
|
|
|
+export const actions = [
|
|
|
|
+ {
|
|
|
|
+ text: '元',
|
|
|
|
+ value: 'MONEY'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ text: '%',
|
|
|
|
+ value: 'PERCENTAGE'
|
|
|
|
+ }
|
|
|
|
+]
|
|
|
|
+
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
name: 'range-model',
|
|
name: 'range-model',
|
|
setup() {
|
|
setup() {
|
|
- const forms = reactive({
|
|
|
|
- show1: false
|
|
|
|
|
|
+ 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 () => {
|
|
|
|
+ // formsRef.value.validate(async (errors: any) => {
|
|
|
|
+ // if (errors) return
|
|
|
|
+
|
|
|
|
+ // const submitData = dataCompare(beforeData.value, forms)
|
|
|
|
+ // if (submitData && submitData.length > 0) {
|
|
|
|
+ // btnLoading.value = true
|
|
|
|
+ // try {
|
|
|
|
+ // await sysParamConfigUpdate({ configs: [...submitData], group: 'ATTENDANCE' })
|
|
|
|
+ // beforeData.value = { ...forms }
|
|
|
|
+ // } catch {}
|
|
|
|
+ // btnLoading.value = false
|
|
|
|
+ // } else {
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ try {
|
|
|
|
+ const submitData = dataCompare(beforeData.value, forms)
|
|
|
|
+ await request.post('/api-school/schoolParamConfig/update', {
|
|
|
|
+ data: [...submitData]
|
|
|
|
+ })
|
|
|
|
+ showToast('保存成功')
|
|
|
|
+ } catch {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ onMounted(() => {
|
|
|
|
+ getDetails()
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+ const onFormatterInt = (val: any) => {
|
|
|
|
+ if (val && val >= 1) {
|
|
|
|
+ return verifiyNumberInteger(val)
|
|
|
|
+ } else {
|
|
|
|
+ return ''
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return () => (
|
|
return () => (
|
|
<div class={styles.ruleContainer}>
|
|
<div class={styles.ruleContainer}>
|
|
<CellGroup inset>
|
|
<CellGroup inset>
|
|
@@ -21,6 +111,9 @@ export default defineComponent({
|
|
<Field
|
|
<Field
|
|
class={[styles.field, styles['field-m'], styles['field-w80']]}
|
|
class={[styles.field, styles['field-m'], styles['field-w80']]}
|
|
autocomplete="off"
|
|
autocomplete="off"
|
|
|
|
+ formatter={onFormatterInt}
|
|
|
|
+ type="number"
|
|
|
|
+ v-model={forms['scope_of_attendance']}
|
|
>
|
|
>
|
|
{{ extra: () => <span>米</span> }}
|
|
{{ extra: () => <span>米</span> }}
|
|
</Field>
|
|
</Field>
|
|
@@ -48,23 +141,29 @@ export default defineComponent({
|
|
<Field
|
|
<Field
|
|
class={[styles.field, styles['field-m'], styles['field-w136']]}
|
|
class={[styles.field, styles['field-m'], styles['field-w136']]}
|
|
autocomplete="off"
|
|
autocomplete="off"
|
|
|
|
+ formatter={(val: string) => {
|
|
|
|
+ return onFormatterInt(val, 'sign_in_attendance_type')
|
|
|
|
+ }}
|
|
|
|
+ type="number"
|
|
|
|
+ v-model={forms['sign_in_attendance']}
|
|
>
|
|
>
|
|
{{
|
|
{{
|
|
extra: () => (
|
|
extra: () => (
|
|
<Popover
|
|
<Popover
|
|
- v-model:show={forms.show1}
|
|
|
|
- actions={[
|
|
|
|
- {
|
|
|
|
- text: '元',
|
|
|
|
- value: 'MONEY'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- text: '%',
|
|
|
|
- value: 'PERCENTAGE'
|
|
|
|
- }
|
|
|
|
- ]}
|
|
|
|
|
|
+ v-model:show={statusList.show1}
|
|
|
|
+ class={styles.popover}
|
|
|
|
+ actions={actions}
|
|
|
|
+ onSelect={(val: any) => {
|
|
|
|
+ forms['sign_in_attendance_type'] = val.value
|
|
|
|
+ }}
|
|
>
|
|
>
|
|
- {{ reference: () => <span class={[styles.unit]}>元</span> }}
|
|
|
|
|
|
+ {{
|
|
|
|
+ reference: () => (
|
|
|
|
+ <div class={[styles.unit, statusList.show1 && styles.active]}>
|
|
|
|
+ {configUnit[forms['sign_in_attendance_type']]}
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+ }}
|
|
</Popover>
|
|
</Popover>
|
|
)
|
|
)
|
|
}}
|
|
}}
|
|
@@ -85,13 +184,49 @@ export default defineComponent({
|
|
)
|
|
)
|
|
}}
|
|
}}
|
|
</Cell>
|
|
</Cell>
|
|
- <Cell></Cell>
|
|
|
|
|
|
+ <Cell>
|
|
|
|
+ {{
|
|
|
|
+ title: () => (
|
|
|
|
+ <div class={[styles.ruleContent, styles.ruleMore]}>
|
|
|
|
+ 单次扣减金额:
|
|
|
|
+ <Field
|
|
|
|
+ class={[styles.field, styles['field-m'], styles['field-w136']]}
|
|
|
|
+ autocomplete="off"
|
|
|
|
+ formatter={onFormatterInt}
|
|
|
|
+ type="number"
|
|
|
|
+ v-model={forms['sign_out_attendance']}
|
|
|
|
+ >
|
|
|
|
+ {{
|
|
|
|
+ extra: () => (
|
|
|
|
+ <Popover
|
|
|
|
+ v-model:show={statusList.show2}
|
|
|
|
+ class={styles.popover}
|
|
|
|
+ actions={actions}
|
|
|
|
+ onSelect={(val: any) => {
|
|
|
|
+ forms['sign_in_attendance_type'] = val.value
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ {{
|
|
|
|
+ reference: () => (
|
|
|
|
+ <div class={[styles.unit, statusList.show2 && styles.active]}>
|
|
|
|
+ {configUnit[forms['sign_out_attendance_type']]}
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+ }}
|
|
|
|
+ </Popover>
|
|
|
|
+ )
|
|
|
|
+ }}
|
|
|
|
+ </Field>
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+ }}
|
|
|
|
+ </Cell>
|
|
</CellGroup>
|
|
</CellGroup>
|
|
|
|
|
|
<Teleport to={'#app'}>
|
|
<Teleport to={'#app'}>
|
|
<OSticky position="bottom">
|
|
<OSticky position="bottom">
|
|
<div class={'btnGroup'}>
|
|
<div class={'btnGroup'}>
|
|
- <Button type="primary" round block>
|
|
|
|
|
|
+ <Button type="primary" round block onClick={onSubmit}>
|
|
保存设置
|
|
保存设置
|
|
</Button>
|
|
</Button>
|
|
</div>
|
|
</div>
|