Blame view

src/components/report/AddReportCustomComponentRel.vue 2.86 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    <el-row>
      <el-col :span="24">
        <el-card>
          <div slot="header" class="clearfix">
            <span>{{ $t('addReportCustomComponentRel.title') }}</span>
          </div>
  
          <el-form :model="form" :rules="rules" ref="form" label-width="150px">
            <el-form-item :label="$t('addReportCustomComponentRel.component')" prop="componentId">
              <el-input v-model="form.name" disabled style="width: calc(100% - 120px)" />
              <el-button type="primary" style="margin-left: 10px; width: 110px" @click="openChooseComponentDialog">
                {{ $t('addReportCustomComponentRel.chooseComponent') }}
              </el-button>
            </el-form-item>
  
            <el-form-item :label="$t('addReportCustomComponentRel.seq')" prop="seq">
              <el-input v-model="form.seq" />
            </el-form-item>
  
            <el-form-item>
              <el-button type="primary" @click="submitForm">{{ $t('common.save') }}</el-button>
              <el-button @click="cancel">{{ $t('common.cancel') }}</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </el-col>
  
      <choose-report-custom-component ref="chooseComponentDialog" @selected="handleComponentSelected" />
    </el-row>
  </template>
  
  <script>
  import { saveReportCustomComponentRel } from '@/api/report/reportCustomComponentRelManageApi'
  import ChooseReportCustomComponent from '@/components/report/ChooseReportCustomComponent'
  
  export default {
    name: 'AddReportCustomComponentRel',
    props: {
      customId: {
        type: String,
        required: true
      }
    },
    components: {
      ChooseReportCustomComponent
    },
    data() {
      return {
        form: {
          customId: this.customId,
          componentId: '',
          name: '',
          seq: ''
        },
        rules: {
          componentId: [
            { required: true, message: this.$t('addReportCustomComponentRel.componentRequired'), trigger: 'blur' }
          ],
          seq: [
            { required: true, message: this.$t('addReportCustomComponentRel.seqRequired'), trigger: 'blur' },
            { pattern: /^\d+$/, message: this.$t('addReportCustomComponentRel.seqMustNumber'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      submitForm() {
        this.$refs.form.validate(async valid => {
          if (valid) {
            try {
              await saveReportCustomComponentRel(this.form)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
73
              this.$message.success(this.$t('common.operationSuccess'))
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
              this.$emit('success')
            } catch (error) {
              this.$message.error(error.message || this.$t('addReportCustomComponentRel.saveError'))
            }
          }
        })
      },
      cancel() {
        this.$emit('cancel')
      },
      openChooseComponentDialog() {
        this.$refs.chooseComponentDialog.open()
      },
      handleComponentSelected(component) {
        this.form.componentId = component.componentId
        this.form.name = component.name
      }
    }
  }
  </script>