22
schangxiang@126.com
2025-05-21 40c6e31e722088fb5577552271eb0af7f695131e
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
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
<template>
  <div class="OrderManagement">
    <Tab :data="headOptions" type="list" @Tab="changeTabFn" />
  </div>
</template>
 
<script lang="ts">
import { defineComponent, ref, markRaw, shallowRef, computed } from 'vue'
import head from 'lodash/head'
import sdk from 'sdk'
const { models } = sdk
const { CanvasNode } = models
import OrderManagement from './views/order-management/index.vue'
import OrderRecords from './views/order-records/index.vue'
import { createProvider } from './hooks/use-permission'
import Tab from '@/components/Tab/Tab'
import { useEditionFeature } from '@/libs/Permission/Permission'
import { _t } from './app'
 
export default defineComponent({
  name: '工序管理',
  components: {
    OrderManagement,
    OrderRecords,
    Tab,
  },
  props: {
    node: CanvasNode,
  },
  setup(props) {
    useEditionFeature()
    const changeTabFn = (type: any) => {
      changeTab(type)
    }
 
    const { permissionCodes, showTabs, initPermission, changeTab } =
      createProvider(props)
    initPermission()
    const headOptions = shallowRef([
      {
        label: '工单管理',
        name: 'OrderManagement',
        component: markRaw(OrderManagement),
      },
      {
        label: '工单记录',
        name: 'OrderRecords',
        component: markRaw(OrderRecords),
      },
    ])
 
    const headActive = ref(head(headOptions.value)?.name)
 
    const headMap = headOptions.value.reduce((acc, item) => {
      // @ts-ignore
      acc[item.name] = item.component
      return acc
    }, {})
    // @ts-ignore
    const activeComponent = computed(() => headMap[headActive.value])
 
    // @ts-ignore
    const removeComponentsFromHeadOptions = (showTabs, headOptions) => {
      // @ts-ignore
      return headOptions.filter((option) => {
        if (option.name === 'OrderManagement')
          return showTabs.includes('Order-tabs-management')
        else if (option.name === 'OrderRecords')
          return showTabs.includes('Order-tabs-records')
        else return false
      })
    }
 
    headOptions.value = removeComponentsFromHeadOptions(
      showTabs.value,
      headOptions.value
    )
 
    return {
      headOptions,
      headActive,
      activeComponent,
      permissionCodes,
      showTabs,
      changeTabFn,
    }
  },
})
</script>
<style lang="scss" scoped>
$borderRadius: 4px;
 
.OrderManagement {
  background-color: #fff;
  border-radius: 5px 5px 0 0;
  width: 100%;
  height: 100%;
  border: 1px solid #dbdbdb;
}
 
.head {
  width: 100%;
  height: 46px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background-color: #e8e8e8;
 
  &-item {
    width: 128px;
    height: 34px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 16px;
  }
 
  &-active {
    color: #5a84ff;
    background-color: #fff;
    border: 1px solid #cfcfcf;
    border-radius: 4px;
    transition: all 0.3s;
  }
}
 
.container-box {
  height: auto;
  box-sizing: border-box;
  padding: 20px;
  overflow-y: scroll;
  background-color: #fff;
}
 
.permission-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
</style>