DxBaselinesRelatedObjects.vue 3.28 KB
<template>
  <div class="relate-object">
    <dee-table
      :columns="columns"
      :data="cacheTableData"
      selection-row
      :options="options"
      :pagination="pagination"
      :index-row="{
        title: '序号',
        align: 'center',
        width: '70'
      }"
    />
  </div>
</template>

<script>
import { post } from '@/utils/http'
export function getBaseline(params) {
  return post(`/DxBaseline/find/recursion`, params)
}

export default {
  name: 'DxBaselinesRelatedObjects',
  displayName: '相关对象',
  modelRelationObjs: ['DxBaseline'],
  // import引入的组件需要注入到对象中才能使用
  components: {},

  props: {
    basicData: {
      type: Object,
      default: () => null
    }
  },
  data() {
    // 这里存放数据
    return {
      columns: [
        {
          title: '编号',
          key: 'number'
        },
        {
          title: '名称',
          key: 'name'
        },
        {
          title: '类型',
          key: 'subTypeDisplayName'
        },
        {
          title: '视图', key: 'dxView.name', align: 'center'
        },
        {
          title: '版本',
          key: 'displayVersion'
        },
        {
          title: '状态',
          key: 'state',
          fildProp: {
            type: 'DictDataVO',
            rule: {
              dictTypeCode: 'ObjStatus' }
          }
        },
        {
          title: '创建者',
          key: 'creator.userName'
        },
        {
          title: '修改时间',
          key: 'modifyTime'
        }
      ],
      tableData: [],
      pagination: {
        currentPage: 1,
        pageSize: 10,
        total: 0,
        pageSizes: [10, 20, 50]
      },
      options: {

      },
      dictLists: {}
    }
  },
  // 监听属性 类似于data概念
  computed: {
    cacheTableData() {
      const start = (this.pagination.currentPage - 1) * this.pagination.pageSize
      const end = start + this.pagination.pageSize
      return this.tableData.slice(start, end)
    }
  },
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成(可以访问当前this实例)
  async created() {
    await this.$dict.getDictList(this.columns).then(res => {
      this.dictLists = res
    })
  },
  // 生命周期 - 挂载完成(可以访问DOM元素)
  mounted() {
    this.$nextTick(() => {
      const id = this.basicData && this.basicData.id
      const params = {
        'openProps': [{
          'name': 'baselineMembers',
          'pageFrom': 1,
          'pageSize': 1000,
          'openProps': [{ 'name': 'target', 'pageFrom': 1, 'pageSize': 1000 }]
        }],
        'pageFrom': 1,
        'pageSize': 1000,
        'searchItems': {
          'items': [{ 'fieldName': 'id', 'operator': 'EQ', 'value': id }],
          'operator': 'AND'
        }
      }
      getBaseline(params).then(res => {
        this.addData = res.items.content[0]
        this.tableData = res.items.content[0].baselineMembers.map(x => {
          Object.assign(x, x.target)
          x = this.$dict.displayDictValue(x, this.dictLists)
          return x
        })
        this.pagination.total = this.tableData.length
      }).catch(e => {})
    })
  },
  activated() {
  },
  // 方法集合
  methods: {}
}
</script>
<style lang='scss'>
.relevant-object{
  margin-top: 10px;
}
</style>