|
|
|
@ -1,8 +1,26 @@ |
|
|
|
<template> |
|
|
|
<el-dialog v-model="showDialog" :title="formData.id ? t('updateVenue') : t('addVenue')" width="50%" class="diy-dialog-wrap" :destroy-on-close="true"> |
|
|
|
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" v-loading="loading"> |
|
|
|
<el-dialog |
|
|
|
v-model="showDialog" |
|
|
|
:title="formData.id ? t('updateVenue') : t('addVenue')" |
|
|
|
width="50%" |
|
|
|
class="diy-dialog-wrap" |
|
|
|
:destroy-on-close="true" |
|
|
|
> |
|
|
|
<el-form |
|
|
|
:model="formData" |
|
|
|
label-width="120px" |
|
|
|
ref="formRef" |
|
|
|
:rules="formRules" |
|
|
|
class="page-form" |
|
|
|
v-loading="loading" |
|
|
|
> |
|
|
|
<el-form-item :label="t('campusId')" prop="campus_id"> |
|
|
|
<el-select class="input-width" v-model="formData.campus_id" clearable :placeholder="t('campusIdPlaceholder')"> |
|
|
|
<el-select |
|
|
|
class="input-width" |
|
|
|
v-model="formData.campus_id" |
|
|
|
clearable |
|
|
|
:placeholder="t('campusIdPlaceholder')" |
|
|
|
> |
|
|
|
<el-option label="请选择" value=""></el-option> |
|
|
|
<el-option |
|
|
|
v-for="(item, index) in campusIdList" |
|
|
|
@ -14,53 +32,57 @@ |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item :label="t('venueName')" prop="venue_name"> |
|
|
|
<el-input v-model="formData.venue_name" clearable :placeholder="t('venueNamePlaceholder')" class="input-width" /> |
|
|
|
<el-input |
|
|
|
v-model="formData.venue_name" |
|
|
|
clearable |
|
|
|
:placeholder="t('venueNamePlaceholder')" |
|
|
|
class="input-width" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item :label="t('capacity')" prop="capacity"> |
|
|
|
<el-input-number v-model="formData.capacity" clearable :placeholder="t('capacityPlaceholder')" class="input-width" :min = "1" max = "500" /> |
|
|
|
<el-input-number |
|
|
|
v-model="formData.capacity" |
|
|
|
clearable |
|
|
|
:placeholder="t('capacityPlaceholder')" |
|
|
|
class="input-width" |
|
|
|
:min="1" |
|
|
|
max="500" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item :label="t('availabilityStatus')" prop="availability_status"> |
|
|
|
<el-radio-group v-model="formData.availability_status" :placeholder="t('availabilityStatusPlaceholder')"> |
|
|
|
<el-radio |
|
|
|
v-for="(item, index) in availability_statusList" |
|
|
|
:key="index" :label="item.value"> |
|
|
|
{{ item.name }} |
|
|
|
</el-radio> |
|
|
|
<el-radio-group |
|
|
|
v-model="formData.availability_status" |
|
|
|
:placeholder="t('availabilityStatusPlaceholder')" |
|
|
|
> |
|
|
|
<!-- <el-radio--> |
|
|
|
<!-- v-for="(item, index) in availability_statusList"--> |
|
|
|
<!-- :key="index"--> |
|
|
|
<!-- :label="item.value"--> |
|
|
|
<!-- >--> |
|
|
|
<!-- {{ item.name }}--> |
|
|
|
<!-- </el-radio>--> |
|
|
|
<el-radio label="1">可用</el-radio> |
|
|
|
<el-radio label="2">不可用</el-radio> |
|
|
|
</el-radio-group> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item :label="t('timeRangeType')" prop="time_range_type"> |
|
|
|
<el-radio-group v-model="formData.time_range_type" :placeholder="t('timeRangeTypePlaceholder')"> |
|
|
|
<el-radio-group |
|
|
|
v-model="formData.time_range_type" |
|
|
|
:placeholder="t('timeRangeTypePlaceholder')" |
|
|
|
> |
|
|
|
<el-radio |
|
|
|
v-for="(item, index) in time_range_typeList" |
|
|
|
:key="index" :label="item.value"> |
|
|
|
:key="index" |
|
|
|
:label="item.value" |
|
|
|
> |
|
|
|
{{ item.name }} |
|
|
|
</el-radio> |
|
|
|
</el-radio-group> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item :label="t('timeRangeStart')" class="input-width"> |
|
|
|
<el-date-picker |
|
|
|
class="flex-1 !flex" |
|
|
|
v-model="formData.time_range_start" |
|
|
|
clearable |
|
|
|
type="datetime" |
|
|
|
value-format="YYYY-MM-DD HH:mm:ss" |
|
|
|
:placeholder="t('timeRangeStartPlaceholder')"> |
|
|
|
</el-date-picker> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="t('timeRangeEnd')" class="input-width"> |
|
|
|
<el-date-picker |
|
|
|
class="flex-1 !flex" |
|
|
|
v-model="formData.time_range_end" |
|
|
|
clearable |
|
|
|
type="datetime" |
|
|
|
value-format="YYYY-MM-DD HH:mm:ss" |
|
|
|
:placeholder="t('timeRangeEndPlaceholder')"> |
|
|
|
</el-date-picker> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="t('fixedTimeRanges')" class="input-width"> |
|
|
|
<el-date-picker |
|
|
|
class="flex-1 !flex" |
|
|
|
@ -68,7 +90,8 @@ |
|
|
|
clearable |
|
|
|
type="datetime" |
|
|
|
value-format="YYYY-MM-DD HH:mm:ss" |
|
|
|
:placeholder="t('fixedTimeRangesPlaceholder')"> |
|
|
|
:placeholder="t('fixedTimeRangesPlaceholder')" |
|
|
|
> |
|
|
|
</el-date-picker> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
@ -76,9 +99,12 @@ |
|
|
|
<template #footer> |
|
|
|
<span class="dialog-footer"> |
|
|
|
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
|
|
|
<el-button type="primary" :loading="loading" @click="confirm(formRef)">{{ |
|
|
|
t('confirm') |
|
|
|
}}</el-button> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
:loading="loading" |
|
|
|
@click="confirm(formRef)" |
|
|
|
>{{ t('confirm') }}</el-button |
|
|
|
> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
@ -89,7 +115,12 @@ import { ref, reactive, computed, watch } from 'vue' |
|
|
|
import { useDictionary } from '@/app/api/dict' |
|
|
|
import { t } from '@/lang' |
|
|
|
import type { FormInstance } from 'element-plus' |
|
|
|
import { addVenue, editVenue, getVenueInfo, getWithCampusList } from '@/app/api/venue' |
|
|
|
import { |
|
|
|
addVenue, |
|
|
|
editVenue, |
|
|
|
getVenueInfo, |
|
|
|
getWithCampusList, |
|
|
|
} from '@/app/api/venue' |
|
|
|
|
|
|
|
let showDialog = ref(false) |
|
|
|
const loading = ref(false) |
|
|
|
@ -104,8 +135,6 @@ const initialFormData = { |
|
|
|
capacity: '', |
|
|
|
availability_status: '', |
|
|
|
time_range_type: '', |
|
|
|
time_range_start: '', |
|
|
|
time_range_end: '', |
|
|
|
fixed_time_ranges: '', |
|
|
|
} |
|
|
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
|
|
@ -117,44 +146,43 @@ const formRules = computed(() => { |
|
|
|
return { |
|
|
|
campus_id: [ |
|
|
|
{ required: true, message: t('campusIdPlaceholder'), trigger: 'blur' }, |
|
|
|
|
|
|
|
] |
|
|
|
, |
|
|
|
], |
|
|
|
venue_name: [ |
|
|
|
{ required: true, message: t('venueNamePlaceholder'), trigger: 'blur' }, |
|
|
|
|
|
|
|
] |
|
|
|
, |
|
|
|
], |
|
|
|
capacity: [ |
|
|
|
{ required: true, message: t('capacityPlaceholder'), trigger: 'blur' }, |
|
|
|
{ validator: (rule: any, value: string, callback: any) => { if (value && !/^\d{1,500}$/.test(value)) { callback(new Error(t('generateBetween')))} else { callback() }}}, |
|
|
|
] |
|
|
|
, |
|
|
|
{ |
|
|
|
validator: (rule: any, value: string, callback: any) => { |
|
|
|
if (value && !/^\d{1,500}$/.test(value)) { |
|
|
|
callback(new Error(t('generateBetween'))) |
|
|
|
} else { |
|
|
|
callback() |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
availability_status: [ |
|
|
|
{ required: true, message: t('availabilityStatusPlaceholder'), trigger: 'blur' }, |
|
|
|
|
|
|
|
] |
|
|
|
, |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: t('availabilityStatusPlaceholder'), |
|
|
|
trigger: 'blur', |
|
|
|
}, |
|
|
|
], |
|
|
|
time_range_type: [ |
|
|
|
{ required: true, message: t('timeRangeTypePlaceholder'), trigger: 'blur' }, |
|
|
|
|
|
|
|
] |
|
|
|
, |
|
|
|
time_range_start: [ |
|
|
|
{ required: true, message: t('timeRangeStartPlaceholder'), trigger: 'blur' }, |
|
|
|
|
|
|
|
] |
|
|
|
, |
|
|
|
time_range_end: [ |
|
|
|
{ required: true, message: t('timeRangeEndPlaceholder'), trigger: 'blur' }, |
|
|
|
|
|
|
|
] |
|
|
|
, |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: t('timeRangeTypePlaceholder'), |
|
|
|
trigger: 'blur', |
|
|
|
}, |
|
|
|
], |
|
|
|
fixed_time_ranges: [ |
|
|
|
{ required: true, message: t('fixedTimeRangesPlaceholder'), trigger: 'blur' }, |
|
|
|
|
|
|
|
] |
|
|
|
, |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: t('fixedTimeRangesPlaceholder'), |
|
|
|
trigger: 'blur', |
|
|
|
}, |
|
|
|
], |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
@ -174,11 +202,13 @@ const confirm = async (formEl: FormInstance | undefined) => { |
|
|
|
|
|
|
|
let data = formData |
|
|
|
|
|
|
|
save(data).then(res => { |
|
|
|
save(data) |
|
|
|
.then((res) => { |
|
|
|
loading.value = false |
|
|
|
showDialog.value = false |
|
|
|
emit('complete') |
|
|
|
}).catch(err => { |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
loading.value = false |
|
|
|
}) |
|
|
|
} |
|
|
|
@ -188,17 +218,30 @@ const confirm = async (formEl: FormInstance | undefined) => { |
|
|
|
// 获取字典数据 |
|
|
|
let availability_statusList = ref([]) |
|
|
|
const availability_statusDictList = async () => { |
|
|
|
availability_statusList.value = await (await useDictionary('SiteStatus')).data.dictionary |
|
|
|
availability_statusList.value = await ( |
|
|
|
await useDictionary('SiteStatus') |
|
|
|
).data.dictionary |
|
|
|
} |
|
|
|
availability_statusDictList() |
|
|
|
watch( |
|
|
|
() => availability_statusList.value, |
|
|
|
() => { |
|
|
|
formData.availability_status = availability_statusList.value[0].value |
|
|
|
} |
|
|
|
availability_statusDictList(); |
|
|
|
watch(() => availability_statusList.value, () => { formData.availability_status = availability_statusList.value[0].value }) |
|
|
|
) |
|
|
|
let time_range_typeList = ref([]) |
|
|
|
const time_range_typeDictList = async () => { |
|
|
|
time_range_typeList.value = await (await useDictionary('ALLOTTED_TIME')).data.dictionary |
|
|
|
time_range_typeList.value = await ( |
|
|
|
await useDictionary('ALLOTTED_TIME') |
|
|
|
).data.dictionary |
|
|
|
} |
|
|
|
time_range_typeDictList(); |
|
|
|
watch(() => time_range_typeList.value, () => { formData.time_range_type = time_range_typeList.value[0].value }) |
|
|
|
|
|
|
|
time_range_typeDictList() |
|
|
|
watch( |
|
|
|
() => time_range_typeList.value, |
|
|
|
() => { |
|
|
|
formData.time_range_type = time_range_typeList.value[0].value |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
const campusIdList = ref([] as any[]) |
|
|
|
const setCampusIdList = async () => { |
|
|
|
@ -210,7 +253,8 @@ const setFormData = async (row: any = null) => { |
|
|
|
loading.value = true |
|
|
|
if (row) { |
|
|
|
const data = await (await getVenueInfo(row.id)).data |
|
|
|
if (data) Object.keys(formData).forEach((key: string) => { |
|
|
|
if (data) |
|
|
|
Object.keys(formData).forEach((key: string) => { |
|
|
|
if (data[key] != undefined) formData[key] = data[key] |
|
|
|
}) |
|
|
|
} |
|
|
|
@ -228,7 +272,12 @@ const mobileVerify = (rule: any, value: any, callback: any) => { |
|
|
|
|
|
|
|
// 验证身份证号 |
|
|
|
const idCardVerify = (rule: any, value: any, callback: any) => { |
|
|
|
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
|
|
|
if ( |
|
|
|
value && |
|
|
|
!/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test( |
|
|
|
value |
|
|
|
) |
|
|
|
) { |
|
|
|
callback(new Error(t('generateIdCard'))) |
|
|
|
} else { |
|
|
|
callback() |
|
|
|
@ -255,7 +304,7 @@ const numberVerify = (rule: any, value: any, callback: any) => { |
|
|
|
|
|
|
|
defineExpose({ |
|
|
|
showDialog, |
|
|
|
setFormData |
|
|
|
setFormData, |
|
|
|
}) |
|
|
|
</script> |
|
|
|
|
|
|
|
|