DxProcessMachineDetail.vue 4.55 KB
Newer Older
wangdanlei's avatar
wangdanlei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
<template>
  <div class="dee-page no-padding">
    <businessTab
      ref="businessTab"
      class="test"
      style="height: 100%;background-color: #fff"
      :is-view="isView"
      :model-name="modelName"
      :type-name="typeName"
      :page-data="pageData"
      :page-name="pageName"
      :config="config"
      :table-options="tableOptions"
      v-bind="configDetails"
      :custom-events="customEvents"
      v-on="layHandler"
      @checkEvent="checkEvent"
      @refreshBasicData="refreshBasicData"
      @refreshNodeData="refreshNodeData"
      @refreshStructure="refreshStructure"
      @close-detail="$emit('close-detail')"
    />
    <dee-dialog
      v-if="!showDialog"
      :key="index"
      width="70%"
      :title="dialogTitle"
      :dialog-visible="dialogShow"
      @handleClose="close"
    >
      <component
        :is="componentName"
        :is-from-detail="true"
        :obj="obj"
        :basic-data="basicData"
        :dialog-show="dialogShow"
        :default-data="{latest:'LATEST'}"
        @close="close"
        @addSuccess="addSuccess"
      />
    </dee-dialog>
    <!-- 自带弹窗的组件 -->
    <component
      :is="componentName"
      v-else
      :is-from-detail="true"
      :width="width"
      :title="dialogTitle"
      :model-name="nameStr"
      :show-dialog="showDialog"
      :default-data="{latest:'LATEST'}"
      @close="showDialog = false"
      @selection="selection"
    />
  </div>
</template>

<script>
import { changeCustomEvent } from './customEvents.js'
import { saveResource } from '@/api/resource'
export default {
  name: 'DxProcessMachineDetail',
  displayName: '资源分类详情',
wangdanlei's avatar
wangdanlei committed
64
  modelRelationObjs: ['DxMachineResource'],
wangdanlei's avatar
wangdanlei committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
  components: { },
  props: {
    isView: {
      type: Boolean,
      default: false
    },
    config: {
      type: Object,
      default: () => {}
    },
    pageData: {
      type: Object,
      default: () => {}
    },
    tableOptions: {
      type: Object,
      default: () => {}
    },
    configDetails: {
      type: Object,
      default: () => {}
    },
    layHandler: {
      type: Object,
      default: () => {}
    },
    typeName: {
      type: [Number, String],
      default: () => ''
    },
    modelName: {
      type: [Number, String],
      default: () => ''
    },
    pageName: {
      type: [Number, String],
      default: () => ''
    },
    isSelf: { // 详情页面单独打开
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      nameStr: 'DxPart',
      customEvents: null,
      checkoutState: null,
      dialogShow: false,
      obj: null,
      index: 0,
      dialogTitle: '',
      componentName: '',
      basicData: {},
      width: '50%',
      showDialog: false
    }
  },
  computed: {},
  watch: {
    basicData: function(val) {
      console.log('basicData========', val)
    }
  },
  // 生命周期 - 创建完成(访问当前this实例)
  created() {},
  // 生命周期 - 挂载完成(访问DOM元素)
  mounted() {
    const PartEvents = changeCustomEvent
    this.customEvents = new PartEvents(this)
  },
  methods: {
    load(val) {
      this.$refs['businessTab'].load(val)
    },
    checkEvent(checkoutState) {
      this.checkoutState = checkoutState
    },
    refreshNodeData(data, type) {
      if (this.isSelf) { // 单独详情
        this.$refs['businessTab'].reload()
      } else {
        this.$emit('refreshNodeData', data, type)
      }
    },
    refreshStructure(data) {
      this.$emit('refreshStructure', data)
    },
    checkCanzhuangjian() {
      this.$emit('checkCanzhuangjian')
    },
    refreshBasicData(data) {
      this.basicData = data
    },
    close() {
      this.dialogShow = false
      this.index++
    },
    addSuccess(data) {
      this.refreshStructure(data)
      this.checkCanzhuangjian()
    },
    openBom(data) {
      this.$emit('openBom', data)
    },
    selection(data) {
      const params = {
        'operator': 'NO_CHANGE',
        'id': this.basicData.id,
        'sourceDxResPartLink': data.map(r => {
          return {
            'operator': 'ADD',
            'target': {
              'operator': 'NO_CHANGE',
              'id': r.id
            }
          }
        })
      }
      if (this.basicData.subTypeName === 'DxProcessMachine') {
        params.dxClassname = 'com.yonde.dcs.resource.common.entity.vo.DxProcessMachineVO'
      }
      saveResource(params, this.basicData.subTypeName).then(res => {
        this.showDialog = false
        this.refreshNodeData(this.basicData)
      }).catch(e => {})
    }
  }
}
</script>
<style lang="scss">
/* @import url(); 引入css类 */

</style>