1
huanghongfeng
2025-03-07 f1f29f5329102870476653fa6c6ca42b80226078
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
<template>
  <div>
    <el-table :data="tableData" style="width: 100%"  :row-class-name="tableRowClassName">
      <el-table-column fixed prop="current_PalletCode" label="托盘条码">
      </el-table-column>
      <el-table-column prop="Current_Parts" label="名称">
      </el-table-column>
      <el-table-column prop="Current_Vehiclenumber" label="车型">
      </el-table-column>
      <el-table-column prop="Current_Models" label="车号">
      </el-table-column>
      <el-table-column prop="Current_Carset" label="车组号">
      </el-table-column>
      <el-table-column prop="Current_count" label="数量">
      </el-table-column>
      <el-table-column prop="Current_Static" label="状态">
      </el-table-column>
      <el-table-column prop="ModifyDate" label="开始检修时间">
 
      </el-table-column>
      <el-table-column fixed="right" label="操作">
    <template v-slot="scope">
      <el-button type="primary" v-if="!scope.row.ModifyDate"  v-on:click="startRepair()" >开始检修</el-button>
      <el-button type="success" v-if="scope.row.ModifyDate"  v-on:click="dialogVisible = true" >检修完成</el-button>
    </template>
  </el-table-column>
    </el-table>
  </div>
 
  <el-dialog
  title="检修完成统计"
  v-model="dialogVisible"
  width="40%"
>
  <div style="font-size: 20px; margin-bottom: 20px;"> <!-- 增大内容字体并增加底部间距 -->
    报废数量:<el-input-number v-model="num"  :min="0" :max="this.zwcount" label="数量" style="font-size: 30px;"/> <!-- 增大输入框字体 -->
  </div>
  <el-select v-model="selectvalue" placeholder="请选择维修结果">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
  <el-button type="success" style="width: 100%; margin-top: 30px;font-size: 20px;height: 40px;" v-on:click="queryDa()">确定</el-button> <!-- 调整按钮位置 -->
</el-dialog>
 
  <div style="width: 40%; position: fixed; left: 40%; bottom: 2%">
    <!-- 输入框,绑定 barocde,清除时触发 clearmessage -->
    <el-input id="inputId" ref="inputId" placeholder="托盘到位后,请扫描检修" v-model="barocde" clearable focus="true"
      @input="handleInput" style="width: 50%;height: 80px;font-size: 28px;">
    </el-input>
    <!-- 清空按钮,点击时清空 barocde 内容并触发焦点 -->
    <el-button type="primary" @click="clearBarcode"
      style="font-size: 30px;margin-left: 20px; padding: 12px 24px; height: 100px;">
      清空托盘码
    </el-button>
 
    <el-button type="success" 
      style="font-size: 30px;margin-left: 20px; padding: 12px 24px; height: 100px;" v-on:click="queryDa2()">
      未检回库
    </el-button>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      barocde: '',  // 当前条码
      zwcount:0,
      tableData: [],  // 保存从 API 获取的数据
      dialogVisible: false,
      repairStarted:false,
      num: 0,
      butboo:true,
      options: [{
          value: '1',
          label: '合格'
        }, {
          value: '2',
          label: '半检修'
        }],
        selectvalue: ''
    }
  },
  methods: {
    handleInput() {
      if (this.barocde !== '') {
        // 发送请求时,确保条码不为空
        console.log('查询条码:', this.barocde);
        this.http
          .get("/api/Dt_Repair/GetBarcodeMessage?barocde=" + this.barocde)
          .then((res) => {
            
            if (res.status) {
              if (res.data != null) {
                console.log(res.data);
                this.tableData = [];
                for (let i = 0; i < res.data.length; i++) {
                  this.tableData.push({
                    current_PalletCode: res.data[i].current_PalletCode,
                    Current_Parts: res.data[i].current_Parts,
                    Current_Vehiclenumber: res.data[i].current_Vehiclenumber,
                    Current_Models: res.data[i].current_Models,
                    Current_Carset: res.data[i].current_Carset,
                    Current_count: res.data[i].current_count,
                    Current_Static: res.data[i].current_Static=="10"?"准备检修":"检修中",
                    ModifyDate:res.data[i].modifyDate
                  })
                  this.zwcount=res.data[i].current_count;
                }
              }
            } else {
              this.$message.error("查询失败!");
            }
          })
          .catch((err) => {
            console.error(err);  // 捕获错误
          });
      }
    },
    // 清空条码内容并聚焦输入框
    clearBarcode() {
      this.barocde = '';  // 清空条码内容
      this.tableData = [];
      this.$refs.inputId.focus();  // 重新聚焦输入框
    },
    tableRowClassName({row, rowIndex}) {
        if (rowIndex === 1) {
          return 'warning-row';
        } else if (rowIndex === 3) {
          return 'success-row';
        }
        return '';
    },
    queryDa(){
      this.http
          .get("/api/Dt_Repair/UpdateBarcoend?barocde=" + this.barocde+"&wcount="+ this.num+"&selectvalue="+this.selectvalue)
          .then((res) => {
            if (res.status) {
              this.$message({ message: "维修结束成功!", type: "success" });
              this.dialogVisible=false,
              this.handleInput();
 
            } else {
              this.$message.error("维修结束失败!");
            }
          })
          .catch((err) => {
            console.error(err);  // 捕获错误
          });
    },
    queryDa2(){
      this.http
        .get("/api/Dt_Repair/UpdateBarcoendwj?barocde=" + this.barocde)
          .then((res) => {
            if (res.status) {
              this.$message({ message: "未检回库成功!", type: "success" });
              this.handleInput();
 
            } else {
              this.$message.error("未检回库失败!");
            }
          })
          .catch((err) => {
            console.error(err);  // 捕获错误
          });
    },
    startRepair(){
      this.http
          .get("/api/Dt_Repair/UpdateBarcode?barocde=" + this.barocde)
          .then((res) => {
            if (res.status) {
              this.$message({ message: "开始检修!", type: "success" });
              this.handleInput();
            } else {
              this.$message.error("开始检修失败!");
            }
          })
          .catch((err) => {
            console.error(err);  // 捕获错误
          });
    }
  }
}
</script>
 
<style>
  .el-table .warning-row {
    background: oldlace;
  }
 
  .el-table .success-row {
    background: #f0f9eb;
  }
</style>