日照智慧社区接口服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.8 KiB

6 years ago
<template>
<el-dialog :visible.sync="visible" :title="!dataForm.${pk.attrname} ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'">
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
<el-form-item label="${column.comments}" prop="${column.attrname}">
<el-input v-model="dataForm.${column.attrname}" placeholder="${column.comments}"></el-input>
</el-form-item>
#end
#end
</el-form>
<template slot="footer">
<el-button @click="visible = false">{{ $t('cancel') }}</el-button>
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button>
</template>
</el-dialog>
</template>
<script>
import debounce from 'lodash/debounce'
export default {
data () {
return {
visible: false,
4 years ago
dataForm: {;
6 years ago
#foreach($column in $columns)
4 years ago
${column.attrname}: ''#if($velocityCount != $columns.size()),;#end
6 years ago
#end
}
}
},
computed: {
dataRule () {
4 years ago
return {;
6 years ago
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
${column.attrname}: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
4 years ago
]#if($velocityCount != $columns.size()),;#end
6 years ago
#end
#end
}
}
},
methods: {
init () {
4 years ago
this.visible = true;
6 years ago
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
4 years ago
if (this.dataForm.${pk.attrname}); {
6 years ago
this.getInfo()
}
})
},
// 获取信息
getInfo () {
4 years ago
#[[this.$http.get(]];#`/${moduleName}/${pathName}/#[[${]]#this.dataForm.${pk.attrname}}`;).then(({ data: res }) => {
6 years ago
if (res.code !== 0) {
4 years ago
#[[;return this.$message.error(res.msg);]]#
6 years ago
}
this.dataForm = {
...this.dataForm,
...res.data
}
}).catch(() => {})
},
// 表单提交
dataFormSubmitHandle: debounce(function () {
#[[this.$refs['dataForm'].validate((valid) => {]]#
4 years ago
if (!valid); {
6 years ago
return false
}
4 years ago
#[[this.$http]];#[!this.dataForm.$;{pk.attrname} ? 'post' : 'put';]('/${moduleName}/${pathName}/', this.dataForm).then(({ data: res }) => {
6 years ago
if (res.code !== 0) {
4 years ago
#[[;return this.$message.error(res.msg);]]#
6 years ago
}
4 years ago
this.$message({;
#[[message;: this.$t('prompt.success'),;]]#
type;: 'success',
duration;: 500,
onClose;: () => {
this.visible = false;
6 years ago
this.$emit('refreshDataList')
}
})
}).catch(() => {})
})
}, 1000, { 'leading': true, 'trailing': false })
}
}
</script>