11
This commit is contained in:
1 parent
c809bdb7e7
commit
08f68cd89b
2 files changed
+219
-105
No files matched your search
+114
-105
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import { ref, reactive } from "vue"
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app"
|
||||
import { isEmpty } from "radash"
|
||||
import dayjs from "dayjs"
|
||||
|
||||
@@ -8,129 +8,138 @@ import { hooks, router } from "@@/index"
|
||||
import { applyApi } from "@@/api"
|
||||
|
||||
const state = reactive<any>({
|
||||
detailType: "add",
|
||||
detailId: null,
|
||||
detail: null,
|
||||
detailType: "add",
|
||||
detailId: null,
|
||||
detail: null,
|
||||
})
|
||||
const applyForm = reactive<any>({
|
||||
displayTimeRange: "",
|
||||
displayTimeRangeStr: "",
|
||||
count: 1,
|
||||
remark: "",
|
||||
displayTimeRange: "",
|
||||
displayTimeRangeStr: "",
|
||||
count: 1,
|
||||
remark: "",
|
||||
})
|
||||
const applyFormRules = reactive<any>({
|
||||
displayTimeRangeStr: [
|
||||
{ required: true, message: '请选择使用时间' }
|
||||
],
|
||||
count: [
|
||||
{ required: true, message: '请输入申请数量' },
|
||||
{ required: true, min: 1, message: '最少申请1张' },
|
||||
{ required: true, max: 20, message: '最多申请20张' },
|
||||
]
|
||||
displayTimeRangeStr: [{ required: true, message: "请选择使用时间" }],
|
||||
count: [
|
||||
{ required: true, message: "请输入申请数量" },
|
||||
{ required: true, min: 1, message: "最少申请1张" },
|
||||
{ required: true, max: 20, message: "最多申请20张" },
|
||||
],
|
||||
})
|
||||
|
||||
onLoad((options: any) => {
|
||||
const { type, id } = options
|
||||
if (!isEmpty(type)) state.detailType = type
|
||||
if (!isEmpty(id)) state.detailId = id
|
||||
if (type === 'view') {
|
||||
getDetail()
|
||||
}
|
||||
});
|
||||
onShow(() => {
|
||||
|
||||
const { type, id } = options
|
||||
if (!isEmpty(type)) state.detailType = type
|
||||
if (!isEmpty(id)) state.detailId = id
|
||||
if (type === "view") {
|
||||
getDetail()
|
||||
}
|
||||
})
|
||||
onShow(() => {})
|
||||
|
||||
const getDetail = async () => {
|
||||
if (isEmpty(state.detailId)) return
|
||||
const _pa = { id: state.detailId }
|
||||
const { data } = await applyApi.foreignDetail(_pa)
|
||||
if (!isEmpty(data)) {
|
||||
state.detail = data
|
||||
const startTime = hooks.useTime(data.applyStartTime, "{y}-{m}-{d}")
|
||||
const endTime = hooks.useTime(data.applyEndTime, "{y}-{m}-{d}")
|
||||
applyForm.displayTimeRangeStr = startTime + "~" + endTime
|
||||
applyForm.count = data.count
|
||||
if (isEmpty(data.remark)) {
|
||||
applyForm.remark = "无"
|
||||
} else {
|
||||
applyForm.remark = data.remark
|
||||
}
|
||||
}
|
||||
if (isEmpty(state.detailId)) return
|
||||
const _pa = { id: state.detailId }
|
||||
const { data } = await applyApi.foreignDetail(_pa)
|
||||
if (!isEmpty(data)) {
|
||||
state.detail = data
|
||||
const startTime = hooks.useTime(data.applyStartTime, "{y}-{m}-{d}")
|
||||
const endTime = hooks.useTime(data.applyEndTime, "{y}-{m}-{d}")
|
||||
applyForm.displayTimeRangeStr = startTime + "~" + endTime
|
||||
applyForm.count = data.count
|
||||
if (isEmpty(data.remark)) {
|
||||
applyForm.remark = "无"
|
||||
} else {
|
||||
applyForm.remark = data.remark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const applyFormRef = ref<any>(null)
|
||||
const doSubmit = async () => {
|
||||
applyFormRef.value.submit()
|
||||
const { isPass } = applyFormRef.value.validate()
|
||||
if (!isPass) return
|
||||
const range = applyForm.displayTimeRange
|
||||
console.log(range);
|
||||
try {
|
||||
uni.showLoading({ title: '申请中...', mask: false });
|
||||
const _pa = {
|
||||
applyStartTime: hooks.useTime(range[0], "{y}-{m}-{d}"),
|
||||
applyEndTime: hooks.useTime(range[1], "{y}-{m}-{d}"),
|
||||
count: applyForm.count,
|
||||
remark: applyForm.remark,
|
||||
}
|
||||
const { data, code }: any = await applyApi.foreignApply(_pa)
|
||||
if (code != 0) throw new Error()
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '申请成功', icon: "none" });
|
||||
router.back()
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
uni.hideLoading()
|
||||
}
|
||||
applyFormRef.value.submit()
|
||||
const { isPass } = applyFormRef.value.validate()
|
||||
if (!isPass) return
|
||||
const range = applyForm.displayTimeRange
|
||||
console.log(range)
|
||||
try {
|
||||
uni.showLoading({ title: "申请中...", mask: false })
|
||||
const _pa = {
|
||||
applyStartTime: hooks.useTime(range[0], "{y}-{m}-{d}"),
|
||||
applyEndTime: hooks.useTime(range[1], "{y}-{m}-{d}"),
|
||||
count: applyForm.count,
|
||||
remark: applyForm.remark,
|
||||
}
|
||||
const { data, code }: any = await applyApi.foreignApply(_pa)
|
||||
if (code != 0) throw new Error()
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "申请成功", icon: "none" })
|
||||
router.back()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
|
||||
<view class="h-30rpx" />
|
||||
<view class="card p-x-30rpx p-y-40rpx">
|
||||
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
|
||||
<tm-form-item name="displayTimeRangeStr" label="使用时间" :showBottom="false">
|
||||
<tm-between-time start="2020-1-1" end="2030-1-1" v-model="applyForm.displayTimeRange"
|
||||
v-model:model-str="applyForm.displayTimeRangeStr" format="YYYY-MM-DD">
|
||||
<view :style="{ pointerEvents: state.detailType == 'view' ? 'auto' : 'none' }">
|
||||
<tm-input v-model="applyForm.displayTimeRangeStr" disabled placeholder="请选择使用时间..">
|
||||
<template v-slot:rightIcon>
|
||||
<text v-if="state.detailType != 'view'"
|
||||
class="p-0.5rem color-#b1b1b1 iconfont icon-xiangxiajiantouxiao"></text>
|
||||
</template>
|
||||
</tm-input>
|
||||
</view>
|
||||
</tm-between-time>
|
||||
</tm-form-item>
|
||||
<view class="h-30rpx" />
|
||||
<tm-form-item name="count" label="申请数量" :showBottom="false">
|
||||
<tm-input v-model="applyForm.count" type="number" :disabled="state.detailType == 'view'"
|
||||
:showClear="state.detailType != 'view'" placeholder="请输入申请数量.." />
|
||||
</tm-form-item>
|
||||
<view class="h-30rpx" />
|
||||
<tm-form-item name="remark" label="备注" :required="false" :showBottom="false">
|
||||
<tm-input v-model="applyForm.remark" type="textarea" :disabled="state.detailType == 'view'"
|
||||
:showClear="state.detailType != 'view'"
|
||||
:placeholder="state.detailType == 'view' ? '' : '请输入备注..'"></tm-input>
|
||||
</tm-form-item>
|
||||
</tm-form>
|
||||
</view>
|
||||
<view v-if="state.detailType != 'view'"
|
||||
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
|
||||
@tap="doSubmit">
|
||||
提交
|
||||
</view>
|
||||
</crud-layout>
|
||||
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
|
||||
<view class="h-30rpx" />
|
||||
<view class="card p-x-30rpx p-y-40rpx">
|
||||
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
|
||||
<tm-form-item name="displayTimeRangeStr" label="使用时间" :showBottom="false">
|
||||
<tm-between-time
|
||||
start="2020-1-1"
|
||||
end="2030-1-1"
|
||||
v-model="applyForm.displayTimeRange"
|
||||
v-model:model-str="applyForm.displayTimeRangeStr"
|
||||
format="YYYY-MM-DD"
|
||||
>
|
||||
<view :style="{ pointerEvents: state.detailType == 'view' ? 'auto' : 'none' }">
|
||||
<tm-input v-model="applyForm.displayTimeRangeStr" disabled placeholder="请选择使用时间..">
|
||||
<template v-slot:rightIcon>
|
||||
<text v-if="state.detailType != 'view'" class="p-0.5rem color-#b1b1b1 iconfont icon-xiangxiajiantouxiao"></text>
|
||||
</template>
|
||||
</tm-input>
|
||||
</view>
|
||||
</tm-between-time>
|
||||
</tm-form-item>
|
||||
<view class="h-30rpx" />
|
||||
<tm-form-item name="count" label="申请数量" :showBottom="false">
|
||||
<tm-input
|
||||
v-model="applyForm.count"
|
||||
type="number"
|
||||
:disabled="state.detailType == 'view'"
|
||||
:showClear="state.detailType != 'view'"
|
||||
placeholder="请输入申请数量.."
|
||||
/>
|
||||
</tm-form-item>
|
||||
<view class="h-30rpx" />
|
||||
<tm-form-item name="remark" label="备注" :required="false" :showBottom="false">
|
||||
<tm-input
|
||||
v-model="applyForm.remark"
|
||||
type="textarea"
|
||||
:disabled="state.detailType == 'view'"
|
||||
:showClear="state.detailType != 'view'"
|
||||
:placeholder="state.detailType == 'view' ? '' : '请输入备注..'"
|
||||
></tm-input>
|
||||
</tm-form-item>
|
||||
</tm-form>
|
||||
</view>
|
||||
<view
|
||||
v-if="state.detailType != 'view'"
|
||||
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
|
||||
@tap="doSubmit"
|
||||
>
|
||||
提交
|
||||
</view>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep() {
|
||||
.tmFormItemLabel {
|
||||
padding-bottom: 10rpx !important;
|
||||
}
|
||||
.tmFormItemLabel {
|
||||
padding-bottom: 10rpx !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in new issue
Block a user