<template>
    <tr 
     :key="obj.name" 
     class="cursor-move" 
     :style="{
        height: '40px',
        background:isEven(index)?'#fff':'#f3f3f3'
      }"
    >
        <td>{{ obj.code }}{{ obj.sort}}</td>
        <td>{{ obj.name }}</td>
        <td>{{ obj.orderItemName }}</td>
        <td>
        <n-date-picker 
            v-model:value="beginTime" 
            type="datetime"
            placeholder="请选择开始时间"
            @update:value="updatehand"
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 100%;" 
        />
        </td>
        <td>
            
        <n-date-picker 
            v-model:value="endTime" 
            type="datetime"
            placeholder="请选择结束时间"
            @update:value="updatehand"
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 100%;"  
        />
        </td>
    </tr>
</template>
<script setup lang="ts">
    import { ref } from 'vue'
    import { getaDtetime } from '@/utils/tool'
    const props = withDefaults(defineProps<{
        obj:any,
        index:any
    }>(), {
        obj:{}
    })

    const emit = defineEmits<{
        update: [index:any,obj:any]
    }>()

    let beginTime = ref<any>(null)
    let endTime = ref<any>(null)

    function isEven(num:any) {
        return num % 2 == 0
    }

    function updatehand() {
        emit('update',props.index,Object.assign(props.obj,{
            beginTime:beginTime.value?getaDtetime(beginTime.value):null,
            endTime:endTime.value?getaDtetime(endTime.value):null
        }))
    }
</script>