Skip to content

Commit cab8de7

Browse files
author
QM303176530
committed
添加首字母小写方法 增加自动填充按键
1 parent 4030cd3 commit cab8de7

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

web/src/utils/stringFun.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ export const toUpperCase = (str) => {
77
}
88
}
99

10+
export const toLowerCase = (str) => {
11+
if (str[0]) {
12+
return str.replace(str[0], str[0].toLowerCase())
13+
} else {
14+
return ""
15+
}
16+
}
17+
1018
// 驼峰转换下划线
1119
export const toSQLLine = (str) => {
1220
if (str == "ID") return "ID"

web/src/view/systemTools/autoCode/component/fieldDialog.vue

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<el-col :span="6">
1313
<el-input v-model="dialogMiddle.fieldName" autocomplete="off"></el-input>
1414
</el-col>
15+
<el-col :offset="1" :span="2">
16+
<el-button @click="autoFill">自动填充</el-button>
17+
</el-col>
1518
</el-form-item>
1619
<el-form-item label="Field中文名" prop="fieldDesc">
1720
<el-col :span="6">
@@ -103,7 +106,7 @@
103106
</template>
104107
<script>
105108
import { getDict } from "@/utils/dictionary";
106-
import { toSQLLine } from "@/utils/stringFun.js";
109+
import { toSQLLine , toLowerCase } from "@/utils/stringFun.js";
107110
import { getSysDictionaryList } from "@/api/sysDictionary";
108111
export default {
109112
name: "FieldDialog",
@@ -184,6 +187,10 @@ export default {
184187
};
185188
},
186189
methods: {
190+
autoFill(){
191+
this.dialogMiddle.fieldJson = toLowerCase(this.dialogMiddle.fieldName)
192+
this.dialogMiddle.columnName = toSQLLine(this.dialogMiddle.fieldJson)
193+
},
187194
async getDbfdOptions() {
188195
this.dialogMiddle.dataType = ""
189196
this.dialogMiddle.dataTypeLong = ""
@@ -203,20 +210,6 @@ export default {
203210
204211
this.dictOptions = dictRes.data.list
205212
},
206-
watch: {
207-
'dialogMiddle.fieldName': function (val) {
208-
if (val.length > 0) {
209-
val = val.replace(val[0], val[0].toLowerCase());
210-
val = toSQLLine(val)
211-
}
212-
213-
this.dialogMiddle.fieldJson = val;
214-
this.dialogMiddle.columnName = val;
215-
},
216-
'dialogMiddle.fieldDesc': function (val) {
217-
this.dialogMiddle.comment = val;
218-
}
219-
},
220213
};
221214
</script>
222215
<style lang="scss">

0 commit comments

Comments
 (0)