diff --git a/test_client/src/api/cms.js b/test_client/src/api/cms.js
index 0f65da2..a35be50 100644
--- a/test_client/src/api/cms.js
+++ b/test_client/src/api/cms.js
@@ -32,3 +32,9 @@ export function getArticle(id) {
method: 'get',
})
}
+export function topArticle(id) {
+ return request({
+ url: `/cms/article/${id}/top/`,
+ method: 'put',
+ })
+}
diff --git a/test_client/src/views/analyse/examtest.vue b/test_client/src/views/analyse/examtest.vue
index 70c8dc8..08a6547 100644
--- a/test_client/src/views/analyse/examtest.vue
+++ b/test_client/src/views/analyse/examtest.vue
@@ -69,6 +69,9 @@
{{ scope.row.consumer_name }}
+
+ {{ scope.row.consumer_company_name }}
+
{{ scope.row.workscope_name }}
diff --git a/test_client/src/views/crm/consumer.vue b/test_client/src/views/crm/consumer.vue
index 15859ab..33ca475 100644
--- a/test_client/src/views/crm/consumer.vue
+++ b/test_client/src/views/crm/consumer.vue
@@ -33,7 +33,7 @@
-->
{{ scope.row.title }}
+
+ {{ scope.row.ifrom }}
+
+
+
+ {{ scope.row.elink }}
+ 原创
+
+
{{ scope.row.create_time }}
@@ -41,6 +50,22 @@
+ 取消置顶
+ 置顶
diff --git a/test_client/src/views/news/newscreate.vue b/test_client/src/views/news/newscreate.vue
index 75fb358..8f0c852 100644
--- a/test_client/src/views/news/newscreate.vue
+++ b/test_client/src/views/news/newscreate.vue
@@ -14,7 +14,10 @@
-
+
+
+
+
@@ -39,6 +42,7 @@ export default {
Form:{
title:'',
ifrom:'',
+ elink:'',
content:''
},
submitLoding: false,
@@ -49,12 +53,13 @@ export default {
ifrom: [
{ required: true, message: "请输入", trigger: "blur" }
],
- content: [
- { required: true, message: "请输入", trigger: "blur" }
- ],
},
+ is_show: true
}
},
+ watch:{
+ 'Form.elink':'showEditor'
+ },
methods:{
goBack() {
this.$router.go(-1)
@@ -80,6 +85,14 @@ export default {
}
});
},
+ showEditor(){
+ if(this.Form.elink){
+ this.Form.content = ''
+ this.is_show = false
+ }else{
+ this.is_show = true
+ }
+ }
}
}
diff --git a/test_client/src/views/news/newsupdate.vue b/test_client/src/views/news/newsupdate.vue
index 335ac6a..29620da 100644
--- a/test_client/src/views/news/newsupdate.vue
+++ b/test_client/src/views/news/newsupdate.vue
@@ -14,7 +14,10 @@
-
+
+
+
+
@@ -39,6 +42,7 @@ export default {
Form:{
title:'',
ifrom:'',
+ elink:'',
content:''
},
submitLoding: false,
@@ -49,16 +53,17 @@ export default {
ifrom: [
{ required: true, message: "请输入", trigger: "blur" }
],
- content: [
- { required: true, message: "请输入", trigger: "blur" }
- ],
},
+ is_show: false
}
},
created() {
this.Form.id = this.$route.query.id //接收参数
this.getArticle();
},
+ watch:{
+ 'Form.elink':'showEditor'
+ },
methods:{
goBack() {
this.$router.go(-1)
@@ -89,6 +94,14 @@ export default {
this.Form = response.data ;
});
},
+ showEditor(){
+ if(this.Form.elink){
+ this.Form.content = ''
+ this.is_show = false
+ }else{
+ this.is_show = true
+ }
+ }
}
}
diff --git a/test_mini/app.js b/test_mini/app.js
index d9d5af7..7d4f53a 100644
--- a/test_mini/app.js
+++ b/test_mini/app.js
@@ -56,9 +56,9 @@ App({
globalData: {
userInfo: null,
userinfo: null, // 服务器传回的消费者信息
- host: 'https://apitest.ctcshe.com',
+ // host: 'https://apitest.ctcshe.com',
mediahost: 'https://apitest.ctcshe.com',
- //host: 'http://127.0.0.1:8000',
+ host: 'http://127.0.0.1:8000',
//mediahost: 'http://127.0.0.1:8000',
token : '',
}
diff --git a/test_mini/app.json b/test_mini/app.json
index cdca009..9fc31ef 100644
--- a/test_mini/app.json
+++ b/test_mini/app.json
@@ -19,7 +19,9 @@
"pages/my/index",
"pages/collect/main",
"pages/workscope/index",
- "pages/yati/index"
+ "pages/yati/index",
+ "pages/article/index",
+ "pages/article/detail"
],
"window": {
"backgroundTextStyle": "light",
@@ -39,11 +41,17 @@
"selectedIconPath": "images/homec.png",
"text": "主页"
},
+ {
+ "pagePath": "pages/article/index",
+ "iconPath": "images/icon_doc.png",
+ "selectedIconPath": "images/icon_doc_fill.png",
+ "text": "资讯"
+ },
{
"pagePath": "pages/my/index",
"iconPath": "images/me.png",
"selectedIconPath": "images/mec.png",
- "text": "个人中心"
+ "text": "我的"
}
]
},
diff --git a/test_mini/images/feeds-fill.png b/test_mini/images/feeds-fill.png
new file mode 100644
index 0000000..d6ac9c5
Binary files /dev/null and b/test_mini/images/feeds-fill.png differ
diff --git a/test_mini/images/feeds.png b/test_mini/images/feeds.png
new file mode 100644
index 0000000..bec6428
Binary files /dev/null and b/test_mini/images/feeds.png differ
diff --git a/test_mini/images/icon_doc.png b/test_mini/images/icon_doc.png
new file mode 100644
index 0000000..dbd89d1
Binary files /dev/null and b/test_mini/images/icon_doc.png differ
diff --git a/test_mini/images/icon_doc_fill.png b/test_mini/images/icon_doc_fill.png
new file mode 100644
index 0000000..23930a2
Binary files /dev/null and b/test_mini/images/icon_doc_fill.png differ
diff --git a/test_mini/pages/article/detail.js b/test_mini/pages/article/detail.js
new file mode 100644
index 0000000..98e8978
--- /dev/null
+++ b/test_mini/pages/article/detail.js
@@ -0,0 +1,75 @@
+// pages/article/detail.js
+const api = require("../../utils/request.js");
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ this.getDetail(options.id)
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+ getDetail: function (id) {
+ var that = this
+ api.request(`/cms/article/${id}/`,'GET').then(res => {
+ that.setData(res.data)
+ })
+ },
+
+})
\ No newline at end of file
diff --git a/test_mini/pages/article/detail.json b/test_mini/pages/article/detail.json
new file mode 100644
index 0000000..8835af0
--- /dev/null
+++ b/test_mini/pages/article/detail.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/test_mini/pages/article/detail.wxml b/test_mini/pages/article/detail.wxml
new file mode 100644
index 0000000..1cf9409
--- /dev/null
+++ b/test_mini/pages/article/detail.wxml
@@ -0,0 +1,16 @@
+
+
+
+ {{title}}
+
+ {{ifrom}}
+ 置顶
+ 原创
+
+
+
+
+
+
+
+
diff --git a/test_mini/pages/article/detail.wxss b/test_mini/pages/article/detail.wxss
new file mode 100644
index 0000000..bda2f6d
--- /dev/null
+++ b/test_mini/pages/article/detail.wxss
@@ -0,0 +1 @@
+/* pages/article/detail.wxss */
\ No newline at end of file
diff --git a/test_mini/pages/article/index.js b/test_mini/pages/article/index.js
new file mode 100644
index 0000000..6dfcd92
--- /dev/null
+++ b/test_mini/pages/article/index.js
@@ -0,0 +1,100 @@
+// pages/lianxi/index.js
+const api = require("../../utils/request.js");
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ results: [],
+ query: {
+ page: 1,
+ limit: 10
+ }
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function () {
+ var that = this
+ that.getList(that.data.query)
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+ },
+ getList: function () {
+ var that = this
+ api.request('/cms/article/', 'GET', that.data.query).then(res => {
+ if (that.data.query.page == 1) {
+ that.data.results = res.data.results
+ } else {
+ that.data.results = that.data.results.concat(res.data.results)
+ }
+
+ that.setData({
+ results: that.data.results,
+ count: res.data.count
+ })
+
+ })
+ },
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+ var that = this
+ that.data.query.page = 1;
+ that.getList();
+ wx.stopPullDownRefresh();
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+ var that = this
+ if (that.data.count <= that.data.query.page * that.data.query.limit) {
+ wx.showToast({
+ title: '没有更多了',
+ icon: 'none'
+ })
+ } else {
+ that.data.query.page = that.data.query.page + 1
+ that.getList()
+ }
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+})
\ No newline at end of file
diff --git a/test_mini/pages/article/index.json b/test_mini/pages/article/index.json
new file mode 100644
index 0000000..8835af0
--- /dev/null
+++ b/test_mini/pages/article/index.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/test_mini/pages/article/index.wxml b/test_mini/pages/article/index.wxml
new file mode 100644
index 0000000..a17e055
--- /dev/null
+++ b/test_mini/pages/article/index.wxml
@@ -0,0 +1,22 @@
+
+
+ {{count}}条资讯
+
+
+
+
+
+ 置顶
+ {{item.title}}
+
+ 来源:
+ {{item.ifrom}}
+ {{item.update_time}}
+
+
+
+ 查看详情
+
+
+
+
\ No newline at end of file
diff --git a/test_mini/pages/article/index.wxss b/test_mini/pages/article/index.wxss
new file mode 100644
index 0000000..a458506
--- /dev/null
+++ b/test_mini/pages/article/index.wxss
@@ -0,0 +1,5 @@
+.head{
+ color:#fff;
+ background-color: cornflowerblue;
+ text-align: center;
+}
\ No newline at end of file
diff --git a/test_server/cms/migrations/0002_auto_20200429_0944.py b/test_server/cms/migrations/0002_auto_20200429_0944.py
new file mode 100644
index 0000000..4a34c73
--- /dev/null
+++ b/test_server/cms/migrations/0002_auto_20200429_0944.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.0.4 on 2020-04-29 01:44
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('cms', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='article',
+ name='frame',
+ field=models.URLField(blank=True, null=True, verbose_name='外部链接'),
+ ),
+ migrations.AddField(
+ model_name='article',
+ name='is_top',
+ field=models.BooleanField(default=False, verbose_name='置顶'),
+ ),
+ ]
diff --git a/test_server/cms/migrations/0003_auto_20200429_1147.py b/test_server/cms/migrations/0003_auto_20200429_1147.py
new file mode 100644
index 0000000..dd073d9
--- /dev/null
+++ b/test_server/cms/migrations/0003_auto_20200429_1147.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.4 on 2020-04-29 03:47
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('cms', '0002_auto_20200429_0944'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='article',
+ old_name='frame',
+ new_name='elink',
+ ),
+ ]
diff --git a/test_server/cms/migrations/0004_auto_20200429_1205.py b/test_server/cms/migrations/0004_auto_20200429_1205.py
new file mode 100644
index 0000000..c639820
--- /dev/null
+++ b/test_server/cms/migrations/0004_auto_20200429_1205.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.4 on 2020-04-29 04:05
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('cms', '0003_auto_20200429_1147'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='article',
+ name='content',
+ field=models.TextField(blank=True, verbose_name='内容'),
+ ),
+ ]
diff --git a/test_server/cms/models.py b/test_server/cms/models.py
index 4ccfb65..8a57448 100644
--- a/test_server/cms/models.py
+++ b/test_server/cms/models.py
@@ -8,8 +8,10 @@ class Article(CommonModel):
文章
'''
title = models.CharField(max_length=60, verbose_name='标题')
- content = models.TextField(verbose_name='内容')
+ elink = models.URLField(verbose_name='外部链接', null=True, blank=True)
+ content = models.TextField(verbose_name='内容', blank=True)
ifrom = models.CharField(max_length=60, verbose_name='来源')
+ is_top = models.BooleanField('置顶', default=False)
class Meta:
verbose_name = '文章'
diff --git a/test_server/cms/serializers.py b/test_server/cms/serializers.py
index 6c1e1f1..4165e3f 100644
--- a/test_server/cms/serializers.py
+++ b/test_server/cms/serializers.py
@@ -11,3 +11,13 @@ class ArticelSerializer(serializers.ModelSerializer):
class Meta:
model = Article
fields = '__all__'
+
+class ArticelListSerializer(serializers.ModelSerializer):
+ """
+ 文章列表序列化
+ """
+ create_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
+ update_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
+ class Meta:
+ model = Article
+ exclude = ('content',)
diff --git a/test_server/cms/views.py b/test_server/cms/views.py
index fa40d7f..6d30954 100644
--- a/test_server/cms/views.py
+++ b/test_server/cms/views.py
@@ -22,7 +22,7 @@ from rest_framework_jwt.settings import api_settings
# Create your views here.
from .models import Article
-from .serializers import ArticelSerializer
+from .serializers import ArticelSerializer, ArticelListSerializer
from utils.custom import CommonPagination
class ArticleViewSet(ModelViewSet):
"""
@@ -36,5 +36,21 @@ class ArticleViewSet(ModelViewSet):
pagination_class = CommonPagination
filter_backends = [DjangoFilterBackend,SearchFilter, OrderingFilter]
search_fields = ('^title','^content')
- ordering_fields = ('id',)
- ordering = ['-id']
\ No newline at end of file
+ ordering_fields = ('title','update_time')
+ ordering = ['-is_top', '-update_time']
+
+ def get_serializer_class(self):
+ if self.action=='list':
+ return ArticelListSerializer
+ else:
+ return ArticelSerializer
+
+ @action(methods=['put'], detail=True, url_name='top_article', perms_map=[{'*':'top_article'}])
+ def top(self, request, *args, **kwargs):
+ '''
+ 置顶文章
+ '''
+ instance = self.get_object()
+ instance.is_top = False if instance.is_top else True
+ instance.save()
+ return Response(status=status.HTTP_200_OK)
\ No newline at end of file
diff --git a/test_server/crm/permission.py b/test_server/crm/permission.py
index 9af6a13..6e417ee 100644
--- a/test_server/crm/permission.py
+++ b/test_server/crm/permission.py
@@ -12,6 +12,7 @@ ConsumerPerms = [
'my_subjects',
'my_examtest',
'examtest_create',
+ 'article_list'
]
class MyPermission(RbacPermission):
diff --git a/test_server/crm/views.py b/test_server/crm/views.py
index ec8859d..152a8ad 100644
--- a/test_server/crm/views.py
+++ b/test_server/crm/views.py
@@ -85,7 +85,7 @@ class ConsumerViewSet(ModelViewSet):
ordering = ['-create_time']
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
filterset_fields = ('company',)
- search_fields = ('^name','^username')
+ search_fields = ('^name','^username','^company__name')
def get_queryset(self):
queryset = self.queryset
@@ -202,10 +202,7 @@ class ConsumerViewSet(ModelViewSet):
companyname = sheet['C'+str(m)].value
if companyname:
companyname = companyname.replace(' ', '')
- if companyname not in companydict:
- return Response({"error":"不存在单位("+companyname+")!请先新建"})
- else:
- companyobj = Company.objects.get(id=companydict[companyname])
+ companyobj = Company.objects.get_or_create(id=companydict[companyname])[0]
workscope = sheet['d'+str(m)].value
if Consumer.objects.filter(username = username).exists():
obj = Consumer.objects.filter(username = username).first()