zoukankan      html  css  js  c++  java
  • vue----element-ui

    select

    <template>
        <div class="sysConfig">
            <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="平台同步下载企业">
                    <template>
                        <!--select修改值的变化是通过v-model(v-model="ruleForm.compId)来体现的"-->
                        <!--sysCompanies:是可以数组(里面是字典),可以通过数据库获取,可以是直接赋初始值-->
                        <el-select v-model="ruleForm.compId">
                            <el-option
                                    v-for="item in sysCompanies"
                                    :key="item.compName"
                                    :label="item.compName"
                                    :value="item.id">
                            </el-option>
                        </el-select>
                    </template>
                </el-form-item>
                <el-form-item label="平台同步主机地址" prop="platUrl">
                    <el-input v-model="ruleForm.platUrl" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="平台加密秘钥" prop="checkPass">
                    <el-input v-model="ruleForm.platEncryptKey" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="平台访问秘钥" prop="platVisitKey">
                    <el-input v-model.number="ruleForm.platVisitKey"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
    </template>
    
    <script lang="ts">
        import {Component, Vue, Provide, Prop} from "vue-property-decorator";
        @Component({components: {}})
        export default class SysUploadLabel extends Vue {
            //select中的值
            @Provide() sysCompanies:any=[];
            //用于传给后台的值
            @Provide() ruleForm: {
                platUrl: String,
                platEncryptKey: String,
                platVisitKey: String
                compId:any
            } = {
                platUrl: '',
                platEncryptKey: '',
                platVisitKey: '',
                compId:''
            }
            @Provide() rules = {
                platUrl: [
                    {required: true, message: '请填写平台同步主机地址', trigger: 'blur'}
                ],
                platEncryptKey: [
                    {required: true, message: '请填写平台加密秘钥', trigger: 'blur'}
                ],
                platVisitKey: [
                    {required: true, message: '请填写平台访问秘钥', trigger: 'blur'}
                ]
            }
            submitForm(formName: string | number) {
                (this.$refs[formName] as any).validate((valid: any) => {
                    if (valid) {
                        (this as any).$axios.updateSysConfig(this.ruleForm).then((res: any) => {
                            this.$message({
                                message: '修改成功',
                                type: 'success'
                            });
                        });
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            }
    
            resetForm(formName: string | number) {
                this.loadData();
            }
    
            created() {
                this.loadData();
            }
    
            loadData() {
                (this as any).$axios.getSysConfig().then((res: any) => {
                    this.ruleForm.platUrl = res.data.platUrl
                    this.ruleForm.platVisitKey = res.data.platVisitKey
                    this.ruleForm.platEncryptKey = res.data.platEncryptKey
                    this.sysCompanies = res.data.sysCompanies
                    //赋初始值
                    this.ruleForm.compId = res.data.compId
                });
            }
        }
    </script>
    
    <style scoped>
        .sysConfig {
             600px;
            margin: 0 auto;
            margin-top: 100px;
        }
    </style>

    ForEach

    this.sysCompanies.forEach((item: any)=>{
                        
    })

    让input框只能输入数字(效果是输入字母,不会显示在input框中)

    <el-input v-model="scope.row.postArea" v-if="scope.row.edit" oninput = "this.value=this.value.replace(/[^d]/g,'')"></el-input> //vue中使用需要加this
    

    点击事件让标签隐藏

    <tag v-if="a"></tag>   //点击事件后,将a变成false
    

      

  • 相关阅读:
    div3--C. Pipes
    Problem F Free Weights
    H
    Problem C Careful Ascent
    Problem L. World Cup
    Problem E. Bet
    Problem D. Ice Cream Tower
    A. Number Theory Problem
    A
    软考知识点梳理--项目评估
  • 原文地址:https://www.cnblogs.com/yanxiaoge/p/11977040.html
Copyright © 2011-2022 走看看