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
<template>
  <j-modal title="预览(仅可预览已完成工单)" :width="948" :visible="visible" switchFullscreen centered
           :mask-closable="false" @cancel="handleCancel" cancelText="关闭">
    <a-spin :spinning="spinning" style="height: 100%">
      <div id="dataTable">
        <div v-for="dataItem in dataSource" class="table-container">
          <div style="page-break-before:always"></div>
 
          <table class="import-table" :id="dataItem.equipmentCode">
            <thead>
            <tr>
              <td colspan="6" style="border: none">
                <div style="text-align: right">{{dataItem.hfCode}}</div>
              </td>
            </tr>
            </thead>
 
            <tbody>
            <tr style="height: 48px;">
              <th colspan="6" style="border: none;font-size: 20px">设备事故登记表</th>
            </tr>
 
            <tr>
              <td>生产单位</td>
              <td>{{dataItem.factoryName}}</td>
              <td>事故发生时间</td>
              <td>{{dataItem.faultStartTime}}</td>
              <td>操作工</td>
              <td>{{dataItem.confirmer_dictText}}</td>
            </tr>
 
            <tr>
              <td>统一编号</td>
              <td>{{dataItem.equipmentCode}}</td>
              <td>设备名称</td>
              <td>{{dataItem.equipmentName}}</td>
              <td>设备型号</td>
              <td>{{dataItem.equipmentModel}}</td>
            </tr>
 
            <tr>
              <td>废品件号</td>
              <td>{{dataItem.scrapPartNumber}}</td>
              <td>废品件数</td>
              <td>{{dataItem.scrapPartQuantity}}</td>
              <td>废品价值</td>
              <td>{{dataItem.scrapPartValue}}</td>
            </tr>
 
            <tr>
              <td colspan="6" style="padding: 5px">
                <div style="text-align: left">操作者填写事故发生经过:</div>
                <div style="text-align: left">1.是否有设备操作证:{{+dataItem.operationCertificate===1?'有(√)无()':'有()无(√)'}}
                </div>
                <div style="text-align: left">2.事故发生后设备是否断电重启:{{+dataItem.powerOffRestart===1?'是(√)否()':'是()否(√)'}}
                </div>
                <div style="text-align: left">3.加工零件是否为批次首件:{{+dataItem.batchFirstPiece===1?'是(√)否()':'是()否(√)'}}</div>
                <div style="text-align: left">
                  4.加工过程中的变动因素(填写是或否):刀具更换({{setValueYesOrNot(dataItem,'tool_replacement')}})工艺更改({{setValueYesOrNot(dataItem,'process_change')}})加工程序更改({{setValueYesOrNot(dataItem,'processing_program_update')}})刀具补偿值更改({{setValueYesOrNot(dataItem,'tool_compensation_adjustment')}})零点偏置值更改({{setValueYesOrNot(dataItem,'zero_point_offset_value_change')}})参数修改({{setValueYesOrNot(dataItem,'parameter_modification')}})其他因素({{setValueYesOrNot(dataItem,'other_factors')}})
                </div>
                <br/>
                <div style="text-align: left">具体更改内容:</div>
                <div style="text-align: left">5.发生事故时所执行的程序:{{dataItem.executeNc}}</div>
                <div style="text-align: left">6.设备发生事故时的现象:</div>
                <div style="text-align: left" v-html="dataItem.accidentPhenomenon.replace(/\n/g,'<br/>')"></div>
                <br/>
                <div style="text-align: left">7.操作工采取了哪些措施(按顺序填写):</div>
                <div style="text-align: left" v-html="dataItem.measure.replace(/\n/g,'<br/>')"></div>
                <div style="text-align: left">8.事故所造成的结果:</div>
                <div style="text-align: left" v-html="dataItem.causingResults.replace(/\n/g,'<br/>')"></div>
                <br/>
                <div style="text-align: right">操作工:{{dataItem.confirmer_dictText}}</div>
                <div style="text-align: right">{{dataItem.confirmTime.split('-')[0]}}&nbsp;年&nbsp;{{dataItem.confirmTime.split('-')[1]}}&nbsp;月&nbsp;{{dataItem.confirmTime.split('-')[2]}}&nbsp;日</div>
              </td>
            </tr>
 
            <tr style="height: 35px;">
              <td>区长</td>
              <td colspan="2">{{dataItem.district_dictText}}</td>
              <td>中心主任</td>
              <td colspan="2">{{dataItem.centerDirector_dictText}}</td>
            </tr>
 
            <tr>
              <td colspan="6" style="padding: 5px">
                <div style="text-align: left">维修人员进行事故分析:</div>
                <div style="text-align: left">
                  1.开始检查的时间:{{dataItem.reportStartTime.split('-')[0]}}年{{dataItem.reportStartTime.split('-')[1]}}月{{dataItem.reportStartTime.split('-')[2]}}日
                </div>
                <div style="text-align: left">2.发生事故后设备的状态:{{dataItem.equipmentStatus}}</div>
                <div style="text-align: left">3.维修人员对事故原因的分析:</div>
                <div style="text-align: left" v-html="dataItem.causeAnalysis.replace(/\n/g,'<br/>')"></div>
                <br/>
                <div style="text-align: left">4.检查的结果:{{dataItem.inspectionResults}}</div>
                <div style="text-align: left">5.事故原因分析过程中所采取的相关行为:</div>
                <div style="text-align: left">{{dataItem.takeSteps}}</div>
                <br/>
                <div style="text-align: left">
                  6.建议采取的措施及时间节点:{{dataItem.suggestionTakeStepsTime.split('-')[0]}}年{{dataItem.suggestionTakeStepsTime.split('-')[1]}}月{{dataItem.suggestionTakeStepsTime.split('-')[2]}}日
                </div>
                <div style="text-align: left" v-html="dataItem.suggestionTakeSteps.replace(/\n/g,'<br/>')"></div>
                <br/>
                <div style="text-align: right">维修人员:{{dataItem.repairConfirm_dictText}}</div>
                <div style="text-align: right">{{dataItem.repairConfirmTime.split('-')[0]}}&nbsp;年&nbsp;{{dataItem.repairConfirmTime.split('-')[1]}}&nbsp;月&nbsp;{{dataItem.repairConfirmTime.split('-')[2]}}&nbsp;日</div>
              </td>
            </tr>
 
            <tr style="height: 35px;">
              <td>维修负责人(组长)</td>
              <td colspan="2">{{dataItem.repairGroupLeader_dictText}}</td>
              <td>维修负责人(区长)</td>
              <td colspan="2">{{dataItem.repairDistrict_dictText}}</td>
            </tr>
 
            <tr>
              <td colspan="6" style="padding: 5px">
                <div style="text-align: left">设备技术专家意见:</div>
                <div style="text-align: left">1.事故发生原因分析的核对:{{+dataItem.checkAgree===1?'同意(√)不同意()':'同意()不同意(√)'}}</div>
                <div style="text-align: left">不同意的原因及分析:{{!dataItem.disagreeReason?'无':dataItem.disagreeReason}}</div>
                <br/>
                <div style="text-align: left">2.整改措施:{{dataItem.rectificationMeasures}}</div>
                <br/>
                <div style="text-align: left">3.事故结论:{{dataItem.accidentConclusion}}</div>
                <br/>
                <div style="text-align: right">技术负责人:{{dataItem.technicalDirector_dictText}}</div>
                <div style="text-align: right">{{dataItem.technicalDirectorTime.split('-')[0]}}&nbsp;年&nbsp;{{dataItem.technicalDirectorTime.split('-')[1]}}&nbsp;月&nbsp;{{dataItem.technicalDirectorTime.split('-')[2]}}&nbsp;日</div>
              </td>
            </tr>
 
            <tr style="height: 35px;">
              <td>技术主管室级领导</td>
              <td colspan="2">{{dataItem.technicalDirectorLeader_dictText}}</td>
              <td>主管部级领导</td>
              <td colspan="2">{{dataItem.technicalDirectorPart_dictText}}</td>
            </tr>
 
            <tr>
              <td colspan="6" style="border: none">
                填写说明:如设备事故未造成产品质量问题,则废品件号、废品件数、废品价值栏填写“/”。
              </td>
            </tr>
            </tbody>
          </table>
        </div>
      </div>
    </a-spin>
 
    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
      <a-button type="primary" @click="handleExportToExcel">导出</a-button>
      <a-button type="primary" v-print="'#dataTable'">打印</a-button>
    </template>
  </j-modal>
</template>
 
<script>
  import { getAction } from '@/api/manage'
  import $ from 'jquery'
  import '@/components/table2excel/table2excel'
 
  export default {
    name: 'EamAccidentsRegisterBatchPrintModal',
    data() {
      return {
        visible: false,
        spinning: false,
        dataSource: [],
        url: {
          list: '/eam/eamReportAccidentsRegister/batchExport'
        }
      }
    },
    methods: {
      /**
       * 批量预览
       * @param ids String 主页面列表勾选ids
       */
      handlePreview(ids) {
        this.visible = true
        this.spinning = true
        this.dataSource = []
        const that = this
        getAction(this.url.list, { ids })
          .then(res => {
            if (res.success) that.dataSource = res.result
          })
          .finally(() => {
            that.spinning = false
          })
      },
 
      // 导出到Excel
      handleExportToExcel() {
        document.querySelectorAll('table.import-table').forEach(element => {
          console.log('element', element.id)
          $(element).table2excel({
            exclude: '.noExl',
            name: 'Excel Document Name',
            filename: '设备事故登记表-' + element.id,
            exclude_img: true,
            fileext: '.xls',
            exclude_links: true,
            exclude_inputs: false
          })
        })
      },
 
      /**
       * 设置变动因素值
       * @param dataItem 对应对象
       * @param value 字典值
       * @returns {string} 是/否
       */
      setValueYesOrNot(dataItem, value) {
        return dataItem.variableFactorsValue !== value ? '否' : '是'
      },
 
      handleCancel() {
        this.close()
      },
 
      close() {
        this.$emit('close')
        this.visible = false
        if (this.$refs.form) this.$refs.form.clearValidate()
      }
    }
  }
</script>
 
<style scoped lang="less">
  /deep/ .ant-modal {
    height: 90%;
    overflow: hidden;
 
    .ant-modal-content {
      height: 100%;
      display: flex;
      flex-direction: column;
      overflow: hidden;
 
      ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
      }
 
      .ant-modal-body {
        flex: 1;
        overflow: auto;
      }
    }
  }
 
  .table-container:not(:last-child) {
    margin-bottom: 20px;
  }
 
  table {
    width: 100%;
    text-align: center;
    table-layout: fixed;
 
    td, th {
      border: 1px solid #000;
    }
 
    td.vertical-display {
      writing-mode: vertical-lr;
      letter-spacing: 5px;
      padding: 5px 0;
    }
  }
</style>