Dialog組件的使用方法

這篇文章主要介紹“Dialog組件的使用方法”,在日常操作中,相信很多人在Dialog組件的使用方法問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Dialog組件的使用方法”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

你所需要的網(wǎng)站建設服務,我們均能行業(yè)靠前的水平為你提供.標準是產(chǎn)品質(zhì)量的保證,主要從事成都網(wǎng)站制作、成都網(wǎng)站建設、企業(yè)網(wǎng)站建設、手機網(wǎng)站開發(fā)、網(wǎng)頁設計、品牌網(wǎng)站建設、網(wǎng)頁制作、做網(wǎng)站、建網(wǎng)站。創(chuàng)新互聯(lián)擁有實力堅強的技術研發(fā)團隊及素養(yǎng)的視覺設計專才。

1.Dialog用法

<el-dialog title="新增巡檢模板" :visible.sync="addDialog" width="40%">
    <el-form ref='addForm' :rules="rules" :model='addForm' label-width="80px">
        <el-form-item label="選擇業(yè)務" prop="bk_biz">
            <el-select v-model="addForm.add_bk_biz" placeholder="請輸入業(yè)務名稱" class="modal1" >
                <el-option v-for="item in bkBizData" :value="item.bk_biz_id +':'+item.bk_biz_name" :label="item.bk_biz_name">
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="模板名稱" prop="temp_name">
            <el-input v-model="addForm.add_temp_name" placeholder="請輸入模板名稱" class="modal1"></el-input>
        </el-form-item>
        <el-form-item label="巡檢腳本" prop="temp_script">
            <el-input v-model="addForm.add_temp_script" type="textarea" placeholder="請輸入巡檢腳本" class="modal1"></el-input>
        </el-form-item>
        <el-form-item label="模板閥值" prop="temp_value">
            <el-input v-model="addForm.add_temp_value" placeholder="請輸入模板閥值" class="modal1"></el-input>
        </el-form-item>
        <el-form-item label="模板備注" prop="temp_note">
            <el-input v-model="addForm.add_temp_note" type="textarea" placeholder="請輸入備注" class="modal1"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="addDialogOk">立即創(chuàng)建</el-button>
            <el-button @click="addDialog = false">取消</el-button>
        </el-form-item>
    </el-form>
</el-dialog>

對應js代碼

<script type="text/javascript">
    new Vue({
        el: '#app',
        data: {
            bkBizData: [],
            addDialog:false,
            addForm: {
                add_bk_biz: '',
                add_temp_name: '',
                add_temp_script: '',
                add_temp_note: '',
                add_temp_threshold: ''
            },
            rules: {
                bk_biz: [
                    { required: true, message: '請選擇業(yè)務', trigger: 'change' }
                ],
                temp_name: [
                    { required: true, message: '請輸入模板名稱', trigger: 'blur' },
                    { min: 2, max: 8, message: '長度在 2 到 8 個字符', trigger: 'change' }
                ],
                temp_script: [
                    { required: true, message: '請輸入巡檢腳本', trigger: 'blur' }
                ],
                temp_note: [
                    { required: true, message: '請輸入備注', trigger: 'blur' },
                    { min: 2, message: '長度最少2位', trigger: 'blur' }
                ],
                temp_value: [
                    { type: 'number', required: true, message: '請輸入閾值', trigger: 'change' }
                ]
            }
        },
        mounted() {
            // 頁面加載就獲取所有模板
            this.init()
        },
        methods: {
            init() {
                axios.get(site_url + "get_biz_list/").then(res => {
                    if (res.data.result){
                        this.bkBizData = res.data.data;
                    }else{
                        this.$message.error('獲取業(yè)務失敗');
                    }
                },'json');
                this.getSearch();
            },
            getSearch() {
                axios.get(site_url + "temp_view/?search_biz=" + this.searchBiz + "&query_str=" + this.searchTempName).then(res => {
                    if (res.data.result){
                        this.tempData = res.data.data;
                    }else{
                        this.$message.error('獲取模板失敗');
                    }
                },'json');
            },
            addDialogOk() {
                this.$refs['addForm'].validate((valid) => {
                    if (valid) {
                        axios.post(site_url + "temp_view/", this.addForm).then(res => {
                            if (res.data.result) {
                                this.$message.success('添加模板成功');
                                this.addDialog = false;
                                this.getSearch();
                                this.addForm = {
                                    add_bk_biz: '',
                                    add_temp_name: '',
                                    add_temp_script: '',
                                    add_temp_value: '',
                                    add_temp_note: ''
                                }
                            } else {
                                this.$message.error('添加模板失敗');
                            }
                        }, 'json');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                })
            },
            ...
        }
    })
</script>

到此,關于“Dialog組件的使用方法”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

網(wǎng)頁名稱:Dialog組件的使用方法
標題網(wǎng)址:http://muchs.cn/article22/iepscc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、企業(yè)網(wǎng)站制作、定制網(wǎng)站、微信小程序、建站公司網(wǎng)站建設

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設計