dataUsage.vue 4.21 KB
<script lang="ts" setup name="dataUsage">
import TableTools from "@/components/Tools/table_tools.vue";
import { commonPageConfig, TableColumnWidth } from '@/utils/enum';
import {
  getDataUsePageList,

} from "@/api/modules/dataDelivery";

const router = useRouter();
const route = useRoute();
const { proxy } = getCurrentInstance() as any;

const searchItemList = ref([
  {
    type: "input",
    label: "",
    field: "dataProductName",
    default: "",
    placeholder: "数据产品名称",
    maxlength: 50,
    clearable: true,
  },
  {
    type: "input",
    label: "",
    field: "contractName",
    default: "",
    placeholder: "合约名称",
    maxlength: 50,
    clearable: true,
  },
]);

const page = ref({
  ...commonPageConfig,
  dataProductName: '',
  contractName: ''
});

const tableFields = ref([
  { label: "序号", type: "index", width: 56, align: "center" },
  {
    label: "数据产品名称", field: "dataProductName", width: 150, type: "text_btn", columClass: 'text_btn', value: "detail", click: (scope) => {
      router.push({
        name: 'productListingDetail',
        query: {
          guid: scope.row.dataProductGuid,
          type: 'detail',
          name: scope.row.dataProductName,
        }
      });
    }
  },
  {
    label: "合约名称", field: "contractName", width: 160, type: "text_btn", columClass: 'text_btn', value: "detail1", click: (scope) => {
      //履约中的合约状态
      router.push({
        name: 'smartContractDetail',
        query: {
          guid: scope.row.guid,
          name: scope.row.contractName,
          type: 'keepAgree',
          isDetail: 'Y'
        }
      });
    }
  },
  {
    label: "交付方式", field: "deliveryMethod", width: 120, getName: (scope) => {
      return scope.row.deliveryMethod == 1 ? '文件' : 'API';
    }
  },
  { label: "交付方", field: "deliveryPartyName", width: 240 },
  { label: "交付时间", field: "deliveryTime", width: 170 },
]);

const currTableData: any = ref({});
const tableInfo = ref({
  id: 'contract-table',
  rowKey: 'guid',
  loading: false,
  fields: tableFields.value,
  data: [], //{ verifySatus: 2 }, { verifySatus: 4 }, { verifySatus: 3, deliveryStatus: 2, }
  page: {
    type: "normal",
    rows: 0,
    ...page.value,
  },
  actionInfo: {
    label: "操作",
    type: "btn",
    width: 160,
    btns: (scope) => {
      let btns: any = [];
      //TODO。根据返回值显示按钮
      btns.push({ label: '日志', value: 'log' });
      return btns;
    }
  }
});

const toSearch = (val: any, clear: boolean = false) => {
  if (clear) {
    searchItemList.value.map((item) => (item.default = ""));
    page.value.dataProductName = '';
    page.value.contractName = '';
  } else {
    page.value.dataProductName = val.dataProductName;
    page.value.contractName = val.contractName;
  }
  getTableData();
};

const getTableData = () => {
  tableInfo.value.loading = true
  getDataUsePageList({
    pageIndex: page.value.curr,
    pageSize: page.value.limit,
    dataProductName: page.value.dataProductName,
    contractName: page.value.contractName
  }).then((res: any) => {
    tableInfo.value.loading = false
    if (res?.code == proxy.$passCode) {
      const data = res.data || {};
      tableInfo.value.data = data.records || []
      tableInfo.value.page.limit = data.pageSize
      tableInfo.value.page.curr = data.pageIndex
      tableInfo.value.page.rows = data.totalRows
    } else {
      res?.msg && proxy.$ElMessage.error(res?.msg)
    }
  }).catch(() => {
    tableInfo.value.loading = false
  })
};

const tablePageChange = (info) => {
  page.value.curr = Number(info.curr);
  page.value.limit = Number(info.limit);
  tableInfo.value.page.curr = page.value.curr;
  tableInfo.value.page.limit = page.value.limit;
  getTableData();
};

onBeforeMount(() => {
  toSearch({});
});

</script>

<template>
  <div class="container_wrap">
    <div class="table_tool_wrap">
      <TableTools :searchItems="searchItemList" :searchId="'contract-search'" @search="toSearch" :init="false" />
    </div>
    <div class="table_panel_wrap" style="height: calc(100% - 44px);">
      <Table :tableInfo="tableInfo" @tablePageChange="tablePageChange" />
    </div>
  </div>
</template>

<style lang="scss" scoped>
.container_wrap {
  padding: 0px 16px;
}
</style>