|
|
@ -5,61 +5,36 @@
|
|
|
|
-->
|
|
|
|
-->
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<div></div>
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<!-- 主单信息组件 -->
|
|
|
|
|
|
|
|
<MainInfo :data="details"></MainInfo>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div></div>
|
|
|
|
<div></div>
|
|
|
|
<div></div>
|
|
|
|
<div></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineComponent, ref, watchEffect, computed, unref } from 'vue'
|
|
|
|
import { defineProps, ref, watch, computed, unref } from 'vue'
|
|
|
|
const props = {
|
|
|
|
// 主单信息组件
|
|
|
|
value: { type: [Object, Number, String, Array] },
|
|
|
|
import MainInfo from './mainInfo.vue'
|
|
|
|
count: { type: Number, default: 60 },
|
|
|
|
defineProps({
|
|
|
|
beforeStartFunc: {
|
|
|
|
details: { type: [Object, Array] }
|
|
|
|
type: Function as PropType<() => Promise<boolean>>,
|
|
|
|
|
|
|
|
default: null,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
|
|
|
name: 'CostEntry',
|
|
|
|
|
|
|
|
components: { Button },
|
|
|
|
|
|
|
|
props,
|
|
|
|
|
|
|
|
setup(props) {
|
|
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { currentCount, isStart, start, reset } = useCountdown(props.count)
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getButtonText = computed(() => {
|
|
|
|
|
|
|
|
return !unref(isStart)
|
|
|
|
|
|
|
|
? t('component.countdown.normalText')
|
|
|
|
|
|
|
|
: t('component.countdown.sendText', [unref(currentCount)])
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
|
|
|
|
props.value === undefined && reset()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @description: Judge whether there is an external function before execution, and decide whether to start after execution
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
async function handleStart() {
|
|
|
|
|
|
|
|
const { beforeStartFunc } = props
|
|
|
|
|
|
|
|
if (beforeStartFunc && isFunction(beforeStartFunc)) {
|
|
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const canStart = await beforeStartFunc()
|
|
|
|
|
|
|
|
canStart && start()
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
start()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return { handleStart, currentCount, loading, getButtonText, isStart }
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// watch(
|
|
|
|
|
|
|
|
// () => props.details,
|
|
|
|
|
|
|
|
// (nval, oval) => {
|
|
|
|
|
|
|
|
// console.log(nval, 222222)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
// export default defineComponent({
|
|
|
|
|
|
|
|
// name: 'CostEntry',
|
|
|
|
|
|
|
|
// props,
|
|
|
|
|
|
|
|
// setup(props) {
|
|
|
|
|
|
|
|
// console.log(props, 222)
|
|
|
|
|
|
|
|
// watchEffect(() => {
|
|
|
|
|
|
|
|
// console.log(props.details)
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|