details.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div>
  3. <el-dialog :title="exData.id ? '编辑': '新增'" :visible.sync="dialog" width="450px" :close-on-click-modal="false"
  4. top="50px">
  5. <el-form ref="form" :model="form" label-width="100px" class="bind-phone">
  6. <el-form-item label="项目名称:">
  7. <el-input v-model="form.project_name" placeholder="请输入项目名称"></el-input>
  8. </el-form-item>
  9. <el-form-item label="LOGO:">
  10. <upload class="marginT-20" type="qrcode" v-model="form.project_logo"></upload>
  11. </el-form-item>
  12. <el-form-item label="项目描述:">
  13. <el-input v-model="form.project_desc" placeholder="请输入项目描述"></el-input>
  14. </el-form-item>
  15. <el-form-item label="项目域名:">
  16. <el-input v-model="form.project_host" placeholder="请输入项目域名"></el-input>
  17. </el-form-item>
  18. </el-form>
  19. <div slot="footer" class="dialog-footer text-center">
  20. <el-button @click="dialog = false">取 消</el-button>
  21. <el-button type="danger" @click="handleSubmit">确 定</el-button>
  22. </div>
  23. </el-dialog>
  24. </div>
  25. </template>
  26. <script>
  27. import upload from '@/components/upload'
  28. export default {
  29. props: {
  30. value: {
  31. type: Boolean,
  32. default: true
  33. },
  34. exData: {
  35. type: Object,
  36. default: function () {
  37. return {}
  38. }
  39. }
  40. },
  41. components: {
  42. upload,
  43. },
  44. data () {
  45. return {
  46. dialog: !!this.value,
  47. form: {
  48. project_name: '',
  49. project_logo: '',
  50. project_desc: '',
  51. project_host: '',
  52. }
  53. }
  54. },
  55. methods: {
  56. async handleSubmit () {
  57. let url = this.exData.id ? '/project/edit' : '/project/add'
  58. const data = await this.$fetch(url, { ...this.form })
  59. if (data.code === 200) {
  60. this.$message.success('提交成功')
  61. this.$emit('success')
  62. this.$store.dispatch('common/setProjectArr')
  63. this.dialog = false
  64. }
  65. }
  66. },
  67. mounted () {
  68. if (this.exData.id) {
  69. this.form.id = this.exData.id
  70. for (const key in this.form) {
  71. this.form[key] = this.exData[key]
  72. }
  73. }
  74. },
  75. watch: {
  76. dialog (val) {
  77. if (!val) this.$emit('input', val)
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .top-tip {
  84. margin-top: -20px;
  85. margin-bottom: 20px;
  86. }
  87. </style>