<template>
  <zj-page-container>
    <zj-page-fill class="neibuview">
      <zj-form-container>
        <zj-form-module title="操作明细">
          <zj-table :columns="operationDetailColumns" :tableData="logList" :tableAttributes="{
            border: true
          }"></zj-table>
        </zj-form-module>
      </zj-form-container>
    </zj-page-fill>
  </zj-page-container>
</template>

<script>
import { orderBaseLogList } from "@/api/workOrderPool.js"
import ImageUpload from '@/components/file-upload'
export default {
  props: {
    id: {
      type: [String, Number],
      default: null,
    }
  },
  components: {
    ImageUpload
  },
  data() {
    return {
      logList: []
    }
  },
  watch: {
    id: {
      handler(newVal, oldVal) {
        this.getOrderBaseLogList()
      },
      deep: true,
      immediate: true,
    },
  },
  computed: {
    operationDetailColumns() {
      return [
        {
          columnAttributes: {
            label: '操作类别',
            prop: 'type',
            width: 140
          }
        },
        {
          columnAttributes: {
            label: '操作内容',
            prop: 'content',
          }
        },
        {
          columnAttributes: {
            label: '附件',
            prop: 'imgSrc',
            width: 310
          },
          render: (h, { row, column, index }) => {
            return <div style="padding: 0 10px">
              <ImageUpload fileList={row.imgSrc ? row.imgSrc.split(",").map(url => ({ url })) : []} limit={100} isEdit={false} />
            </div>
          }
        },
        {
          columnAttributes: {
            label: '操作时间',
            prop: 'createTime',
            width: 140
          }
        },
        {
          columnAttributes: {
            label: '操作人',
            prop: 'createBy',
            width: 140
          }
        }
      ]
    }
  },
  methods: {
    // 获取操作记录
    getOrderBaseLogList() {
      if (this.id) {
        orderBaseLogList({
          orderBaseId: this.id
        }).then(res => {
          this.logList = res.data
        })
      }
    },
  }
}
</script>

<style lang="scss" scoped>
.neibuview {
  box-sizing: border-box;
  padding-left: 16px;

  ::v-deep &>.zj-page-fill-scroll {
    box-sizing: border-box;
    padding-right: 16px;

    &>div:nth-child(1) {
      margin-top: 20px;
    }
  }
}
</style>
