<template>
  <app-dialog v-model="visible" :fullscreen="true" :hide-footer="true" :loading="loading" :title="title" append-to-body class="detail-dialog" width="800px">
    <div class="pa-11 bg-white h-95 flex-col mt-11 border-radius-5">
      <app-table
        :column="columns"
        :pagination="pagination"
        :table-data="tableData"
        :table-loading="tableLoading"
        :total="total"
        @pagination-change="onPaginationChange"
      />
    </div>
  </app-dialog>
</template>

<script>
import tableMixin from '@/mixins/table.js'; // 列表mixins
import dialogMixin from '@/mixins/dialog.js';
import API from '@/api/business/tyDataManageQuery';

export default {
  name: 'ServiceDialog',
  mixins: [dialogMixin, tableMixin],
  props: {
    selectedRows: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    const TABLE_CONFIG = {
      // 列表表头
      columns: [
        { label: '单位名称', prop: 'companyName', width: '180', align: 'center' },
        { label: '资源项名称', prop: 'name', width: '180', align: 'center' },
        { label: '资源项编码', prop: 'code', width: '150', align: 'center' },
        { label: '系统名称', prop: 'sysName', width: '200', align: 'center' },
        { label: '系统编码', prop: 'sysCode', width: '120', align: 'center' },
        { label: '数据表名', prop: 'tableName', width: '140', align: 'center' },
        { label: '数据总量', prop: 'totalNum', width: '130', align: 'center' },
        { label: '当天新增量', prop: 'addNum', width: '130', align: 'center' },
        { label: '当天修改量', prop: 'updateNum', width: '130', align: 'center' },
        { label: '当天删除量', prop: 'delNum', width: '130', align: 'center' },
        { label: '当天变化量', prop: 'changeNum', width: '130', align: 'center' },

        { label: '数据变化时间', prop: 'countDate', align: 'center' },
      ],
      // tableData: [
      //   {
      //     id: '1',
      //     companyName: '用于文件管理新增和修改',
      //     name: '萨达撒',
      //     code: 'i24Jh2jN',
      //     sysName: 'STATUS',
      //     sysCode: '4114',
      //     tableName: '454',
      //     totalNum: '22',
      //     addNum: '45',
      //     updateNum: '1',
      //     delNum: 1,
      //     changeNum: '222',
      //     countDate: '233',
      //   },
      // ],
    };

    return {
      ...TABLE_CONFIG,
    };
  },
  computed: {
    dataMethod() {
      return API.getHistroyByDay;
    },
  },
  mounted() {},
  methods: {
    /**
     * @description: dialog每次显示时触发的init方法
     * @param {*} data 传入data
     * @return {*}
     */
    initData(data) {
      const orgForm = this.$options.data().form;
      this.form = { ...orgForm, ...data };
      this.$nextTick(() => {
        this.$refs.form.clearValidate();
      });
      this.id = data.id;
      this.updateApiCallsData(data.id);
      // this.apiCalls();
    },

    // apiCalls() {
    //   const data = this.updateApiCallsData(this.id);
    //   // console.log('======', data);
    //   API.apiLog(data)
    //     .then(res => {
    //       console.log('cacacacssaa', res.rows);
    //       this.tableData = res.rows || [];
    //       if (res && res.rows && Array.isArray(res.rows)) {
    //         this.tableData = res.rows.map(item => {
    //           return {
    //             apiName: item.apiName,
    //             apiUrl: item.apiUrl,
    //             requestIp: item.requestIp,
    //             requestTime: item.requestTime,
    //             requestParams: item.requestParams,
    //             responseResult: item.responseResult,
    //             responseTimeLength: item.responseTimeLength,
    //             requestStatus: item.requestStatus,
    //           };
    //         });
    //       } else {
    //         console.error('接口返回数据格式不符合预期，无法正确渲染日志信息');
    //         this.tableData = [];
    //       }
    //     })
    //     .catch(error => {
    //       console.error('获取数据源失败', error);
    //     });
    // },
  },
};
</script>

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