瀏覽代碼

修改

master
yangzhou-cyber 3 年之前
父節點
當前提交
3ab2deca38
共有 5 個檔案被更改,包括 119 行新增60 行删除
  1. +17
    -14
      src/api/basicTable/category.js
  2. +3
    -2
      src/config/axios.js
  3. +1
    -1
      src/store/getters.js
  4. +89
    -34
      src/views/basicTable/category.vue
  5. +9
    -9
      vue.config.js

+ 17
- 14
src/api/basicTable/category.js 查看文件

@@ -1,17 +1,20 @@
import axios from "@/config/axios"

export function add(params){
return axios.post('/category/add',params)
}
export function getList(params){
return axios.get('/category/index',{params})
}
export function edit(params){
return axios.put('/category/edit',params)
}
export function del(params){
return axios.delete('/category/delete',params)
}
export function getDetail(index){
return axios.get("/category/info"+index)
export default {
add(params) {
console.log(params)
return axios.post('/category/add', params)
},
getList(params) {
return axios.get('/category/index', { params })
},
edit(params) {
return axios.put('/category/edit', params)
},
del(params) {
return axios.delete('/category/delete', params)
},
getDetail(index) {
return axios.get("/category/info" + index)
},
}

+ 3
- 2
src/config/axios.js 查看文件

@@ -7,11 +7,12 @@ import VueAxios from 'vue-axios'
import store from '@/store'
import router from '@/router'
import setting from './setting'
import {MessageBox} from 'element-ui'
import { MessageBox } from 'element-ui'

Vue.use(VueAxios, axios);

axios.defaults.baseURL = setting.baseURL;
axios.defaults.withCredentials = true;
axios.defaults.headers.common[setting.tokenHeaderName] = store.state.user.token;

/* 响应拦截器 */
@@ -28,7 +29,7 @@ axios.interceptors.response.use((res) => {
callback: action => {
if (action === 'confirm') {
store.dispatch('user/setToken').then(() => {
router.push({path: '/login'});
router.push({ path: '/login' });
});
}
},

+ 1
- 1
src/store/getters.js 查看文件

@@ -1,4 +1,4 @@
export default {
theme: state => state.theme,
user: state => state.user
user: state => state.user,
}

+ 89
- 34
src/views/basicTable/category.vue 查看文件

@@ -3,9 +3,7 @@
<el-card shadow="never">
<search :search-params="searchParams" />
<div class="operating">
<el-button size="small" type="warning" @click="showAdd == true"
>新增</el-button
>
<el-button size="small" type="warning" @click="add">新增</el-button>
<el-button size="small" type="default">批量删除</el-button>
<el-button size="small" type="default">批量导入</el-button>
</div>
@@ -13,7 +11,7 @@
highlight-current-row
:data="dataList"
border
height="calc(100vh - 360px)"
:height="tableHeight"
>
<el-table-column
type="selection"
@@ -30,31 +28,37 @@
label="考核年度"
min-width="80"
align="center"
prop="year"
></el-table-column>
<el-table-column
label="表编号"
min-width="80"
align="center"
prop="code"
></el-table-column>
<el-table-column
label="表格名称"
min-width="100"
align="center"
prop="name"
></el-table-column>
<el-table-column
label="备注"
min-width="100"
align="center"
prop="note"
></el-table-column>
<el-table-column
label="创建时间"
min-width="100"
align="center"
prop="createTime"
></el-table-column>
<el-table-column
label="创建人"
min-width="80"
align="center"
prop="createUser"
></el-table-column>
<el-table-column
label="操作"
@@ -72,46 +76,46 @@
class="ele-pagination-circle"
/>
</el-card>
<el-dialog title="添加表" :visible.sync="showAdd" width="600px">
<el-dialog
title="添加表"
:visible.sync="showAdd"
width="400px"
custom-class="ele-dialog-form"
>
<el-form
:model="form"
label-width="82px"
custom-class="editForm"
@keyup.enter.native="save"
@submit.native.prevent
ref="editForm"
:rules="rules"
>
<el-row :gutter="15">
<el-col :sm="12">
<el-form-item label="考核年度:">
<el-input></el-input>
</el-form-item>
<el-form label="表格名称:">
<el-input placeholder="请输入如表格编号"></el-input>
</el-form>
<el-form label="创建时间:">
<el-input placeholder="请输入如表格编号"></el-input>
</el-form>
</el-col>
<el-col :sm="12">
<el-form-item label="表编号:">
<el-input></el-input>
</el-form-item>
<el-form label="备注:">
<el-input placeholder="请输入如表格编号"></el-input>
</el-form>
<el-form label="创建人:">
<el-input placeholder="请输入如表格编号"></el-input>
</el-form>
</el-col>
</el-row>
<el-form-item label="考核年度:" prop="year">
<el-date-picker type="year" placeholder="选择考核年度" style="width:100%" clearable v-model="form.year">
</el-date-picker>
</el-form-item>
<el-form-item label="表格名称:" prop="name">
<el-input placeholder="请输入如表格名称" clearable v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="表编号:" prop='code'>
<el-input placeholder="请输入表编号" clearable v-model="form.code"></el-input>
</el-form-item>
<el-form-item label="备注:">
<el-input type="textarea" :rows="4" v-model="form.note"></el-input>
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="showAdd = false">取消</el-button>&nbsp;
<el-button type="primary" @click="save">保存</el-button>
</div>
</el-dialog>
</div>
</template>

<script>
import search from "./search";
import api from "@/api/basicTable/category";
import api from "@/api/basicTable/category.js";
export default {
components: {
search,
@@ -119,21 +123,72 @@ export default {
data() {
return {
searchParams: {},
dataList: [],
dataList: [
{ code: "fadfadf", name: "fadfadf", note: "fdafa", year: "fdfadf" },
],
count: 0,
page: {
page: 1,
limit: 10,
limit: Math.floor((document.documentElement.clientHeight - 360-45) / 45),
},
showAdd: false,
form: {},
tableHeight: document.documentElement.clientHeight - 360,
rules: {
code: [{ required: true, message: "表编号", trigger: "blur" }],
name: [{ required: true, message: "请输入表格名称", trigger: "blur" }],
year: [{ required: true, message: "请输入考核年度" }],
},
};
},
created() {
api.getList();
this.getDataList(this.page);
},
methods: {
add() {},
getDataList(params) {
const loading = this.$loading({ lock: true });
api
.getList(params)
.then((res) => {
loading.close();
this.dataList = res.data.data.records;
this.count=res.data.data.total
})
.catch(() => {
loading.close();
this.dataList = [];
this.count=0
});
},
add(row) {
console.log(row)
this.form = { code: "", name: "", note: "", year: "" };
this.showAdd = true;
},
edit(row) {
console.log(row)
this.form = Object.assign({}, row);
this.showAdd = true;
},
save() {
this.$refs["editForm"].validate((valid) => {
console.log(valid)
if (valid) {
const loading = this.$loading({ lock: true });
let action = this.form.id ? "edit" : "add";
api[action](this.form)
.then((res) => {
console.log(res);
loading.close();
})
.catch((e) => {
console.log(e)
loading.close();
this.$message.error(this.form.id ? "修改失败" : "添加失败");
});
}
});
},
},
};
</script>

+ 9
- 9
vue.config.js 查看文件

@@ -3,15 +3,15 @@ const CompressionWebpackPlugin = require('compression-webpack-plugin');
module.exports = {
devServer: {
open: true,
proxy: {
"/api": {
target: "http://47.98.157.120:9031/",
changeOrigin: true,
// pathRewrite: {
// "^/api": "/"
// }
}
}
// proxy: {
// "/api": {
// target: "http://47.98.157.120:9031/",
// changeOrigin: true,
// // pathRewrite: {
// // "^/api": "/"
// // }
// }
// }
},
productionSourceMap: false,
transpileDependencies: ['element-ui'], // 需要兼容IE10要放开这个

Loading…
取消
儲存