|
@@ -1,6 +1,12 @@
|
|
|
<template>
|
|
|
- <base-dialog title="设置工作量" :width="useVW(400)" @update:model-value="(v) => emit('update:modelValue', v)">
|
|
|
- <base-form :items="items" :model="model" :label-width="useVW(80)">
|
|
|
+ <base-dialog
|
|
|
+ title="设置工作量"
|
|
|
+ :width="useVW(500)"
|
|
|
+ :footer="false"
|
|
|
+ destroy-on-close
|
|
|
+ @update:model-value="(v) => emit('update:modelValue', v)"
|
|
|
+ >
|
|
|
+ <base-form ref="formRef" :rules="rules" :items="items" :model="model" :label-width="useVW(100)" :disabled="loading">
|
|
|
<template #form-item-markerName>
|
|
|
{{ data?.markerName }}
|
|
|
</template>
|
|
@@ -15,24 +21,36 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts" name="SetWorkload">
|
|
|
-import { reactive, ref } from 'vue'
|
|
|
-import { ElFormItem } from 'element-plus'
|
|
|
+import { reactive } from 'vue'
|
|
|
+import { ElFormItem, ElMessage } from 'element-plus'
|
|
|
import BaseDialog from '@/components/element/BaseDialog.vue'
|
|
|
import BaseForm from '@/components/element/BaseForm.vue'
|
|
|
import useForm from '@/hooks/useForm'
|
|
|
import useVW from '@/hooks/useVW'
|
|
|
+import useFetch from '@/hooks/useFetch'
|
|
|
import ConfirmButton from '@/components/common/ConfirmButton.vue'
|
|
|
|
|
|
-import type { EpFormItem } from 'global-type'
|
|
|
-import type { ExtractApiResponse } from 'api-type'
|
|
|
+import type { EpFormItem, EpFormRules } from 'global-type'
|
|
|
+import type { ExtractApiParams, ExtractApiResponse } from 'api-type'
|
|
|
|
|
|
const props = defineProps<{ data?: ExtractArrayValue<ExtractApiResponse<'getStatisticsByGroup'>> }>()
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue'])
|
|
|
|
|
|
-const { formRef } = useForm()
|
|
|
+const { fetch: markerSetCount, loading } = useFetch('markerSetCount')
|
|
|
|
|
|
-const model = reactive({})
|
|
|
+const { formRef, elFormRef } = useForm()
|
|
|
+
|
|
|
+const model = reactive<ExtractApiParams<'markerSetCount'>>({
|
|
|
+ markDayCount: void 0,
|
|
|
+ markTotalCount: void 0,
|
|
|
+ userId: [],
|
|
|
+})
|
|
|
+
|
|
|
+const rules: EpFormRules = {
|
|
|
+ markTotalCount: [{ required: true, message: '请填写评卷员工作量' }],
|
|
|
+ markDayCount: [{ required: true, message: '请填写评卷员每日工作量' }],
|
|
|
+}
|
|
|
|
|
|
const items: EpFormItem[] = [
|
|
|
{
|
|
@@ -42,19 +60,32 @@ const items: EpFormItem[] = [
|
|
|
{
|
|
|
label: '工作量',
|
|
|
slotType: 'input',
|
|
|
+ prop: 'markTotalCount',
|
|
|
},
|
|
|
{
|
|
|
label: '每日工作量',
|
|
|
slotType: 'input',
|
|
|
+ prop: 'markDayCount',
|
|
|
},
|
|
|
]
|
|
|
|
|
|
-function onConfirm() {
|
|
|
- console.log('onConfirm', props.data)
|
|
|
+const onConfirm = async () => {
|
|
|
+ try {
|
|
|
+ if (!props.data?.markerId) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const valid = await elFormRef?.value?.validate()
|
|
|
+ if (valid) {
|
|
|
+ await markerSetCount({ ...model, userId: [props.data.markerId] })
|
|
|
+ }
|
|
|
+ ElMessage.success('设置成功')
|
|
|
+ emit('update:modelValue', false)
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-function onCancel() {
|
|
|
- console.log('onCancel')
|
|
|
+const onCancel = () => {
|
|
|
emit('update:modelValue', false)
|
|
|
}
|
|
|
</script>
|