Tang 2 yıl önce
ebeveyn
işleme
c645e4be78

+ 37 - 0
src/api/XfWebApi.js

@@ -164,4 +164,41 @@ export default {
             noToken: true
         })
     },
+    // 上传文件 返回文件地址
+    XfWebApiUploadFile(data) {
+        return request({
+            url: '/api/XfWebApi/UploadFile',
+            method: 'post',
+            data: data,
+            noToken: true
+        })
+    },
+
+    //新闻列表
+    XfWebApiGetMyNewsList(data) {
+        return request({
+            url: '/api/XfWebApi/GetMyNewsList',
+            method: 'get',
+            params: data,
+            tokenName
+        })
+    },
+    //保存新闻新增、编辑
+    XfWebApiSaveNews(data) {
+        return request({
+            url: '/api/XfWebApi/SaveNews',
+            method: 'post',
+            data: data,
+            tokenName
+        })
+    },
+    //新闻详细
+    XfWebApiGetNewsDetail(data) {
+        return request({
+            url: '/api/XfWebApi/GetNewsDetail',
+            method: 'get',
+            params: data,
+            tokenName
+        })
+    },
 }

+ 12 - 0
src/components/header/index.vue

@@ -96,6 +96,7 @@
         </el-menu>
         <div class="nav_footerBox">
           <el-button type="text" @click="openMembership">会员申请</el-button>
+          <el-button type="text" @click="contribute">投稿中心</el-button>
           <el-button type="text" @click="openSuggestion">网站建议</el-button>
           <br />
           <template v-if="$store.state.token">
@@ -218,6 +219,17 @@ export default {
       this.show = false;
       this.dialogVisibleLogin = true;
     },
+    //投稿入口
+    contribute() {
+      if (this.$store.state.token) {
+      this.show = false;
+        this.$router.push({
+          path: "contribute",
+        });
+      } else {
+        this.login();
+      }
+    },
     outLogin() {
       this.show = false;
       this.$message.success("已退出登录");

+ 66 - 0
src/components/membership/index.vue

@@ -73,6 +73,26 @@
                 clearable
                 v-model.trim="ruleForm[item.prop]"
               ></el-input-number>
+              <div v-else-if="item.scope === 'file'" style="display: flex">
+                <a
+                  v-if="ruleForm[item.prop]"
+                  :href="$methods.splitImgHost(ruleForm.FilePath)"
+                  target="_blank"
+                  class="file_style"
+                  >点击查看文件</a
+                >
+                <label for="uploads" style="vertical-align: text-bottom"
+                  ><span class="btn">{{
+                    ruleForm[item.prop] ? "更换文件" : "上传文件"
+                  }}</span></label
+                >
+                <input
+                  type="file"
+                  id="uploads"
+                  style="display: none"
+                  @change="uploadImg"
+                />
+              </div>
               <el-input
                 v-else
                 clearable
@@ -242,6 +262,11 @@ export default {
           label: "密码",
           prop: "Pwd",
         },
+        {
+          label: "资料上传",
+          prop: "FilePath",
+          scope: "file",
+        },
       ],
       ruleForm: { CompanyTypeName: "", MemberLevel: "" },
       rules: {
@@ -294,6 +319,38 @@ export default {
     });
   },
   methods: {
+    uploadImg(e) {
+      var self = this;
+      var file = e.target.files[0];
+      if (file === undefined) {
+        return;
+      }
+      if (file.size > 10 * 1024 * 1024) {
+        self.$message.error("文件不得大于10MB");
+        return;
+      }
+      var type = e.target.value.toLowerCase().split(".").splice(-1);
+      if (
+        type[0] != "jpg" &&
+        type[0] != "pdf" &&
+        type[0] != "png" &&
+        type[0] != "jpeg"
+      ) {
+        self.$message.error("上传格式需为:.jpg/.png/.jpeg/.pdf");
+        e.target.value = "";
+        return;
+      }
+      let formDatas = new FormData();
+      formDatas.append("file", file);
+      this.$api
+        .XfWebApiUploadFile(formDatas)
+        .then((res) => {
+          this.$set(this.ruleForm, "FilePath", res.Data);
+        })
+        .finally(() => {
+          e.target.value = "";
+        });
+    },
     close() {
       // this.$refs["ruleForm"].resetFields();
       this.loading = false;
@@ -336,4 +393,13 @@ export default {
 ::v-deep .el-dialog {
   margin-top: 3vh !important;
 }
+.file_style {
+  margin-right: 14px;
+  color: blue;
+  cursor: pointer;
+}
+.btn {
+  cursor: pointer;
+  color:red;
+}
 </style>

+ 6 - 1
src/router/index.js

@@ -39,7 +39,12 @@ const routes = [
         name: 'searchKey',
         component: () => import('@/views/searchKey/index'),
         meta: { title: '搜索页', icon: '', affix: true }
-      }
+      },
+      {
+        path: 'contribute',
+        component: () => import('@/views/contribute/index'),
+        meta: { title: '投稿中心', icon: '', affix: true }
+      },
     ]
   },
   {

+ 4 - 4
src/utils/request.js

@@ -7,10 +7,10 @@ axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
 // 创建axios实例
 // export const BASE_URL = process.env.VUE_APP_BASE_API
 // export const BASE_IMG_URL = process.env.VUE_APP_IMG_API
-export const BASE_URL = 'https://api.gzxfxh2022.com/'
-export const BASE_IMG_URL = 'https://api.gzxfxh2022.com'
-// export const BASE_URL = 'http://192.168.1.12:8032/'
-// export const BASE_IMG_URL = 'http://192.168.1.12:8032'
+// export const BASE_URL = 'https://api.gzxfxh2022.com/'
+// export const BASE_IMG_URL = 'https://api.gzxfxh2022.com'
+export const BASE_URL = 'http://192.168.1.12:8032/'
+export const BASE_IMG_URL = 'http://192.168.1.12:8032'
 const service = axios.create({
   // axios中请求配置有baseURL选项,表示请求URL公共部分
   baseURL: BASE_URL,

+ 206 - 0
src/views/contribute/index.vue

@@ -0,0 +1,206 @@
+<template>
+  <div id="">
+    <el-main>
+      <h1 style="font-size: 20px; text-align: center">
+        投稿中心
+        <el-button
+          type="success"
+          style="float: right"
+          size="small"
+          @click="contributeFunc()"
+          >投稿</el-button
+        >
+        <div style="clear: both"></div>
+      </h1>
+      <el-main v-loading="loading" class="notList_box">
+        <div
+          class="notList_style"
+          v-for="(items, indexs) in notList"
+          @click="jumpInfo(items)"
+        >
+          <i></i>
+          <div class="title">{{ items.Title }}</div>
+          <span class="time">
+            <!-- {{ $methods.onlyFormaHao(items.CreateTime) }} -->
+            <el-button
+              v-if="items.Status == 2"
+              type="primary"
+              size="small"
+              style="margin-right: 10px"
+              @click.stop="contributeFunc(items)"
+              >修改</el-button
+            ><el-tag
+              type="warning"
+              effect="dark"
+              v-if="items.Status !== 1 && items.Status !== 2"
+              >{{ strStatus(items.Status) }}</el-tag
+            ><el-tag
+              @click.stop="showAlert(items.ProcessItemName)"
+              v-if="items.Status == 2"
+              type="danger"
+              effect="dark"
+              >{{ strStatus(items.Status) }}</el-tag
+            ></span
+          >
+        </div>
+      </el-main>
+      <van-empty v-if="notList.length == 0" description="暂无数据" />
+      <el-pagination
+        v-if="notList.length > 0"
+        class="paginations"
+        @current-change="handleCurrentChange"
+        :current-page.sync="formData.pageindex"
+        :page-size="formData.pagesize"
+        layout="total, prev, pager, next"
+        :total="total"
+      >
+      </el-pagination>
+      <operation ref="operation" @search="getSearch()"></operation>
+    </el-main>
+  </div>
+</template>
+
+<script>
+import operation from "./operation.vue";
+export default {
+  name: "contribute",
+  components: { operation },
+  data() {
+    return {
+      notList: [],
+      loading: false,
+      total: 0,
+      formData: {
+        pagesize: 6, //每页内容条数
+        pageindex: 1, //当前第几页
+      },
+    };
+  },
+  created() {
+    this.getSearch();
+  },
+  methods: {
+    showAlert(str) {
+      this.$dialog.alert({
+        message: str || "空",
+      });
+    },
+    strStatus(str) {
+      var val = "";
+      switch (str) {
+        case 0:
+          val = "已关闭";
+          break;
+        case 2:
+          val = "审核不通过";
+          break;
+        case 3:
+          val = "审核中";
+          break;
+
+        default:
+          break;
+      }
+      return val;
+    },
+    contributeFunc(item) {
+      if (item) {
+        this.edit(item);
+      } else {
+        this.$refs.operation.showInit();
+      }
+    },
+    edit(item) {
+      this.$api.XfWebApiGetNewsDetail({ newsid: item.NewsId }).then((res) => {
+        if (res.Data.CreateTime) {
+          res.Data.CreateTime = this.$methods.onlyFormaHao(res.Data.CreateTime);
+        }
+        this.$refs.operation.showInit(res.Data);
+      });
+    },
+    clear() {
+      this.total = 0;
+      this.formData = {
+        pagesize: 6, //每页内容条数
+        pageindex: 1, //当前第几页
+      };
+      this.getSearch();
+    },
+    getSearch(int) {
+      this.loading = true;
+      this.$api
+        .XfWebApiGetMyNewsList(this.formData)
+        .then((res) => {
+          this.notList = res.Data.List || [];
+          this.total = res.Data.TotalCount;
+        })
+        .finally(() => {
+          this.loading = false;
+        });
+    },
+    handleCurrentChange(e) {
+      this.formData.pageindex = e;
+      this.getSearch();
+    },
+    //跳转详情页
+    jumpInfo(e) {
+      if (e.Status == 0) {
+        this.$message.warning("文章已关闭");
+        return;
+      }
+      if (e.Status == 2) {
+        this.$message.warning("文章审核不通过");
+        return;
+      }
+      if (e.Status == 3) {
+        this.$message.warning("文章审核中");
+        return;
+      }
+      this.$router.push({
+        path: "info",
+        query: {
+          MenuId: e.MenuId,
+          NewsId: e.NewsId,
+        },
+      });
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.notList_box {
+  padding: 48px 0px;
+  .notList_style {
+    display: flex;
+    align-items: center;
+    margin-bottom: 40px;
+    & > i {
+      width: 10px;
+      height: 10px;
+      background-color: #2453af;
+      border-radius: 50%;
+      margin-right: 14px;
+      flex-shrink: 0;
+    }
+    & > .title {
+      flex: 1;
+      word-break: break-all;
+      text-overflow: ellipsis;
+      overflow: hidden;
+      display: -webkit-box;
+      -webkit-line-clamp: 1;
+      -webkit-box-orient: vertical;
+      color: #222;
+      font-weight: 500;
+      font-size: 28px;
+      margin-right: 20px;
+    }
+    & > .time {
+      color: #636b75;
+      font-size: 24px;
+      flex-shrink: 0;
+    }
+  }
+}
+</style>

+ 279 - 0
src/views/contribute/operation.vue

@@ -0,0 +1,279 @@
+<template>
+  <div id="">
+    <el-dialog
+      :close-on-click-modal="false"
+      title="投稿"
+      :visible.sync="dialogVisible"
+      width="90vw"
+    >
+      <el-form
+      label-position="top"
+        :model="ruleForm"
+        :rules="rules"
+        ref="ruleForm"
+        label-width="80px"
+        class="demo-ruleForm"
+      >
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="所属菜单" prop="MenuId">
+              <el-cascader
+                :disabled="disActive"
+                v-model="ruleForm.MenuId"
+                placeholder="选择目录"
+                :options="routerTableData"
+                :props="{
+                  value: 'MenuId',
+                  label: 'Name',
+                  children: 'ChildList',
+                  emitPath: false,
+                }"
+              ></el-cascader
+            ></el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="标题" prop="Title">
+              <el-input v-model.trim="ruleForm.Title"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="图片上传" prop="ImageUrl">
+              <el-image
+                v-if="ruleForm.ImageUrl"
+                style="width: 112px; height: 70px"
+                :src="$methods.splitImgHost(ruleForm.ImageUrl)"
+                :preview-src-list="[$methods.splitImgHost(ruleForm.ImageUrl)]"
+              >
+              </el-image>
+              <label for="uploads" style="vertical-align: text-bottom"
+                ><span class="btn">{{
+                  ruleForm.ImageUrl ? "更换图片" : "上传图片"
+                }}</span></label
+              >
+              <input
+                type="file"
+                id="uploads"
+                style="display: none"
+                @change="uploadImg"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="是否置顶" prop="IsTop">
+              <el-radio-group v-model="ruleForm.IsTop">
+                <el-radio :label="true">是</el-radio>
+                <el-radio :label="false">否</el-radio>
+              </el-radio-group></el-form-item
+            >
+          </el-col>
+
+          <el-col :span="24">
+            <el-form-item label="会员可见" prop="IsMemberRead">
+              <el-radio-group v-model="ruleForm.IsMemberRead">
+                <el-radio :label="true">是</el-radio>
+                <el-radio :label="false">否</el-radio>
+              </el-radio-group></el-form-item
+            >
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="状态" prop="Status">
+              <el-radio-group v-model="ruleForm.Status">
+                <el-radio :label="1">正常</el-radio>
+                <el-radio :label="0">停用</el-radio>
+              </el-radio-group></el-form-item
+            >
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="创建时间" prop="CreateTime">
+              <el-date-picker
+                v-model="ruleForm.CreateTime"
+                type="datetime"
+                placeholder="选择创建日期时间"
+                format="yyyy-MM-dd HH:mm:ss"
+                value-format="yyyy-MM-dd HH:mm:ss"
+              >
+              </el-date-picker
+            ></el-form-item>
+          </el-col>
+
+          <el-col :span="24">
+            <el-form-item label="文章内容" prop="NewContent">
+              <div class="tinymce-box">
+                <editor
+                  ref="tinymceRef"
+                  :value="ruleForm.NewContent"
+                  :imgUrl="'XfWebApiUploadFile'"
+                ></editor>
+              </div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button size="small" @click="close">取 消</el-button>
+        <el-button
+          size="small"
+          type="primary"
+          @click="submit('ruleForm')"
+          :loading="loading"
+          >确 定</el-button
+        >
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import Editor from "@/components/tinymce";
+export default {
+  components: { Editor },
+  data() {
+    return {
+      dialogVisible: false,
+      ruleForm: {
+        Title: "",
+        IsTop: false,
+        IsMemberRead: false,
+        Status: 1,
+        MenuId: "",
+        ImageUrl: "",
+        CreateTime: "",
+      },
+      rules: {
+        Title: [{ required: true, message: "请输入标题", trigger: "blur" }],
+        // ImageUrl: [
+        //   { required: true, message: "请上传图片", trigger: "change" },
+        // ],
+        MenuId: [
+          {
+            required: true,
+            message: "请选择所属菜单",
+            trigger: ["blur", "change"],
+          },
+        ],
+      },
+      loading: false,
+      routerTableData: [],
+      disActive: false,
+    };
+  },
+  methods: {
+    getGDFunc() {
+      let A = this.routerTableData.find((i) => i.Name == "协会期刊");
+      if (A) {
+        let B = A.ChildList.find((i) => i.Name == "在线投稿");
+        if (B) {
+          return B.MenuId;
+        } else {
+          return "";
+        }
+      } else {
+        return "";
+      }
+    },
+    getMenuList() {
+      return new Promise((resolve) => {
+        this.$api.XfWebApiGetMenuList({ parentid: -1 }).then((res) => {
+          this.routerTableData = res.Data || [];
+          resolve();
+        });
+      });
+    },
+    async showInit(e, id) {
+      await this.getMenuList();
+      if (e) {
+        this.$nextTick(() => {
+          this.ruleForm = e;
+          this.disActive = true;
+        });
+      } else {
+        this.ruleForm = {
+          Title: "",
+          IsTop: false,
+          IsMemberRead: false,
+          Status: 1,
+          ImageUrl: "",
+          MenuId: this.getGDFunc(),
+          CreateTime: "",
+        };
+        this.disActive = this.ruleForm.MenuId ? true : false;
+      }
+      this.dialogVisible = true;
+    },
+    uploadImg(e) {
+      var self = this;
+      var file = e.target.files[0];
+      if (file === undefined) {
+        return;
+      }
+      if (file.size > 0.9 * 1024 * 1024) {
+        self.$message.error("图片不得大于900kb");
+        return;
+      }
+      var type = e.target.value.toLowerCase().split(".").splice(-1);
+      if (type[0] != "jpg" && type[0] != "png" && type[0] != "jpeg") {
+        self.$message.error("上传格式需为:.jpg/.png/.jpeg");
+        e.target.value = "";
+        return;
+      }
+      let formDatas = new FormData();
+      formDatas.append("file", file);
+      this.$api
+        .XfWebApiUploadFile(formDatas)
+        .then((res) => {
+          this.$set(this.ruleForm, "ImageUrl", res.Data);
+        })
+        .finally(() => {
+          e.target.value = "";
+        });
+    },
+    close() {
+      this.disActive = false;
+      this.loading = false;
+      this.$refs["ruleForm"].resetFields();
+      this.dialogVisible = false;
+    },
+    submit(formName) {
+      this.$refs[formName].validate(async (valid) => {
+        if (valid) {
+          this.ruleForm.NewContent = this.$refs.tinymceRef.getContent();
+          this.$api.XfWebApiSaveNews(this.ruleForm).then((res) => {
+            this.close();
+            this.$emit("search");
+          });
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.btn {
+  display: inline-block;
+  line-height: 1;
+  white-space: nowrap;
+  cursor: pointer;
+  border: 1px solid #dcdfe6;
+  -webkit-appearance: none;
+  text-align: center;
+  box-sizing: border-box;
+  outline: none;
+  margin: 0;
+  margin-left: 14px;
+  transition: 0.1s;
+  font-weight: 500;
+  -moz-user-select: none;
+  -webkit-user-select: none;
+  -ms-user-select: none;
+  padding: 8px 16px;
+  font-size: 14px;
+  border-radius: 4px;
+  color: #fff;
+  background-color: #409eff;
+  border-color: #409eff;
+}
+</style>

+ 7 - 2
src/views/home/index.vue

@@ -91,16 +91,21 @@
         {{ item.Title }}
       </p>
     </div>
+    <membership
+      :dialogVisible.sync="dialogVisibleMembership"
+    />
   </div>
 </template>
 
 <script>
+import membership from "@/components/membership/index.vue";
 import tab from "./tab.vue";
 export default {
   name: "home",
-  components: { tab },
+  components: { tab,membership },
   data() {
     return {
+      dialogVisibleMembership:false,
       smallBoxList: [
         {
           img: require("@/assets/images/icon_入会申请@2x.png"),
@@ -235,7 +240,7 @@ export default {
         });
     },
     openJumpVip() {
-      // this.$refs.membership.showInit();
+      this.dialogVisibleMembership = true
     },
   },
 };

+ 11 - 0
src/views/info/index.vue

@@ -7,6 +7,7 @@
     </div>
     <van-divider />
     <van-empty description="暂无数据" v-if="!infoData.NewContent" />
+    <van-empty :description="msgStatus" v-else-if="msgStatus" />
     <div
       v-else
       class="ql-editor html_content"
@@ -24,6 +25,7 @@ export default {
   components: { Share },
   data() {
     return {
+      msgStatus: "",
       routerData: {},
       infoData: {},
       config: {
@@ -73,6 +75,15 @@ export default {
         .XfWebApiGetNewsDetail({ newsid: this.routerData.NewsId })
         .then((res) => {
           this.infoData = res.Data;
+          if (this.infoData.Status == 0) {
+            this.msgStatus = "文章已关闭";
+          }
+          if (this.infoData.Status == 2) {
+            this.msgStatus = "文章审核不通过";
+          }
+          if (this.infoData.Status == 3) {
+            this.msgStatus = "文章审核中";
+          }
         });
     },
   },