commit | author | age
|
9bcb19
|
1 |
<template> |
I |
2 |
<a-card :bordered="false" v-show="indexConfigShow"> |
|
3 |
<div class="table-operator"> |
|
4 |
<a-button class="but_item" type="dashed" @click="handleCancel" icon="rollback">返回</a-button> |
|
5 |
<a-button type="primary" icon="plus" @click="handleSubmit">保存</a-button> |
|
6 |
</div> |
|
7 |
<a-table |
|
8 |
ref="table" |
|
9 |
size="middle" |
|
10 |
:columns="columns" |
|
11 |
:dataSource="loadData" |
|
12 |
:pagination="false" |
|
13 |
:alert="true" |
|
14 |
:loading="tableLoading" |
|
15 |
:rowKey="(record) => record.id" |
|
16 |
> |
|
17 |
<template slot="columnComment" slot-scope="text, record"> |
|
18 |
<a-input v-model="record.columnComment" /> |
|
19 |
</template> |
|
20 |
<template slot="javaType" slot-scope="text, record"> |
|
21 |
<a-select style="width: 120px" v-model="record.javaType" :disabled="judgeColumns(record)"> |
|
22 |
<a-select-option v-for="(item,index) in javaTypeData" :key="index" :value="item.code">{{ item.name }}</a-select-option> |
|
23 |
</a-select> |
|
24 |
</template> |
|
25 |
<template slot="effectType" slot-scope="text, record"> |
|
26 |
<a-select style="width: 120px" v-model="record.effectType" :disabled="judgeColumns(record)"> |
|
27 |
<a-select-option v-for="(item,index) in effectTypeData" :key="index" :value="item.code">{{ item.name }}</a-select-option> |
|
28 |
</a-select> |
|
29 |
</template> |
|
30 |
<template slot="dictTypeCode" slot-scope="text, record"> |
|
31 |
<a-select |
|
32 |
style="width: 120px" |
|
33 |
v-model="record.dictTypeCode" |
|
34 |
:disabled="record.effectType !== 'radio' && |
|
35 |
record.effectType !== 'select' && record.effectType !== 'checkbox'"> |
|
36 |
<a-select-option v-for="(item,index) in dictDataAll" :key="index" :value="item.code">{{ item.name }}</a-select-option> |
|
37 |
</a-select> |
|
38 |
</template> |
|
39 |
<template slot="whetherTable" slot-scope="text, record"> |
|
40 |
<a-checkbox v-model="record.whetherTable"/> |
|
41 |
</template> |
|
42 |
<template slot="whetherRetract" slot-scope="text, record"> |
|
43 |
<a-checkbox v-model="record.whetherRetract"/> |
|
44 |
</template> |
|
45 |
<template slot="whetherAddUpdate" slot-scope="text, record"> |
|
46 |
<a-checkbox v-model="record.whetherAddUpdate" :disabled="judgeColumns(record)"/> |
|
47 |
</template> |
|
48 |
<template slot="whetherRequired" slot-scope="text, record"> |
|
49 |
<a-checkbox v-model="record.whetherRequired" :disabled="judgeColumns(record)"/> |
|
50 |
</template> |
|
51 |
<template slot="queryWhether" slot-scope="text, record"> |
|
52 |
<a-switch v-model="record.queryWhether"> |
|
53 |
<a-icon slot="checkedChildren" type="check" /> |
|
54 |
<a-icon slot="unCheckedChildren" type="close" /> |
|
55 |
</a-switch> |
|
56 |
</template> |
|
57 |
<template slot="queryType" slot-scope="text, record"> |
|
58 |
<a-select style="width: 100px" v-model="record.queryType" :disabled="!record.queryWhether"> |
|
59 |
<a-select-option v-for="(item,index) in codeGenQueryTypeData" :key="index" :value="item.code">{{ item.name }}</a-select-option> |
|
60 |
</a-select> |
|
61 |
</template> |
|
62 |
</a-table> |
|
63 |
</a-card> |
|
64 |
</template> |
|
65 |
<script> |
|
66 |
import { sysCodeGenerateConfigList, sysCodeGenerateConfigEdit } from '@/api/modular/gen/sysCodeGenerateConfigManage' |
|
67 |
export default { |
|
68 |
data () { |
|
69 |
return { |
|
70 |
// 表头 |
|
71 |
columns: [ |
|
72 |
{ |
|
73 |
title: 'java字段', |
|
74 |
dataIndex: 'javaName' |
|
75 |
}, |
|
76 |
{ |
|
77 |
title: '字段描述', |
|
78 |
dataIndex: 'columnComment', |
|
79 |
scopedSlots: { customRender: 'columnComment' } |
|
80 |
}, |
|
81 |
{ |
|
82 |
title: '物理类型', |
|
83 |
dataIndex: 'dataType' |
|
84 |
}, |
|
85 |
{ |
|
86 |
title: 'java类型', |
|
87 |
dataIndex: 'javaType', |
|
88 |
scopedSlots: { customRender: 'javaType' } |
|
89 |
}, |
|
90 |
{ |
|
91 |
title: '作用类型', |
|
92 |
dataIndex: 'effectType', |
|
93 |
scopedSlots: { customRender: 'effectType' } |
|
94 |
}, |
|
95 |
{ |
|
96 |
title: '字典', |
|
97 |
dataIndex: 'dictTypeCode', |
|
98 |
scopedSlots: { customRender: 'dictTypeCode' } |
|
99 |
}, |
|
100 |
{ |
|
101 |
title: '列表显示', |
|
102 |
align: 'center', |
|
103 |
dataIndex: 'whetherTable', |
|
104 |
scopedSlots: { customRender: 'whetherTable' } |
|
105 |
}, |
|
106 |
{ |
|
107 |
title: '列字段省略', |
|
108 |
align: 'center', |
|
109 |
dataIndex: 'whetherRetract', |
|
110 |
scopedSlots: { customRender: 'whetherRetract' } |
|
111 |
}, |
|
112 |
{ |
|
113 |
title: '增改', |
|
114 |
align: 'center', |
|
115 |
dataIndex: 'whetherAddUpdate', |
|
116 |
scopedSlots: { customRender: 'whetherAddUpdate' } |
|
117 |
}, |
|
118 |
{ |
|
119 |
title: '必填', |
|
120 |
align: 'center', |
|
121 |
dataIndex: 'whetherRequired', |
|
122 |
scopedSlots: { customRender: 'whetherRequired' } |
|
123 |
}, |
|
124 |
{ |
|
125 |
title: '是否是查询', |
|
126 |
align: 'center', |
|
127 |
dataIndex: 'queryWhether', |
|
128 |
scopedSlots: { customRender: 'queryWhether' } |
|
129 |
}, |
|
130 |
{ |
|
131 |
title: '查询方式', |
|
132 |
dataIndex: 'queryType', |
|
133 |
scopedSlots: { customRender: 'queryType' } |
|
134 |
} |
|
135 |
], |
|
136 |
indexConfigShow: false, |
|
137 |
tableLoading: false, |
|
138 |
visible: false, |
|
139 |
loadData: [], |
|
140 |
javaTypeData: [], |
|
141 |
effectTypeData: [], |
|
142 |
dictDataAll: [], |
|
143 |
codeGenQueryTypeData: [], |
|
144 |
yesOrNoData: [] |
|
145 |
} |
|
146 |
}, |
|
147 |
methods: { |
|
148 |
/** |
|
149 |
* 打开界面 |
|
150 |
*/ |
|
151 |
open (data) { |
|
152 |
this.indexConfigShow = true |
|
153 |
this.tableLoading = true |
|
154 |
const dictOption = this.$options |
|
155 |
this.javaTypeData = dictOption.filters['dictData']('code_gen_java_type') |
|
156 |
this.effectTypeData = dictOption.filters['dictData']('code_gen_effect_type') |
|
157 |
this.dictDataAll = dictOption.filters['dictDataAll']() |
|
158 |
this.yesOrNoData = dictOption.filters['dictData']('yes_or_no') |
|
159 |
this.codeGenQueryTypeData = dictOption.filters['dictData']('code_gen_query_type') |
|
160 |
const params = { |
|
161 |
codeGenId: data.id |
|
162 |
} |
|
163 |
sysCodeGenerateConfigList(params).then((res) => { |
|
164 |
this.loadData = res.data |
|
165 |
this.loadData.forEach(item => { |
|
166 |
for (const key in item) { |
|
167 |
if (item[key] === 'Y') { |
|
168 |
item[key] = true |
|
169 |
} |
|
170 |
if (item[key] === 'N') { |
|
171 |
item[key] = false |
|
172 |
} |
|
173 |
} |
|
174 |
}) |
|
175 |
this.tableLoading = false |
|
176 |
}) |
|
177 |
}, |
|
178 |
/** |
|
179 |
* 提交表单 |
|
180 |
*/ |
|
181 |
handleSubmit () { |
|
182 |
this.tableLoading = true |
|
183 |
// 做数组属性转换, 咱先来一个切断双向绑定,学习的童鞋下回记下啊 |
|
184 |
// eslint-disable-next-line prefer-const |
|
185 |
let loadDatas = JSON.parse(JSON.stringify(this.loadData)) |
|
186 |
loadDatas.forEach(item => { |
|
187 |
// 必填那一项转换 |
|
188 |
for (const key in item) { |
|
189 |
if (item[key] === true) { |
|
190 |
item[key] = 'Y' |
|
191 |
} |
|
192 |
if (item[key] === false) { |
|
193 |
item[key] = 'N' |
|
194 |
} |
|
195 |
} |
|
196 |
}) |
|
197 |
const param = { |
|
198 |
sysCodeGenerateConfigParamList: loadDatas |
|
199 |
} |
|
200 |
sysCodeGenerateConfigEdit(param).then((res) => { |
|
201 |
this.tableLoading = false |
|
202 |
if (res.success) { |
|
203 |
this.$message.success('编辑成功') |
|
204 |
this.handleCancel() |
|
205 |
} else { |
|
206 |
this.$message.error('编辑失败:' + res.message) |
|
207 |
} |
|
208 |
}) |
|
209 |
}, |
|
210 |
/** |
|
211 |
* 判断是否(用于是否能选择或输入等) |
|
212 |
*/ |
|
213 |
judgeColumns (data) { |
|
214 |
if (data.columnName.indexOf('create_user') > -1 || |
|
215 |
data.columnName.indexOf('create_time') > -1 || |
|
216 |
data.columnName.indexOf('update_user') > -1 || |
|
217 |
data.columnName.indexOf('update_time') > -1 || |
|
218 |
data.columnKey === 'PRI') { |
|
219 |
return true |
|
220 |
} |
|
221 |
return false |
|
222 |
}, |
|
223 |
handleCancel () { |
|
224 |
this.$emit('ok') |
|
225 |
this.loadData = [] |
|
226 |
this.indexConfigShow = false |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
</script> |