<template>
    <el-dialog title="详情" width="80%" :visible.sync="dialogVisible" @close="dialogVisible = false">
        <div class="head-container">
            <span>【退货出库】</span>
        </div>
        <div class="head-container">
            <el-table :data="tableData.detail.stockSnap" v-loading="tableData.loading" height="400px">
                <el-table-column :label="`商品名称${tableData.detail.stockSnap.length}`" prop="name"></el-table-column>
                <el-table-column label="变动数量" prop="number">
                    <template v-slot="scope">
                        {{ scope.row.number }}{{ scope.row.unitName }}
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div class="head-container">
            <div class="row">备注：{{ tableData.detail.remark }}</div>
            <div class="row">操作人：{{ tableData.detail.operatorSnap.name }}</div>
            <div class="row">创建时间：{{ tableData.detail.createdAt }}</div>
        </div>
    </el-dialog>
</template>

<script>
import dayjs from 'dayjs'
import { tbProductStockOperateDetail } from '@/api/invoicing'
export default {
    data() {
        return {
            dayjs,
            dialogVisible: false,
            tableData: {
                loading: false,
                detail: {
                    stockSnap: [],
                    operatorSnap: {
                        name: ''
                    }
                }
            }
        }
    },
    methods: {
        show(id) {
            this.dialogVisible = true
            this.getTableData(id)
        },
        async getTableData(id) {
            this.tableData.loading = true
            try {
                const res = await tbProductStockOperateDetail(id)
                this.tableData.loading = false
                this.tableData.detail = res
            } catch (error) {
                console.log(error);
            }
        }
    }
}
</script>

<style scoped lang="scss">
.row {
    padding-bottom: 10px;
}
</style>