初始提交
This commit is contained in:
125
src/components/article/add.vue
Normal file
125
src/components/article/add.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<div class="main_box screen1" v-loading="loading">
|
||||
<el-form :model="articleModel" :rules="rules" ref="editor" label-width="100px">
|
||||
<el-form-item prop="CatalogId" label="分类" size="small">
|
||||
<el-select v-model="articleModel.CatalogId" placeholder="请选择">
|
||||
<el-option label="华连头条" :value="1"></el-option>
|
||||
<el-option label="优惠活动" :value="2"></el-option>
|
||||
<el-option label="常见问题" :value="3"></el-option>
|
||||
<el-option label="新手教程" :value="4"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="Title" label="标题">
|
||||
<el-input placeholder="请填标题" v-model="articleModel.Title" size="small"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="SubTitle" label="副标题">
|
||||
<el-input placeholder="请填副标题" v-model="articleModel.SubTitle" size="small"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="Keyword" label="关键字">
|
||||
<el-input v-model="articleModel.Keyword" type="number" size="small"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="AccessCount" label="访问人数">
|
||||
<el-input
|
||||
placeholder="请填访问人数:"
|
||||
v-model="articleModel.AccessCount"
|
||||
type="number"
|
||||
size="small"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="OnLine" label="发布状态">
|
||||
<el-switch
|
||||
v-model="articleModel.Publish"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
size="small"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="editor-container">
|
||||
<UE v-model="articleModel.Content" :config="config" ref="ue"></UE>
|
||||
</div>
|
||||
<div class="handel_box clr">
|
||||
<el-button @click="$router.go(-1)" size="small">取 消</el-button>
|
||||
<el-button type="primary" @click="save('editor')" size="small">确定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
let that;
|
||||
export default {
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
articleModel: {
|
||||
Publish: 0,
|
||||
id: 0,
|
||||
Thumb: "",
|
||||
CatalogId:1,
|
||||
},
|
||||
loading: false,
|
||||
rules: {
|
||||
Title: [this.$vaild.required("标题")],
|
||||
SubTitle: [this.$vaild.required("副标题")]
|
||||
// Banner: [this.$vaild.required("课程主图")],
|
||||
// Cover: [this.$vaild.required("课程封面")],
|
||||
},
|
||||
config: {
|
||||
serverUrl: this.$api.baseURL + "ueditor",
|
||||
UEDITOR_HOME_URL: "/static/ueditor/",
|
||||
autoHeightEnabled: false,
|
||||
initialFrameHeight: 500
|
||||
},
|
||||
options: []
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.$store.commit("setCurrentNav", "资讯管理>>添加资讯");
|
||||
var query = this.$route.query;
|
||||
if (query.optype == 2) {
|
||||
this.getInfo(query.id);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getInfo(id) {
|
||||
this.$api.get("course/v1/article/Get", { id: id }).then(res => {
|
||||
this.articleModel = res.Data;
|
||||
});
|
||||
},
|
||||
save(formName) {
|
||||
var that = this;
|
||||
this.$refs[formName].validate(valid => {
|
||||
if (valid) {
|
||||
if (that.$route.query.optype == "1") {
|
||||
that.add();
|
||||
} else if (that.$route.query.optype == "2") {
|
||||
that.edit();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
add() {
|
||||
this.$api.post("course/v1/article/post", this.articleModel).then(res => {
|
||||
this.$router.push({ name: "articlelist" });
|
||||
});
|
||||
},
|
||||
edit() {
|
||||
this.$api.post("course/v1/article/put", this.articleModel).then(res => {
|
||||
this.$router.push({ name: "articlelist" });
|
||||
});
|
||||
},
|
||||
upload(callback) {
|
||||
this.$api.upload("oss/v1/ImageCloud/upload").then(res => {
|
||||
callback && callback(res.Data);
|
||||
});
|
||||
},
|
||||
setCover(ret) {
|
||||
this.articleModel.Thumb = ret.Url;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-form {
|
||||
width: 600px;
|
||||
}
|
||||
</style>
|
||||
104
src/components/article/index.vue
Normal file
104
src/components/article/index.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<div v-loading="loading">
|
||||
<div class="heior_box">
|
||||
<el-button size="small" type="primary" icon="el-icon-plus" v-href="'add?optype=1'">添加文章</el-button>
|
||||
<div class="search-box">
|
||||
<el-input v-model="searchModel.keyWord" placeholder="请输入名称/标题" clearable size="small">
|
||||
<el-button slot="append" icon="el-icon-search" @click="search"></el-button>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
<el-table :data="retData.Data" size="medium" :height="$getHeight(100)" row-key="Id" border>
|
||||
<!-- <el-table-column label="图片" width="80">
|
||||
<template slot-scope="scope">
|
||||
<img :src="scope.row.Thumb" style="width:50px;height:20px" />
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column prop="CatalogId" label="分类" width="180" :formatter="catalogFormat"></el-table-column>
|
||||
<el-table-column prop="Title" label="标题" width="180"></el-table-column>
|
||||
<el-table-column prop="SubTitle" label="子标题" width="180"></el-table-column>
|
||||
<el-table-column prop="AccessCount" label="访问人数"></el-table-column>
|
||||
<el-table-column prop="CreateTime" label="发布时间" aformatter="formatterTime"></el-table-column>
|
||||
<el-table-column label="发布状态">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.Publish"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
@change="audit(scope.row)"
|
||||
></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template slot-scope="scope">
|
||||
<span class="handel cursor edit" v-href="'add?optype=2&id='+scope.row.Id">编辑</span>
|
||||
<span class="handel cursor del" @click="del(scope.row)">删除</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="block">
|
||||
<el-pagination
|
||||
v-if="retData.Data.length>0"
|
||||
@current-change="get"
|
||||
:page-size="20"
|
||||
:current-page.sync="searchModel.PageIndex"
|
||||
layout="total,prev, pager, next"
|
||||
:total="retData.TotalCount"
|
||||
></el-pagination>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "treeTable",
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
retData: { TotalCount: 0, Data: [] },
|
||||
searchModel: {
|
||||
PageIndex: 1,
|
||||
keyWord: ""
|
||||
},
|
||||
catalogFormat(data) {
|
||||
console.log(data)
|
||||
return data.CatalogId==1?"华连头条":"使用技巧";
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.get();
|
||||
},
|
||||
methods: {
|
||||
search(){
|
||||
this.searchModel.PageIndex=1;
|
||||
this.get();
|
||||
},
|
||||
get() {
|
||||
this.$api.get("course/v1/article/page", this.searchModel).then(res => {
|
||||
this.retData = res;
|
||||
});
|
||||
},
|
||||
del(item) {
|
||||
var that = this;
|
||||
this.$confirm("确定删除?", "", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(_ => {
|
||||
this.$api.post("course/v1/article/Delete?id=" + item.Id).then(res => {
|
||||
that.get();
|
||||
});
|
||||
});
|
||||
},
|
||||
audit(item) {
|
||||
this.$api.post("course/v1/article/Audit?id=" + item.Id).then(res => {
|
||||
item.Publish = res.Data;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
||||
Reference in New Issue
Block a user