DxPartSpecialPart.vue 4.06 KB
/**
* @Description:
* @author 李亦康
* @date 2020/10/12
*/
<template>
  <div class="special-part">
    <dee-table
      :data="tableData"
      :columns="columns"
      :index-row="{title: '序号',width: '70px'}"
      :options="{maxHeight: 300}"
    />
  </div>
</template>

<script>
import { post } from '@/utils/http'
export default {
  name: 'DxPartSpecialPart',
  displayName: '特定替换件',
  modelRelationObjs: ['DxPart'],
  components: {},
  props: {
    basicData: {
      type: Object,
      required: true,
      default: () => {
      }
    },
    businessData: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      tableData: [],
      columns: [
        { title: '装配编号', key: 'source.number', headerAlign: 'center' },
        { title: '装配版本', key: 'source.displayVersion', headerAlign: 'center' },
        { title: '视图', key: 'target.dxView.name', headerAlign: 'center' },
        { title: '对象类型', key: 'target.subTypeDisplayName', headerAlign: 'center' },
        { title: '编号', key: 'target.number', headerAlign: 'center', component:
{ name: 'jumpDetailsPage', show: true }},
        { title: '名称', key: 'target.name', headerAlign: 'center' },
        { title: '开始时间', key: 'startTime', headerAlign: 'center', formatter(row, column) { if (row.startTime) { return row.startTime.split(' ')[0] } else { return '' } } },
        { title: '结束时间', key: 'endTime', headerAlign: 'center', formatter(row, column) { if (row.endTime) { return row.endTime.split(' ')[0] } else { return '' } } },
        { title: '创建者', key: 'target.creator.userName', headerAlign: 'center' },
        { title: '上次修改时间', key: 'target.modifyTime', headerAlign: 'center' }
      ]
    }
  },
  computed: {},
  watch: {
    basicData: {
      immediate: true,
      deep: true,
      handler: function(val) {
      }
    },
    businessData: {
      deep: true,
      handler: function(data) {
        this.getPartSubstituteLinks(data)
      }
    }
  },
  created() {
  },
  mounted() {
    this.getPartSubstituteLinks(this.businessData)
  },
  methods: {
    getPartSubstituteLinks(businessData) {
      if (businessData && businessData.nodeData && businessData.nodeData.id && businessData.nodeData.target) {
        this.load(businessData.nodeData.target, businessData.nodeData.id)
      }
    },
    load(partId, linkId) {
      this.tableData = []
      const partQuery = {
        pageFrom: 1,
        pageSize: 9999,
        searchItems: {
          items: [{
            fieldName: 'id',
            operator: 'EQ',
            value: partId
          }]
        },
        openProps: [{
          name: 'targetUsageLinks',
          pageFrom: 1,
          pageSize: 9999,
          searchItems: {
            items: [{
              fieldName: 'id',
              operator: 'EQ',
              value: linkId
            }]
          },
          openProps: [{
            name: 'source'
          },
          {
            name: 'partSubstituteLinks',
            pageFrom: 1,
            pageSize: 9999,
            openProps: [{
              pageFrom: 1,
              pageSize: 9999,
              name: 'target'
            }
            ]
          }]
        }]
      }
      post('/DxPart/find/recursion', partQuery).then(res => {
        if (res.items &&
          res.items.content &&
          res.items.content[0] &&
          res.items.content[0].targetUsageLinks &&
          res.items.content[0].targetUsageLinks[0] &&
          res.items.content[0].targetUsageLinks[0].partSubstituteLinks) {
          const source = res.items.content[0].targetUsageLinks[0].source
          this.tableData = res.items.content[0].targetUsageLinks[0].partSubstituteLinks.map(row => {
            return {
              source: source,
              id: row.id,
              startTime: row.startTime,
              endTime: row.endTime,
              target: row.target
            }
          })
        }
      }).finally(() => {
      })
    }
  }
}
</script>
<style lang='scss'>
.special-part {
  margin-top: 10px;
  margin-bottom: 20px;
}
</style>