<template>
  <div>
    <xy-dialog ref="dialog" height="90%" :is-show.sync="isShow" type="form" :title="typeName" :form="form">
      <template v-slot:logotable>
        <xy-table :list="list" :total="total" stripe
          @pageSizeChange="e => {select.page_size = e,getList()}" @pageIndexChange="e => {select.page = e,getList()}"
          :table-item="table">
          <template v-slot:btns>
            <div></div>
            <!-- <el-table-column align='center' label="操作" width="200" header-align="center">
              <template slot-scope="scope">
                <div>
                  <Button type="primary" style='margin-right:5px;margin-bottom:5px;' size="small"
                    @click="editUnit(scope.row,1)">发布任务</Button>
                </div>
                <div>
                  <Button type="primary" style='margin-right:5px;margin-bottom:5px;' size="small"
                    @click="editorPlan(scope.row.id,'editor')">编辑计划</Button>
                </div>
              </template>
            </el-table-column> -->
          </template>
        </xy-table>
      </template>
      <template v-slot:footerContent>
        <Button type="primary" ghost style='margin-left:5px;margin-bottom:5px;' @click="isShow = false">关闭</Button>

      </template>
    </xy-dialog>




  </div>
</template>

<script>
  import {
    save,
    index
  } from "@/api/system/baseForm.js";

  export default {
    // mixins:[mixins],
    components: {

    },
    data() {
      return {
        isShow: false,
        type: 'add',
        typeName: '日志',
        id: '',
        select:{
          page:1,
          page_size:10,
          with_relations: ['admin']
        },
        form:{logotable:''},
        list:[],
        total:0,
        table: [{
            label: "操作人",
            prop: 'admin.name',
            align: 'center',
            width: 120
          },
          {
            label: "操作",
            prop: 'op_name',
            align: 'left',
          },
          {
            label: "操作时间",
            prop: 'created_at',
            align: 'center',
            width: 180
          }
        ],
      }
    },
    created() {

    },
    methods: {
      getList() {
        index({
          table_name: 'missions_logs',
          page:this.select.page,
          page_size:this.select.page_size,
          with_relations:this.select.with_relations,
          filter: [{
            "key": "mission_id",
            "op": "eq",
            "value": this.id
          }],
        }).then(res => {
          this.list = res.data
          this.total = res.total
        })
      },
    },
    watch: {

      isShow(newVal) {
        if (newVal) {
          if(this.id){
            this.getList()
          }
        } else {
          this.id = ''
          this.$refs['dialog'].reset()
        }
      },
    }

  }
</script>

<style scoped lang="scss">
  ::v-deep .logotable{
    flex-basis: 100%;
  }
  ::v-deep .xy-table__page{
    align-items: center;
  }
  ::v-deep .xy-table__setting{
    bottom:13px;
  }
</style>
