kyy
2025-02-11 bb05da47c66341aa5d65c965528271d03f37a1e1
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
<template>
  <view>
    <view class="form-container">
      <form :modelValue="formData">
        <view class="form-group">
          <label class="form-label">生产车间:</label>
          <superwei-combox :candidates="deptList" placeholder="请选择或输入"
                           v-model="formData.deptName"
                           :isJSON="true" keyName="deptName"
                           @select="checkDept"
                           class="picker form-input"
                           style="border: none;"></superwei-combox>
        </view>
        <view class="form-group">
          <label class="form-label">产线编码:</label>
          <superwei-combox :candidates="lineList" placeholder="请选择或输入"
                           v-model="formData.lineNo"
                           :isJSON="true" keyName="lineNo"
                           @select="checkLine"
                           class="picker form-input"
                           style="border: none;"></superwei-combox>
        </view>
        <view class="form-group">
          <label class="form-label">线体名称:</label>
          <input class="form-input" disabled="true" type="text" v-model="formData.lineName"/>
        </view>
      </form>
    </view>
    <view class="list-container">
      <uni-table ref="table" border emptyText="暂无更多数据">
        <uni-tr>
          <uni-th align="center" style="color: #FFFFFF;background-color: lightskyblue;">线体名称</uni-th>
          <uni-th align="center" style="color: #FFFFFF;background-color: lightskyblue;">暂停时间</uni-th>
        </uni-tr>
        <uni-tr v-for="(item, index) in tableData" :key="index">
          <uni-td align="center">
            <input class="form-input" disabled="true" type="text" v-model="item.lineName"/>
          </uni-td>
          <uni-td align="center">
            <input class="form-input" disabled="true" type="text" v-model="item.createDate"/>
          </uni-td>
        </uni-tr>
      </uni-table>
    </view>
 
    <view class="plus-button">
      <button type="warn" @click="save">提交开启</button>
    </view>
  </view>
</template>
 
<script>
export default {
  data() {
    return {
      formData: {},
      deptList: [],
      lineList: [],
      tableData: []
    }
  },
  onLoad(options) {
    //初始化检验单号
    this.$post({
      url: "/Suspend/getOpenDept"
    }).then(res => {
      this.deptList = res.data.tbBillList;
    });
  },
  methods: {
    save() {
 
      if(this.tableData.length === 0){
        this.$showMessage("没有需要开启的机台");
        return;
      }
 
      let data = this.tableData.filter(item => item.lineNo === this.formData.lineNo)[0];
 
      let specifiedTime = new Date(data.createDate);
      let currentTime = new Date();
 
      // 计算时间差(单位:毫秒)
      let timeDifference = currentTime.getTime() - specifiedTime.getTime();
 
      // 将时间差转换为分钟
      let minutesDifference = timeDifference / (1000 * 60);
 
      this.formData.timeDifference = minutesDifference.toFixed(3);
 
      this.formData.id = data.id;
 
      this.formData.isSuspend = 1
 
      this.$post({
        url: "/Suspend/UpdateById",
        data: {
          entity: this.formData
        }
      }).then(res => {
        if (res.data.tbBillList > 0) {
          this.formData = {};
          this.tableData = [];
          this.$showMessage("开启成功");
        } else {
          this.$showMessage("开启失败");
        }
      });
 
    },
    checkDept(event) {
      this.formData.deptNo = event.deptNo;
      this.formData.deptName = event.deptName;
 
      this.$post({
        url: "/Suspend/getOpenLine",
        data: {
          deptCode: this.formData.deptNo
        }
      }).then(res => {
        this.lineList = res.data.tbBillList;
      });
 
      this.$post({
        url: "/Suspend/getAllByDeptNo",
        data: {
          deptCode: this.formData.deptNo
        }
      }).then(res1 => {
        this.tableData = res1.data.tbBillList;
      });
 
    },
    checkLine(event) {
      this.formData.lineNo = event.lineNo;
      this.formData.lineName = event.lineName;
    },
    radioChange(e) {
      this.formData.isSuspend = e.detail.value;
    },
  }
}
</script>
 
<style>
.form-group {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #c9c9c9;
}
 
.form-label {
  margin-bottom: 0;
  padding: 5px;
}
 
.form-input {
  flex: 1;
  margin-bottom: 0;
  padding: 5px;
}
 
.picker {
  flex: 1;
  margin-bottom: 0;
  padding: 5px;
  font-size: 12px;
}
 
/* 默认样式 */
.list-container {
  height: 60vh;
  /* 设置列表容器的高度为剩余空间,并减去表单容器的高度 */
  overflow-y: auto;
  /* 允许列表容器垂直滚动 */
  padding: 10px;
  /* 可选:添加一些内边距,使列表内容更美观 */
}
 
.form-container {
  padding: 10px;
  /* 可选:添加一些内边距,使表单内容更美观 */
}
 
.plus-button {
  line-height: 59px;
  font-size: 24px;
  cursor: pointer;
  z-index: 1000;
  margin-bottom: 35px;
}
</style>