<!--
|
* @Author: 陈祝文 15821704398@163.com
|
* @Date: 2023-03-17 10:33:58
|
* @LastEditors: 陈祝文 15821704398@163.com
|
* @LastEditTime: 2023-03-17 14:33:36
|
* @FilePath: \iwara-scada-web\src\views\main\WorkPieceInfo\editForm.vue
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
-->
|
<template>
|
<a-modal
|
title="质量状态修改"
|
:width="450"
|
:visible="visible"
|
:confirmLoading="confirmLoading"
|
@ok="handleSubmit"
|
@cancel="handleCancel"
|
>
|
<a-form-model :model="form" ref="formRef" :label-col="labelCol" :wrapper-col="wrapperCol" :rules="rules">
|
<a-form-model-item label="质量状态" >
|
<a-radio-group v-model="form.status">
|
<a-radio v-for="item in statusArr" :key="item.value" :value="item.value">{{ item.title }}</a-radio>
|
</a-radio-group>
|
</a-form-model-item>
|
|
<a-form-model-item label="工序" >
|
<a-select allow-clear v-model="form.workingProcedureCurrent" placeholder="请选择工序">
|
<a-select-option v-for="(item, index) in processSelectData" :key="index" :value="item.code">
|
{{ item.name }}
|
</a-select-option>
|
</a-select>
|
</a-form-model-item>
|
|
<a-form-model-item label="密码" prop="pwd">
|
<a-input v-model="form.pwd" type="password" placeholder="请输入密码"></a-input>
|
</a-form-model-item>
|
</a-form-model>
|
</a-modal>
|
</template>
|
|
<script>
|
import { updatePieceStatus } from '@/api/modular/main/WorkPieceInfoManage'
|
export default {
|
props: {
|
selectedRows: { type: Array, default: () => [] },
|
processSelectData: { type: Array, default: () => [] }
|
},
|
emits: ['refresh'],
|
data() {
|
return {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 15 }
|
},
|
visible: false,
|
confirmLoading: false,
|
form: {
|
status: '',
|
pwd: ''
|
},
|
statusArr: [
|
{ value: '1', title: '合格' },
|
{ value: '2', title: '不合格' },
|
{ value: '3', title: '疑似' }
|
],
|
rules: {
|
status: [{ required: true, message: '质量状态不能为空', trigger: 'blur' }],
|
workingProcedureCurrent: [{ required: true, message: '工序不能为空', trigger: 'blur' }],
|
pwd: [{ required: true, message: '密码不能为空', trigger: 'blur' }]
|
}
|
}
|
},
|
methods: {
|
handleSubmit() {
|
this.$refs.formRef.validate((vali) => {
|
if (vali) {
|
// 判断是否选中同一种
|
const status = this.selectedRows[0].qualityState
|
console.log(status, 'status')
|
const count = this.selectedRows.reduce((curr, item) => {
|
if (item.qualityState == status) {
|
curr++
|
}
|
return curr
|
}, 0)
|
|
if (count != this.selectedRows.length) {
|
return this.$message.error('选中的质量状态包含多种')
|
}
|
|
this.confirmLoading = true
|
const checkPiece = this.selectedRows.reduce((curr, item) => {
|
curr.push({
|
workPieceID: item.workPieceID,
|
qualityHistoryState: item.qualityState,
|
workingProcedureCurrent: item.workingProcedureCurrent,
|
id: item.id
|
})
|
return curr
|
}, [])
|
const param = {
|
workPieceInfoLst: checkPiece,
|
qualityState: this.form.status,
|
workingProcedureCurrent: this.form.workingProcedureCurrent,
|
password: this.form.pwd
|
}
|
updatePieceStatus(param)
|
.then((res) => {
|
this.confirmLoading = false
|
this.$message.success('修改成功')
|
this.handleCancel()
|
this.visible = false
|
this.$emit('refresh')
|
})
|
.catch((err) => {
|
console.log(err)
|
this.confirmLoading = false
|
})
|
} else {
|
this.confirmLoading = false
|
this.$message.error('表单验证失败')
|
}
|
})
|
},
|
handleCancel() {
|
this.form = {
|
status: '',
|
pwd: ''
|
}
|
this.visible = false
|
}
|
}
|
}
|
</script>
|