schangxiang@126.com
2024-11-21 60735779c303c2dd10feea45d7fd761103b225e0
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<template>
  <div>
      <el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
        <el-form :model="formModel" ref="queryForm" labelWidth="90">
          <el-row>
            <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
            <el-form-item label="关键字">
              <el-input v-model="formModel.searchKey" clearable=""
                placeholder="库位编号,容器编号" />
            </el-form-item>
          </el-col>
 
          <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUIWmsStockQuan">
                        <el-form-item label="所在库区" prop="areaCode">
                            <el-select v-model="formModel.areaCode" placeholder="请选择所在库区">
                                <el-option v-for="(item,index) in arr1"  :key="index" :value="item.code" :label="`[${item.code}] ${item.value}`"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col> 
            <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUIWmsStockQuan">
              <el-form-item label="库位编号:">
                <el-input v-model.trim="formModel.WareLocationCode" placeholder="请输入库位编号" clearable></el-input>
              </el-form-item>
            </el-col>
 
            <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10" v-if="showAdvanceQueryUIWmsStockQuan">
              <el-form-item label="容器编号:">
                <el-input v-model.trim="formModel.WareContainerCode" placeholder="请输入容器编号" clearable></el-input>
              </el-form-item>
            </el-col>
      
            <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
              <el-form-item label="库位状态:">
                <el-select v-model="formModel.inventoryType" clearable placeholder="请选择库位状态"  style="width: 100%;">
                  <el-option v-for="item in storageStatusEnum" :key="item.value" :label="item.title"
                    :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
 
            <!-- 隐藏的筛选条件 -->
            <!-- <template>
              <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
                <el-form-item label="锁定状态:">
                  <el-select v-model="formModel.isLocked" clearable placeholder="请选择锁定状态">
                    <el-option v-for="item in isAutoEnum" :key="item.value" :label="item.title" :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
 
                <el-form-item label="巷道:">
                  <el-select v-model="formModel.Lane" clearable placeholder="请选择巷道">
                    <el-option v-for="item in LangEnum" :key="item.value" :label="item.title" :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
                <el-form-item label="所属排:">
                  <el-select v-model="formModel.Row" clearable placeholder="请选择所属排">
                    <el-option v-for="(item, index) in strorageRowEnum" :key="item" :label="`第${index + 1}排`"
                      :value="index + 1" />
                  </el-select>
                </el-form-item>
              </el-col>
            </template> -->
            <!-- <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="4" class="mb10">
              <el-form-item label-width="20px">
                <el-button type="primary" icon="el-icon-search" @click="getLocationPage(2)">查询</el-button>
                <el-button icon="ele-Refresh" @click="() => formModel = {}"> 重置 </el-button>
              </el-form-item>
            </el-col> -->
 
 
            <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6" class="mb10">
            <el-form-item>
              <el-button-group style="display: flex; align-items: center">
                <el-button type="primary" icon="ele-Search" @click="getLocationPage(2)">
                  查询
                </el-button>
                <el-button icon="ele-Refresh" @click="() => formModel = {}">
                  重置
                </el-button>
                <el-button icon="ele-ZoomIn" @click="changeAdvanceQueryUIWmsStockQuan"
                  v-if="!showAdvanceQueryUIWmsStockQuan" style="margin-left: 5px">
                  高级查询
                </el-button>
                <el-button icon="ele-ZoomOut" @click="changeAdvanceQueryUIWmsStockQuan"
                  v-if="showAdvanceQueryUIWmsStockQuan" style="margin-left: 5px">
                  隐藏
                </el-button>
               
              </el-button-group>
            </el-form-item>
          </el-col>
 
          </el-row>
 
        </el-form>
      </el-card>
 
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
  <div class="msi-content" style="height:calc(100vh - 200px)">
      <!-- 统计区域 -->
      <count-view :countData="countList"></count-view>
      <!-- 库位展示 -->
      <content-view :contentData="dataList"></content-view>
    </div>
</el-card>
   
  </div>
</template>
<script lang="ts" setup>
import { nextTick, onMounted, ref } from 'vue'
//import SearchBar from '@/components/SearchBar.vue'
import { getStorageView } from '/@/api/main/ReportCenter/storageView';
 
import CountView from './component/CountView.vue'
import ContentView from './component/ContentView.vue'
import { ElMessage } from 'element-plus';
import { handleSlectDataWmsArea } from '/@/utils/selectData';
 
const showAdvanceQueryUIWmsStockQuan = ref(false);
// 改变高级查询的控件显示状态
const changeAdvanceQueryUIWmsStockQuan = () => {
  showAdvanceQueryUIWmsStockQuan.value = !showAdvanceQueryUIWmsStockQuan.value;
};
 
 
const LangEnum = ref([  // 所属巷道
  {
    value: '1',
    title: '1巷道'
  },
  {
    value: '2',
    title: '2巷道'
  },
  {
    value: '3',
    title: '3巷道'
  }
])
const isAutoEnum: any[] = [
  {
    title: '否',
    value: 0
  },
  {
    title: '是',
    value: 1
  }
]
 
 
//库位状态
const storageStatusEnum = ref([
  {
    value: '0',
    title: '空库位'
  },
  {
    value: '1',
    title: '空容器库位'
  },
  {
    value: '2',
    title: '有货库位'
  },
])
 
const strorageRowEnum = ref<any>([]) // 所属排
//列表请求数据
const formModel = ref({
  Lane: '',
  Row: '',
  MaterialCode: '',
  inventoryType: '',
  ShelfCode: '',
  Code: '',
  ContainerCode: '',
  Status: '',
  isLocked: '',
  areaCode:"A2",
  PageNo: 1,
  PageSize: 10000
})
 
//库位列表数据
const dataList = ref([]);
//统计的数据
const countList = ref([
  {
    type: 0,
    title: '空库位:',
    count: 0
  },
  {
    type: 1,
    title: '有货库位(空容器):',
    count: 0
  },
  {
    type: 2,
    title: '有货库位(物料):',
    count: 0
  },
  // {
  //   type: 3,
  //   title: '锁定库位:',
  //   count: 0
  // },
  // {
  //   type: 4,
  //   title: '禁用库位:',
  //   count: 0
  // }
]);
 
// 按照行列相同进行分组
const sortClass = (sortData: any) => {
  const groupBy = (array: any, f: any) => {
    let groups = {};
    array.forEach((o) => {
      let group = JSON.stringify(f(o));
      groups[group] = groups[group] || [];
      groups[group].push(o);
    });
    return Object.keys(groups).map((group) => {
      return groups[group];
    });
  };
  const sorted = groupBy(sortData, (item) => {
    return item.lane + '-' + item.column; // 返回需要分组的对象
  });
  return sorted;
};
 
// 分组前
// console.log(listData);
// 分组后
// console.log(sortClass(listData));
 
//库位图列表
const getLocationPage = async (param?: any) => {
  if (param && param == 2) {
    if (formModel.value.Lane == "" && formModel.value.Row != "") {
      ElMessage.warning("请选择所属巷道!")
      return
    }
  }
 
  if(!formModel.value.areaCode){
    ElMessage.warning("请选择所在库区!")
    return
  }
 
  var res = await getStorageView(Object.assign(formModel.value, {}));
  if (res.data.code == 200) {
    const { data } = res;
    const result = data.result;
    strorageRowEnum.value = new Array(4).fill(0);
    countList.value[0].count = result.emptyLocation || 0;    //空库位
    countList.value[1].count = result.emptyContainerLocation || 0;   //空容器库位
    countList.value[2].count = result.materialLocation || 0;  //有货库位
    // countList.value[3].count = result.lockedLocation || 0; //锁定库位
    // countList.value[4].count = result.disableLocation || 0; //禁用库位
    debugger
    if (res.data.result.lanes) {
      res.data.result.lanes.forEach((element: any) => {
        element.rows.forEach((item: any) => {
          item.rowLocations2 = sortClass(item.rowLocations)
        })
      });
    }
    dataList.value = res.data.result.lanes;
 
  }
 
}
getLocationPage()
 
const resetFormModel = JSON.parse(JSON.stringify(formModel.value));
//重置搜索
const resetForm = () => {
  formModel.value = JSON.parse(JSON.stringify(resetFormModel));
  // getLocationPage()
};
 
let arr1:any =ref("") //下拉读取接口
// 页面加载时
onMounted(async () => {
  nextTick(async () => {
    arr1.value = await handleSlectDataWmsArea({
      page: 1,
            pageSize: 1000,
            total: 0,
            IsDisabled:false,
      isVirtually:false,
      areaType:1 //立体库
    }); //下拉读取接口
  });
});
 
 
</script>
<style lang="less" scoped>
.msi-content {
  overflow: auto;
}
</style>