Skip to content

Commit

Permalink
(feature)完善表单与列表页
Browse files Browse the repository at this point in the history
  • Loading branch information
jingchenxu committed Aug 30, 2019
1 parent e8aa47a commit 52bbd10
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 43 deletions.
13 changes: 13 additions & 0 deletions src/mock/data/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@
"mstatus": 1,
"morder": 0
},
{
"mid": 24,
"mkey": "art-tag",
"mname": "文章标签管理",
"micon": "md app",
"mpath": "/syspage3",
"mtip": "简单列表页",
"mrender": "default",
"mpid": 2,
"mlevel": 2,
"mstatus": 1,
"morder": 0
},
{
"mid": 3,
"mkey": "set",
Expand Down
1 change: 1 addition & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const router:Router = new Router({
{ path: 'syspage1', name: 'syspage1', component: () => import('@/views/mis/sys/SysPage1.vue') },
{ path: 'syspage2', name: 'syspage2', component: () => import('@/views/mis/sys/SysPage2.vue') },
{ path: 'syspage3', name: 'syspage3', component: () => import('@/views/mis/sys/SysPage3.vue') },
{ path: 'art-tag', name: 'art-tag', component: () => import('@/views/mis/sys/ArtTag.vue') },
{ path: 'usercenter', name: 'usercenter', component: () => import('@/views/mis/set/UserCenter.vue') },
{ path: 'usersetting', name: 'usersetting', component: () => import('@/views/mis/set/UserSetting.vue') },
{ path: 'notfound', name: 'notfound', component: () => import('@/views/mis/exception/NotFound.vue') },
Expand Down
10 changes: 5 additions & 5 deletions src/views/mis/components/MisTable/MisTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
v-loading="loading"
@select="handleSelect"
@row-dblclick="handleDbclick">
<Column :key="index" :column-item="columnItem" v-for="(columnItem, index) of columnList"/>
<Column :key="index" :column-item="columnItem" v-for="(columnItem, index) of tableColumn"/>
<!-- <el-table-column type="index" align="center" width="50"/>
<el-table-column type="selection" align="center" width="55"/>
<el-table-column prop="date" :formatter="dataFormat" label="日期" width="180"/>
Expand Down Expand Up @@ -41,8 +41,7 @@ export default class MisTable extends Vue {
private columns: () => []
@Prop({ default: [] })
private tabledata: Array<any>
private columnList = [
@Prop({ default: () => [
{
type: 'index',
align: 'center',
Expand All @@ -55,7 +54,7 @@ export default class MisTable extends Vue {
},
{
prop: 'date',
formatter: this.dataFormat,
// formatter: (this as any).dataFormat,
label: '日期',
width: 180
},
Expand All @@ -68,7 +67,8 @@ export default class MisTable extends Vue {
prop: 'address',
label: '地址'
}
]
]})
private tableColumn: Array<TableColumn>
private handleDbclick (row: any, column: any, event: any) {
console.log('双击被触发了')
Expand Down
93 changes: 55 additions & 38 deletions src/views/mis/for/ArticlePublish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,29 @@
<Input v-model="form.subtitle" placeholder="请输入文章副标题"></Input>
</FormItem>
</Col>
<Col span="8" style="padding-right:10px">
<Col span="24">
<FormItem label="文章简介" prop="bref">
<!-- <Input v-model="form.bref" type="textarea" :autosize="{minRows: 3,maxRows: 5}" placeholder="请输入文章简介"></Input> -->
<Input v-model="form.bref" placeholder="请输入文章简介"></Input>
</FormItem>
</Col>
<Col span="8">
<FormItem label="文章分类" prop="articletype">
<Select v-model="form.articletype" filterable>
<Option v-for="item in firstLevelList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
<Select v-model="form.articletype" filterable>
<Option v-for="item in firstLevelList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
</FormItem>
</Col>
<Col span="16">
<FormItem label="文章标签" prop="level2">
<Select v-model="form.tags" filterable multiple>
<Option v-for="item in secondLevelList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
<FormItem label="文章标签" prop="tags">
<Select v-model="form.tags" filterable multiple>
<Option v-for="item in secondLevelList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
</FormItem>
</Col>
<Col span="8">
<FormItem label="文章顺序" prop="serial">
<Input v-model="form.serial" placeholder="请输入文章顺序"></Input>
</FormItem>
</Col>
<Col span="24">
Expand All @@ -43,66 +54,72 @@
</template>

<script>
import Article from "./beans/Article";
export default {
name: 'ArticlePublish',
data () {
name: "ArticlePublish",
data() {
return {
loading: false,
form: {
context: '# hello',
tags: []
},
form: new Article(),
form_disabled: false,
rules: {
title: [
{ required: true, message: '文章标题不能为空!', trigger: 'blur' }
{ required: true, message: "文章标题不能为空!", trigger: "blur" }
],
subtitle: [
{ required: true, message: '文章副标题不能为空', trigger: 'blur' }
{ required: true, message: "文章副标题不能为空", trigger: "blur" }
],
articletype: [
{ required: true, message: '请选择文章分类', trigger: 'change' }
{ required: true, message: "请选择文章分类", trigger: "change" }
]
},
firstLevelList: [
{
label: '试题',
value: '01'
label: "文章",
value: "01"
},
{
label: "基础知识",
value: "02"
},
{
label: '文章',
value: '02'
label: "面试题",
value: "03"
}
],
secondLevelList: [
{
label: 'java',
value: '01'
label: "java",
value: "01"
},
{
label: 'javascript',
value: '02'
label: "javascript",
value: "02"
}
]
}
};
},
methods: {
handleSubmit () {
this.$refs.form.validate((valid) => {
handleSubmit() {
this.$refs.form.validate(valid => {
if (valid) {
this.loading = true
this.$axios.post('/api/savearticle', this.form).then(res => {
this.loading = false
if (res.success) {
this.$Message.success(res.msg)
}
})
// this.loading = true;
this.$axios
.post("/codekeep/art/save_article", this.form)
.then(res => {
// this.loading = false;
if (res.success) {
this.$Message.success(res.msg);
}
});
} else {
this.$Message.error('表单校验失败')
this.$Message.error("表单校验失败");
}
})
});
}
}
}
};
</script>

<style lang="less" scoped>
Expand Down
18 changes: 18 additions & 0 deletions src/views/mis/for/beans/Article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default class Article {
constructor () {
this.uuid = ''
this.serial = 0
this.title = ''
this.context = ''
// this.createdate = new Date()
// this.modifydate = new Date()
this.articleid = null
this.userid = ''
this.subtitle = ''
this.bref = ''
this.articletype = '01'
this.hot = 0
this.star = 0
// this.tags = ['01', '02']
}
}
115 changes: 115 additions & 0 deletions src/views/mis/sys/ArtTag.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<template>
<mis-simple-list>
<div class="search-items-container">
<Form ref="searchParams" :model="searchParams" inline>
<FormItem prop="tagname">
<Input clearable type="text" v-model="searchParams.tagname" @on-enter="handleSearch" placeholder="请输入标签名称">
</Input>
</FormItem>
<FormItem>
<Button type="primary" :loading="searching" icon="ios-search" @click="handleSearch('searchParams')">查询</Button>
</FormItem>
<FormItem>
<Button type="primary" icon="ios-redo" @click="handleAdd('searchParams')">导出</Button>
</FormItem>
</Form>
</div>
<mis-table :tabledata="data" :tableColumn="column" :loading="searching" />
<white-space />
<Page @on-change="handlePageChange" :total="total" show-sizer />
</mis-simple-list>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import MisTable from "../components/MisTable";
import MisSimpleList from "../components/MisSimpleList";
@Component({
name: "art_tag",
components: {
MisTable,
MisSimpleList
}
})
export default class SysPage3 extends Vue {
private data() {
return {
searchParams: {},
searchUrl: "/codekeep/art/search_tag",
searching: false,
currentPage: 1,
pageSize: 10,
total: 0,
data: [],
column: [
{
type: "index",
align: "center",
width: 50
},
{
type: "selection",
align: "center",
width: 50
},
{
prop: "tagid",
label: "标签编号",
width: 180
},
{
prop: "tagname",
label: "标签名称",
width: 180
},
{
prop: "icon",
label: "标签图标",
width: 180
},
{
prop: "desc",
label: "标签描述"
}
]
};
}
private mounted() {
this.initList();
}
private async initList() {
await this.handleSearch();
}
private handleSearch() {
let vm = this as any;
(this as any).searching = true;
let searchParams: any = Object.assign((this as any).searchParams, {});
searchParams["pagenumber"] = (this as any).currentPage;
searchParams["pagesize"] = (this as any).pageSize;
let params = new URLSearchParams();
for (let key in searchParams) {
if (searchParams[key]) {
params.append(key, searchParams[key]);
}
}
(this as any).$axios.get(`${(this as any).searchUrl}`, { params })
.then((res: any) => {
(this as any).searching = false
this.data = res.list
(this as any).total = res.total
})
}
private handleAdd() {}
private handleBack() {}
private handlePageChange(currentPage: number) {
(this as any).currentPage = currentPage;
this.handleSearch();
}
}
</script>
3 changes: 3 additions & 0 deletions src/views/mis/sys/beans/ArtTag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ArtTag {
tagid:
}
17 changes: 17 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ module.exports = {
// 为开发环境修改配置...
}
},
devServer: {
proxy: {
'/codekeep': {
target: 'http://localhost:2048/codekeep',
// changeOrigin: true,
// ws: true,
bypass: function (req, res, proxyOptions) {
// console.dir(req)
// console.dir(res)
// console.dir(proxyOptions)
},
pathRewrite: {
'^/codekeep': ''
}
}
}
},
css: {
loaderOptions: {
less: {
Expand Down

0 comments on commit 52bbd10

Please sign in to comment.