Ben Lin
2024-06-26 d78bfcfe33940427c68033511f9adc35ca2f79d7
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
64
65
66
/*
 * @Description: 产品工艺路线相关
 * @Author: Ben Lin
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-25 18:30:51
 */
 
import { GetRoutePTree } from '/@/api/tigerapi/mes/router';
import { convertToTree } from '/@/api/tigerapi/system';
 
function _default() {
  const methods = {
    /**
     * @description: 获取树形图标
     * @param {Recordable} params
     * @return {*}
     */
    CreateIcon: (params: Recordable<any>) => {
      let icon = '';
      switch (params['type']) {
        case 'Product':
          icon = 'similar-product|svg';
          break;
        case 'Route':
          icon = 'route|svg';
          break;
        case 'Node':
          icon = 'node|svg';
          break;
        case 'Action':
          icon = 'rot_action|svg';
          break;
        case 'Customer':
          icon = 'customer|svg';
          break;
      }
      return icon;
    },
    /**
     * @description: 高级表单和详情页面返回主页面的url
     * @return {*}
     */  
    GetHomeUrl: () => {
      return `/V_BAS_PROD/LC/${encodeURI(JSON.stringify({ ID: 'V_BAS_PROD', colSlots: [], crudColSlots: [] }))}`;
    },
    /**
     * @description: 获取树形数据
     * @param {string} type
     * @return {*}
     */
    fetchTreeData: async (type: string, itemCode: string) => {
      let data = { title: '', treeData: [] as any[], fieldNames: {} };
      let prodTreeData = await GetRoutePTree(itemCode);
      data.treeData = convertToTree(prodTreeData, 'pid', 'id', 'root');
      data.title = '工艺路线';
      data.fieldNames = { key: 'id', title: 'name' };
      return data;
    },
  };
 
  return [methods];
}
 
export default _default;