作者 雷海东

生产计划派工、验收状态更改

@@ -110,7 +110,7 @@ @@ -110,7 +110,7 @@
110 <a-divider type="vertical" /> 110 <a-divider type="vertical" />
111 <a @click="handleAddpg(record)" :disabled="record.totalWorkingHours - record.dispatchedWorkingHours === 0">派工</a> 111 <a @click="handleAddpg(record)" :disabled="record.totalWorkingHours - record.dispatchedWorkingHours === 0">派工</a>
112 <a-divider type="vertical" /> 112 <a-divider type="vertical" />
113 - <a @click="handleYans(record)">验收</a> 113 + <a @click="handleYans(record)" :disabled="record.totalWorkingHours - record.dispatchedWorkingHours === 0 && record.verifyStatus==1">验收</a>
114 </span> 114 </span>
115 </a-table> 115 </a-table>
116 </div> 116 </div>
@@ -160,7 +160,6 @@ export default { @@ -160,7 +160,6 @@ export default {
160 }) 160 })
161 }, 161 },
162 add(record) { 162 add(record) {
163 -  
164 console.log('产品类型:', record.productType) 163 console.log('产品类型:', record.productType)
165 this.productType = record.productType 164 this.productType = record.productType
166 this.panduan = record 165 this.panduan = record
@@ -169,12 +168,12 @@ export default { @@ -169,12 +168,12 @@ export default {
169 if (ress) { 168 if (ress) {
170 //如果已派工时为0总工时*工时比例,否则(总工时-已派工时)*工时比例 169 //如果已派工时为0总工时*工时比例,否则(总工时-已派工时)*工时比例
171 console.log(record.dispatchedWorkingHours) 170 console.log(record.dispatchedWorkingHours)
172 - if (record.dispatchedWorkingHours <= 0 || record.dispatchedWorkingHours==='') { 171 + if (record.dispatchedWorkingHours <= 0 || record.dispatchedWorkingHours === '') {
173 console.log('aa', ress.result) 172 console.log('aa', ress.result)
174 console.log(record.totalWorkingHours) 173 console.log(record.totalWorkingHours)
175 // 将获取到的工序列表添加到数据源中 174 // 将获取到的工序列表添加到数据源中
176 this.res = ress.result.map((item) => ({ 175 this.res = ress.result.map((item) => ({
177 - workingProcedure: item.gongxu + " (" + (item.bili * 100).toFixed() + "%)", 176 + workingProcedure: item.gongxu + ' (' + (item.bili * 100).toFixed() + '%)',
178 undertaker: '', // 初始为空,等待用户输入 177 undertaker: '', // 初始为空,等待用户输入
179 workHours: parseFloat((record.totalWorkingHours * item.bili).toFixed(2)) 178 workHours: parseFloat((record.totalWorkingHours * item.bili).toFixed(2))
180 .toString() 179 .toString()
@@ -212,11 +211,15 @@ export default { @@ -212,11 +211,15 @@ export default {
212 // 触发表单验证 211 // 触发表单验证
213 this.$refs.form.validate((valid) => { 212 this.$refs.form.validate((valid) => {
214 if (valid) { 213 if (valid) {
215 - if (!this.res.some((record) => !record.undertaker) && !this.res.some((record)=>!record.workHours)) { 214 + // 过滤出承接人不为空的记录
  215 + const nonEmptyUndertakerRecords = this.res.filter((record) => record.undertaker)
  216 + if (nonEmptyUndertakerRecords.length>0) {
  217 +
216 // 检查是否所有输入框的值都是数字 218 // 检查是否所有输入框的值都是数字
217 - const allNumeric = this.res.every((record) => /^\d+(\.\d+)?$/.test(record.workHours));  
218 - if(allNumeric){ 219 + const allNumeric = this.res.every((record) => /^\d+(\.\d+)?$/.test(record.workHours))
  220 + if (allNumeric) {
219 that.confirmLoading = true 221 that.confirmLoading = true
  222 + data=nonEmptyUndertakerRecords;
220 console.log('res:', this.res) 223 console.log('res:', this.res)
221 // 使用 reduce 方法累加工时字段值 224 // 使用 reduce 方法累加工时字段值
222 const zong = this.res.reduce((acc, current) => { 225 const zong = this.res.reduce((acc, current) => {
@@ -224,15 +227,15 @@ export default { @@ -224,15 +227,15 @@ export default {
224 return acc + parseFloat(current.workHours) 227 return acc + parseFloat(current.workHours)
225 }, 0) 228 }, 0)
226 console.log(this.panduan.dispatchedWorkingHours) 229 console.log(this.panduan.dispatchedWorkingHours)
227 - if(this.panduan.dispatchedWorkingHours==='' || this.panduan.dispatchedWorkingHours===null){  
228 - this.panduan.dispatchedWorkingHours=0 230 + if (this.panduan.dispatchedWorkingHours === '' || this.panduan.dispatchedWorkingHours === null) {
  231 + this.panduan.dispatchedWorkingHours = 0
229 } 232 }
230 console.log(this.panduan.dispatchedWorkingHours) 233 console.log(this.panduan.dispatchedWorkingHours)
231 const zongpaifa = parseFloat(this.panduan.dispatchedWorkingHours) + zong 234 const zongpaifa = parseFloat(this.panduan.dispatchedWorkingHours) + zong
232 console.log('派发工时和:', zong) 235 console.log('派发工时和:', zong)
233 console.log('已派发工时:', zongpaifa) 236 console.log('已派发工时:', zongpaifa)
234 if (zongpaifa <= this.panduan.totalWorkingHours) { 237 if (zongpaifa <= this.panduan.totalWorkingHours) {
235 - addPg(this.url.add, this.res) 238 + addPg(this.url.add, data)
236 .then((res) => { 239 .then((res) => {
237 if (res.success) { 240 if (res.success) {
238 that.$message.success(res.message) 241 that.$message.success(res.message)
@@ -248,12 +251,12 @@ export default { @@ -248,12 +251,12 @@ export default {
248 that.$message.error('派发工时超过总工时') 251 that.$message.error('派发工时超过总工时')
249 that.confirmLoading = false 252 that.confirmLoading = false
250 } 253 }
251 - }else{ 254 + } else {
252 that.$message.error('工时格式错误') 255 that.$message.error('工时格式错误')
253 that.confirmLoading = false 256 that.confirmLoading = false
254 } 257 }
255 } else { 258 } else {
256 - that.$message.error('页面字段不能为空') 259 + that.$message.error('没有派工给承接人')
257 that.confirmLoading = false 260 that.confirmLoading = false
258 } 261 }
259 } 262 }
@@ -160,6 +160,7 @@ export default { @@ -160,6 +160,7 @@ export default {
160 yanshouList(this.url.queryByNumber, { orderId: record.orderId }).then((ress) => { 160 yanshouList(this.url.queryByNumber, { orderId: record.orderId }).then((ress) => {
161 if (ress) { 161 if (ress) {
162 this.res = ress.result.map((item) => ({ 162 this.res = ress.result.map((item) => ({
  163 + orderNumber:item.orderNumber,
163 id: item.id, 164 id: item.id,
164 workingProcedure: item.workingProcedure, 165 workingProcedure: item.workingProcedure,
165 undertaker: item.undertaker, 166 undertaker: item.undertaker,