xyc
3 天以前 53052625c7c520744a4ca061e204ec9594ca67f8
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
<template>
  <div class="page">
    <div class="page-title">
      <div>
        <h2>完工信息上报</h2>
        <p>从完工情况处理页点“完工”进入;提交成功后派工单完工状态写为“完工”,并进入验收申请</p>
      </div>
      <el-button icon="el-icon-back" @click="$router.push('/fault/completion')">返回完工处理</el-button>
    </div>
 
    <div class="toolbar">
      <span>派工单</span>
      <el-select v-model="form.workOrderId" filterable placeholder="请选择派工单" style="width:360px" :disabled="!!routeWorkOrderId" @change="loadSelected">
        <el-option v-for="item in selectableOrders" :key="item.id" :label="item.workOrderNo + ' - ' + item.contractorName" :value="item.id"></el-option>
      </el-select>
      <div class="spacer"></div>
      <el-tag v-if="workOrder" size="small" type="info">{{ workOrder.xNo }} · {{ workOrder.equipmentName }}</el-tag>
    </div>
 
    <el-form ref="form" :model="form" :rules="rules" label-width="120px" class="completion-form">
      <section class="form-section">
        <h3>基础信息</h3>
        <el-row :gutter="16">
          <el-col :span="8"><el-form-item label="X号"><el-input v-model="form.xNo" readonly></el-input></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="承修单位"><el-input v-model="form.contractorName" readonly></el-input></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="工程编号"><el-input v-model="form.engineeringNo"></el-input></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="开工时间"><el-date-picker v-model="form.startDate" type="date" value-format="yyyy-MM-dd" style="width:100%"></el-date-picker></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="完工时间"><el-date-picker v-model="form.finishDate" type="date" value-format="yyyy-MM-dd" style="width:100%"></el-date-picker></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="承修人"><el-input v-model="form.contractorPerson"></el-input></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="T内施工"><el-input v-model="form.tInternalConstruction"></el-input></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="牵连工程"><el-input v-model="form.relatedProject"></el-input></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="完工耗时(天)"><el-input-number v-model="form.durationDays" :min="0" style="width:100%"></el-input-number></el-form-item></el-col>
          <el-col :span="8"><el-form-item label="承修人数"><el-input-number v-model="form.personCount" :min="0" style="width:100%"></el-input-number></el-form-item></el-col>
          <el-col :span="8">
            <el-form-item label="验收方式">
              <el-radio-group v-model="form.acceptanceMode">
                <el-radio-button label="冷态">冷态</el-radio-button>
                <el-radio-button label="热态">热态</el-radio-button>
                <el-radio-button label="海上">海上</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="8"><el-form-item label="项目名称"><el-input v-model="form.itemName"></el-input></el-form-item></el-col>
          <el-col :span="24"><el-form-item label="修后质量情况"><el-input v-model="form.qualityInfo" type="textarea" :rows="3"></el-input></el-form-item></el-col>
          <el-col :span="24"><el-form-item label="故障说明"><el-input v-model="form.faultDescription" type="textarea" :rows="3"></el-input></el-form-item></el-col>
          <el-col :span="24"><el-form-item label="原因分析"><el-input v-model="form.reasonAnalysis" type="textarea" :rows="3"></el-input></el-form-item></el-col>
        </el-row>
      </section>
 
      <section class="form-section">
        <div class="section-head">
          <h3>处理解决情况</h3>
          <el-button icon="el-icon-plus" @click="addSolution">添加一行</el-button>
        </div>
        <el-table :data="form.solutions" border size="small">
          <el-table-column label="序号" type="index" width="60" align="center"></el-table-column>
          <el-table-column label="处理解决情况"><template slot-scope="{ row }"><el-input v-model="row.content"></el-input></template></el-table-column>
          <el-table-column label="操作" width="70"><template slot-scope="{ $index }"><el-button type="text" class="danger-link" @click="form.solutions.splice($index, 1)">删除</el-button></template></el-table-column>
        </el-table>
      </section>
 
      <section class="form-section">
        <div class="section-head">
          <h3>维修器材 / 元器件消耗情况</h3>
          <el-button icon="el-icon-plus" @click="addMaterial">添加一行</el-button>
        </div>
        <el-table :data="form.materials" border size="small">
          <el-table-column label="序号" type="index" width="60" align="center"></el-table-column>
          <el-table-column label="名称" min-width="140"><template slot-scope="{ row }"><el-input v-model="row.name"></el-input></template></el-table-column>
          <el-table-column label="规格型号" min-width="130"><template slot-scope="{ row }"><el-input v-model="row.specification"></el-input></template></el-table-column>
          <el-table-column label="技术参数" min-width="150"><template slot-scope="{ row }"><el-input v-model="row.technicalParameter"></el-input></template></el-table-column>
          <el-table-column label="数量" width="120"><template slot-scope="{ row }"><el-input-number v-model="row.quantity" :min="0" controls-position="right" style="width:100%"></el-input-number></template></el-table-column>
          <el-table-column label="计量单位" width="100"><template slot-scope="{ row }"><el-input v-model="row.unit"></el-input></template></el-table-column>
          <el-table-column label="合格证明" min-width="130"><template slot-scope="{ row }"><el-input v-model="row.certificate"></el-input></template></el-table-column>
          <el-table-column label="出库单号" min-width="140"><template slot-scope="{ row }"><el-input v-model="row.outboundNo"></el-input></template></el-table-column>
          <el-table-column label="来源" width="110"><template slot-scope="{ row }"><el-input v-model="row.source"></el-input></template></el-table-column>
          <el-table-column label="备注" min-width="140"><template slot-scope="{ row }"><el-input v-model="row.remark"></el-input></template></el-table-column>
          <el-table-column label="操作" width="70" fixed="right"><template slot-scope="{ $index }"><el-button type="text" class="danger-link" @click="form.materials.splice($index, 1)">删除</el-button></template></el-table-column>
        </el-table>
      </section>
 
      <div class="submit-bar">
        <el-checkbox v-model="confirmed">已核对完工信息,提交后派工单进入完工验收流程</el-checkbox>
        <el-button type="primary" size="medium" :loading="saving" :disabled="!confirmed" @click="submit">提交完工信息</el-button>
      </div>
    </el-form>
  </div>
</template>
<script>
import api from '@/api'
export default {
  name: 'CompletionReport',
  data() {
    return {
      workOrder: null,
      selectableOrders: [],
      confirmed: false,
      saving: false,
      form: this.blankForm(),
      rules: {}
    }
  },
  computed: {
    routeWorkOrderId() {
      const value = this.$route.query.workOrderId
      return value ? Number(value) : null
    }
  },
  created() {
    if (this.routeWorkOrderId) {
      this.form.workOrderId = this.routeWorkOrderId
      this.loadSelected()
    } else {
      this.loadSelectable()
    }
  },
  methods: {
    blankForm() {
      return {
        workOrderId: null,
        engineeringNo: '',
        xNo: '',
        contractorName: '',
        startDate: '',
        finishDate: '',
        contractorPerson: '',
        tInternalConstruction: '',
        relatedProject: '',
        durationDays: 0,
        personCount: 0,
        acceptanceMode: '冷态',
        qualityInfo: '',
        reasonAnalysis: '',
        faultDescription: '',
        itemName: '',
        solutions: [],
        materials: []
      }
    },
    loadSelectable() {
      api.get('/work-orders', { params: { status: 'UNFINISHED,WAIT_PARTS,WAIT_TEST' } }).then(res => { this.selectableOrders = res.data || [] })
    },
    loadSelected() {
      if (!this.form.workOrderId) return
      api.get('/work-orders/' + this.form.workOrderId).then(res => {
        this.workOrder = res.data || null
        if (!this.workOrder) return
        this.form.xNo = this.workOrder.xNo
        this.form.contractorName = this.workOrder.contractorName
        this.form.engineeringNo = this.workOrder.faultCode + '-W'
        this.form.itemName = this.workOrder.equipmentName + '检修'
        this.form.faultDescription = this.workOrder.engineeringNameDesc
        this.form.tInternalConstruction = this.workOrder.reportUnit
        this.form.finishDate = new Date().toISOString().slice(0, 10)
      })
    },
    addSolution() {
      this.form.solutions.push({ content: '' })
    },
    addMaterial() {
      this.form.materials.push({ name: '', specification: '', technicalParameter: '', quantity: 1, unit: '件', certificate: '', outboundNo: '', source: '库存', remark: '' })
    },
    submit() {
      if (!this.form.workOrderId) return this.$message.warning('请选择派工单')
      if (!this.form.finishDate) return this.$message.warning('请选择完工时间')
      this.saving = true
      api.post('/work-orders/completion', this.form).then(() => {
        this.$message.success('完工信息已提交,验收申请已生成')
        this.$router.push('/acceptance/application')
      }).finally(() => { this.saving = false })
    }
  }
}
</script>
<style scoped>
.completion-form { padding-bottom: 78px; }
.form-section { margin-bottom: 12px; padding: 14px; border: 1px solid #dce4ec; border-radius: 4px; background: #fff; }
.form-section h3 { margin: 0 0 14px; color: #31465d; font-size: 15px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.submit-bar { position: fixed; right: 0; bottom: 0; left: 228px; z-index: 4; display: flex; align-items: center; justify-content: flex-end; gap: 18px; height: 64px; padding: 0 20px; border-top: 1px solid #d6e0e9; background: #fff; box-shadow: 0 -2px 8px rgba(30,50,70,.06); }
.danger-link { color: #d9534f; }
@media (max-width: 900px) { .submit-bar { left: 0; } }
</style>