<template>
  <div>
    <Modal :width="60" title="订单日志" :value.sync="isShow" @on-visible-change="$emit('update:isShow',$event)">
      <xy-table :is-page="false" :list="list" :table-item="table" :height="300">
        <template v-slot:btns>
          <div></div>
        </template>
      </xy-table>
    </Modal>
  </div>
</template>

<script>
import {getItemLogs} from "@/api/order"
import {parseTime} from '@/utils'

export default {
  props:{
    id:Number,
    isShow:{
      type:Boolean,
      default:false
    }
  },
  data() {
    return {
      list:[],
      table:[
        {
          label:'用户',
          prop:'operator.name',
          width: 120
        },
        {
          label:'时间',
          prop:'created_at',
          width: 160,
          formatter:(cell,data,value) => {
            return parseTime(new Date(value),'{y}-{m}-{d}')
          }
        },
        {
          label:'操作',
          prop:'operate_name',
          width: 120
        },
        {
          label:'备注',
          prop:'remark',
          align:'left',
          sortable:false
        }
      ],
    }
  },
  methods: {
    async getLog(){
      const res = await getItemLogs({
        item_id:this.id
      })
      this.list = res.data
    }
  },
  watch:{
    isShow(newVal){
      if(newVal){
        this.getLog()
      }
    }
  }

}
</script>

<style scoped lang="scss">
</style>
