|
@@ -0,0 +1,105 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-dialog
|
|
|
+ v-loading="loading"
|
|
|
+ :visible.sync="visible"
|
|
|
+ :close-on-press-escape="true"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :show-close="false"
|
|
|
+ append-to-body
|
|
|
+ custom-class="home-edit-dialog link-add-dialog"
|
|
|
+ title="添加外部应用"
|
|
|
+ >
|
|
|
+ <div class="form-box">
|
|
|
+ <el-form :ref="formName" :model="formData" :rules="rules" label-width="100px">
|
|
|
+ <el-form-item prop="designation" label="应用名称">
|
|
|
+ <el-input v-model="formData.designation" clearable placeholder="请输入" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="url" label="应用URL">
|
|
|
+ <el-input v-model="formData.url" clearable placeholder="请输入" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button @click="close">取消</el-button>
|
|
|
+ <el-button type="primary" @click="saveItem">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+
|
|
|
+import { pushLinkAdd } from '@/api/link'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'LinkAdd',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // dialog
|
|
|
+ visible: false,
|
|
|
+ // form
|
|
|
+ formName: 'editForm',
|
|
|
+ formData: {
|
|
|
+ designation: '',
|
|
|
+ url: ''
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ designation: [
|
|
|
+ { required: true, message: '请输入应用名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ url: [
|
|
|
+ { type: 'url', required: true, message: '请输入应用URL', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ // others
|
|
|
+ loading: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ saveItem() {
|
|
|
+ this.$refs[this.formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.loading = true
|
|
|
+ pushLinkAdd(this.formData).then(res => {
|
|
|
+ this.loading = false
|
|
|
+ this.visible = false
|
|
|
+ this.$emit('refreshData')
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '保存成功!'
|
|
|
+ })
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ this.loading = false
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ duration: 0,
|
|
|
+ showClose: true,
|
|
|
+ message: '保存出错:' + error.message
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 加载dialog
|
|
|
+ */
|
|
|
+ open() {
|
|
|
+ this.visible = true
|
|
|
+ },
|
|
|
+ close() {
|
|
|
+ this.visible = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.home-edit-dialog {
|
|
|
+ width: 500px !important;
|
|
|
+}
|
|
|
+
|
|
|
+.form-box {
|
|
|
+ margin: 20px;
|
|
|
+}
|
|
|
+</style>
|