panyong c435a04ee2 新增管理后台模板 | 2 éve | |
---|---|---|
.. | ||
build | 2 éve | |
config | 2 éve | |
mock | 2 éve | |
public | 2 éve | |
src | 2 éve | |
.editorconfig | 2 éve | |
.env.development | 2 éve | |
.env.production | 2 éve | |
.eslintignore | 2 éve | |
.eslintrc.js | 2 éve | |
.gitignore | 2 éve | |
.prettierrc | 2 éve | |
README.md | 2 éve | |
babel.config.js | 2 éve | |
jsconfig.json | 2 éve | |
package.json | 2 éve | |
postcss.config.js | 2 éve | |
version.md | 2 éve | |
vue.config.js | 2 éve |
自己不断修改的vue admin 模板
<!-- 验证方法在@/utils/rules里面 -->
<el-form :model="loginForm" :rules="formRules" ref="loginForm" label-position="top">
<el-form-item prop="username" :rules="formRules.required">
<el-input placeholder="用户名" v-model="loginForm.username" size="default"><i slot="prepend"
class="el-icon-user-solid"></i>
</el-input>
</el-form-item>
<el-form-item prop="password" :rules="formRules.password">
<el-input show-password placeholder="密码" v-model="loginForm.password" size="default"
@keydown.enter.native="handleSubmit"><i slot="prepend" class="el-icon-lock"></i></el-input>
</el-form-item>
<el-button @click="handleSubmit" type="primary" class="button-login" size="default">提交</el-button>
</el-form>
<!-- 传其余参数可以使用下面的方法 -->
<el-form-item prop="confirmPassword" :rules="formRules.confirmPassword(registerForm)">
<el-input show-password placeholder="再次输入密码" v-model="registerForm.confirmPassword" size="default">
<i slot="prepend" class="el-icon-lock"></i>
</el-input>
</el-form-item>
全部放在
@/utils/enum.js
里面,已全部挂载到Vue.prototype下面
全部放在
@/utils/filter.js
里面,已全部挂载到Vue.prototype下面
统一的axios参数在
@/api/index.js
下面,已全部挂载到Vue.prototype下面
// 具体使用方法,例:
//
methods: {
async
handleSubmit()
{
this.$refs.form.validate(async valid => {
if (valid) {
// this.$fetch第三个参数可选,默认'post',如果是使用get方法,第三个参数传'get'
const data = await this.$fetch('/v1/front/otherApi', { ...this.form })
if (data.code === 0) {
this.$message.success('提交成功')
this.$emit('success')
this.dialog = false
} else {
this.reloadImg()
}
}
})
}
}
dialog弹窗尽量使用组件引入,dialog例子在
@/components/_dialog/exampleDialog
里面
<!-- 应用例子 -->
<template>
<exampleDialog v-if="exampleDialog.show" v-model="exampleDialog.show" :exampleData="exampleDialog.data"
@success="searchSubmit"></exampleDialog>
</template>
使用
@/mixin/page.js
使用前最好看一下下面例子包含了表格统一和全局枚举(enum)的应用
// 页面引用js部分
import page from '@/mixin/page'
export default {
mixins: [page],
data() {
return {
time: [],
searchForm: {},
tableData: [],
tableUrl: '/v1/front/user/list'
}
},
methods: {},
mounted() {
this.init()
},
}
<!-- template部分 -->
<template>
<div>
<div class="search-box">
<el-form ref="form" :inline="true" :model="searchForm" clearable label-width="100px">
<el-form-item label="变更时间:">
<el-date-picker
:editable="false"
v-model="time"
@change="timearr => {timearr ? (searchForm.create_time_start = timearr[0], searchForm.create_time_end = timearr[1]) : searchForm.create_time_start = searchForm.create_time_end = undefined}"
type="daterange"
value-format="yyyy-MM-dd"
start-placeholder="开始时间"
end-placeholder="结束时间"
></el-date-picker>
</el-form-item>
<el-form-item label="收支状态:">
<el-select v-model="searchForm.budget_type" placeholder="全部">
<el-option label="全部" value></el-option>
<!-- 注意,这里budget_type就是放在全局enum中的参数 -->
<el-option v-for="(item, index) in budget_type" :key="index" :label="item" :value="index"></el-option>
</el-select>
</el-form-item>
<el-form-item class="ml-10">
<el-button class type="primary" @click="searchSubmit">查询</el-button>
</el-form-item>
</el-form>
</div>
<!-- 这里的vheight根据实际情况来 -->
<el-table :data="tableData" stripe v-loading="tableLoading" fit class="marginT-10 order-table" border
:max-height="vheight">
<el-table-column label="创建时间" prop="create_time"></el-table-column>
<el-table-column label="收支类型" align="center" prop="budget_type"
:formatter="row => budget_type[row.budget_type]"></el-table-column>
<el-table-column label="变更类型" align="center" prop="change_type"
:formatter="row => $store.getters.enum.coin_change_type_arr[row.change_type]"></el-table-column>
<el-table-column label="变更数目" align="center" prop="coin_change_number"
:formatter="row => row.coin_change_number + '金币'"></el-table-column>
<el-table-column label="变更后数目" align="center" prop="after_change_remain_coins"
:formatter="row => row.after_change_remain_coins + '金币'"></el-table-column>
<el-table-column label="备注" prop="remarks"></el-table-column>
</el-table>
<el-pagination
class="marginT-20"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:hide-on-single-page="true"
:current-page="page"
:page-size="page_size"
:page-sizes="[10, 20, 100, 200, 300, 400]"
background
layout="total, sizes, prev, pager, next, jumper"
:total="totalCount"/>
</div>
</template>
@/utils/vue-bus.js
里面。yarn
## or
npm i
npm run build
## or
yarn build
[API]()
[测试]() [生产]()