parts.js 8.84 KB
Newer Older
wangdanlei's avatar
wangdanlei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import {
  post,
  get,
  put,
  del
} from '../utils/http'

// import { getDynamicAttr } from '@/utils/util'

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

export function expandBOM(id, level = -1) {
wangdanlei's avatar
wangdanlei committed
15
  return post(`/DxPart/expandBOM`, { partId: id, level: level, partOpenProps: ['dxView'] })
wangdanlei's avatar
wangdanlei committed
16 17 18 19
  // return post(`/DxPart/expandBOM`, { partId: id, level: level })
}

export function expandSandboxBOM(sandboxId, level = -1, partId = null,) {
wangdanlei's avatar
wangdanlei committed
20
  return post(`/DxPart/expandBOM`, { sandboxId: sandboxId, partId: partId, level: level, partOpenProps: ['dxView', 'dxContext'] })
wangdanlei's avatar
wangdanlei committed
21 22 23
}

export function convertView(params) {
wangdanlei's avatar
wangdanlei committed
24
  return post(`/DxPart/convertView`, params, true)
wangdanlei's avatar
wangdanlei committed
25 26 27 28 29 30 31 32 33 34 35 36
}

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

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

export function addPart(params) {
wangdanlei's avatar
wangdanlei committed
37
  return post(`/DxPart/recursion`, params, true)
wangdanlei's avatar
wangdanlei committed
38 39 40 41
  // return post(`/DxPart/recursion`, params)
}

export function addPartInSandbox(params) {
wangdanlei's avatar
wangdanlei committed
42
  return post(`/DxPart/addPart?parentPartId=${params.parentPartId}&isCreate=${params.isCreate}`, params.dxPartVos, true)
wangdanlei's avatar
wangdanlei committed
43 44 45
}

export function addBaseline(params) {
wangdanlei's avatar
wangdanlei committed
46
  return post(`/DxBaseline/recursion`, params, true)
wangdanlei's avatar
wangdanlei committed
47 48 49 50 51 52 53 54 55 56 57 58 59
}

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

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

export function checkoutPart(objId, sandboxId = null) {
  if (sandboxId) {
    // return post(`/DxPart/version/${objId}/checkout?sandboxId=${sandboxId}`)
wangdanlei's avatar
wangdanlei committed
60
    return post(`/DxPart/version/${objId}/checkoutOverride?sandboxId=${sandboxId}`, null, true)
wangdanlei's avatar
wangdanlei committed
61
  } else {
wangdanlei's avatar
wangdanlei committed
62
    return post(`/DxPart/version/${objId}/checkout`, null, true)
wangdanlei's avatar
wangdanlei committed
63 64 65
  }
}

wangdanlei's avatar
wangdanlei committed
66 67
export function undoCheckout(objId, sandboxId = null) {
  return post(`/DxPart/version/${objId}/undoCheckoutOverride?sandboxId=${sandboxId}`, null, true)
wangdanlei's avatar
wangdanlei committed
68 69
}

wangdanlei's avatar
wangdanlei committed
70 71
export function checkinPart(objId, note, sandboxId = null) {
  return post(`/DxPart/version/${objId}/checkin?sandboxId=${sandboxId}&note=${note}`, null, true)
wangdanlei's avatar
wangdanlei committed
72 73 74 75 76 77 78 79
}

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

// 保存CA数据
export function saveCAData(params) {
wangdanlei's avatar
wangdanlei committed
80
  return post('/DxChangeActivity/recursion', params, true)
wangdanlei's avatar
wangdanlei committed
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
}

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
    }
  })
wangdanlei's avatar
wangdanlei committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
  return post(`/DxPart/recursion`, part, true)
}

export function removeSandboxLinks(objId, linkPropName, linkIds, sandboxId) {
  const part = {
    operator: 'NO_CHANGE',
    id: objId,
    sandboxId: sandboxId
  }
  part[linkPropName] = linkIds.map(linkId => {
    return {
      operator: 'REMOVE',
      id: linkId
    }
  })
  return post(`/DxPart/recursionInSandbox`, part, true)
wangdanlei's avatar
wangdanlei committed
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
}

// 添加关系
export function addLinks(objId, linkPropName, targetIds, sandboxId = 0) {
  const part = {
    operator: 'NO_CHANGE',
    id: objId
  }
  part[linkPropName] = targetIds.map(linkId => {
    return {
      operator: 'ADD',
      sandboxId: sandboxId,
      target: {
        operator: 'NO_CHANGE',
        id: linkId
      }
    }
  })
wangdanlei's avatar
wangdanlei committed
185
  return post(`/DxPart/recursion`, part, true)
wangdanlei's avatar
wangdanlei committed
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
}

// 添加新建描述文档
export function addDesLinks(objId, linkPropName, form, sandboxId = 0) {
  const part = {
    operator: 'NO_CHANGE',
    id: objId
  }
  part[linkPropName] = [{
    operator: 'ADD',
    sandboxId: sandboxId,
    target: {
      ...form
    }
  }]
wangdanlei's avatar
wangdanlei committed
201
  return post(`/DxPart/recursion`, part, true)
wangdanlei's avatar
wangdanlei committed
202 203 204 205 206 207 208 209 210
}

// 更新关系属性
export function updateLink(objId, linkPropName, linkData) {
  const part = {
    operator: 'NO_CHANGE',
    id: objId
  }
  part[linkPropName] = linkData
wangdanlei's avatar
wangdanlei committed
211
  return post(`/DxPart/recursion`, part, true)
wangdanlei's avatar
wangdanlei committed
212 213 214 215 216 217
}

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

wangdanlei's avatar
wangdanlei committed
218 219
export function getSandboxWorkingCopy(modelName, params) {
  return get(`/${modelName}/version/getWorkingCopySandbox/${params}`)
wangdanlei's avatar
wangdanlei committed
220 221
}

wangdanlei's avatar
wangdanlei committed
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
// export function getLayouts(typeKey, layoutType) {
//   return get('/model/form/config/layout', { layoutType, typeKey })
// }

export function getLayouts(typeKey, layoutType) {
  return new Promise((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
237 238
// #endregion

wangdanlei's avatar
wangdanlei committed
239 240
export function removePart(params, sandboxId = null) {
  return post(`/DxPart/removePart?usagelinkId=${params.usagelinkId}&partId=${params.partId}&sandboxId=${sandboxId}`, true)
wangdanlei's avatar
wangdanlei committed
241 242 243 244 245 246 247
}

export function getProcessRouteByUsagelinkId(usagelinkId) {
  return get(`/DxProcessRoute/getProcessRouteByUsagelinkId?usagelinkId=${usagelinkId}`)
}

export function addProcessRoute(params) {
wangdanlei's avatar
wangdanlei committed
248
  return post(`/DxProcessRoute/addOrUpdateProcessRoute?usagelinkId=${params.usagelinkId}`, params.list, true)
wangdanlei's avatar
wangdanlei committed
249 250 251
}

export function deleteRoute(ids) {
wangdanlei's avatar
wangdanlei committed
252
  return del(`/DxProcessRoute/batch/${ids}`, true)
wangdanlei's avatar
wangdanlei committed
253 254 255 256 257 258 259 260 261 262 263
}

export function dxSandboxPublish(id) {
  return put(`/DxSandbox/publish?id=${id}`)
}

export function dxSandboxCancel(id) {
  return put(`/DxSandbox/cancel?id=${id}`)
}

export function dxView(id) {
wangdanlei's avatar
wangdanlei committed
264 265 266 267
  return get(`/DxView/page/${id}`)
}

export function dxViewId(id) {
wangdanlei's avatar
wangdanlei committed
268 269 270 271 272 273 274 275
  return get(`/DxView/${id}`)
}

export function dxContext() {
  return get(`/DxContext`)
}

export function removeSandboxDescribeDoc(params) {
wangdanlei's avatar
wangdanlei committed
276
  return post(`/DxPartDescribeLink/removeSandboxDescribeDoc`, params, true)
wangdanlei's avatar
wangdanlei committed
277 278 279
}

export function checkSandboxObjectIsCheckouted(params) {
wangdanlei's avatar
wangdanlei committed
280
  return get(`/DxSandboxMemberLink/checkSandboxObjectIsCheckouted`, params, true)
wangdanlei's avatar
wangdanlei committed
281 282 283
}

export function savePartAndUsagelink(params) {
wangdanlei's avatar
wangdanlei committed
284
  return post(`/DxPart/savePartAndUsagelink`, params, true)
wangdanlei's avatar
wangdanlei committed
285 286 287 288 289 290 291 292 293 294 295
}

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

export function checkEquivalenceLink(params) {
  return get(`/DxEquivalenceLink/checkEquivalenceLink`, params)
}

export function romoveDxEquivalence(id) {
wangdanlei's avatar
wangdanlei committed
296
  return del(`/DxEquivalenceLink/batch/${id}`, true)
wangdanlei's avatar
wangdanlei committed
297 298 299
}

export function checkPartIsPreviousView(params) {
wangdanlei's avatar
wangdanlei committed
300
  return get(`/DxPart/checkPartIsPreviousView`, params, true)
wangdanlei's avatar
wangdanlei committed
301 302 303 304 305 306 307 308 309
}
// 查询下一个大版本号
export function getNextVersion(modelName, id, targetViewId) {
  if (targetViewId) {
    return get(`/${modelName}/version/latest/?id=${id}&targetViewId=${targetViewId}`)
  }
  return get(`/${modelName}/version/latest/?id=${id}`)
}
export function checkinWithSave(params) {
wangdanlei's avatar
wangdanlei committed
310
  return post(`/DxPart/checkinWithSave`, params, true)
wangdanlei's avatar
wangdanlei committed
311 312 313 314 315
}
// 批量修订,升级大版本
export function modifyVersion(params) {
  const ids = params.ids.map(x => `ids=${x}`).join('&')
  const str = ids ? ('?' + ids) : ''
wangdanlei's avatar
wangdanlei committed
316
  return post(`/DxPart/version/newVersions${str}`, true)
wangdanlei's avatar
wangdanlei committed
317 318 319 320 321
}
//  批量修订,升级大版本
export function modifyCADVersion(params) {
  const ids = params.ids.map(x => `ids=${x}`).join('&')
  const str = ids ? ('?' + ids) : ''
wangdanlei's avatar
wangdanlei committed
322
  return post(`/DxCADDocument/version/newVersions${str}`, true)
wangdanlei's avatar
wangdanlei committed
323 324 325
}
// 修改状态
export function changeStatus(params) {
wangdanlei's avatar
wangdanlei committed
326
  return put(`/DxPart/lifecycle/changeStatus`, params, true)
wangdanlei's avatar
wangdanlei committed
327 328
}
export function savePart(params) {
wangdanlei's avatar
wangdanlei committed
329 330 331 332 333 334 335 336 337 338 339 340 341 342
  return post(`/DxPart/recursion`, params, true)
}

export function recursionInSandbox(params) {
  return post(`/DxPart/recursionInSandbox`, params, true)
}
// 清空替换件时间
export function operatorDateField(params) {
  return post(`/operatorField`, params)
}

// 获取标准件库树数据
export function getStandardPartTreeData(id) {
  return post(`/DxStdPartCategory/child/${id}`, {})
wangdanlei's avatar
wangdanlei committed
343
}
wangdanlei's avatar
wangdanlei committed
344 345 346 347

export function coverDxUsageLink(params) {
  return post(`/DxUsageLink/batchCover`, params)
}