<template>
|
<view class="form-container">
|
<u--form :model="formData" ref="uForm">
|
<u-form-item label="检验单号" label-width="150rpx">
|
<u-input v-model="formData.PI_BILLNO" placeholder="请输入检验单号" disabled />
|
</u-form-item>
|
<u-form-item label="负责人" label-width="150rpx">
|
<u-input v-model="formData.PI_staffName" placeholder="此单据暂无负责人" disabled />
|
</u-form-item>
|
<u-form-item label="新负责人" label-width="150rpx" prop="PI_NEW_staffName"
|
@click.native="show_PI_NEW_staffName = true" :required="true">
|
<u-input class="input_Form" v-model="formData.PI_NEW_staffName" disabled placeholder="请选择新负责人"
|
disabled-color="#ffffff" />
|
<u-icon slot="right" name="arrow-down" />
|
</u-form-item>
|
|
|
<!-- 新负责人选择器 -->
|
<u-picker :show="show_PI_NEW_staffName" :columns="[PI_NEW_staffName_Options]" keyName="label"
|
@confirm="confirm_PI_NEW_staffName" @cancel="show_PI_NEW_staffName = false" />
|
|
|
<!-- 提交按钮 -->
|
<u-button type="primary" @click="submitForm" class="submit-btn">
|
提交
|
</u-button>
|
</u--form>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
show_PI_NEW_staffName: false,
|
|
formData: {
|
PI_BILLNO: '', //检验单号
|
PI_USER: '', //委托人
|
PI_NEW_staffName: '', //新负责人
|
PI_NEW_staffUserID: '', //新负责人ID
|
PI_Roleids:"",
|
IQCJL:false
|
|
},
|
PI_NEW_staffName_Options: [] ,
|
// 添加校验规则
|
rules: {
|
PI_NEW_staffName: [{
|
required: true,
|
message: '请选择新负责人',
|
trigger: ['change']
|
}]
|
}
|
};
|
},
|
mounted() {
|
this.loadInspectorsList();
|
|
},
|
methods: {
|
confirm_PI_NEW_staffName(e) {
|
const selected = e.value[0];
|
this.formData.PI_NEW_staffName = selected.label;
|
this.formData.PI_NEW_staffUserID=selected.value;
|
this.show_PI_NEW_staffName = false;
|
},
|
onReady() {
|
this.$refs.uForm.setRules(this.rules);
|
},
|
onLoad(options) {
|
//options中包含了url附带的参数
|
let params = options;
|
|
this.formData.PI_BILLNO = params["releaseNo"];
|
this.formData.PI_USER = params["userID"];
|
this.formData.PI_staffName = params["staffName"];
|
this.formData.PI_Roleids=params["roleids"];
|
if(this.formData.PI_staffName=='null')
|
{
|
this.formData.PI_staffName='';
|
}
|
},
|
loadInspectorsList() {
|
// 从API获取检验员列表
|
this.$post({
|
url: "/Llj/getAllInspectors",
|
data: {
|
|
}
|
}).then(res => {
|
this.PI_NEW_staffName_Options = res.data;
|
});
|
|
|
},
|
//提交
|
async submitForm() {
|
try {
|
const valid = await this.$refs.uForm.validate()
|
if (valid) {
|
uni.showToast({
|
title: '提交成功',
|
icon: 'success'
|
})
|
// 这里添加后续业务逻辑
|
this.$post({
|
url: "/LLJ/SaveCheckBy",
|
data: {
|
releaseNo:this.formData.PI_BILLNO,
|
userID:this.formData.PI_USER,
|
NewStaffName:this.formData.PI_NEW_staffName,
|
NewStaffUserID:this.formData.PI_NEW_staffUserID
|
|
}
|
}).then(res => {
|
|
if (res.status == 0) {
|
uni.showToast({
|
title: res.message,
|
icon: 'success'
|
})
|
//关闭当前页面,返回上一页面或多级页面
|
setTimeout(() => {
|
uni.navigateBack();
|
}, 2000);
|
} else {
|
uni.showToast({
|
title: res.message,
|
icon: 'error'
|
})
|
}
|
});
|
}
|
} catch (error) {
|
console.error('验证失败:', error)
|
uni.showToast({
|
title: '请填写必填项',
|
icon: 'error',
|
duration: 2000
|
})
|
}
|
}
|
}
|
};
|
</script>
|
|
<style>
|
.form-container {
|
padding: 30rpx;
|
}
|
|
.submit-btn {
|
margin-top: 60rpx;
|
}
|
|
.input_Form {
|
pointer-events: none;
|
}
|
</style>
|