xwt
3 天以前 f4711865a8ea9566910bfcc6daa31795b89272a7
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
<template>
  <view class="page">
    <!-- 表单区域 -->
    <view class="form-container">
      <form :modelValue="formData">
        <view class="form-group">
          <label class="form-label">退换料单号:</label>
          <superwei-combox
            :candidates="docList"
            placeholder="请选择"
            v-model="formData.docNo"
            @select="onDocChange"
            class="form-input"
          />
        </view>
        <view class="form-group">
          <label class="form-label">生产工单:</label>
          <input class="form-input" type="text" v-model="formData.moNo" disabled />
        </view>
        <view class="form-group">
          <label class="form-label">退补料类型:</label>
          <input class="form-input" type="text" v-model="formData.type" disabled />
        </view>
        <view class="form-group">
          <label class="form-label">产品编码:</label>
          <input class="form-input" type="text" v-model="formData.productCode" disabled />
        </view>
        <view class="form-group">
          <label class="form-label">部门名称:</label>
          <input class="form-input" type="text" v-model="formData.deptName" disabled />
        </view>
        <view class="form-group">
          <label class="form-label">创建时间:</label>
          <input class="form-input" type="text" v-model="formData.createTime" disabled />
        </view>
      </form>
    </view>
 
    <!-- 明细表格 -->
   <view class="list-container">
     <uni-table border stripe emptyText="暂无明细数据">
       <uni-tr>
         <uni-th align="center">序号</uni-th>
         <uni-th align="center">物料</uni-th>
         <uni-th align="center">规格</uni-th>
         <uni-th align="center">申请数量</uni-th>
         <uni-th align="center">退料原因</uni-th>
       </uni-tr>
       <uni-tr v-for="(item, index) in detailList" :key="index">
         <uni-td align="center">{{ index + 1 }}</uni-td>
         <uni-td align="center">{{ item.material }}</uni-td>
         <uni-td align="center">{{ item.spec }}</uni-td>
         <uni-td align="center">{{ item.qty }}</uni-td>
         <uni-td align="center">
           <input class="form-input" type="text" v-model="item.reason" />
         </uni-td>
       </uni-tr>
     </uni-table>
   </view>
 
    <!-- 审核按钮 -->
 <view class="plus-button">
   <button type="warn" @click="confirmReview">确认审核</button>
   <button type="default" @click="rejectReview" style="margin-left: 10px;">驳回</button>
 </view>
 
  </view>
</template>
 
<script>
export default {
  data() {
    return {
      docList: [],
      formData: {
        docNo: '',
        moNo: '',
        type: '',
        productCode: '',
        deptName: '',
        createTime: ''
      },
      detailList: [],
      readonlyFields: [
        { label: '生产工单:', field: 'moNo' },
        { label: '退补料类型:', field: 'type' },
        { label: '产品编码:', field: 'productCode' },
        { label: '部门名称:', field: 'deptName' },
        { label: '创建时间:', field: 'createTime' }
      ]
    };
  },
  methods: {
  onDocChange(selectedDoc) {
 
    this.formData.docNo = selectedDoc;
  
    // 根据 docNo 获取表头数据
    this.$post({
      url: "/RetMat/GetHeader",
      data: { docNo: selectedDoc }
    }).then(res => {
      if (res.status === 0) {
        this.formData = {
          ...this.formData,
          moNo: res.data.mono,
          type: res.data.type,
          productCode: res.data.productcode,
          deptName: res.data.deptname,
          createTime: res.data.createtime
        };
      } else {
        uni.showToast({ title: '获取表头失败', icon: 'none' });
      }
    });
  
    // 获取明细数据
    this.$post({
      url: "/RetMat/GetList",
      data: { docNo: selectedDoc }
    }).then(res => {
      if (res.status === 0) {
        this.detailList = res.data.map(item => ({
          material: item.material,
          spec: item.spec,
          qty: item.qty,
          reason: item.reason || '',
          ItemId: item.itemid  
        }));
      } else {
        uni.showToast({ title: '获取明细失败', icon: 'none' });
      }
    });
  }
,
    confirmReview() {
        if (!this.formData.docNo) {
          uni.showToast({ title: '请先选择退换料单号', icon: 'none' });
          return;
        }
  const dataToSave = {
    docNo: this.formData.docNo,
    user: this.$loginInfo.account,
    items: this.detailList.map(item => ({
         material: "",
      ItemId: item.ItemId,
      Reason: item.reason
    }))
 
  };
console.log(dataToSave);
  this.$post({
    url: "/RetMat/SaveReview",
    data: dataToSave
  }).then(res => {
    if (res.status === 0) {
      uni.showToast({ title: '审核成功', icon: 'success' });
    } else {
      uni.showToast({ title: res.message, icon: 'none' });
    }
  });
},
 
 rejectReview() {
   if (!this.formData.docNo) {
     uni.showToast({ title: '请先选择退换料单号', icon: 'none' });
     return;
   }
 
   uni.showModal({
     title: '确认驳回',
     content: '是否确认驳回该退换料申请?',
     success: res => {
       if (res.confirm) {
         const dataToReject = {
           docNo: this.formData.docNo,
           user: this.$loginInfo.account,
           items: this.detailList.map(item => ({
             material: item.material,
             reason: item.reason,
             itemId: item.ItemId
           }))
         };
 
         this.$post({
           url: "/RetMat/Reject",
           data: dataToReject
         }).then(res => {
           if (res.status === 0) {
             uni.showToast({ title: '驳回成功', icon: 'success' });
             this.formData = {};
             this.detailList = [];
           } else {
             uni.showToast({ title: res.message, icon: 'none' });
           }
         });
       }
     }
   });
 }
 
 
 
 
  },
  onLoad() {
    this.$post({ url: "/RetMat/GetAllDocs" }).then(res => {
      //this.docList = res.data;
       this.docList = res.data.map(item => item.thL_NO);
    });
  }
};
</script>
 
<style>
.page {
  padding: 10px;
}
.form-container {
  padding: 12px;
}
.form-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.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;
}
.list-container {
  padding: 10px;
  height: 60vh;
  overflow-y: auto;
}
.plus-button {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}
 
</style>