<style lang="less">
    .operate{
        >table{
            background:#E6F0FE;
            width:calc(100% - 20px);
            margin:10px;
            border-radius: 7px;
            text-align: center;
            tr:first-child{
                font-size: 13px;
                >td{
                    height:30px;
                }
            }
            tr:not(:first-child){
                >td{
                    padding-bottom:18px;
                    >div{
                        height: 45px;
                        background: #fff;
                        padding: 6px 0;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                    }
                    &:first-child{
                        >div{
                            border-left: 3px solid #8D90FF;
                            color:#5E9AFE;
                        }
                    }
                    &:last-child{
                        >div{
                            color:#42A071;
                        }
                    }
                }
            }
            tr:last-child>td{ padding-bottom:30px; }
        }
    }
</style>
<template>
    <div class="operate" :style="list.length==0&&'background:#fff;height:100%;'">
        <table cellspacing="0" v-if="list.length>0">
            <tr>
                <td></td>
                <td>米数</td>
                <td>匹数</td>
                <td>金额</td>
            </tr>
            <tr v-for="(v,i) in list" :key="i">
                <td>
                    <div @click="routerToOperateDetail(v)" style="text-decoration:underline;">{{v.sType}}</div>
                </td>
                <td>
                    <div>{{Number(v.nQty||0).toLocaleString()}}</div>
                </td>
                <td>
                    <div>{{Number(v.nPieces||0).toLocaleString()}}</div>
                </td>
                <td>
                    <div>{{ v.sType == '收货' || v.sType == '检验' || v.sType == '成品入库' ? '' : Number(v.nAmount||0).toLocaleString()}}</div>
                </td>
            </tr>
        </table>
        <img src="@/assets/noData.jpg" style="width:100%;" v-else/>
    </div>
</template>
<script>
import util from "@/libs/util.js"
export default {
    name:"operate",
    props:{
        start:Date,
        end:Date,
    },
    data(){
        return{
            list:[],
        }
    },
    watch:{
        start(n){
            this.search()
        },
        end(n){
            this.search()
        },
    },
    created(){
        this.$nextTick(()=>{
            this.search()
        })
    },
    methods:{
        async search(){
            var value= await this.request('getBoss',{
                data:[
                    {key:"url",value:"Operation gai"},
                    {key:"begin_date",value:util.dateFormat(this.start,"yyyy-MM-dd")},
                    {key:"end_date",value:(this.end?util.dateFormat(this.end,"yyyy-MM-dd"):util.dateFormat(new Date,"yyyy-MM-dd"))+' 23:59'}
                ],
                params:{},
            },true,{})
            if(typeof value=='object'&&value.length>0){
                this.list=value
            }else{
                this.list=[]
            }
        },
        routerToOperateDetail(row){
            let data = util.deepClone(row);
            data.begin_date = util.dateFormat(this.start,"yyyy-MM-dd");
            data.end_date = (this.end?util.dateFormat(this.end,"yyyy-MM-dd"):util.dateFormat(new Date,"yyyy-MM-dd"))+' 23:59';
            this.$store.dispatch('saveKanbanHdr',data);
            this.$store.dispatch('saveRefresh',true);
            this.$router.push({name:'tiipOperateDetail',type:row.sType})
        }
    },
}
</script>
