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
<template>
  <a-modal title="计算MTBF" :visible="visible" :width="400" @cancel="handleModalClose" @ok="handleComputeMTBF"
           :maskClosable="false">
    <a-form-model ref="form" :model="model" :labelCol="labelColLong" :wrapperCol="wrapperColLong" :rules="validateRules">
      <a-row>
        <a-col :span="24">
          <a-form-model-item label="月份" prop="month">
            <a-month-picker v-model="model.month" style="width: 100%" value-format="YYYY-MM"
                            placeholder="请选择月份"></a-month-picker>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
  </a-modal>
</template>
 
<script>
  import mdcApi from '@/api/mdc'
 
  export default {
    name: 'ComputeEquipmentFailureCloseTimeModal',
    components: {},
    data() {
      return {
        visible: false,
        model: {},
        validateRules: {
          month: [
            { required: true, message: '请选择月份!' }
          ]
        },
        labelColLong: {
          xs: { span: 24 },
          sm: { span: 4 }
        },
        wrapperColLong: {
          xs: { span: 24 },
          sm: { span: 20 }
        }
      }
    },
    methods: {
      handleComputeMTBF() {
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            mdcApi.computeMTBFApi(this.model)
              .then(res => {
                if (res.success) {
                  this.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                  this.handleModalClose()
                } else {
                  this.$notification.error({
                    message: '消息',
                    description: '计算失败'
                  })
                }
              })
              .catch(err => {
                this.$notification.error({
                  message: '消息',
                  description: '计算失败'
                })
              })
          }
        })
 
      },
 
      handleModalClose() {
        this.visible = false
        this.model = {}
      }
    }
  }
</script>
 
<style scoped>
 
</style>