独墅湖高教创新区危化品智慧管控平台(新危化品)
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
<template>
  <div class="app-container">
    <div style="display: flex;justify-content: space-between">
      <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" >
        <el-form-item label="品名:" >
          <el-input v-model="data.queryParams.params.name" placeholder="请输入品名" clearable></el-input>
        </el-form-item>
        <el-form-item label="产品编号:" >
          <el-input v-model="data.queryParams.params.productSn" placeholder="请输入产品编号" clearable></el-input>
        </el-form-item>
        <el-form-item >
          <el-button
              type="primary"
              @click="getList"
          >查询</el-button>
          <el-button
              type="primary"
              plain
              @click="reset"
          >重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true" :cell-style="cellStyle">
      <el-table-column label="序号" type="index" align="center" width="80" />
      <el-table-column label="品名" prop="hazmatBasic.name" align="center"  />
      <el-table-column label="产品编号" prop="hazmatBasic.productSn" align="center" />
      <el-table-column label="CAS号" prop="hazmatBasic.cas" align="center" />
      <el-table-column label="厂家" prop="hazmatBasic.manufacturer" align="center" />
      <el-table-column label="供应商" prop="hazmatBasic.supplier" align="center" />
      <el-table-column label="危险性质" prop="hazmatBasic.hazmatCharacter" align="center" />
      <el-table-column label="最小包装" align="center" width="120">
        <template #default="scope">
          <span>{{scope.row.hazmatBasic.metering}}{{scope.row.hazmatBasic.unit}} / {{scope.row.hazmatBasic.minPackage == 0 ? '瓶' :scope.row.hazmatBasic.minPackage == 1?'袋':scope.row.hazmatBasic.minPackage == 2?'桶 ':scope.row.hazmatBasic.minPackage == 3?'盒':scope.row.hazmatBasic.minPackage == 4?'箱':'其他'}}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="批号" prop="batchNo" align="center" width="120" />-->
      <el-table-column label="当前库存" prop="stock" align="center" width="120">
        <template #default="scope">
          <el-tooltip
              v-if="scope.row.stock +scope.row.missStock < scope.row.hazmatBasic.safeNum"
              class="box-item"
              effect="light"
              :content="`当前库存小于安全库存(${scope.row.hazmatBasic.safeNum})`"
              placement="top"
          >
            <span style="cursor: pointer">{{scope.row.stock}}</span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="不完整归还" prop="missStock" align="center" width="120" >
        <template #default="scope">
          <el-tooltip
              v-if="scope.row.stock +scope.row.missStock < scope.row.hazmatBasic.safeNum"
              class="box-item"
              effect="light"
              :content="`当前库存小于安全库存(${scope.row.hazmatBasic.safeNum})`"
              placement="top"
          >
            <span style="cursor: pointer">{{scope.row.missStock}}</span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="安全库存" prop="hazmatBasic.safeNum" align="center" width="120" />
      <el-table-column label="所在仓库" prop="warehouseName" align="center" />
      <el-table-column label="存储柜" prop="cupboardName" align="center" />
      <el-table-column label="创建时间" prop="hazmatBasic.createTime" align="center" width="120" />
<!--      <el-table-column label="状态" prop="state" align="center">-->
<!--        <template #default="scope">-->
<!--          <span>{{scope.row.state === 0 ? '未入库' : '已入库'}}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200" >
        <template #default="scope">
          <el-button link type="primary"  @click="getProRecord(scope.row)" >动库记录</el-button>
          <el-button link type="primary" @click="toDetail(scope.row)">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />
    <raw-warehouse-dialog ref="dialogRef" @getList="getList"></raw-warehouse-dialog>
 
  </div>
</template>
 
<script setup>
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
const router = useRouter()
const route = useRoute()
import rawWarehouseDialog from './rawWarehouseRecord.vue'
import {
  delRawRecord,
  doEntryRaw,
  getRawList,
  getRawRecord,
  getRawWarehouseRecord
} from "@/api/hazardousChemicals/rawRecord";
import {useRoute, useRouter} from "vue-router";
const { proxy } = getCurrentInstance();
const loading = ref(false);
const dialogRef = ref();
const codeRef = ref();
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    params :{
      name: '',
      productSn: ''
    }
  },
  total: 0,
  dataList: []
});
 
const selectValue = ref([])
const { queryParams, total, dataList } = toRefs(data);
const classHourRef = ref();
onMounted(()=>{
  if(route.query.val){
    const val = JSON.parse(route.query.val)
    if(val){
      data.queryParams.pageNum = val.pageNum;
      data.queryParams.pageSize = val.pageSize;
    }
  }
  getList()
})
 
const getList = async () => {
  loading.value = true
  const res = await getRawList(data.queryParams)
  if(res.code == 200){
    data.dataList = res.data.list
    data.total = res.data.total
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
 
const openDialog = (type, value) => {
  dialogRef.value.openDialog(type, value);
}
 
/** 重置新增的表单以及其他数据  */
function reset() {
  data.queryParams = {
    pageNum: 1,
    pageSize: 10,
    params :{
      name: '',
      productSn: ''
    }
  }
  getList()
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delRawRecord(val.id)
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
 
const toDetail = (val) => {
  const obj = {
    pageNum: data.queryParams.pageNum,
    pageSize: data.queryParams.pageSize,
    basicId: val.basicId,
    warehouseId: val.warehouseId
  }
  const v = JSON.stringify(obj)
  router.push({ path: "/rawDetail", query: { val: v } });
}
 
const getProRecord = (val) => {
  dialogRef.value.openDialog(val)
}
 
const cellStyle = ({ row, column,rowIndex, columnIndex }) => {
  let arr = []
  if (data.dataList !== null) {
    data.dataList.filter((item, index) => {
      arr.push(item.basicId)
    })
  }
  for (var i = 0; i <= arr.length; i++) {
    if (arr[i] === row.basicId) {
      if(row.stock + row.missStock < row.hazmatBasic.safeNum){
        if (columnIndex === 8 || columnIndex === 9){
          return { backgroundColor: '#FFD7CC !important',color:' red' }
        }
      }
    }
  }
};
 
defineExpose({
  getList
});
 
</script>