zjh
昨天 d123ca35bb3ec4982af44aeb1ffffa8a3569a21b
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
<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>