123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <template>
- <div>
- <el-dialog :title="exData.id ? '编辑': '新增'" :visible.sync="dialog" width="450px" :close-on-click-modal="false"
- top="50px">
- <el-form ref="form" :model="form" label-width="100px" class="bind-phone">
- <el-form-item label="项目名称:">
- <el-input v-model="form.project_name" placeholder="请输入项目名称"></el-input>
- </el-form-item>
- <el-form-item label="LOGO:">
- <upload class="marginT-20" type="qrcode" v-model="form.project_logo"></upload>
- </el-form-item>
- <el-form-item label="项目描述:">
- <el-input v-model="form.project_desc" placeholder="请输入项目描述"></el-input>
- </el-form-item>
- <el-form-item label="项目域名:">
- <el-input v-model="form.project_host" placeholder="请输入项目域名"></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer text-center">
- <el-button @click="dialog = false">取 消</el-button>
- <el-button type="danger" @click="handleSubmit">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import upload from '@/components/upload'
- export default {
- props: {
- value: {
- type: Boolean,
- default: true
- },
- exData: {
- type: Object,
- default: function () {
- return {}
- }
- }
- },
- components: {
- upload,
- },
- data () {
- return {
- dialog: !!this.value,
- form: {
- project_name: '',
- project_logo: '',
- project_desc: '',
- project_host: '',
- }
- }
- },
- methods: {
- async handleSubmit () {
- let url = this.exData.id ? '/project/edit' : '/project/add'
- const data = await this.$fetch(url, { ...this.form })
- if (data.code === 200) {
- this.$message.success('提交成功')
- this.$emit('success')
- this.$store.dispatch('common/setProjectArr')
- this.dialog = false
- }
- }
- },
- mounted () {
- if (this.exData.id) {
- this.form.id = this.exData.id
- for (const key in this.form) {
- this.form[key] = this.exData[key]
- }
- }
- },
- watch: {
- dialog (val) {
- if (!val) this.$emit('input', val)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .top-tip {
- margin-top: -20px;
- margin-bottom: 20px;
- }
- </style>
|