石广澎
2023-12-12 122f6d1db1e0af5ede6f96cd390f393e5f222e99
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<template>
  <div class="content">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card shadow="never">
          <div slot="header" class="clearfix">
            <span class="font-18 font-bold">调拨待办</span>
          </div>
          <div class="f-r f-r-between m-b-10">
            <el-radio-group @change="changeAudit" v-model="waitType" size="mini">
              <el-radio-button label="0">待出库</el-radio-button>
              <el-radio-button label="1">待入库</el-radio-button>
            </el-radio-group>
            <div class="to-more" @click="nav('/stock/transfer/transferissue')">查看更多 ></div>
          </div>
          <el-table v-loading="waitLoading" :data="waitWorkData" class="top-tb" height="220" :show-header="false"
                    size="medium">
            <el-table-column prop="businessFormCode" align="center" width="130"></el-table-column>
            <el-table-column prop="inWarehouseName" align="left" min-width="130">
              <template slot-scope="{row}">
                <el-tooltip class="item" effect="dark" :content="row.inWarehouseName " placement="top-start">
                  <div class="font-14 color-333"
                       style="width: 100%;white-space:nowrap;text-overflow: ellipsis;overflow: hidden">
                    {{ row.inWarehouseName }}
                  </div>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column prop="operatorName" align="center" width="80"></el-table-column>
            <el-table-column prop="createTime" align="center" width="160">
              <template slot-scope="scope">
                <span class="font-14 color-333">{{ formattTime(scope.row.createTime) }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="date" label="操作" fixed="right" align="center" width="80">
              <template slot-scope="scope">
                <el-button style="padding: 4px 15px" @click.native.prevent="aduitThis(scope.row)" size="mini" type="primary">处理</el-button>
              </template>
            </el-table-column>
            <el-empty slot="empty" description="暂无数据"></el-empty>
          </el-table>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card shadow="never">
          <div slot="header" class="clearfix">
            <span class="font-18 font-bold">预警通知</span>
          </div>
          <div class="f-r f-r-between m-b-10">
            <el-radio-group size="mini" v-model="earlyWarningType" @change="changeEarlyWarning">
              <el-radio-button label="">全部</el-radio-button>
              <el-radio-button label="2">缺货 <span v-if="warningTypeNum.lowNum">({{warningTypeNum.lowNum}})</span></el-radio-button>
              <el-radio-button label="1">超出 <span v-if="warningTypeNum.upNum">({{warningTypeNum.upNum}})</span></el-radio-button>
            </el-radio-group>
            <div class="to-more" @click="nav('/stock/ledger/alertQuery')">查看更多 ></div>
          </div>
          <el-table v-loading="earlyLoading" :data="earlyWarningData" class="top-tb" height="220" :show-header="false"
                    size="medium">
            <el-table-column prop="baseGoodsTemplateName" align="left" min-width="130">
              <template slot-scope="{row}">
                <el-tooltip class="item" effect="dark" :content="row.baseGoodsTemplateName " placement="top-start">
                  <div class="font-14 color-333"
                       style="width: 100%;white-space:nowrap;text-overflow: ellipsis;overflow: hidden">
                    {{ row.baseGoodsTemplateName }}
                  </div>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column prop="baseGoodsModelsName" align="left" min-width="130">
              <template slot-scope="{row}">
                <el-tooltip class="item" effect="dark" :content="row.baseGoodsModelsName " placement="top-start">
                  <div class="font-14 color-333"
                       style="width: 100%;white-space:nowrap;text-overflow: ellipsis;overflow: hidden">
                    {{ row.baseGoodsModelsName }}
                  </div>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column prop="surplus" align="left" min-width="130">
              <template slot-scope="{row}">
                <span class="font-14 color-333">剩余{{ row.warehouseCount }}{{ row.unit }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="warningTime" align="center" width="160">
              <template slot-scope="{row}">
                <span class="font-14 color-333">{{ formattTime(row.warningTime) }}</span>
              </template>
            </el-table-column>
            <el-empty slot="empty" description="暂无数据"></el-empty>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
    <!-- 中间统计部分-->
    <div class="f-r f-r-between total-list">
      <div class="total-item">
        <div class="font-14 color-666">物品数量</div>
        <div class="font-14 color-333" style="margin-top:6px;"><span
            class="total-num">{{ goodsNumPrice.totalNum }}</span></div>
      </div>
      <div class="total-item">
        <div class="font-14 color-666">资产总金额</div>
        <div class="font-14 color-333" style="margin-top:6px;"><span
            class="total-num">{{ goodsNumPrice.totalPrice }}</span>万元
        </div>
      </div>
      <div class="total-item">
        <div class="font-14 color-666">物品占用率</div>
        <div class="font-14 color-333" style="margin-top:6px;"><span
            class="total-num">{{ goodsNumPrice.zhanYouPercent }}%</span></div>
      </div>
      <div class="total-item">
        <div class="font-14 color-666">A类物品数量</div>
        <div class="font-14 color-333" style="margin-top:6px;"><span
            class="total-num">{{ goodsNumPrice.aTotalNum }}</span></div>
      </div>
      <div class="total-item">
        <div class="font-14 color-666">B类物品数量</div>
        <div class="font-14 color-333" style="margin-top:6px;"><span
            class="total-num">{{ goodsNumPrice.bTotalNum }}</span></div>
      </div>
    </div>
    <!-- 类别金额统计/类别数量统计 -->
    <el-row :gutter="20">
      <el-col :span="12">
        <LBSLTJ :num="goodsNumPrice"></LBSLTJ>
      </el-col>
      <el-col :span="12">
        <LBJETJ :num="goodsNumPrice"></LBJETJ>
      </el-col>
    </el-row>
    <!--  资产增长/报废统计图(数量)-->
    <XYZC></XYZC>
  </div>
</template>
 
<script>
import listPage from '@/views/mixins/listPage';
import {getGoodsNumPrice} from '@/api/dashboard'
// 创建Context
import {LongToDateTime} from "@/utils/DateFormatter";
import {transfeIncome, transferList, transferOutput} from "@/api/stock/transfer";
import {getWarningTypeNum, geWarningList} from '@/api/stock/ledger'
 
const ComponentContext = require.context('./components', false, /\.vue$/i);
let res_components = {};
// 生成待待注册组件集合
ComponentContext.keys().forEach((componentFilePath) => {
  let comp = ComponentContext(componentFilePath);
  res_components[componentFilePath.replace(/^\.\/(.*)\.\w+$/, '$1')] = comp.default;
});
export default {
  name: 'Dashboard',
  components: {...res_components},
  mixins: [listPage],
  data() {
    return {
      earlyLoading: false,
      waitLoading: false,
      goodsNumPrice: {
        aTotalNum: 0,
        aTotalPrice: 0,
        bTotalNum: 0,
        bTotalPrice: 0,
        cTotalNum: 0,
        cTotalPrice: 0,
        tenantId: 0,
        totalNum: 0,
        totalPrice: 0,
        xiaFaNum: 0,
        zhanYouPercent: 0,
      },
      waitType: '0',
      waitWorkData: [], // 待办工作
      earlyWarningType: '',
      warningTypeNum: {
        lowNum: 0,
        totalNum: 0,
        upNum: 0,
      },
      earlyWarningData: [] // 预警通知
    };
  },
  created() {
    this.getAuditList()
    this.getWarningList()
    getGoodsNumPrice().then(res => {
      if(res){
        this.goodsNumPrice = res
      }
 
    })
  },
  methods: {
    // 格式化时间
    formattTime(time) {
      return LongToDateTime(time)
    },
    changeAudit(e) {
      this.waitType = e
      this.$nextTick(() => {
        this.getAuditList()
      })
    },
    // 获取预警通知列表数据
    getAuditList() {
      this.waitLoading = true
      this.waitWorkData = []
      let params = {
        pageNum: 1,
        pageSize: 5,
      }
      if (this.waitType === '0') {
        params.outAgencyId = this.userInfo.tenantId
        params.states = 0
      } else {
        params.inAgencyId = this.userInfo.tenantId
        params.states = 1
      }
      transferList(params).then((res) => {
        this.waitLoading = false
        this.waitWorkData = res.datas;
      }).catch(() => {
        this.waitLoading = false
      });
    },
    aduitThis(row) {
      if (this.waitType === '0') {
        this.handleOutput(row)
      } else {
        this.handleIncome(row)
      }
    },
    // 入库
    handleIncome(row) {
      this.$confirm(`您确定 单号:${row.businessFormCode}  接收入库吗?`, '接收入库', {
        beforeClose: (action, instance, done) => {
          if (action == 'confirm') {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = '执行中...';
            transfeIncome({id: row.id})
                .then((res) => {
                  this.$message.success('接收入库成功!');
                  done();
                  instance.confirmButtonLoading = false;
                  this.search(1);
                })
                .catch(() => {
                  done();
                });
          } else {
            done();
          }
        },
      });
    },
    //出库
    handleOutput(row) {
      this.$confirm(`您确定 单号:${row.businessFormCode}  调拨出库吗?`, '调拨出库', {
        beforeClose: (action, instance, done) => {
          if (action == 'confirm') {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = '执行中...';
            transferOutput({id: row.id})
                .then((res) => {
                  this.$message.success('调拨出库成功!');
                  done();
                  instance.confirmButtonLoading = false;
                  this.search(1);
                })
                .catch(() => {
                  done();
                });
          } else {
            done();
          }
        },
      });
    },
    // 切换预警通知
    changeEarlyWarning(e) {
      this.earlyWarningType = e
      this.$nextTick(() => {
        this.getWarningList()
      })
    },
    // 获取预警通知列表数据
    getWarningList() {
      this.earlyLoading = true
      this.earlyWarningData = []
      getWarningTypeNum().then(res => {
        this.warningTypeNum = res
        geWarningList({
          warningType: this.earlyWarningType,
          pageNum: 1,
          pageSize: 5,
        }).then(res => {
          this.earlyLoading = false
          this.earlyWarningData = res.datas;
        }).catch(() => {
          this.waitLoading = false
        });
      })
 
    },
    //  跳转
    nav(url) {
      this.$router.push(url)
    }
  }
 
};
</script>
<style lang="scss" scoped>
.content {
  padding: 10px
}
 
.to-more {
  font-size: 14px;
  color: #0d997c;
  cursor: pointer;
}
 
.m-b-10 {
  margin-bottom: 10px;
}
 
.top-tb {
  width: 100%;
}
 
.total-list {
  padding: 15px 0;
}
 
.total-item {
  width: 19%;
  padding: 12px 20px;
  border-radius: 4px;
  margin-right: 1%;
  background-color: #FFFFFF;
  border-left: 4px solid #fb6260;
}
 
.total-item:last-child {
  margin: 0;
}
 
.total-num {
  font-size: 24px;
  font-weight: bold;
  margin-right: 3px;
}
</style>