xjc 3 年之前
父節點
當前提交
56086a491f
共有 3 個文件被更改,包括 415 次插入1 次删除
  1. 12 1
      src/router.js
  2. 223 0
      src/views/match/addArticle.vue
  3. 180 0
      src/views/match/notice.vue

+ 12 - 1
src/router.js

@@ -37,7 +37,18 @@ export default new Router({
         path: '/group',
         component: () => import('./views/match/group.vue'),
         name: '赛事分组'
-      }, ]
+      },{
+        path: '/notice',
+        component: () => import('./views/match/notice.vue'),
+        name: '赛事公告'
+      },
+      {
+        path: '/addNotice',
+        component: () => import('./views/match/addArticle.vue'),
+        name: '新增公告',
+        show:0,
+        isLeaf:1
+      }]
     },
     {
       path: '/player',

+ 223 - 0
src/views/match/addArticle.vue

@@ -0,0 +1,223 @@
+<style lang="scss">
+.add {
+  .el-input,
+  button {
+    width: 300px;
+  }
+  .bm-view {
+    width: 100%;
+  }
+  .avatar-uploader .el-upload {
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+  }
+  .avatar-uploader .el-upload:hover {
+    border-color: #409eff;
+  }
+  .avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 178px;
+    height: 178px;
+    line-height: 178px;
+    text-align: center;
+  }
+  .avatar {
+    width: 178px;
+    height: 178px;
+    display: block;
+  }
+  .imgs{
+    li{
+      display: inline-block;
+      width: 150px;
+      height: 150px;
+      overflow: hidden;
+      margin: 0 10px;
+    }
+    .up_img{
+      border: 1px dashed #999;
+      border-radius: 4px;
+      font-size: 50px;
+      text-align: center;
+      line-height: 150px;
+      color:#999;
+      position: relative;
+      input{
+        position: absolute;
+        width: 100%;
+        height: 100%;
+        left:0;
+        top: 0;
+        opacity: 0;
+      }
+    }
+  }
+}
+</style>
+<template>
+  <section class="add">
+    <p>内容管理 > 新增公告</p>
+    <div class="content">
+      <el-form label-width="80px">
+        <el-form-item label="标题">
+          <el-input placeholder="标题" v-model="form.title"></el-input>
+        </el-form-item>
+        <el-form-item label="详情">
+          <fuEditor v-model="form.content" :isClear="isClear" @change="change"></fuEditor>
+        </el-form-item>
+        <el-form-item label=" ">
+          <el-button type="primary" @click="save">保存</el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+  </section>
+</template>
+<script>
+import fuEditor from "@/components/fuEditor/index.vue";
+export default {
+  components: {
+    fuEditor
+  },
+  data() {
+    return {
+      test: "",
+      list:[],
+      form: {
+        title: "",
+        category_id: '',
+        content: "",
+        imgs: [],
+        address: "",
+        point: ""
+      },
+      isClear: false,
+      keyword:'',
+      point:{
+        lng:'',
+        lat:''
+      },
+      BMap:null
+    };
+  },
+  methods: {
+    getData() {
+      this.$api.getArticleById({ id: this.form.id }).then(res => {
+        this.form = res.data.data;
+        this.point={
+          lng:this.form.point.split(',')[0],
+          lat:this.form.point.split(',')[1]
+        }
+      });
+    },
+    getContent(){
+      this.$api.getContentList({page:this.page}).then(res => {
+        this.loading=false
+        if (res.status == 200) {
+          this.list = res.data.data.list;
+        } else {
+          this.$message({
+            message: res.message,
+            type: "error"
+          });
+        }
+      });
+    },
+    change(val) {
+      this.form.content = val;
+    },
+    upload(type){
+          var file=document.getElementById(type).files;
+          var data=new FormData();
+            data.append("file",file[0])
+          this.$api.uploadFile(data).then(res=>{
+              if(res.data.code==0){
+                      let imgs=this.form.imgs||[];
+                      imgs.push(res.data.data.url)
+                      this.form.imgs=imgs
+                      // this.$set(form,type,res.data.data.url)
+                      this.$message({message: '上传成功!',type: 'success'});
+                  }else{
+                      this.$message.error(res.data.message);
+                  }
+          })
+      },
+    save() {
+      var parm = this.form;
+      parm.point=this.point.lng+','+this.point.lat
+      if (parm.id) {
+        // debugger;
+        this.$api.editArticle(parm).then(res => {
+          if (res.data.code == 0) {
+            this.$message({ message: "修改成功!", type: "success" });
+            this.$router.push({ path: "/article" });
+          } else {
+            this.$message.error(res.data.message);
+          }
+        });
+      } else {
+        this.$api.addArticle(parm).then(res => {
+          if (res.data.code == 0) {
+            this.$message({ message: "添加成功!", type: "success" });
+            this.$router.push({ path: "/article" });
+          } else {
+            this.$message.error(res.data.message);
+          }
+        });
+      }
+    },
+    onBaiduMapReady(e) {
+      // const that = this
+      this.BMap = e.BMap
+    },
+     getClickInfo(e) {
+      // 调整地图中心位置
+      this.point=e.point
+
+      // 此时已经可以获取到BMap类
+      if (this.BMap) {
+        const that = this
+        // Geocoder() 类进行地址解析
+        // 创建地址解析器的实例
+        const geoCoder = new this.BMap.Geocoder()
+        // getLocation() 类--利用坐标获取地址的详细信息
+        // getPoint() 类--获取位置对应的坐标
+        geoCoder.getLocation(e.point, function(res) {
+          const addrComponent = res.addressComponents
+          const surroundingPois = res.surroundingPois
+          const province = addrComponent.province
+          const city = addrComponent.city
+          const district = addrComponent.district
+          let addr = addrComponent.street
+          if (surroundingPois.length > 0 && surroundingPois[0].title) {
+            if (addr) {
+              addr += `-${surroundingPois[0].title}`
+            } else {
+              addr += `${surroundingPois[0].title}`
+            }
+          } else {
+            addr += addrComponent.streetNumber
+          }
+          that.form.address=province+city+district+addr
+        })
+      }
+    },
+  },
+  created() {
+    this.getContent()
+    if (this.$route.query.id) {
+      this.form.id = this.$route.query.id;
+      this.id = this.$route.query.id;
+      this.getData();
+    }
+  }
+};
+</script>
+
+
+
+
+

+ 180 - 0
src/views/match/notice.vue

@@ -0,0 +1,180 @@
+<template>
+    <section class="content">
+        <h4>赛事公告</h4>
+        <el-divider></el-divider>
+        <el-form label-width="80px" class="filter-form">
+            <el-row>
+                <el-col :span="6">
+                    <el-form-item label="公告名称">
+                        <el-input @clear="getData()" clearable v-model="queryParams.name" placeholder="请输入公告名称" size="mini"></el-input>
+                    </el-form-item>
+                </el-col>
+                <el-col :span="4">
+                    <el-form-item label-width="10" style='margin-left:10px'>
+                        <el-button type="primary" @click="getData" size="mini">筛选</el-button>
+                        <el-button
+                        type="primary"
+                        plain
+                        icon="el-icon-plus"
+                        size="mini"
+                        @click="handleAdd"
+                        >新增公告</el-button>
+                    </el-form-item>
+                </el-col>
+            </el-row>   
+        </el-form>
+        <el-table v-loading='loading' :data="list" style="width: 100%;margin-top:10px;" height="50vh">
+                <el-table-column align="center" prop="name" label="公告名称"/>
+                <el-table-column align="center"  prop="end_time" label="创建时间"/>
+                <el-table-column align="center"  prop="date" label="操作">
+                    <template slot-scope="scope">
+                        <el-button @click="title='编辑赛事',open=true,form=scope.row" size="mini" type="warning">编辑</el-button>
+                        <el-button @click="del(scope.row.id)" size="mini" type="danger">删除</el-button>
+                    </template>
+                </el-table-column>
+        </el-table>
+        <Page
+            ref="pageButton"
+            :current="form.page"
+            :page_size="form.page_size"
+            :total="total"
+            @pageChange="gopage"
+        />
+        <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+            <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+                <el-form-item label="比赛名称" prop="name">
+                    <el-input clearable v-model="form.name" placeholder="请输入比赛名称"></el-input>
+                </el-form-item>
+                <el-form-item label="开始时间" prop="start_time">
+                    <el-date-picker
+                    v-model="form.start_time"
+                    type="date"
+                    placeholder="选择日期"
+                    format="yyyy-MM-dd"
+                    value-format="yyyy-MM-dd"
+                    size="mini"
+                    >
+                    </el-date-picker>
+                </el-form-item>
+                <el-form-item label="结束时间" prop="end_time">
+                    <el-date-picker
+                    v-model="form.end_time"
+                    type="date"
+                    placeholder="选择日期"
+                    format="yyyy-MM-dd"
+                    value-format="yyyy-MM-dd"
+                    size="mini"
+                    >
+                    </el-date-picker>
+                </el-form-item>
+            </el-form>
+            <div slot="footer" class="dialog-footer">
+                <el-button type="primary" @click="submitForm">确 定</el-button>
+                <el-button @click="open=false">取 消</el-button>
+            </div>
+        </el-dialog>
+    </section>
+</template>
+<script>
+import Page from "../../components/Page";
+export default {
+    components: {
+        Page,
+    },
+    data(){
+        return{
+            loading:false,
+            queryParams:{
+                page:1
+            },
+            form:{},
+            list:[{},{}],
+            total:0,
+            title:'新增赛事',
+            open:false,
+            rules:{
+                name: [
+                    { required: true, message: '请输入比赛名称', trigger: 'blur' }
+                ],
+                start_time: [
+                    { required: true, message: '请输入开始时间', trigger: 'blur' }
+                ],
+                end_time: [
+                    { required: true, message: '请输入结束时间', trigger: 'blur' }
+                ]
+            },
+            matchList:[],
+            groupList:[],
+            userList:[]
+        }
+    },
+    methods:{
+        del(id) {
+        this.$confirm("确定删除吗?", "提示", {
+            type: "warning",
+        }).then(() => {
+            this.$api.delMatch({ id: id }).then((res) => {
+            this.$message({
+                message: "删除成功",
+                type: "success",
+            });
+            this.getData();
+            });
+        });
+        },
+        gopage(size) {
+            if (size) {
+                this.queryParams.page_size = size;
+            }
+            this.queryParams.page = this.$refs.pageButton.page;
+            this.getData();
+        },
+        getData(){
+            this.loading = true;
+            this.$api.getMatchList().then(res=>{
+                this.matchList=res.data.data
+            })
+            this.$api.getGroupList().then(res=>{
+                this.groupList=res.data.data
+            })
+            this.$api.getUserSearch().then(res=>{
+                this.userList=res.data.data
+            })
+            // 
+            this.$api.getMatchs(this.queryParams).then(res=>{
+                this.list=res.data.data.list
+                this.total = res.data.data.total;
+                this.loading = false;
+            })
+        },
+        handleAdd(){
+            this.open=true;
+            this.title='新增赛事';
+            this.form={}
+        },
+        /** 提交按钮 */
+        submitForm() {
+            this.$refs["form"].validate(valid => {
+                if (valid) {
+                if (this.form.id != null) {
+                    this.$api.updateMatch(this.form).then(response => {
+                    this.msgSuccess("修改成功");
+                    this.open = false;
+                    this.getData();
+                    });
+                } else {
+                    this.$api.addMatch(this.form).then(response => {
+                    this.msgSuccess("新增成功");
+                    this.open = false;
+                    this.getData();
+                    });
+                }
+        }
+      });
+    },
+    },
+    created(){
+       this.getData() 
+    }
+}
+</script>