zhaowei
2 天以前 80a8050560fdd4cc18aee57c3ed176a9019dec2a
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
<template>
  <j-modal :title="title" :width="1200" :visible="visible" :confirmLoading="confirmLoading" @ok="handleOk"
           @cancel="handleCancel" cancelText="关闭" centered>
    <a-spin :spinning="spinning">
      <a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
        <a-row>
          <a-col :span="customSpan">
            <a-form-model-item label="维修开始时间" prop="actualStartTime" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-date-picker show-time v-model="model.actualStartTime" :allowClear="false"
                             value-format="YYYY-MM-DD HH:mm:ss"
                             style="width:100%"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="customSpan">
            <a-form-model-item label="维修结束时间" prop="actualEndTime" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-date-picker show-time v-model="model.actualEndTime" :allowClear="false"
                             value-format="YYYY-MM-DD HH:mm:ss"
                             style="width:100%"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="customSpan">
            <a-form-model-item label="故障原因">
              <a-textarea placeholder="请输入故障原因" v-model="model.faultReason"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="customSpan">
            <a-form-model-item label="故障分析">
              <a-textarea placeholder="请输入故障分析" v-model="model.faultAnalysis"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="customSpan">
            <a-form-model-item label="排故过程">
              <a-textarea placeholder="请输入排故过程" v-model="model.faultProcess"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="customSpan">
            <a-form-model-item label="预防措施">
              <a-textarea placeholder="请输入预防措施" v-model="model.faultPrevent"/>
            </a-form-model-item>
          </a-col>
        </a-row>
 
        <j-vxe-table ref="editableDetailTable" rowNumber rowSelection bordered alwaysEdit toolbar
                     :toolbarConfig="detail.toolbarConfig" keep-source :height="300"
                     :dataSource="detail.dataSource" :columns="detail.columns">
 
        </j-vxe-table>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>
 
<script>
  import { postAction, getAction } from '@/api/manage'
  import LxSearchEquipmentSelect from '@views/eam/equipment/modules/LxSearchEquipmentSelect.vue'
  import { JVXETypes } from '@comp/jeecg/JVxeTable'
 
  export default {
    name: 'EamRepairOrderModal',
    components: { LxSearchEquipmentSelect },
    data() {
      return {
        title: '操作',
        visible: false,
        model: {},
        customSpan: 12,
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        confirmLoading: false,
        spinning: false,
        validatorRules: {
          actualStartTime: [{ required: true, message: '请选择维修开始时间', trigger: 'change' }],
          actualEndTime: [{ required: true, message: '请选择维修结束时间', trigger: 'change' }]
        },
        detail: {
          dataSource: [],
          columns: [
            {
              title: 'ID',
              key: 'id',
              type: JVXETypes.hidden
            },
            {
              title: '维修人',
              key: 'repairUser',
              align: 'center',
              placeholder: '请输入${title}',
              type: JVXETypes.input,
              validateRules: [{ required: true, message: '请输入${title}' }]
            },
            {
              title: '是否是主维修人',
              key: 'repairPrimary',
              align: 'center',
              type: JVXETypes.select,
              placeholder: '请选择${title}',
              dictCode: 'yn',
              validateRules: [{ required: true, message: '请选择${title}' }]
            },
            {
              title: '维修时长',
              key: 'repairDuration',
              align: 'center',
              placeholder: '请输入${title}',
              type: JVXETypes.inputNumber,
              validateRules: [{ required: true, message: '请输入${title}' }]
            },
            {
              title: '备注',
              key: 'remark',
              align: 'center',
              type: JVXETypes.textarea,
              placeholder: '请输入${title}'
            }
          ],
          toolbarConfig: {
            // prefix 前缀;suffix 后缀
            slot: ['prefix', 'suffix'],
            // add 新增按钮;remove 删除按钮;clearSelection 清空选择按钮
            btn: ['add', 'remove', 'clearSelection']
          }
        },
        url: {
          report: '/eam/eamRepairOrder/report',
          detail: '/eam/eamRepairPerson/list'
        }
      }
    },
    methods: {
      handleFillIn(record) {
        this.visible = true
        this.model = Object.assign({}, record)
        this.getRepairDetailByApi(record.id)
      },
 
      getRepairDetailByApi(repairId) {
        this.spinning = true
        this.detail.dataSource = []
        getAction(this.url.detail, { repairId })
          .then(res => {
            if (res.success) this.detail.dataSource = res.result
          })
          .finally(() => {
            this.spinning = false
          })
      },
 
      async handleOk() {
        const errMap = await this.$refs.editableDetailTable.validateTable()
        if (errMap) return
 
        const that = this
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = that.spinning = true
 
            that.model.eamRepairPersonList = that.$refs.editableDetailTable.getTableData()
 
            postAction(that.url.report, that.model)
              .then((res) => {
                if (res.success) {
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                  that.$emit('ok')
                  that.close()
                } else {
                  that.$notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                that.confirmLoading = that.spinning = false
              })
          } else {
            return false
          }
        })
      },
 
      close() {
        this.$emit('close')
        this.visible = false
        if (this.$refs.form) this.$refs.form.clearValidate()
      },
 
      handleCancel() {
        this.close()
      }
    }
  }
</script>