| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <template>
- <el-dialog
- :title="title"
- :visible.sync="dialogFormVisible"
- width="500px"
- @close="close"
- >
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
- <el-form-item label="标题" prop="title">
- <el-input v-model="form.title" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="close">取 消</el-button>
- <el-button type="primary" @click="save">确 定</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import {{ camelCase name }}Api from '@/api/{{moduleName}}/{{ camelCase name }}'
- export default {
- name: '{{ properCase name }}Edit',
- data() {
- return {
- form: {
- title: '',
- },
- rules: {
- title: [{ required: true, trigger: 'blur', message: '请输入标题' }],
- },
- title: '',
- dialogFormVisible: false,
- }
- },
- created() {},
- methods: {
- showEdit(row) {
- if (!row) {
- this.title = '添加'
- } else {
- this.title = '编辑'
- this.form = Object.assign({}, row)
- }
- this.dialogFormVisible = true
- },
- close() {
- this.$refs['form'].resetFields()
- this.form = this.$options.data().form
- this.dialogFormVisible = false
- },
- save() {
- this.$refs['form'].validate(async (valid) => {
- if (valid) {
- const { msg } = await {{ camelCase name }}Api.doEdit(this.form)
- this.$baseMessage(msg, 'success')
- this.$emit('fetch-data')
- this.close()
- } else {
- return false
- }
- })
- },
- },
- }
- </script>
|