entityManager.vue.ftl
3.21 KB
1
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<#assign baseUrl><#noparse>${</#noparse>${cfg.system}<#noparse>}</#noparse><#if package.ModuleName??>/${package.ModuleName}</#if>/${table.entityPath}/v1</#assign>
<template>
<div>
<ht-table
ref="htTable"
:data="rows"
:pageResult="pagination"
:selection="true"
quick-search-props="${table.fields[0].propertyName}"
:show-export="false"
:show-custom-column="false"
@loading="loadData"
>
<template v-slot:toolbar>
<el-button-group>
<el-button size="small" @click="showDialog()" icon="el-icon-plus">添加</el-button>
<el-button
v-popconfirm="{ before: removeValid, confirm: handleRemove }"
type="danger"
icon="el-icon-delete"
>删除</el-button>
</el-button-group>
</template>
<template>
<ht-table-column type="index" width="50" align="center" label="序号" />
<#list table.fields as field>
<#assign propertyName>${cfg.cgUtil.getPropertyName(cfg.boEntList,table.name,field.name,field.propertyName)}</#assign>
<ht-table-column
prop="${propertyName}"
label="${field.comment!""}"
:sortable="true"
:show-overflow-tooltip="true"
>
<#if field_index == 0 >
<template v-slot="{row}">
<el-link
type="primary"
@click="showDialog(row.id)"
title="查看详情"
>{{row.${propertyName}}}</el-link>
</template>
</#if>
</ht-table-column>
</#list>
</template>
</ht-table>
<${table.entityName}-manager-edit ref="${table.entityName}ManagerEdit"></${table.entityName}-manager-edit>
</div>
</template>
<script>
import ${table.entityName}ManagerEdit from "./${table.entityName}ManagerEdit.vue";
import api from "@/api/${table.entityName}.js"
export default {
name: '${table.entityName}Manager',
components:{${table.entityName}ManagerEdit},
data() {
return {
dialogVisible: false,
rows: [],
pagination: {
page: 1,
pageSize: 50,
total: 0
},
${table.entityName}: {},
saveMethod: "POST"
};
},
computed: {
tableHeight() {
return this.$baseTableHeight()
},
},
methods: {
showDialog(id) {
this.$refs.${table.entityName}ManagerEdit.showDialog(id);
},
loadData(param, cb) {
api.loadData(param||{}).then(
(resp) => {
let response = resp.data || resp
this.rows = response.rows
this.total = response.total
this.pagination = {
page: response.page,
pageSize: response.pageSize,
total: response.total
}
}
)
.finally(() => cb && cb());
},
removeValid() {
if (this.$refs.htTable.selection.length == 0) {
this.$message({ message: '请至少选择一条记录', type: 'warning' })
return false
}
return true
},
handleRemove() {
const ids = []
this.$refs.htTable.selection.forEach((item) => {
ids.push(item.id)
})
api.deleteByIds(ids.join(',')).then(() => {
this.loadData()
})
},
}
};
</script>