Browse Source

自动化代码可以自动创建form,前端样式修复,前端mixin位置转移

main
QM303176530 4 years ago
parent
commit
8584da85df
  1. 80
      server/resource/template/fe/table.vue.tpl
  2. 2
      web/src/mixins/infoList.js
  3. 14
      web/src/style/main.scss
  4. 6
      web/src/utils/request.js
  5. 2
      web/src/view/example/customer/customer.vue
  6. 2
      web/src/view/example/upload/upload.vue
  7. 2
      web/src/view/superAdmin/api/api.vue
  8. 2
      web/src/view/superAdmin/authority/authority.vue
  9. 2
      web/src/view/superAdmin/dictionary/sysDictionary.vue
  10. 2
      web/src/view/superAdmin/dictionary/sysDictionaryDetail.vue
  11. 2
      web/src/view/superAdmin/menu/menu.vue
  12. 2
      web/src/view/superAdmin/operation/sysOperationRecord.vue
  13. 2
      web/src/view/superAdmin/user/user.vue

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

@ -92,7 +92,33 @@
></el-pagination>
<el-dialog :before-close="closeDialog" :visible.sync="dialogFormVisible" title="弹窗操作">
此处请使用表单生成器生成form填充 表单默认绑定 formData 如手动修改过请自行修改key
<el-form :model="formData" label-position="right" label-width="80px">
{{- range .Fields}}
<el-form-item label="{{.FieldDesc}}:">
{{- if eq .FieldType "bool" }}
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
{{ end -}}
{{- if eq .FieldType "string" }}
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" ></el-input>
{{ end -}}
{{- if eq .FieldType "int" }}
{{- if .DictType}}
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value"></el-option>
</el-select>
{{ else -}}
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入"></el-input>
{{ end -}}
{{ end -}}
{{- if eq .FieldType "time.Time" }}
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
{{ end -}}
{{- if eq .FieldType "float64" }}
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
{{ end -}}
</el-form-item>
{{ end -}}
</el-form>
<div class="dialog-footer" slot="footer">
<el-button @click="closeDialog">取 消</el-button>
<el-button @click="enterDialog" type="primary">确 定</el-button>
@ -111,14 +137,13 @@ import {
get{{.StructName}}List
} from "@/api/{{.PackageName}}"; // 此处请自行替换地址
import { formatTimeToStr } from "@/utils/data";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
export default {
name: "{{.StructName}}",
mixins: [infoList],
data() {
return {
listApi: get{{.StructName}}List,
listApi: get{{ .StructName }}List,
dialogFormVisible: false,
visible: false,
type: "",
@ -126,11 +151,27 @@ export default {
multipleSelection: [],
{{- range .Fields}}
{{- if .DictType }}
{{.DictType}}Options:[],
{{ .DictType }}Options:[],
{{ end -}}
{{end -}}
formData: {
{{range .Fields}}{{.FieldJson}}:null,{{ end }}
{{range .Fields}}
{{- if eq .FieldType "bool" -}}
{{.FieldJson}}:false,
{{ end -}}
{{- if eq .FieldType "string" -}}
{{.FieldJson}}:"",
{{ end -}}
{{- if eq .FieldType "int" -}}
{{.FieldJson}}:0,
{{ end -}}
{{- if eq .FieldType "time.Time" -}}
{{.FieldJson}}:new Date(),
{{ end -}}
{{- if eq .FieldType "float64" -}}
{{.FieldJson}}:0,
{{ end -}}
{{ end }}
}
};
},
@ -193,7 +234,22 @@ export default {
this.dialogFormVisible = false;
this.formData = {
{{range .Fields}}
{{.FieldJson}}:null,{{ end }}
{{- if eq .FieldType "bool" -}}
{{.FieldJson}}:false,
{{ end -}}
{{- if eq .FieldType "string" -}}
{{.FieldJson}}:"",
{{ end -}}
{{- if eq .FieldType "int" -}}
{{.FieldJson}}:0,
{{ end -}}
{{- if eq .FieldType "time.Time" -}}
{{.FieldJson}}:new Date(),
{{ end -}}
{{- if eq .FieldType "float64" -}}
{{.FieldJson}}:0,
{{ end -}}
{{ end }}
};
},
async delete{{.StructName}}(row) {
@ -236,11 +292,11 @@ export default {
},
async created() {
await this.getTableData();
{{- range .Fields -}}
{{- if .DictType -}}
await this.getDict("{{.DictType}}")
{{- end -}}
{{- end -}}
{{ range .Fields -}}
{{- if .DictType }}
await this.getDict("{{.DictType}}");
{{ end -}}
{{- end }}
}
};
</script>

2
web/src/components/mixins/infoList.js → web/src/mixins/infoList.js

@ -28,10 +28,12 @@ export default {
},
async getTableData(page = this.page, pageSize = this.pageSize) {
const table = await this.listApi({ page, pageSize, ...this.searchInfo })
if(table.code == 0){
this.tableData = table.data.list
this.total = table.data.total
this.page = table.data.page
this.pageSize = table.data.pageSize
}
}
}
}

14
web/src/style/main.scss

@ -1013,3 +1013,17 @@ li {
}
}
}
.el-input-number__decrease, .el-input-number__increase{
position: absolute;
z-index: 1;
top: 6px !important;
width: 42px;
height: 26px;
line-height: 26px;
text-align: center;
background: #F5F7FA;
color: #606266;
cursor: pointer;
font-size: 13px;
}

6
web/src/utils/request.js

@ -50,7 +50,7 @@ service.interceptors.request.use(
message: error,
type: 'error'
})
return Promise.reject(error);
return error;
}
);
@ -73,7 +73,7 @@ service.interceptors.response.use(
if (response.data.data && response.data.data.reload) {
store.commit('user/LoginOut')
}
return Promise.reject(response.data.msg)
return response.data.msg
}
},
error => {
@ -83,7 +83,7 @@ service.interceptors.response.use(
message: error,
type: 'error'
})
return Promise.reject(error)
return error
}
)

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

@ -75,7 +75,7 @@ import {
getExaCustomerList
} from "@/api/customer";
import { formatTimeToStr } from "@/utils/data";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
export default {
name: "Customer",

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

@ -82,7 +82,7 @@
<script>
const path = process.env.VUE_APP_BASE_API;
import { mapGetters } from "vuex";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
import { getFileList, deleteFile } from "@/api/fileUploadAndDownload";
import { downloadImage } from "@/utils/downloadImg";
import { formatTimeToStr } from "@/utils/data";

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

@ -109,7 +109,7 @@ import {
updateApi,
deleteApi
} from '@/api/api'
import infoList from '@/components/mixins/infoList'
import infoList from '@/mixins/infoList'
import { toSQLLine } from '@/utils/stringFun'
const methodOptions = [
{

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

@ -100,7 +100,7 @@ import Menus from "@/view/superAdmin/authority/components/menus";
import Apis from "@/view/superAdmin/authority/components/apis";
import Datas from "@/view/superAdmin/authority/components/datas";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
export default {
name: "Authority",
mixins: [infoList],

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

@ -118,7 +118,7 @@ import {
getSysDictionaryList
} from "@/api/sysDictionary"; //
import { formatTimeToStr } from "@/utils/data";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
export default {
name: "SysDictionary",
mixins: [infoList],

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

@ -115,7 +115,7 @@ import {
getSysDictionaryDetailList
} from "@/api/sysDictionaryDetail"; //
import { formatTimeToStr } from "@/utils/data";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
export default {
name: "SysDictionaryDetail",

2
web/src/view/superAdmin/menu/menu.vue

@ -181,7 +181,7 @@ import {
deleteBaseMenu,
getBaseMenuById
} from "@/api/menu";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
import icon from "@/view/superAdmin/menu/icon";
export default {
name: "Menus",

2
web/src/view/superAdmin/operation/sysOperationRecord.vue

@ -114,7 +114,7 @@ import {
deleteSysOperationRecordByIds
} from '@/api/sysOperationRecord' //
import { formatTimeToStr } from '@/utils/data'
import infoList from '@/components/mixins/infoList'
import infoList from '@/mixins/infoList'
export default {
name: 'SysOperationRecord',

2
web/src/view/superAdmin/user/user.vue

@ -98,7 +98,7 @@ import {
deleteUser
} from "@/api/user";
import { getAuthorityList } from "@/api/authority";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
import { mapGetters } from "vuex";
import CustomPic from "@/components/customPic";
import ChooseImg from "@/components/chooseImg";

Loading…
Cancel
Save