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
<template>
  <a-modal title="计算OEE" :visible="visible" :width="550" @cancel="handleModalClose" @ok="handleComputeOee"
           :maskClosable="false">
    <a-form-model :model="model" :labelCol="labelColLong" :wrapperCol="wrapperColLong">
      <a-row>
        <a-col :span="24">
          <a-form-model-item label="日期">
            <a-range-picker v-model="dates" style="width: 100%" value-format="YYYY-MM-DD"
                            @change="dateParamChange"></a-range-picker>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
  </a-modal>
</template>
 
<script>
  import mdcApi from '@/api/mdc'
 
  export default {
    name: 'ComputeOeeModal',
    components: {},
    data() {
      return {
        visible: false,
        model: {},
        dates: [],
        labelColLong: {
          xs: { span: 24 },
          sm: { span: 3 }
        },
        wrapperColLong: {
          xs: { span: 24 },
          sm: { span: 21 }
        }
      }
    },
    methods: {
      handleComputeOee() {
        console.log('model', this.model)
        if (this.dates.length === 0) {
          this.$notification.warning({
            message: '消息',
            description: '请选择时间'
          })
          return
        }
 
        mdcApi.computeOeeApi(this.model)
          .then(res => {
            if (res.success) {
              this.$notification.success({
                message: '消息',
                description: res.message
              })
              this.visible = false
            } else {
              this.$notification.error({
                message: '消息',
                description: '计算失败'
              })
            }
          })
          .catch(err => {
            this.$notification.error({
              message: '消息',
              description: '计算失败'
            })
          })
      },
 
      dateParamChange(value1, value2) {
        this.model.startTime = value2[0]
        this.model.endTime = value2[1]
      },
 
      handleModalClose() {
        this.visible = false
        this.model = {}
        this.dates = []
      }
    }
  }
</script>
 
<style scoped>
 
</style>