<template>
|
<u-modal :show="show" title="选择状态" :closeOnClickOverlay="true" @confirm="handlerConfirm" @close="close">
|
<view class="status_flex">
|
<view v-for="(item,index) in statusArr" :key="item.code" class="flex_item" @click="activeIndex = index" :class="activeIndex == index ? 'active_item' : ''">
|
{{item.title}}
|
</view>
|
<u-form labelPosition="left" labelWidth="100rpx" :model="form" :rules="rules" ref="uForm">
|
<u-form-item v-if="activeIndex==1||activeIndex==2" required label="不合格原因" prop="qualityErrorInfo">
|
<u-textarea :maxlength="255" v-model="form.qualityErrorInfo" placeholder="请输入不合格原因"></u-textarea>
|
</u-form-item>
|
<u-form-item required label="密码" prop="pwd">
|
<u-input v-model="form.pwd" type="password" placeholder="请输入密码" style="width: 450rpx;"></u-input>
|
</u-form-item>
|
</u-form>
|
|
</view>
|
</u-modal>
|
</template>
|
|
<script>
|
import {$alert} from '@/static/js/utils/index.js'
|
import { updateSomeBarStatus} from '@/api/unBindAll/index.js'
|
export default {
|
emits: ['updateData'],
|
data() {
|
return {
|
show: false,
|
activeIndex: 100,
|
checkArr:[],
|
statusArr:[],
|
form: {
|
pwd: '',
|
qualityErrorInfo: ''
|
},
|
rules: {
|
pwd: {
|
type: 'string',
|
required: true,
|
message: '请输入密码',
|
trigger: ['blur', 'change']
|
},
|
qualityErrorInfo: {
|
type: 'string',
|
required: true,
|
message: '请输入不合格原因',
|
trigger: ['blur', 'change']
|
}
|
}
|
}
|
},
|
watch:{
|
activeIndex:{
|
handler(val){
|
if(val==1) {
|
this.form.qualityErrorInfo='不合格'
|
}else if(val==2){
|
this.form.qualityErrorInfo='疑似'
|
}else {
|
this.form.qualityErrorInfo=''
|
}
|
}
|
}
|
},
|
methods: {
|
showModal(checkArr,statusArr){
|
this.show=true
|
this.checkArr=checkArr
|
this.statusArr=statusArr
|
},
|
// 选中的状态传递给父组件
|
handlerConfirm() {
|
|
if(this.activeIndex > 2) {
|
return uni.showToast({
|
title: '请选择状态',
|
icon: 'error'
|
})
|
}
|
|
this.$refs.uForm.validate().then(res => {
|
const pieceArr = this.checkArr.reduce((curr,item) => {
|
curr.push(item.workPieceID)
|
return curr;
|
},[])
|
|
const params = {
|
workPieceIDList: pieceArr,
|
qualityState: this.statusArr[this.activeIndex].code,
|
password: this.form.pwd,
|
qualityErrorInfo:this.form.qualityErrorInfo
|
}
|
updateSomeBarStatus(params).then(res => {
|
uni.showToast({
|
title:'批量更改成功'
|
})
|
this.$emit('updateData')
|
this.close()
|
})
|
})
|
},
|
close() {
|
this.show = false
|
this.activeIndex = 100;
|
this.form = {
|
pwd: '',
|
qualityErrorInfo: ''
|
}
|
}
|
|
},
|
onReady() {
|
this.$refs.uForm.setRules(this.rules)
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.status_flex {
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
justify-content: center;
|
align-items: center;
|
.flex_item {
|
width: 450rpx;
|
height: 70rpx;
|
text-align: center;
|
line-height: 70rpx;
|
border: 1px solid $color-common;
|
color: $color-common;
|
font-size: 32rpx;
|
font-weight: 550;
|
background: #fff;
|
margin-bottom: 30rpx;
|
}
|
.active_item {
|
background: $color-common;
|
color: #fff;
|
}
|
}
|
</style>
|