DialogForm.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <el-dialog
  3. v-if="visible"
  4. width="600px"
  5. :title="form.id?'编辑文旅数据开放网站':'新建文旅数据开放网站'"
  6. :visible.sync="visible"
  7. >
  8. <el-form v-loading="isLoading" :model="form" label-width="100px" label-position="top">
  9. <el-form-item label="网站标题">
  10. <el-input v-model="form.title"/>
  11. </el-form-item>
  12. <el-form-item label="网站URL">
  13. <el-input v-model="form.url"/>
  14. </el-form-item>
  15. <el-form-item label="备注说明">
  16. <el-input v-model="form.remark"/>
  17. </el-form-item>
  18. </el-form>
  19. <div slot="footer" class="dialog-footer">
  20. <el-button @click="visible = false">取 消</el-button>
  21. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  22. </div>
  23. </el-dialog>
  24. </template>
  25. <script>
  26. import { save, updateById } from '@/api/open_website'
  27. export default {
  28. components: {},
  29. data() {
  30. return {
  31. visible: false,
  32. isLoading: false,
  33. form: {}
  34. }
  35. },
  36. mounted() {
  37. },
  38. methods: {
  39. open(data) {
  40. this.visible = true
  41. this.isLoading = false
  42. this.form = Object.assign({}, data)
  43. },
  44. handleSubmit() {
  45. console.log(this.form)
  46. if (this.form.id) {
  47. updateById(this.form.id, this.form).then(() => {
  48. this.visible = false
  49. this.$emit('ok')
  50. }).finally(() => {
  51. this.isLoading = false
  52. })
  53. } else {
  54. save(this.form).then(res => {
  55. this.visible = false
  56. this.$emit('ok')
  57. }).finally(() => {
  58. this.isLoading = false
  59. })
  60. }
  61. }
  62. }
  63. }
  64. </script>