独墅湖高教创新区危化品智慧管控平台(新危化品)
zhouwx
2025-04-17 a8593f5ca77a934b31bbdd3b919d8e41796cb920
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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<template>
  <div class="notice">
    <div v-if="state.dataList.length>0">
      <div class="title">
        <span style="margin-right: 5px">{{state.form.name}}( {{state.form.productSn}} )</span>
        <span>二维码识别号:{{state.form.code}} </span>
      </div>
      <div class="content" >
        <el-timeline style="max-width: 600px">
          <el-timeline-item
              v-for="(item, index) in state.dataList"
              :key="index"
              :icon="item.icon"
              :type="item.type"
              :color="item.color"
              :size="item.size"
              :hollow="item.hollow"
          >
            {{ item.description }}
            <span style="color: #03752e;font-weight: 600" v-if="item.num > 0">{{item.stateName}}</span>&nbsp;
            <span style="color: #f6828e;font-weight: 600" v-else>{{item.stateName}}</span>&nbsp;
            <span style="color: #03752e" v-if="item.num > 0">{{item.num >0 ? '+' + item.num: item.num}}{{item.unit}}</span>
            <span style="color: #f6828e" v-else>{{item.num}}{{item.unit}}</span>
          </el-timeline-item>
        </el-timeline>
      </div>
    </div>
    <div v-else>
      <el-empty description="暂无数据" />
    </div>
  </div>
</template>
<script setup>
import {onUnmounted, reactive, ref, toRefs} from 'vue'
import {getAllRawFlow, getRawFlow} from "@/api/hazardousChemicals/rawRecord";
import {ElMessage} from "element-plus";
import {getAllProFlow, getFlowByCode} from "@/api/hazardousChemicals/productRecord";
import { MoreFilled } from '@element-plus/icons-vue'
const busRef = ref();
const length = ref()
const title = ref('')
const state = reactive({
  form: {
    id: '',
    name: '',
    productSn: '',
    code: ''
  },
  dataList: [],
  active: null
})
 
 
const openDialog = async (type, value) => {
  title.value = type;
  if(type === 'code'){
    state.form.code = value
  }else {
 
    state.form = JSON.parse(JSON.stringify(value))
  }
 
  await getAllFlow()
}
 
const getAllFlow = async () => {
  if(title.value == 'pro' || title.value =='proRecord'){
    let param = {}
    if(title.value == 'pro'){
      param = {
        productId: state.form.id
      }
    }else {
      param = {
        productId: state.form.productId
      }
    }
    const res = await getAllProFlow(param)
    if(res.code == 200){
      if(res.data && res.data.length>0) {
        state.dataList = res.data.map(item => {
          return {
            ...item,
            unit: item.productBasic.unit,
            stateName: item.state ==0 ?'入库': item.state ==1 ? '取用' :item.state ==2 ? '归还': item.state ==3 ? '标签作废' : item.state ==4 ? '用尽登记':item.state ==5 ? '销售' : '',
            description: `${item.updateTime}   ${item.user.departName ? item.user.departName +'部门'  : ''}   ${item.user.name}  进行了 `,
            size: 'large',
            type: 'primary',
            icon: MoreFilled,
          }
        })
        state.form.name = res.data[0].productBasic.name
        state.form.productSn = res.data[0].productBasic.productSn
        state.form.code = res.data[0].code
        console.log("state.dataList", state.dataList)
      }else {
        state.dataList=[]
      }
    }else{
      ElMessage.warning(res.message)
    }
  }else if(title.value == 'raw' || title.value =='rawRecord'){
    let param = {}
    if(title.value == 'raw'){
      param = {
        hazmatId: state.form.id
      }
    }else {
      param = {
        hazmatId: state.form.hazmatId
      }
    }
    const res = await getAllRawFlow(param)
    if(res.code == 200){
      if(res.data && res.data.length>0){
        state.dataList = res.data.map(item => {
          return {
            ...item,
            unit:item.hazmatBasic.unit,
            stateName: item.state ==0 ?'入库': item.state ==1 ? '取用' :item.state ==2 ? '归还': item.state ==3 ? '标签作废' : item.state ==4 ? '用尽登记':item.state ==5 ? '销售' : item.state ==6? '零头入库':'',
            description: `${item.updateTime}  ${item.user.departName ? item.user.departName +'部门'  : ''}   ${item.user.name}  进行了 `,
            size: 'large',
            type: 'primary',
            icon: MoreFilled,
          }
        })
        state.form.name = res.data[0].hazmatBasic.name
        state.form.productSn = res.data[0].hazmatBasic.productSn
        state.form.code = res.data[0].code
        console.log("state.dataList",state.dataList)
      }else {
        state.dataList = []
      }
    }else{
      ElMessage.warning(res.message)
    }
  }else if(title.value == 'code'){
    const param = {
      code: state.form.code
    }
    const res = await getFlowByCode(param)
    if(res.code == 200){
      if(res.data && res.data.length>0){
        if(res.data[0].hazmatBasic){
          state.dataList = res.data.map(item => {
            return {
              ...item,
              unit:item.hazmatBasic.unit,
              stateName: item.state ==0 ?'入库': item.state ==1 ? '取用' :item.state ==2 ? '归还': item.state ==3 ? '标签作废' : item.state ==4 ? '用尽登记':item.state ==5 ? '销售' : item.state ==6? '零头入库':'',
              description: `${item.updateTime}  ${item.user.departName ? item.user.departName +'部门'  : ''}   ${item.user.name}  进行了 `,
              size: 'large',
              type: 'primary',
              icon: MoreFilled,
            }
          })
          state.form.name = res.data[0].hazmatBasic.name
          state.form.productSn = res.data[0].hazmatBasic.productSn
          state.form.code = res.data[0].code
          console.log("state.dataList",state.dataList)
        }else {
          state.dataList = res.data.map(item => {
            return {
              ...item,
              unit:item.productBasic.unit,
              stateName: item.state ==0 ?'入库': item.state ==1 ? '取用' :item.state ==2 ? '归还': item.state ==3 ? '标签作废' : item.state ==4 ? '用尽登记':item.state ==5 ? '销售' : '',
              description: `${item.updateTime}  ${item.user.departName? item.user.departName  +'部门'  : ''}   ${item.user.name}  进行了 `,
              size: 'large',
              type: 'primary',
              icon: MoreFilled,
            }
          })
          state.form.name = res.data[0].productBasic.name
          state.form.productSn = res.data[0].productBasic.productSn
          state.form.code = res.data[0].code
          console.log("state.dataList",state.dataList)
        }
 
      }else {
        state.dataList = []
      }
    }else{
      ElMessage.warning(res.message)
    }
  }
}
onUnmounted(()=>{
  state.form = {
    id: '',
    name: '',
    productSn: '',
    code: ''
  }
  state.dataList = []
})
 
defineExpose({
  openDialog
});
 
</script>
 
<style scoped lang="scss">
.notice{
  padding: 20px;
  display: flex;
  flex-direction: column;
  .title{
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
  }
  .content{
    margin-top: 40px;
 
    :deep(.el-timeline) {
      font-size: 16px;
    }
    :deep(.el-timeline-item__node--large) {
      left: -8px;
      width: 25px;
      height: 25px;
      top: -5px;
    }
  }
}
</style>