addMobile.vue 7.6 KB
<template>
    <el-dialog :title="title" :visible.sync="open" v-if="open" width="1000px" append-to-body top="10vh" custom-class="new_dialog">
        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
            <el-row :gutter="24">
                <el-col :span="12">
                    <el-form-item label="模型编号" prop="modelNo" label-width="120px">
                        <el-input v-model="modelNo" placeholder="请输入模型编号" :disabled='true' />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="模型名称" prop="modelName" label-width="120px">
                        <el-input v-model="form.modelName" placeholder="请输入模型名称" :disabled='disabled' />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="12">
                    <el-form-item label="模型版本" prop="modelVersion" label-width="120px">
                        <el-input v-model="form.modelVersion" placeholder="请输入模型版本" :disabled='disabled' />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="模型标识" prop="modelJob" label-width="120px">
                        <el-input v-model="form.modelJob" placeholder="请输入模型标识" :disabled='disabled' />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="24">
                    <el-form-item label="备注" prop="remarks" label-width="120px">
                        <el-input v-model="form.remarks" type="textarea" placeholder="请输入备注" show-word-limit
                            :disabled='disabled' />
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer" v-if="!disabled">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>
  
  <script>
import { modelManagerSave, modelManagerEdit, getModelNo } from "@/api/postList/list";
export default {
    name: 'addMobile',
    dicts: ['sys_normal_disable', 'name_roll_type'],
    props: [

    ],
    data() {
        return {
            imageUrl: '',
            labelProduct: [],
            checkList: [],
            open: false,
            // 弹出层标题
            title: "",
            // 表单参数
            form: {
                modelNo:''
            },
            modelNo:"",
            domains: [{
                value: ''
            }],
            disabled: true,
            // 表单校验
            rules: {
                // modelNo: [
                //     { required: true, message: "模型编号不能为空", trigger: "blur" }
                // ],
                modelName: [
                    { required: true, message: "模型名称不能为空", trigger: "blur" }
                ],
                modelVersion: [
                    { required: true, message: "模型版本不能为空", trigger: "blur" }
                ],
                modelJob:[
                    { required: true, message: "模型标识不能为空", trigger: "blur" }
                ]
            },
            pickerOptions: {
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        picker.$emit('pick', new Date());
                    }
                }, {
                    text: '昨天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', date);
                    }
                }, {
                    text: '一周前',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', date);
                    }
                }]
            },
            value2: '',
            id: ''
        }
    },
    methods: {
        // 取消按钮
        cancel() {
            this.open = false;
            this.form = {}
        },
        add() {
            this.open = true;
            this.form = {}
            this.id = ''
            getModelNo().then(response => {
                this.modelNo = response.msg
            });
        },
        edit(res) {
            this.form = res
            this.open = true;
            console.log(res.modelNo)
            this.modelNo = res.modelNo
            this.id = res.id
        },
        see(res) {
            this.form = res
            this.open = true;
            var lis = {
                pageNum: 1,
                pageSize: 10000,
            }
            getModelNo(lis).then(response => {
                this.labelProduct = response.rows
            });
        },
        handleAvatarSuccess(res, file) {
            this.imageUrl = URL.createObjectURL(file.raw);
        },
        beforeAvatarUpload(file) {
            const isJPG = file.type === 'image/jpeg';
            const isLt2M = file.size / 1024 / 1024 < 2;

            if (!isJPG) {
                this.$message.error('上传头像图片只能是 JPG 格式!');
            }
            if (!isLt2M) {
                this.$message.error('上传头像图片大小不能超过 2MB!');
            }
            return isJPG && isLt2M;
        },
        /** 提交按钮 */
        submitForm: function () {
            this.$refs["form"].validate(valid => {
                this.form.modelNo = this.modelNo
                this.form.id = this.id
                if (valid) {
                    if (this.id) {
                        modelManagerEdit(this.form).then(response => {
                            if (response.code == 200) {
                                this.$modal.msgSuccess(response.msg);
                                this.open = false;
                                this.$emit("getList")
                            } else {
                                this.$modal.msgSuccess(response.msg);
                            }
                        });
                    } else {
                        modelManagerSave(this.form).then(response => {
                            if (response.code == 200) {
                                this.$modal.msgSuccess(response.msg);
                                this.open = false;
                                this.$emit("getList")
                            } else {
                                this.$modal.msgSuccess(response.msg);
                            }
                        });
                    }
                }
            });
        },
    }
}
</script>
  
  <style>
  .box1 {
      display: flex;
      justify-content: space-around;
      width: 100%;
  }
  
  .avatar-uploader .el-upload {
      border: 1px dashed #d9d9d9;
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
  }
  
  .avatar-uploader .el-upload:hover {
      border-color: #409EFF;
  }
  
  .avatar-uploader-icon {
      font-size: 28px;
      color: #8c939d;
      width: 178px;
      height: 178px;
      line-height: 178px;
      text-align: center;
  }
  
  .avatar {
      width: 178px;
      height: 178px;
      display: block;
  }
  
  .new_dialog {
      height: 60%;
      overflow: hidden;
      overflow-y: scroll;
  }
  </style>