parts.js 3.66 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
import {
  post,
  get
} from '../utils/http'

export function getPart(params) {
  return post(`/DxPart/find/recursion`, params)
}

export function expandBOM(id, level = -1) {
  return post(`/DxPart/expandBOM`, { partId: id, level: level })
}

export function findByNumber(params) {
  return get(`/DxPart/findByNumber`, params)
}

export function getPartByES(params) {
  return post(`/DxDocument/search`, params)
}

export function addPart(params) {
  return post(`/DxPart/recursion`, params)
}

export function addBaseline(params) {
  return post(`/DxBaseline/recursion`, params)
}

export function getBaseline(params) {
  return post(`/DxBaseline/find/recursion`, params)
}

export function getBaselineMemeber(params) {
  return post(`/DxBaseline/getMemberMatrix`, params)
}

export function checkoutPart(objId) {
wangdanlei's avatar
wangdanlei committed
39
  return post(`/DxPart/version/${objId}/checkoutOverride`)
wangdanlei's avatar
wangdanlei committed
40 41 42
}

export function undoCheckout(objId) {
wangdanlei's avatar
wangdanlei committed
43
  return post(`/DxPart/version/${objId}/undoCheckoutOverride`)
wangdanlei's avatar
wangdanlei committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 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
}

export function checkinPart(objId) {
  return post(`/DxPart/version/${objId}/checkin`)
}

export function getLinks(params) {
  return post(`/usageLinks/search`, params)
}

// 保存CA数据
export function saveCAData(params) {
  return post('/DxChangeActivity/recursion', params)
}

export function getPartDetail({ id, openProps }) {
  const params = {
    'openProps': [],
    'pageFrom': 1,
    'pageSize': 10,
    'searchItems': {
      'children': [
      ],
      'items': [
        {
          'fieldName': 'id',
          'operator': 'EQ',
          'value': id
        }
      ],
      'operator': 'AND'
    }
  }
  params.openProps = openProps
  return post('/DxPart/find/recursion', params)
}

// #region 20.10.25 fangming 临时操作关系,希望前段架构设计通用接口
// 获取关系数据
export function loadLink(objId, linkPropName) {
  const partSearchItem = {
    searchItems: {
      items: [{
        fieldName: 'id',
        operator: 'EQ',
        value: objId
      }]
    },
    pageFrom: 1,
    pageSize: 20,
    openProps: [{
      name: linkPropName,
      pageFrom: 1,
      pageSize: 10,
      openProps: [{
        name: 'target',
        pageFrom: 1,
        pageSize: 10
      }]
    }]
  }
  return new Promise((resolve, reject) => {
    post(`/usageLinks/search`, partSearchItem).then((r) => {
      alert(r)
      resolve(r)
    }).catch(error => {
      reject(error)
    })
  })
}

// 移除有关系
export function removeLinks(objId, linkPropName, linkIds) {
  const part = {
    operator: 'NO_CHANGE',
    id: objId
  }
  part[linkPropName] = linkIds.map(linkId => {
    return {
      operator: 'REMOVE',
      id: linkId
    }
  })
  return post(`/DxPart/recursion`, part)
}

// 添加关系
export function addLinks(objId, linkPropName, targetIds) {
  const part = {
    operator: 'NO_CHANGE',
    id: objId
  }
  part[linkPropName] = targetIds.map(linkId => {
    return {
      operator: 'ADD',
      target: {
        operator: 'NO_CHANGE',
        id: linkId
      }
    }
  })
  return post(`/DxPart/recursion`, part)
}

// 更新关系属性
export function updateLink(objId, linkPropName, linkData) {
  const part = {
    operator: 'NO_CHANGE',
    id: objId
  }
  part[linkPropName] = linkData
  return post(`/DxPart/recursion`, part)
}

export function getWorkingCopy(modelName, params) {
  return get(`/${modelName}/version/getWorkingCopy/${params}`)
}

export function getLayouts(typeKey, layoutType) {
wangdanlei's avatar
wangdanlei committed
163 164 165 166 167 168 169 170 171
  return new Promise(async(resolve, reject) => {
    get('/DxModelComponent/findModelComponent', { modelDefName: typeKey, layoutType }).then(res => {
      if (res.items && res.items.content) {
        resolve({
          items: res.items.content
        })
      }
    })
  })
wangdanlei's avatar
wangdanlei committed
172 173 174
}

// #endregion