Commit af433352 by 吴迪

添加data

parent 57b5bb90
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
if (data && data.code === 0) { if (data && data.code === 0) {
#foreach($column in $columns) #foreach($column in $columns)
#if($column.columnName != $pk.columnName) #if($column.columnName != $pk.columnName)
this.dataForm.${column.attrname} = data.${classname}.${column.attrname} this.dataForm.${column.attrname} = data.data.${column.attrname}
#end #end
#end #end
} }
......
<template>
<div>
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="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>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
<el-button @click="visible = false">取消</el-button>
</span>
</div>
</template>
<script>
export default {
data () {
return {
dataForm: {
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
${column.attrname}: 0,
#else
${column.attrname}: ''#if($velocityCount != $columns.size()),#end
#end
#end
},
dataRule: {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
${column.attrname}: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
]#if($velocityCount != $columns.size()),#end
#end
#end
}
}
},
methods: {
// 表单提交
dataFormSubmit () {
#[[this.$refs['dataForm'].validate((valid) => {]]#
if (valid) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/${!this.dataForm.${pk.attrname} ? 'save' : 'update'}`),
method: 'post',
#[[data: this.$http.adornData({]]#
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
'${column.attrname}': this.dataForm.${column.attrname} || undefined,
#else
'${column.attrname}': this.dataForm.${column.attrname}#if($velocityCount != $columns.size()),#end
#end
#end
})
}).then(({data}) => {
if (data && data.code === 0) {
#[[this.$message({]]#
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
#[[this.$emit('refreshDataList')]]#
}
})
} else {
#[[this.$message.error(data.msg)]]#
}
})
}
})
}
}
}
</script>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="getDataList()">查询</el-button> <el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button> <el-button v-if="isAuth('${moduleName}:${pathName}:save')" type="primary" @click="addHandle()">新增</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button> <el-button v-if="isAuth('${moduleName}:${pathName}:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
width="150" width="150"
label="操作"> label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.${pk.attrname})">修改</el-button> <el-button type="text" size="small" @click="updateHandle(scope.row.${pk.attrname})">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.${pk.attrname})">删除</el-button> <el-button type="text" size="small" @click="deleteHandle(scope.row.${pk.attrname})">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
...@@ -51,13 +51,10 @@ ...@@ -51,13 +51,10 @@
:total="totalPage" :total="totalPage"
layout="total, sizes, prev, pager, next, jumper"> layout="total, sizes, prev, pager, next, jumper">
</el-pagination> </el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div> </div>
</template> </template>
<script> <script>
import AddOrUpdate from './${pathName}-add-or-update'
export default { export default {
data () { data () {
return { return {
...@@ -73,9 +70,6 @@ ...@@ -73,9 +70,6 @@
addOrUpdateVisible: false addOrUpdateVisible: false
} }
}, },
components: {
AddOrUpdate
},
activated () { activated () {
this.getDataList() this.getDataList()
}, },
...@@ -93,7 +87,7 @@ ...@@ -93,7 +87,7 @@
}) })
}).then(({data}) => { }).then(({data}) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.dataList = data.list this.dataList = data.data.list
this.totalPage = data.totalCount this.totalPage = data.totalCount
} else { } else {
this.dataList = [] this.dataList = []
...@@ -117,15 +111,21 @@ ...@@ -117,15 +111,21 @@
selectionChangeHandle (val) { selectionChangeHandle (val) {
this.dataListSelections = val this.dataListSelections = val
}, },
// 新增 / 修改 // 新增
addOrUpdateHandle (id) { addHandle () {
this.addOrUpdateVisible = true #[[this.$nextTick(() => {]]#
#[[this.$nextTick(() => {]]# #[[this.$router.push]]#({ name: 'manage-${pathName}-${pathName}addui' })
this.$refs.addOrUpdate.init(id) #[[})]]#
}) },
// 修改
updateHandle (id) {
#[[this.$nextTick(() => {]]#
#[[this.$router.push]]#({ name: 'manage-${pathName}-${pathName}'updateui', params: { id: id } })
#[[})]]#
}, },
// 删除 // 删除
deleteHandle (id) { deleteHandle (id) {
// 提示要修改成name,每个表的都不一样,所以做不了通用的,暂时使用id
var ids = id ? [id] : this.dataListSelections.map(item => { var ids = id ? [id] : this.dataListSelections.map(item => {
return item.${pk.attrname} return item.${pk.attrname}
}) })
......
-- 菜单SQL -- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('0', '${comments}', '${moduleName}/${pathName}', NULL, '1', 'config', '6'); VALUES ('0', '${comments}', '${moduleName}/${pathName}/${pathName}', NULL, '1', 'config', '6');
-- 按钮父菜单ID -- 按钮父菜单ID
set @parentId = @@identity; set @parentId = @@identity;
...@@ -14,3 +14,12 @@ INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `or ...@@ -14,3 +14,12 @@ INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `or
SELECT @parentId, '修改', null, '${moduleName}:${pathName}:update', '2', null, '6'; SELECT @parentId, '修改', null, '${moduleName}:${pathName}:update', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, '${moduleName}:${pathName}:delete', '2', null, '6'; SELECT @parentId, '删除', null, '${moduleName}:${pathName}:delete', '2', null, '6';
-- 新增的${moduleName}ui菜单
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('53', '${comments}-新增', '${moduleName}/${pathName}/${pathName}addui', '${moduleName}:${pathName}:save', '1', 'config', '6');
-- 修改的${moduleName}ui菜单
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('53', '${comments}-修改', '${moduleName}/${pathName}/${pathName}updateui', '${moduleName}:${pathName}:update', '1', 'config', '6');
<template>
<div>
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="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>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
<el-button @click="visible = false">取消</el-button>
</span>
</div>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
${column.attrname}: 0,
#else
${column.attrname}: ''#if($velocityCount != $columns.size()),#end
#end
#end
},
dataRule: {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
${column.attrname}: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
]#if($velocityCount != $columns.size()),#end
#end
#end
}
}
},
mounted () {
this.$nextTick(() => {
this.init(this.$route.params.id)
})
},
methods: {
init (id) {
this.dataForm.${pk.attrname} = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.${pk.attrname}) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/info/#[[$]]#{this.dataForm.${pk.attrname}}`),
method: 'get',
#[[params: this.$http.adornParams()]]#
}).then(({data}) => {
if (data && data.code === 0) {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
this.dataForm.${column.attrname} = data.data.${column.attrname}
#end
#end
}
})
}
})
},
// 表单提交
dataFormSubmit () {
#[[this.$refs['dataForm'].validate((valid) => {]]#
if (valid) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/${!this.dataForm.${pk.attrname} ? 'save' : 'update'}`),
method: 'post',
#[[data: this.$http.adornData({]]#
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
'${column.attrname}': this.dataForm.${column.attrname} || undefined,
#else
'${column.attrname}': this.dataForm.${column.attrname}#if($velocityCount != $columns.size()),#end
#end
#end
})
}).then(({data}) => {
if (data && data.code === 0) {
#[[this.$message({]]#
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
#[[this.$emit('refreshDataList')]]#
}
})
} else {
#[[this.$message.error(data.msg)]]#
}
})
}
})
}
}
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment