Skip to content

Commit e8c6d38

Browse files
author
QM303176530
committed
自动化代码可以自动创建form,前端样式修复,前端mixin位置转移
1 parent eeaaa40 commit e8c6d38

File tree

13 files changed

+101
-29
lines changed

13 files changed

+101
-29
lines changed

server/resource/template/fe/table.vue.tpl

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,33 @@
9292
></el-pagination>
9393

9494
<el-dialog :before-close="closeDialog" :visible.sync="dialogFormVisible" title="弹窗操作">
95-
此处请使用表单生成器生成form填充 表单默认绑定 formData 如手动修改过请自行修改key
95+
<el-form :model="formData" label-position="right" label-width="80px">
96+
{{- range .Fields}}
97+
<el-form-item label="{{.FieldDesc}}:">
98+
{{- if eq .FieldType "bool" }}
99+
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="" inactive-text="" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
100+
{{ end -}}
101+
{{- if eq .FieldType "string" }}
102+
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" ></el-input>
103+
{{ end -}}
104+
{{- if eq .FieldType "int" }}
105+
{{- if .DictType}}
106+
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
107+
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value"></el-option>
108+
</el-select>
109+
{{ else -}}
110+
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入"></el-input>
111+
{{ end -}}
112+
{{ end -}}
113+
{{- if eq .FieldType "time.Time" }}
114+
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
115+
{{ end -}}
116+
{{- if eq .FieldType "float64" }}
117+
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
118+
{{ end -}}
119+
</el-form-item>
120+
{{ end -}}
121+
</el-form>
96122
<div class="dialog-footer" slot="footer">
97123
<el-button @click="closeDialog">取 消</el-button>
98124
<el-button @click="enterDialog" type="primary">确 定</el-button>
@@ -111,26 +137,41 @@ import {
111137
get{{.StructName}}List
112138
} from "@/api/{{.PackageName}}"; // 此处请自行替换地址
113139
import { formatTimeToStr } from "@/utils/data";
114-
import infoList from "@/components/mixins/infoList";
115-
140+
import infoList from "@/mixins/infoList";
116141
export default {
117142
name: "{{.StructName}}",
118143
mixins: [infoList],
119144
data() {
120145
return {
121-
listApi: get{{.StructName}}List,
146+
listApi: get{{ .StructName }}List,
122147
dialogFormVisible: false,
123148
visible: false,
124149
type: "",
125150
deleteVisible: false,
126151
multipleSelection: [],
127152
{{- range .Fields}}
128153
{{- if .DictType }}
129-
{{.DictType}}Options:[],
154+
{{ .DictType }}Options:[],
130155
{{ end -}}
131156
{{end -}}
132157
formData: {
133-
{{range .Fields}}{{.FieldJson}}:null,{{ end }}
158+
{{range .Fields}}
159+
{{- if eq .FieldType "bool" -}}
160+
{{.FieldJson}}:false,
161+
{{ end -}}
162+
{{- if eq .FieldType "string" -}}
163+
{{.FieldJson}}:"",
164+
{{ end -}}
165+
{{- if eq .FieldType "int" -}}
166+
{{.FieldJson}}:0,
167+
{{ end -}}
168+
{{- if eq .FieldType "time.Time" -}}
169+
{{.FieldJson}}:new Date(),
170+
{{ end -}}
171+
{{- if eq .FieldType "float64" -}}
172+
{{.FieldJson}}:0,
173+
{{ end -}}
174+
{{ end }}
134175
}
135176
};
136177
},
@@ -192,8 +233,23 @@ export default {
192233
closeDialog() {
193234
this.dialogFormVisible = false;
194235
this.formData = {
195-
{{range .Fields}}
196-
{{.FieldJson}}:null,{{ end }}
236+
{{range .Fields}}
237+
{{- if eq .FieldType "bool" -}}
238+
{{.FieldJson}}:false,
239+
{{ end -}}
240+
{{- if eq .FieldType "string" -}}
241+
{{.FieldJson}}:"",
242+
{{ end -}}
243+
{{- if eq .FieldType "int" -}}
244+
{{.FieldJson}}:0,
245+
{{ end -}}
246+
{{- if eq .FieldType "time.Time" -}}
247+
{{.FieldJson}}:new Date(),
248+
{{ end -}}
249+
{{- if eq .FieldType "float64" -}}
250+
{{.FieldJson}}:0,
251+
{{ end -}}
252+
{{ end }}
197253
};
198254
},
199255
async delete{{.StructName}}(row) {
@@ -236,11 +292,11 @@ export default {
236292
},
237293
async created() {
238294
await this.getTableData();
239-
{{- range .Fields -}}
240-
{{- if .DictType -}}
241-
await this.getDict("{{.DictType}}")
242-
{{- end -}}
243-
{{- end -}}
295+
{{ range .Fields -}}
296+
{{- if .DictType }}
297+
await this.getDict("{{.DictType}}");
298+
{{ end -}}
299+
{{- end }}
244300
}
245301
};
246302
</script>

web/src/components/mixins/infoList.js renamed to web/src/mixins/infoList.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ export default {
2828
},
2929
async getTableData(page = this.page, pageSize = this.pageSize) {
3030
const table = await this.listApi({ page, pageSize, ...this.searchInfo })
31-
this.tableData = table.data.list
32-
this.total = table.data.total
33-
this.page = table.data.page
34-
this.pageSize = table.data.pageSize
31+
if(table.code == 0){
32+
this.tableData = table.data.list
33+
this.total = table.data.total
34+
this.page = table.data.page
35+
this.pageSize = table.data.pageSize
36+
}
3537
}
3638
}
3739
}

web/src/style/main.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,3 +1013,17 @@ li {
10131013
}
10141014
}
10151015
}
1016+
1017+
.el-input-number__decrease, .el-input-number__increase{
1018+
position: absolute;
1019+
z-index: 1;
1020+
top: 6px !important;
1021+
width: 42px;
1022+
height: 26px;
1023+
line-height: 26px;
1024+
text-align: center;
1025+
background: #F5F7FA;
1026+
color: #606266;
1027+
cursor: pointer;
1028+
font-size: 13px;
1029+
}

web/src/utils/request.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ service.interceptors.request.use(
5050
message: error,
5151
type: 'error'
5252
})
53-
return Promise.reject(error);
53+
return error;
5454
}
5555
);
5656

@@ -73,7 +73,7 @@ service.interceptors.response.use(
7373
if (response.data.data && response.data.data.reload) {
7474
store.commit('user/LoginOut')
7575
}
76-
return Promise.reject(response.data.msg)
76+
return response.data.msg
7777
}
7878
},
7979
error => {
@@ -83,7 +83,7 @@ service.interceptors.response.use(
8383
message: error,
8484
type: 'error'
8585
})
86-
return Promise.reject(error)
86+
return error
8787
}
8888
)
8989

web/src/view/example/customer/customer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import {
7575
getExaCustomerList
7676
} from "@/api/customer";
7777
import { formatTimeToStr } from "@/utils/data";
78-
import infoList from "@/components/mixins/infoList";
78+
import infoList from "@/mixins/infoList";
7979
8080
export default {
8181
name: "Customer",

web/src/view/example/upload/upload.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<script>
8383
const path = process.env.VUE_APP_BASE_API;
8484
import { mapGetters } from "vuex";
85-
import infoList from "@/components/mixins/infoList";
85+
import infoList from "@/mixins/infoList";
8686
import { getFileList, deleteFile } from "@/api/fileUploadAndDownload";
8787
import { downloadImage } from "@/utils/downloadImg";
8888
import { formatTimeToStr } from "@/utils/data";

web/src/view/superAdmin/api/api.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ import {
109109
updateApi,
110110
deleteApi
111111
} from '@/api/api'
112-
import infoList from '@/components/mixins/infoList'
112+
import infoList from '@/mixins/infoList'
113113
import { toSQLLine } from '@/utils/stringFun'
114114
const methodOptions = [
115115
{

web/src/view/superAdmin/authority/authority.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ import Menus from "@/view/superAdmin/authority/components/menus";
100100
import Apis from "@/view/superAdmin/authority/components/apis";
101101
import Datas from "@/view/superAdmin/authority/components/datas";
102102
103-
import infoList from "@/components/mixins/infoList";
103+
import infoList from "@/mixins/infoList";
104104
export default {
105105
name: "Authority",
106106
mixins: [infoList],

web/src/view/superAdmin/dictionary/sysDictionary.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ import {
118118
getSysDictionaryList
119119
} from "@/api/sysDictionary"; // 此处请自行替换地址
120120
import { formatTimeToStr } from "@/utils/data";
121-
import infoList from "@/components/mixins/infoList";
121+
import infoList from "@/mixins/infoList";
122122
export default {
123123
name: "SysDictionary",
124124
mixins: [infoList],

web/src/view/superAdmin/dictionary/sysDictionaryDetail.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ import {
115115
getSysDictionaryDetailList
116116
} from "@/api/sysDictionaryDetail"; // 此处请自行替换地址
117117
import { formatTimeToStr } from "@/utils/data";
118-
import infoList from "@/components/mixins/infoList";
118+
import infoList from "@/mixins/infoList";
119119
120120
export default {
121121
name: "SysDictionaryDetail",

0 commit comments

Comments
 (0)