charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
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
356
357
358
359
360
361
362
363
364
<template>
  <div class="rightContent">
    <el-dialog
            title="配置初期时间"
            :visible.sync="timeModal"
            width="30%"
            :before-close="handlerClose">
      <el-form style="width: 80%;margin: 20px auto;" ref="sysFormRef">
        <el-form-item label="日期配置:">
          <el-select v-model="startDate.day" style="margin-left: 20px">
            <el-option v-for="day in 28" :value="day.toString().padStart(2,'0')":label="day.toString().padStart(2,'0')"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="时间配置:">
          <el-time-select
                  :picker-options="startPickerOptions"
                  v-model="startDate.time"
                  type="time"
                  format="HH:mm"
                  value-format="HH:mm"
                  :clearable='true'
                  class='margin_left_20px'>
          </el-time-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="timeModal = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="saveStartDate" size="mini">保存</el-button>
      </span>
    </el-dialog>
    <div class="top">
      <SearchCommonView :add-title="'新建'" :showAdd="false" :placeholder="'请输入产品编码/产品名称搜索'" :amount-view="false" :showDownload="true" @downloadClick="downHttpClick"
         @searchClick="getList" >
        <template slot="leftButton">
          <el-date-picker
                    v-model="monthBoundObject.date"
                    value-format="yyyy-MM"
                    format="yyyy-MM"
                    type="month"
                    :clearable='false'
                    class='margin_left_20px'
                    @change='getData'
                    placeholder="选择日期"
                    :picker-options="pickerOptions">
          </el-date-picker>
          <el-button size="mini" @click="timeModal=true" class="el-icon-setting" type="text" style="margin-left: 10px">配置</el-button>
        </template>
      </SearchCommonView>
    </div>
    <div class="list-view">
      <div class="table">
        <TableCommonView ref="tableListRef" :loading="isTableOneLoading" :table-list="tableList" :showCheckcol='false' @selTableCol="selTableCol">
          <template slot="tableButton">
              <el-table-column label="期初库存" prop='inventoryStart'>
                <el-table-column v-for="unit in unitList" :label="unit.name" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.beginMoreUnitsArr,unit.name,scope.row.beginAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <!--<el-table-column label="件" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.beginMoreUnitsArr,'件',scope.row.beginAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="匹" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.beginMoreUnitsArr,'匹',scope.row.beginAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="米数" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.beginMoreUnitsArr,'米数',scope.row.beginAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="重量" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.beginMoreUnitsArr,'重量',scope.row.beginAmount,scope.row.unit)}}
                  </template>
                </el-table-column>-->
              </el-table-column>
              <el-table-column label="本月入库" prop='inInventoryCurrentMonth'>
                <el-table-column v-for="unit in unitList" :label="unit.name" prop='inInventoryCurrentMonth' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.inputMoreUnitsArr,unit.name,scope.row.inputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <!--<el-table-column label="件" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.inputMoreUnitsArr,'件',scope.row.inputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="匹" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.inputMoreUnitsArr,'匹',scope.row.inputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="米数" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.inputMoreUnitsArr,'米数',scope.row.inputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="重量" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.inputMoreUnitsArr,'重量',scope.row.inputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>-->
              </el-table-column>
              <el-table-column label="本月出库" prop='outInventoryCurrentMonth'>
                <el-table-column v-for="unit in unitList" :label="unit.name" prop='outInventoryCurrentMonth' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.outputMoreUnitsArr,unit.name,scope.row.outputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <!--<el-table-column label="件" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.outputMoreUnitsArr,'件',scope.row.outputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="匹" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.outputMoreUnitsArr,'匹',scope.row.outputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="米数" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.outputMoreUnitsArr,'米数',scope.row.outputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="重量" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.outputMoreUnitsArr,'重量',scope.row.outputAmount,scope.row.unit)}}
                  </template>
                </el-table-column>-->
              </el-table-column>
              <el-table-column label="期末库存" prop='inventoryEnd'>
                <el-table-column v-for="unit in unitList" :label="unit.name" prop='inventoryEnd' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.MoreUnitsArr,unit.name,scope.row.amount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <!--<el-table-column label="件" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.MoreUnitsArr,'件',scope.row.amount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="匹" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.MoreUnitsArr,'匹',scope.row.amount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="米数" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.MoreUnitsArr,'米数',scope.row.amount,scope.row.unit)}}
                  </template>
                </el-table-column>
                <el-table-column label="重量" prop='inventoryStart' min="90">
                  <template slot-scope="scope">
                    {{getUnitValue(scope.row.MoreUnitsArr,'重量',scope.row.amount,scope.row.unit)}}
                  </template>
                </el-table-column>-->
              </el-table-column>
            </template>
        </TableCommonView>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
    </div>
    </div>
</template>
 
<script>
 
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getmonthStats ,getSystemConfigApi,saveSystemConfigApi} from "@/api/reportForm/inventoryRwport"
import newDate from "@/api/date";
import { downloadMonthStats } from "@/api/downFile"
import FileSaver from 'file-saver'
import _ from 'lodash'
const { getPreviousMonth,formatTime,getCurrentMonth} = newDate;
import {getUnitInfo} from "@/api/basic/standard";
 
export default {
  name: "outboundDetail",
  props: {},
  components: {  },
  mixins: [pageMixin],
  computed: {},
  data() {
    return {
        unitList:[],
        systemParams:{
            ID:0,
            configType:1,
            name:'',
        },
        startDate:{
            day:'01',
            time:'00:00'
        },
        timeModal:false,
      monthBoundObject:{
        keyWord:'',
        date:getCurrentMonth(),
      },
        startPickerOptions:{
            start:'00:00',
            step:'00:30',
            end:'23:59'
        },
      tableList: {},
      showcol: [],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > formatTime(getCurrentMonth());
        },
      },
      isTableOneLoading: false,
    }
  },
  created() {
    this.setTable();
    this.getData();
    this.querySystemConfig();
      this.getUnitInfo();
  },
  methods: {
      async getUnitInfo(){
          const { code,data }=await getUnitInfo();
          if(code===200){
              this.unitList=data;
          }
      },
      async querySystemConfig(){
          const params={configType:1};
          const {code,data}=await getSystemConfigApi(params);
          if(code===200){
              if(data.val){
                  this.systemParams.ID=data.id;
                  this.systemParams.name=data.name;
                  this.startDate.day=data.val.split("-")[0];
                  this.startDate.time=data.val.split("-")[1];
                  //this.monthBoundObject.date=this.$moment(this.monthBoundObject.date).format('yyyy-MM')+'-'+this.startDate.day
              }
          }
      },
      handlerClose(){
        this.timeModal=false;
        this.$refs.sysFormRef.resetFields();
      },
      async saveStartDate(){
        const params={...this.systemParams,val:this.startDate.day+'-'+this.startDate.time};
        const {code} =await saveSystemConfigApi(params);
        if(code===200){
            this.$message.success('配置成功');
            this.querySystemConfig();
            this.timeModal=false;
        }else{
            this.$message.error('配置失败');
        }
      },
     // 下载
     downHttpClick: _.debounce(function(){
      downloadMonthStats({
          date:this.monthBoundObject.date,
          keyword: this.monthBoundObject.keyWord,
          page: this.pagerOptions.currPage,
          pageSize: this.pagerOptions.pageSize
      }).then(res => {
        if (res) {
          FileSaver.saveAs(res, '月度统计报表.xlsx');
          this.$message.success("下载成功!");
        }
      })
    }, 1000),
    getUnitValue(list,val,num,unit){
      let  string='--'
      if(list){
        if(list.length>0){
          for(let i in list){
            if(list[i].unit==val){
              string=list[i].amount
              break;
            }
          }
        }
      }
      if(unit==val){
        string=num
      }
      return string
    },
    setTable() {
      this.tableList = {
        tableInfomation: [],
        selectBox: false,
        selectIndex:true,
        showcol: this.showcol,
        allcol: [],
        tableColumn: this.setTableColumn(this.showcol)
      };
      let allcol = [];
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        if (!this.tableList.tableColumn[i].default) {
          const label = this.tableList.tableColumn[i].label
          allcol.push(label)
        }
      }
      this.tableList.allcol = allcol
    },
    setTableColumn() {
      let tableColumn = [
        {
          label: "产品编码",
          prop: "productId",
          min:110,
          isShowColumn: true,
          default: true
        },
        {
          label: "产品名称",
          prop: "productName",
          min:110,
          isShowColumn: true,
          default: true
        },
      ];
      return tableColumn
    },
    selTableCol(val) {
      this.showcol = val;
      this.tableList.tableColumn = this.setTableColumn(val)
    },
    // 库存报表跳转请求数据
    async getData() {
      this.isTableOneLoading = true;
      //this.monthBoundObject.date=this.$moment(this.monthBoundObject.date).format('yyyy-MM')+'-'+this.startDate.day;
        await getmonthStats({
          date:this.monthBoundObject.date,
          keyword: this.monthBoundObject.keyWord,
          page: this.pagerOptions.currPage,
          pageSize: this.pagerOptions.pageSize
        }).then((res) => {
          if (res.code == 200&&res.data) {
            this.tableList.tableInfomation = res.data||[]
          }else{
            this.tableList.tableInfomation = res.data||[]
          }
          this.pagerOptions.totalCount = res.total
          this.isTableOneLoading = false;
        })
      
    },
    // 搜索
    getList(val) {
      this.monthBoundObject.keyWord = val;
      this.getData()
    },
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped></style>