yangys
2024-01-13 f466ae4fdc645c66c9f25e2e4598b9809e2b41af
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<!-- 日常保养计划 -->
<template>
    <div>
        <!-- 查询表单 -->
        <el-form :model="dataForm" status-icon ref="dataForm" label-width="100px" style="margin-top:10px;">
            <el-row>
                <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
                    <el-form-item label="统一编号" prop="uuid">
                        <el-input type="text" v-model="dataForm.uuid"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
                    <el-form-item label="设备名称" prop="machineName">
                        <el-select v-model="dataForm.machineName" placeholder="---请选择---" clearable>
                            <el-option
                            v-for="item in machineName"
                            :key="item.id"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
                    <el-form-item label="设备型号" prop="type">
                        <el-input type="text" v-model="dataForm.type"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
                    <el-form-item label="设备规格" prop="specification">
                        <el-input type="text" v-model="dataForm.specification"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
                    <el-form-item label="使用部门" prop="department">
                        <el-select v-model="dataForm.department" placeholder="---请选择---" clearable >
                            <el-option
                            v-for="item in department"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
                    <el-form-item label="安装位置" prop="location">
                        <el-input type="text" v-model="dataForm.location" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
                    <el-form-item label="计划开始日期" prop="planStartDate">
                        <el-date-picker
                        clearable
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                        v-model="dataForm.planStartDate"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
                    <el-form-item label="计划完成日期" prop="planFinishDate">
                        <el-date-picker
                        clearable
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                        v-model="dataForm.planFinishDate"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
 
        <div style="display: flex;justify-content: center;align-items: center;margin-top:15px;">
            <el-button size="mini" type="primary" @click="submitForm()" plain>查询</el-button>
            <el-button size="mini" type="warning" @click="resetForm()" plain>重置</el-button>
        </div>
 
        <div style="margin: 20px 5px">
            <el-button size="mini" @click="addDevice(1)" type="info" plain>添加</el-button>
            <el-button size="mini" @click="deleteHandle(1)" type="danger" plain :disabled="multipleSelection.length < 1">批量删除</el-button>
        </div>
        <!-- 表格 -->
        <el-table
            ref="tableData"
            :data="tableData"
            v-loading.table="listLoading"
            element-loading-text="Loading"
            fit bclass="mdc-table"
            style="width: 99%"
            border
            @selection-change="handleSelectionChange">
            <el-table-column
                type="selection"
                align="center"
                width="55">
            </el-table-column>
            <el-table-column
                align="center"
                label="统一编号"
                prop="uuid">
            </el-table-column>
            <el-table-column
                align="center"
                label="设备名称"
                width="150"
                :show-overflow-tooltip="true"
                prop="machineName">
            </el-table-column>
            <el-table-column
                align="center"
                label="设备型号"
                prop="type">
            </el-table-column>
            <el-table-column
                align="center"
                label="设备规格"
                prop="specification">
            </el-table-column>
            <el-table-column
                align="center"
                label="使用单位"
                prop="department">
            </el-table-column>
            <el-table-column
                align="center"
                label="保养者"
                prop="userName">
            </el-table-column>
            <el-table-column
                align="center"
                label="保养周期"
                prop="period">
            </el-table-column>
            <el-table-column
                align="center"
                label="保养类型"
                prop="style">
                <template slot-scope="scope">
                    <span>{{scope.row.style === "1" ? "日常保养" : scope.row.style === "2" ? "一级保养" :
                      scope.row.style === "3" ? "二级保养" : "三级保养" }}</span>
                </template>
            </el-table-column>
            <el-table-column
                align="center"
                width="110"
                label="是否合格"
                prop="isQualified">
                <template slot-scope="scope">
                    <span>{{scope.row.isQualified === "1"? "合格" : "不合格"}}</span>
                </template>
            </el-table-column>
            <el-table-column
                align="center"
                width="120"
                :show-overflow-tooltip="true"
                label="计划开始时间">
                <template slot-scope="scope">
                    <span v-if="scope.row.startDateFrom">{{scope.row.startDateFrom+ '~' +scope.row.startDateTo}}</span>
                    <span v-else></span>
                </template>
            </el-table-column>
            <el-table-column
                align="center"
                width="120"
                :show-overflow-tooltip="true"
                label="计划完成时间">
                <template slot-scope="scope">
                    <span v-if="scope.row.completeDateFrom">{{scope.row.completeDateFrom+ '~' +scope.row.completeDateTo}}</span>
                    <span v-else></span>
                </template>
            </el-table-column>
            <el-table-column
                align="center"
                width="150"
                :show-overflow-tooltip="true"
                label="保养内容与存在问题"
                prop="detail">
            </el-table-column>
            <el-table-column
                align="center"
                label="编辑"
                prop="editor">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" @click="addDevice(2,scope.row,$event)">编辑</el-button>
                    <el-button size="mini" type="text" @click="deleteHandle(2,scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
 
        <dailyMAdd ref="dailyMAddD" @reflash="submitForm" v-bind:styles="style"></dailyMAdd>
    </div>
</template>
<script>
import { secondMaintain, getMachineList, maintainDelete, userList, departmentGet } from '@/api/MdcApi'
import dailyMAdd from './dialog/dailyMAdd'
export default {
  components: {
    dailyMAdd
  },
  data() {
    return {
      dataForm: {
        uuid: '', // 统一编号
        machineName: '', // 设备名称
        type: '', // 设备型号
        specification: '', // 设备规格
        department: '', // 使用部门
        location: '', // 安装位置
        planStartDate: '', // 计划开始日期
        planFinishDate: '' // 计划完成日期
      },
      tableData: [],
      multipleSelection: [], // 多选
      style: '1',
      state: 1,
      // 下拉框
      machineName: [], // 设备名称
      // department: [], // 使用部门
      maintainPerson: [], // 保养人
      department: [{ value: '使用部门', label: '使用部门' }],
      tableLoading: false,
      listLoading: false,
      routes: this.$route.path
    }
  },
  methods: {
    // 查询
    submitForm() {
      this.listLoading = true
      const startDateFrom = this.dataForm.planStartDate[0] ? this.dataForm.planStartDate[0] : ''
      const startDateTo = this.dataForm.planStartDate[1] ? this.dataForm.planStartDate[0] : ''
      const completeDateFrom = this.dataForm.planFinishDate[0] ? this.dataForm.planFinishDate[0] : ''
      const completeDateTo = this.dataForm.planFinishDate[1] ? this.dataForm.planFinishDate[0] : ''
      const isQualified = ''
      // styles, name, uuid, specification, type, department, location, startDateFrom, startDateTo, completeDateFrom, completeDateTo, isQualified, state
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          secondMaintain(this.style, this.dataForm.machineName, this.dataForm.uuid, this.dataForm.specification, this.dataForm.type,
            this.dataForm.department, this.dataForm.location, startDateFrom, startDateTo, completeDateFrom, completeDateTo, isQualified, this.state
          ).then(res => {
            this.listLoading = false
            if (res.result === 'SUCCESS') {
              this.tableData = res.list
            } else {
              this.$message({
                type: 'error',
                message: res.result
              })
            }
          })
        }
      })
    },
    // 添加
    addDevice(n, row, event) {
      if (n === 1) {
        this.$nextTick(() => {
          this.$refs.dailyMAddD.init(n)
        })
      } else {
        this.$nextTick(() => {
          this.$refs.dailyMAddD.init(n, row)
        })
      }
    },
    // 删除
    deleteHandle(n, row) {
      let ids = []
      if (n === 1) {
        this.multipleSelection.map(item => {
          ids.push(item.id)
        })
      } else {
        ids.push(row.id)
      }
      ids = ids.join(',')
      this.$confirm('确定要永久删除此项?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        maintainDelete(this.style, ids).then(res => {
          // if(res.result == ""){}
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
          this.submitForm()
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    /**
         * 初始化已有机床
         */
    initDevices() {
      this.machineName = []
      this.maintainPerson = []
      this.department = []
      // 设备名称
      getMachineList().then(res => {
        res.list.map(item => {
          this.machineName.push({
            label: item.name,
            value: item.name,
            id: item.id
          })
        })
        //    .split('_')[1]
      })
      // 使用单位
      userList().then(res => {
        res.list.map(elem => {
          this.maintainPerson.push({
            label: elem.user,
            value: elem.user,
            id: elem.id
          })
        })
      })
      // 获取部门
      departmentGet().then(res => {
        res.list.map(elem => {
          this.department.push({
            label: elem.name,
            value: elem.name,
            id: elem.id
          })
        })
      })
    },
    // 重置
    resetForm() {
      this.$refs.dataForm.resetFields()
    },
    // 多选
    handleSelectionChange(val) {
      this.multipleSelection = val
    }
  },
  mounted() {
    this.initDevices()
    this.submitForm()
  },
  watch: {
    $route(val, from) {
      if (val.fullPath.indexOf('dailymaintain') >= 0) {
        this.style = '1'
      } else if (val.fullPath.indexOf('firstmaintain') >= 0) {
        this.style = '2'
      } else if (val.fullPath.indexOf('maintainTwo') >= 0) {
        this.style = '3'
      } else if (val.fullPath.indexOf('maintainThree') >= 0) {
        this.style = '4'
      } else {
        this.style = '1'
      }
      this.submitForm() // 查询
      this.initDevices()
    }
  }
}
</script>
 
<style>
    .el-form-item__label{font-weight:normal;line-height: 30px;}
    .el-input__inner{height:30px;line-height: 30px;}
    .el-select{width:100%;}
    .el-form-item{margin-bottom:8px;}
    .el-date-editor .el-range-separator{width:10%;}
    .el-table td{white-space: nowrap;}
    .duojiTable td{white-space: nowrap !important;}
    .el-table td, .el-table th {padding: 2px 0;}
 
    .el-date-editor .el-range__icon{line-height: 0;}
    .el-date-editor .el-range-separator{width:10%;line-height: 25px;}
    .el-date-editor{width: 100%!important;}
    .el-form-item__content{line-height: 30px;}
</style>