<script>
export default {
    methods: {
        /** 提交按钮 */
        submitForm: function () {
            this.$refs["form"].validate((valid) => {
                if (valid) {
                    console.log(JSON.stringify(this.form));

                    if (this.form.id != undefined && this.opertype === 2) {
                        updateQcGp12ServiceStatistics(this.form)
                            .then((res) => {
                                this.msgSuccess("修改成功");
                                this.open = false;
                                this.getList();
                            })
                            .catch((err) => {
                                //TODO 错误逻辑
                            });
                    } else {
                        addQcGp12ServiceStatistics(this.form)
                            .then((res) => {
                                this.msgSuccess("新增成功");
                                this.open = false;
                                this.getList();
                            })
                            .catch((err) => {
                                //TODO 错误逻辑
                            });
                    }
                }
            });
        },
        /** 新增表单校验规则 */
        rules: {
            id: [
                { required: true, message: "序号不能为空", trigger: "blur" }
            ],
            workOrder: [
                { required: true, message: "工单号不能为空", trigger: "blur" }
            ],
            partNumber: [
                { required: true, message: "零件号不能为空", trigger: "blur" }
            ],
            description: [
                { required: true, message: "零件描述不能为空", trigger: "blur" }
            ],
            specification: [
                { required: true, message: "规格不能为空", trigger: "blur" }
            ],
            color: [
                { required: true, message: "颜色不能为空", trigger: "blur" }
            ],
            team: [
                { required: true, message: "班组不能为空", trigger: "blur" }
            ],
            siteNo: [
                { required: true, message: "站点号不能为空", trigger: "blur" }
            ],
            comNo: [
                { required: true, message: "串口号不能为空", trigger: "blur" }
            ],
            startTime: [
                { required: true, message: "开始时间不能为空", trigger: "change" }
            ],
            endTime: [
                { required: true, message: "结束时间不能为空", trigger: "change" }
            ],
            requireNumber: [
                { required: true, message: "投入数不能为空", trigger: "blur" }
            ],
            qualifiedNumber: [
                { required: true, message: "合格数不能为空", trigger: "blur" }
            ],
            qualifiedRate: [
                { required: true, message: "合格率不能为空", trigger: "blur" }
            ],
            damoNumber: [
                { required: true, message: "打磨数不能为空", trigger: "blur" }
            ],
            baofeiNumber: [
                { required: true, message: "报废数不能为空", trigger: "blur" }
            ],
        },
    },
};
</script>