Github地址 https://github.com/ZhiYiDai/F... 歡迎點個star前端
基於vue iview後臺管理系統前端快速開發解決方案vue
# install dependencies npm install or yarn # serve with hot reload at localhost:8000 npm run dev # build for production with minification npm run build
Ffast-FE 是一套基於vue iview後臺管理系統前端快速開發解決方案,封裝了大量經常使用組件佈局。
已實現基本的系統管理頁面,您能夠用其中的組件快速開發屬於你的頁面。
已實現頁面(總體佈局界面,用戶管理,角色管理,字典管理,權限菜單,接口測試,系統日誌)
開發中的頁面(代碼生成)
演示地址 http://demo.ffast.cn/ 備用地址http://39.107.104.190/ffastjava
<template> <CrudView :tableOptions="tableOptions" :treeOptions="treeOptions"></CrudView> </template> <script> /** * 彈出式表單參數 */ const tableEditOptions = { // 是否啓用跳轉到編輯頁面,爲空或false則用彈出模態框進行編輯 editPage: true, // 模態框寬度 width: 600, // 表單標籤寬度 labelWidth: 70, // 表單數據 dynamic: [ [ {name: 'id', hidden: true}, { name: 'name', type: 'text', span: 12, label: '資源名', rules: {required: true} }, {name: 'parentId', type: 'treeSelect', dataFromTree: true, span: 12, label: '父資源'} ], [ {name: 'url', type: 'text', span: 24, label: '菜單Url'} ], [ {name: 'identity', type: 'text', span: 12, label: '標識符'}, {name: 'icon', type: 'text', span: 12, label: '圖標'} ], [ {name: 'weight', type: 'text', span: 12, label: '權重'} ], [ { name: 'status', openText: '顯示', closeText: '隱藏', type: 'switch', span: 12, label: '狀態', value: 1, trueValue: 1, falseValue: 0 }, { name: 'resType', type: 'radio', span: 12, label: '類型', value: 1, data: [{label: '菜單', value: 1}, {label: '權限', value: 2}], rules: {required: true, type: 'number'} } ], [ { name: 'addBaseCrud', type: 'switch', openText: '是', closeText: '否', span: 12, label: '添加基礎權限', value: false } ] ] } /** * 樹參數 */ const treeOptions = { title: '權限菜單', // 左邊樹數據地址 dataUrl: '/sys/res/list', // 左邊樹增長數據地址 createUrl: '/sys/res/create', // 左邊樹刪除數據地址 deleteUrl: '/sys/res/delete', // 左邊樹更新數據地址 updateUrl: '/sys/res/update', // 是否顯示工具欄 showToolbar: true, editOptions: tableEditOptions } /** * 表格參數 */ const tableOptions = { editOptions: tableEditOptions, selection: [], pageSize: 20, // 表單窗口標題 title: '權限菜單', // 權限前綴 permsPrefix: 'res', // 表格數據地址 dataUrl: '/sys/res/list', // 表格數據增長地址 createUrl: '/sys/res/create', // 表格數據刪除地址 deleteUrl: '/sys/res/delete', // 表格數據更新地址 updateUrl: '/sys/res/update', // 查詢請求參數 param: {}, // 表格列數據 columns: [ {type: 'selection', width: 60, align: 'center'}, {key: 'name', title: '資源名', minWidth: 160, maxWidth: 280}, { key: 'resType', width: 80, title: '類型', //類型枚舉 (自動將值(id)轉換爲對應標籤value) enum: [{value: '菜單', id: 1, el: 'strong'}, {value: '權限', id: 2}] }, {key: 'identity', title: '標識符', width: 200}, {key: 'url', title: '菜單Url', minWidth: 200, maxWidth: 400}, {key: 'parentId', title: '父資源', width: 160, dataFromTree: true}, { key: 'icon', width: 100, title: '菜單圖標', render: (h, params) => { const row = params.row return h('Icon', { props: { type: row.icon } }) } }, {key: 'weight', title: '權重', width: 80}, { key: 'status', width: 80, title: '狀態', enum: ['隱藏', '顯示'] } ], // 表格搜索表單 searchDynamic: [ [ {name: 'name', label: '資源名', span: 4, type: 'text'}, {name: 'identity', label: '標識符', span: 4, type: 'text'}, {name: 'url', label: 'Url', span: 4, type: 'text'}, {name: 'status', label: '狀態', span: 3, type: 'text'}, { name: 'resType', type: 'select', data: [{label: '菜單', value: 1}, {label: '權限', value: 2}], span: 3, label: '類型' } ] ] } import CrudView from 'components/views/CrudView' export default { data() { return { tableOptions, treeOptions } }, computed: {}, methods: {}, mounted() { }, components: {CrudView} } </script>
支持十多種表單組件:
1.input text(單行輸入框)
2.input textarea(多行輸入框)
3.select(下拉選擇框)
4.radio(單選框)
5.checkbox(多選框)
6.treeSelect(選擇樹)
7.input number(數字輸入框)
8.date(日期選擇)
9.datetime(日期時間選擇)
10.datetimerange(日期時間段選擇)
11.ImgUpload(圖片上傳表單組件)
12.editor(基於vue-quill-editor富文本)
13.PopupSelect(彈出式選擇)git
<template> <div class="main-view main-view-full" style="padding-top: 50px"> <row> <i-col span="24"> <FormDynamic ref="dynamic1" v-model="fromData" :data="dynamic1" :label-width="120"> </FormDynamic> </i-col> </row> <PopupEdit ref="popupEdit" :width="1000" :dynamic="dynamic1" @on-success="editSuccess" :label-width="120"> </PopupEdit> <PopupSelect ref="popSelect" :content="userPage"></PopupSelect> </div> </template> <script> import {FormDynamic, PopupEdit, PopupSelect} from 'components/'; let self = null; const dynamic1 = [ [ {type: 'title', span: 24, text: 'Input'} ], [ { name: 'numberData', type: 'number', span: 6, // 最小值 min:1, // 最大值 max:80010 label: 'Number' }, { name: 'textData', type: 'text', span: 6, label: 'text', value: 'DefaultValue', rules: {required: true, type: 'string'} }, { name: 'passwordData', type: 'text', span: 6, password: true, label: 'PasswordText', rules: {required: true, type: 'string', message: '密碼不能爲空'} }, { name: 'textarea', type: 'text', placeholder: '多行文本輸入框', span: 6, label: 'TextareaLabel', textarea: {minRows: 1, maxRows: 6} } ], [ {type: 'title', span: 24, text: 'date'} ], [ {name: 'date1', type: 'date', span: 6, label: 'DateLabel'}, {name: 'date2', type: 'datetime', span: 6, label: 'DateTimeLabel'}, {name: 'date3', type: 'datetimerange', span: 6, label: 'Datetimerange'} ], [ {type: 'title', span: 24, text: 'DataSelect'} ], [ { name: 'selectData', type: 'select', span: 8, value: 0, label: 'SelectLabel', data: [ {label: '選項1', value: 0}, {label: '選項2', value: 1}, {label: '選項3', value: 2}, {label: '選項4', value: 3} ], onChange: (val, from, data) => { alert('onChange'); } }, { name: 'selectData2', type: 'select', span: 6, value: 0, label: 'URLSelectLabel', // value 字段名 valField: 'id', // label 字段名 textField: 'name', // 經過設置數據url地址進行獲取 dataUrl: '/sys/dict/get?type=job', onChange: (val, from, data) => { alert('onChange'); } }, { name: 'selectData3', type: 'select', span: 6, value: 0, label: 'DictSelectLabel', // 直接取字典數據 dict: 'job', onChange: (val, from, data) => { alert('onChange'); } } ], [ {type: 'title', span: 24, text: 'Title'} ], [ { name: 'radioData', type: 'radio', span: 6, value: 0, label: 'RadioLabel', data: [ {label: '選項1', value: 0}, {label: '選項2', value: 1}, {label: '選項3', value: 2}, {label: '選項4', value: 3} ], onChange: (val, from, data) => { alert('onChange'); } }, { name: 'checkboxData', type: 'checkbox', span: 8, label: 'CheckboxLabel', data: [ {label: '選項1', value: 0}, {label: '選項2', value: 1}, {label: '選項3', value: 2}, {label: '選項4', value: 3} ], enableCheckAll: true, checkAllLabel: '全選', checkAll: true, onChange: (val, from, data) => { alert('onChange'); } }, { name: 'deviceTypeId', type: 'treeSelect', span: 8, label: 'TreeSelectLabel', // 若是是CrudView 支持從左邊樹綁定數據,select組件一樣支持 dataFromTree: true, textField: 'name', valField: 'id', dataUrl: '/sys/res/list', onChange: (val, from, data) => { alert('onChange'); } }, { name: 'popSelectId', span: 8, label: 'PopupSelectLabel', type: 'popText', textField: 'popSelectName', onClick(fromData) { self.$refs['popSelect'].open((selection) => { console.log(selection[0].id); self.$set(fromData, 'popSelectId', selection[0].id); self.$set(fromData, 'popSelectName', selection[0].username); }) } } ], [ { name: 'imgData', // 最多隻能上傳2張 max: 2, type: 'imgUpload', span: 24, label: 'ImgUploadLabel' }, {name: 'editor', type: 'editor', span: 24, label: 'EditorLabel', placeholder: '富文本編輯器'} ], [ { name: 'button', type: 'buttons', span: 24, data: [ { label: 'SetData', onClick() { // 給表單設置數據 self.$refs.dynamic1.setFormData({numberData: 10001, textData: 'SetData'}) } }, { label: 'GetFormData', onClick() { self.$refs.dynamic1.submit((param) => { console.log(param); alert(JSON.stringify(param)) }, (res) => { // 表單驗證失敗 }); } }, { // 彈出窗口編輯表單 label: 'PopupWindow', onClick() { self.$refs.popupEdit.open({ title: 'PopupEditWindow', // 確認提交url postUrl: null }, self.fromData); } }, { label: 'GotoEditPage', onClick() { self.editOptions.editSuccess = self.editSuccess; let action = { // 窗口標題 title: 'title', // 確認提交請求url postUrl: '' } self.$router.push({ path: self.$router.currentRoute.path + '/edit', query: {options: self.editOptions, action: action, data: self.fromData} }) } } ] } ] ]; /** * 彈出式表單參數 */ const editOptions = { width: 1200, labelWidth: 120, dynamic: dynamic1 }; export default { data() { return { editOptions, dynamic1, fromData: {} } }, computed: { // 彈出選擇頁面 userPage() { return import('pages/sys/user'); } }, methods: { // 編輯成功 editSuccess(res) { console.log(res); } }, mounted() { self = this; }, components: { FormDynamic, PopupEdit, PopupSelect } } </script>
[ [{}...],//第一行 [], //第二行 [], //第三行 ] 也能夠設置爲span:24 獨佔一行
rules: { required: true, //開啓表單驗證 type: 'number', //驗證類型 message: '分類不能爲空'//提示信息 }
具體請看https://github.com/yiminghe/a...github
1.彈出式編輯表單(PopupEdit) 2.跳轉式編輯表單 (edit.vue)npm
CrudTreeView(樹編輯佈局)後端
PhotoViewer(圖片預覽組件)iview
DataTree(數據樹)async
DataSelect(數據下拉框,支持直接填入字典標識)編輯器
DataTable(數據表格)
CrudTree(增刪改查樹)
CrudTable(增刪表格)
PermsValid(權限驗證)
...
CrudView -> CrudTable -> DataTable -> IView Table -> PopupEdit -> FormDynamic -> Edit -> FormDynamic -> CrudTree -> DataTree -> IView Tree -> PopupEdit -> FormDynamic -> Edit -> FormDynamic
https://github.com/ZhiYiDai/F... (Ffast java)文檔整理中...