소스 검색

修改建立网站、获取网站列表、添加及编辑资讯的页面

FengR 1 주 전
부모
커밋
7f266f6599
3개의 변경된 파일315개의 추가작업 그리고 23개의 파일을 삭제
  1. 82 1
      src/views/news/creatNews.vue
  2. 49 18
      src/views/website/WebsiteList.vue
  3. 184 4
      src/views/website/addWebsite.vue

+ 82 - 1
src/views/news/creatNews.vue

@@ -61,6 +61,7 @@
                     <el-option label="头条" :value="1"></el-option>
                     <el-option label="轮播图" :value="2"></el-option>
                     <el-option label="今日热点" :value="6"></el-option>
+                    <el-option label="规章制度" :value="8"></el-option>
                   </el-select>
                 </el-form-item>
               </div>
@@ -202,6 +203,34 @@
                   :picker-options="pickerOptions" value-format="yyyy-MM-dd">
                 </el-date-picker>
               </el-form-item>
+              <el-form-item label="附件:" class="custom-align-right" prop="" >
+                <div v-if="fjUrl " class="chooseImgDiv1">
+                  <div> {{ this.fjUrl }}
+                    <div></div>
+                  </div>
+                </div>
+                <div class="uploaderBox" @mouseenter="hovering = true" mouseleave="hovering = false">
+                  <el-upload class="avatar-uploader" action="#" :show-file-list="false" :before-upload="beforeAvatarUpload1">
+                    <!-- 预览图片 -->
+                    <div v-if="fjUrl" class="notchooseImgDiv">
+                      <img src="http://192.168.1.234:19000/pre/image/png/20260107/1767778011971130.png">
+                      <div class="notchooseImgDivText">已上传文档</div>
+                    </div>
+                    
+                    <div v-else class="chooseImgDiv">
+                      <div>
+                        <img src="@/assets/public/upload/noImage.png">
+                        <div>选择文档</div>
+                      </div>
+                    </div>
+                  </el-upload>
+                  <input type="hidden" v-model="form.fujian">
+                  <span class="photo_tips">支持文件形式pdf,word,jpg,zip文件最大50M。</span>
+                  <div v-if="hovering && form.fujian" class="delete-button" @click="handleDelete1">
+                    <i class="el-icon-delete"></i>
+                  </div>
+                </div>
+              </el-form-item>
             </div>
           </div>
         </div>
@@ -328,6 +357,7 @@ export default {
         survey_type: 0, //0:单选 1:复选
         commend_id: [],//手动推荐
         publiced_at: null,//发布时间
+        fujian: "",//附件
       },
       //1.2 表单验证规则
       formRules: {
@@ -371,6 +401,7 @@ export default {
 
       //1.4图片上传
       imgUrl: "",//在页面上显示缩略图
+      fjUrl: "",//在页面上显示附件
       //获取父级导航池
       parentKey: 0,//获取父级导航
       parentData: {
@@ -535,6 +566,39 @@ export default {
       // 阻止默认的上传行为
       return false;
     },
+    //1.1.1 直接上传文件
+    beforeAvatarUpload1(file) {
+      const isWord = file.type ==='application/msword' || 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || 'application/vnd.ms-word' || 'doc';
+      const isPdf = file.type === 'application/pdf' || file.type === 'application/x-pdf' || file.type === 'application/acrobat' || file.type === 'pdf' || file.type === 'text/x-pdf' || file.type === 'application/x-download' || file.type === 'application/octet-stream';
+      const isZip = file.type === 'application/zip' || file.type === 'application/x-zip-compressed' || file.type === 'application/x-zip' || file.type === 'application/x-compress' || file.type === 'application/x-compressed' || file.type === 'multipart/x-zip' || file.type === 'multipart/x-zip-compressed' || file.type === 'zip';
+      const isLt50M = file.size / 1024 / 1024 < 50;
+      console.log('文件类型',file.type)
+      if (!isWord && !isExcel && !isPdf && !isZip) {
+        this.$message.error('上传文件只能是 Word/Excel/Pdf/压缩包 格式!');
+        return false;
+      }
+      if (!isLt50M) {
+        this.$message.error('上传文件大小不能超过 50MB!');
+        return false;
+      }
+
+      const formData = new FormData();
+      formData.append('file', file);
+
+      this.$store.dispatch('pool/uploadFile', formData).then(res => {
+        this.fjUrl = res.data.imgUrl;//显示缩略图
+        this.form.fujian = res.data.imgUrl;//提供表单地址
+        console.log(res.data.imgUrl)
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '网络错误,请重试!'
+        });
+      })
+
+      // 阻止默认的上传行为
+      return false;
+    },
     //1.2 提交表单
     addToServe() {
       //判断是否为外链
@@ -694,6 +758,7 @@ export default {
         this.form.copyfrom = "";
         this.form.fromurl = "";
         this.form.status = 0;
+        this.form.fujian = "";//清空附件 URL
       }
     },
     //1.4更新详细地址
@@ -707,6 +772,12 @@ export default {
       this.imgUrl = ''; // 清空图片 URL
       this.form.imgurl = ''; // 清空表单中的图片 URL
     },
+    //1.5 删除附件
+    handleDelete1() {
+      // 删除附件
+      this.fjUrl = ''; // 清空附件 URL
+      this.form.fujian = ''; // 清空表单中的附件 URL
+    },
     //提交表单 end ------------------------------------------------------------>
 
     //2.跳转操作 start ------------------------------------------------------------>
@@ -731,6 +802,7 @@ export default {
       };
       this.$store.dispatch('news/getArticleInfo', data).then(res => {
         this.form.title = res.data.title;
+        this.fjUrl = res.data.fujian; // 回显附件 URL
         //判断是否使用了外链
         if (res.data.islink == 1) {
           this.form.islink = true;
@@ -797,6 +869,7 @@ export default {
         this.form.status = res.data.status;
         this.form.survey_name = res.data.survey_name;
         this.form.commend_id = JSON.parse(res.data.commend_id);
+        this.form.fujian = res.data.fujian;
         if (res.data.is_survey == null) {
           this.form.is_survey = 0;
         } else {
@@ -1237,5 +1310,13 @@ export default {
   font-size: 12px;
   color: #999;
 }
-
+.notchooseImgDiv img{
+    width: 120px;
+    height: 120px;
+    margin-left: 11px;
+}
+.notchooseImgDiv .notchooseImgDivText{
+    font-size: 14px;
+    margin-top: -25px;
+}
 // 执行v-deep穿透scope选择器 end------------------------------------------------------------></style>

+ 49 - 18
src/views/website/WebsiteList.vue

@@ -4,19 +4,39 @@
     <div class="layerBox_search">
       <div class="layerBoxLine">
         <el-row>
-          <el-col :span="8">
+          <el-col :span="5">
             <div class="searchBox">
               <div class="searchTitle">网站名称:</div>
               <el-input placeholder="请输入网站名称" autocomplete="off" v-model="getApiData.keyword" />
             </div>
           </el-col>
-          <el-col :span="8">
+          <el-col :span="5">
             <div class="searchBox">
               <div class="searchTitle">上级网系:</div>
               <el-cascader v-model="getApiData.website_column_id" :props="{ checkStrictly: true }"
                 :options="website_column_arr" clearable></el-cascader>
             </div>
           </el-col>
+          <el-col :span="5">
+            <div class="searchBox">
+              <div class="searchTitle">是否核心站:</div>
+              <el-select v-model="getApiData.is_core" placeholder="请选择是否核心站">
+                  <el-option label="是" value="1"></el-option>
+                  <el-option label="否" value="0"></el-option>
+              </el-select>
+            </div>
+          </el-col>
+          <el-col :span="5">
+            <div class="searchBox">
+              <div class="searchTitle">网站分类:</div>
+               <el-select v-model="getApiData.web_type" 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>
+            </div>
+          </el-col>
           <!-- <el-col :span="8">
           <div class="searchBox">
             <div class="searchTitle">行政区划:</div>
@@ -348,7 +368,9 @@ export default {
       getApiData: {
         keyword: "",//网站名称查询
         website_column_id: [],//使用网系id查询
-        city_id: [],//使用城市id查询
+        // city_id: [],//使用城市id查询
+        web_type: null,//网站类型查询
+        is_core: null,//是否核心网站查询
         page: 1,//当前是第几页
         pageSize: 10,//一共多少条
       },
@@ -429,9 +451,9 @@ export default {
       if (this.getApiData.website_column_id.length > 0) {
         this.getApiData.website_column_id = this.getApiData.website_column_id[this.getApiData.website_column_id.length - 1];
       }
-      if (this.getApiData.city_id.length > 0) {
-        this.getApiData.city_id = this.getApiData.city_id[this.getApiData.city_id.length - 1];
-      }
+      // if (this.getApiData.city_id.length > 0) {
+      //   this.getApiData.city_id = this.getApiData.city_id[this.getApiData.city_id.length - 1];
+      // }
       //如果是搜索,重新加载第一页
       if (type == "search") {
         this.getApiData.page = 1;
@@ -444,18 +466,25 @@ export default {
         //   if(item.city_name==null){item.city_name="--"}
         //   newData.push(item)
         // }
-        //显示1-10编号
-        for (let i = 0; i < res.data.rows.length; i++) {
-          newData[i] = res.data.rows[i];
-          newData[i].index = i + 1;
+        if(res.data.length==0){
+          this.tableData = []; //给与内容
+          this.allCount = 0; //给与总条数
+        }else{
+          // console.log(res.data)
+          //显示1-10编号
+          for (let i = 0; i < res.data.rows.length; i++) {
+            newData[i] = res.data.rows[i];
+            newData[i].index = i + 1;
+          }
+          console.log(newData)
+          //格式化网站地址
+          // res.data.rows.forEach(item => {
+          //   item.website_url = item.website_url.join(', ');
+          // });
+          this.tableData = newData; //给与内容
+          this.allCount = res.data.count; //给与总条数
         }
-        console.log(newData)
-        //格式化网站地址
-        // res.data.rows.forEach(item => {
-        //   item.website_url = item.website_url.join(', ');
-        // });
-        this.tableData = newData; //给与内容
-        this.allCount = res.data.count; //给与总条数
+        
         // console.log('tableData',tableData);
       }).catch(() => {
         this.$message({
@@ -527,7 +556,9 @@ export default {
       this.tableData = [];
       this.getApiData.keyword = "";
       this.getApiData.website_column_id = [];
-      this.getApiData.city_id = [];
+      //this.getApiData.city_id = [];
+      this.getApiData.web_type = null;
+      this.getApiData.is_core = null;
       //this.getApiData.city_arr_id = [];
       this.getApiData.page = 1;
       this.getApiData.pageSize = 10;

+ 184 - 4
src/views/website/addWebsite.vue

@@ -73,11 +73,27 @@
                                     @click="deleteUrlInput(4)" class="formLabelDelIcon"></el-button>
                             </div>
                         </el-form-item>
-                        <el-form-item label="上级网系:" :label-width="formLabelWidth" prop="website_column_arr_id"
+                        <el-form-item label="网站属性:" :label-width="formLabelWidth" prop="website_column_arr_id"
                             class="custom-align-right">
                             <el-cascader v-model="form.website_column_arr_id" :props="{ checkStrictly: true }"
                                 :options="website_column_arr"></el-cascader>
                         </el-form-item>
+                        <el-form-item label="网站类型:" :label-width="formLabelWidth" prop="web_type"
+                            class="custom-align-right">
+                            <el-select v-model="form.web_type" clearable 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 label="是否核心站:" :label-width="formLabelWidth" prop="is_core"
+                            class="custom-align-right">
+                            <el-radio-group v-model="form.is_core">
+                                <el-radio :label="1">是</el-radio>
+                                <el-radio :label="0">否</el-radio>
+                            </el-radio-group>
+                        </el-form-item>
                         <el-form-item label="网站logo:" prop="logo" :label-width="formLabelWidth"
                             :class="['custom-form-item']" class="custom-align-right">
                             <div class="uploaderBox">
@@ -174,6 +190,66 @@
                             </template>
                             <el-input v-model="form.ad_key" autocomplete="off" @change="checkWebsiteName(form.ad_key,0)" placeholder="请输入网站名称缩写" :disabled="website_column_arr_id.includes(3)"></el-input>
                         </el-form-item>
+                        <el-form-item label="网站二维码:" prop="qr_code" :label-width="formLabelWidth"
+                            :class="['custom-form-item']" class="custom-align-right">
+                            <div class="uploaderBox">
+                                <!--图片上传组件 start ------------------------------------------------------------>
+                                <div class="avatar-upload-container" @mouseenter="hovering = true"
+                                    @mouseleave="hovering = false">
+                                    <!-- 上传组件 -->
+                                    <el-upload class="avatar-uploader" action="#" :show-file-list="false"
+                                        :before-upload="beforeAvatarUpload5">
+                                        <!-- 预览图片 -->
+                                        <img v-if="logoUrl_5" :src="logoUrl_5" class="avatar">
+                                        <!-- 上传图标 -->
+                                        <!-- <i v-else class="el-icon-plus avatar-uploader-icon"></i> -->
+                                        <div v-else class="chooseImgDiv">
+                                            <div>
+                                                <img src="@/assets/public/upload/noImage.png">
+                                                <div>选择图片</div>
+                                            </div>
+                                        </div>
+                                        <input type="hidden" name="qr_code" v-model="form.qr_code">
+                                    </el-upload>
+                                    <!-- 删除按钮,当鼠标悬浮时显示 -->
+                                    <div v-if="hovering && logoUrl_5" class="delete-button" @click="handleDelete5">
+                                        <i class="el-icon-delete"></i>
+                                    </div>
+                                    <span class="photo_tips">请上传网站二维码,不大于500K。</span>
+                                </div>
+                                <!--图片上传组件 end ------------------------------------------------------------>
+                            </div>
+                        </el-form-item>
+                        <el-form-item label="网站首页图:" prop="index_img" :label-width="formLabelWidth"
+                            :class="['custom-form-item']" class="custom-align-right">
+                            <div class="uploaderBox">
+                                <!--图片上传组件 start ------------------------------------------------------------>
+                                <div class="avatar-upload-container" @mouseenter="hovering = true"
+                                    @mouseleave="hovering = false">
+                                    <!-- 上传组件 -->
+                                    <el-upload class="avatar-uploader" action="#" :show-file-list="false"
+                                        :before-upload="beforeAvatarUpload6">
+                                        <!-- 预览图片 -->
+                                        <img v-if="logoUrl_6" :src="logoUrl_6" class="avatar">
+                                        <!-- 上传图标 -->
+                                        <!-- <i v-else class="el-icon-plus avatar-uploader-icon"></i> -->
+                                        <div v-else class="chooseImgDiv">
+                                            <div>
+                                                <img src="@/assets/public/upload/noImage.png">
+                                                <div>选择图片</div>
+                                            </div>
+                                        </div>
+                                        <input type="hidden" name="index_img" v-model="form.index_img">
+                                    </el-upload>
+                                    <!-- 删除按钮,当鼠标悬浮时显示 -->
+                                    <div v-if="hovering && logoUrl_6" class="delete-button" @click="handleDelete6">
+                                        <i class="el-icon-delete"></i>
+                                    </div>
+                                    <span class="photo_tips">请上传网站首页图,不大于500K。</span>
+                                </div>
+                                <!--图片上传组件 end ------------------------------------------------------------>
+                            </div>
+                        </el-form-item>
                     </div>
                 </el-form>
             </el-row>
@@ -426,6 +502,8 @@ export default {
                     { url: "", show: false }
                 ],
                 website_column_arr_id: [],//需要提交的上级网系 数组
+                web_type:null,//网站类型
+                is_core:null,//是否核心网站
                 //city_arr_id:[0],//需要提交的城市id
                 logo: "",//logo地址 提交文件换取地址
                 title: "",//需要提交的网站标题
@@ -433,6 +511,8 @@ export default {
                 description: "",//需要提交的网站描述
                 suffix: "",//需要提交的网站后缀
                 ad_key: "",//需要提交的网站名称缩写
+                qr_code: "",//需要提交的二维码地址
+                index_img: "",//需要提交的首页图片地址
                 //template_id:""//选择的网站皮肤
             },
             //3.2 表单验证规则
@@ -465,6 +545,8 @@ export default {
             logoUrl_2: '',
             logoUrl_3: '',
             logoUrl_4: '',
+            logoUrl_5: '',
+            logoUrl_6: '',
             hovering: false, // 鼠标悬浮状态 悬浮时显示删除
             //3.5 模板列表
             TemplateList: [],
@@ -545,12 +627,12 @@ export default {
             this.form.keywords = newTags.join(',');
         },
         //设置图片格式 __网站LOGO__
-        beforeAvatarUpload(file) {
+        beforeAvatarUpload(file,type) {
             const isJPG = file.type === 'image/jpeg';
             const isPNG = file.type === 'image/png';
             const isGIF = file.type === 'image/gif';
             const isLt2M = file.size / 1024 / 1024 < 2;
-
+            console.log(type)
             if (!isJPG && !isPNG && !isGIF) {
                 this.$message.error('上传缩略图只能是 JPG 或 PNG 或 GIF 格式!');
                 return false;
@@ -711,26 +793,107 @@ export default {
             // 阻止默认的上传行为
             return false;
         },
+        //二维码图片
+        beforeAvatarUpload5(file) {
+            const isJPG = file.type === 'image/jpeg';
+            const isPNG = file.type === 'image/png';
+            const isGIF = file.type === 'image/gif';
+            const isLt2M = file.size / 1024 / 1024 < 2;
+
+            if (!isJPG && !isPNG && !isGIF) {
+                this.$message.error('上传缩略图只能是 JPG 或 PNG 或 GIF 格式!');
+                return false;
+            }
+            if (!isLt2M) {
+                this.$message.error('上传缩略图大小不能超过 2MB!');
+                return false;
+            }
+
+            const formData = new FormData();
+            formData.append('file', file);
+
+            this.$store.dispatch('pool/uploadFile', formData).then(res => {
+                this.logoUrl_5 = res.data.imgUrl;//显示缩略图
+                this.form.qr_code = res.data.imgUrl;//提供表单地址
+                console.log('888888888888888----------------',res.data.imgUrl)
+            }).catch(() => {
+                this.$message({
+                    type: 'info',
+                    message: '网络错误,请重试!'
+                });
+            })
+
+            // 阻止默认的上传行为
+            return false;
+        },
+        //网站首页图片
+        beforeAvatarUpload6(file) {
+            const isJPG = file.type === 'image/jpeg';
+            const isPNG = file.type === 'image/png';
+            const isGIF = file.type === 'image/gif';
+            const isLt2M = file.size / 1024 / 1024 < 2;
+
+            if (!isJPG && !isPNG && !isGIF) {
+                this.$message.error('上传缩略图只能是 JPG 或 PNG 或 GIF 格式!');
+                return false;
+            }
+            if (!isLt2M) {
+                this.$message.error('上传缩略图大小不能超过 2MB!');
+                return false;
+            }
+
+            const formData = new FormData();
+            formData.append('file', file);
+
+            this.$store.dispatch('pool/uploadFile', formData).then(res => {
+                this.logoUrl_6 = res.data.imgUrl;//显示缩略图
+                this.form.index_img = res.data.imgUrl;//提供表单地址
+                console.log(res.data.imgUrl)
+            }).catch(() => {
+                this.$message({
+                    type: 'info',
+                    message: '网络错误,请重试!'
+                });
+            })
+
+            // 阻止默认的上传行为
+            return false;
+        },
         handleDelete() {
             // 删除图片
+            this.form.logo = '';
             this.logoUrl = ''; // 清空图片 URL
         },
         handleDelete1() {
             // 删除图片
+            this.ruleForm.project_logo = '';
             this.logoUrl_1 = ''; // 清空图片 URL
         },
         handleDelete2() {
             // 删除图片
+            this.ruleForm.company_logo = '';
             this.logoUrl_2 = ''; // 清空图片 URL
         },
         handleDelete3() {
             // 删除图片
+            this.ruleForm.service_qq_img = '';
             this.logoUrl_3 = ''; // 清空图片 URL
         },
         handleDelete4() {
             // 删除图片
+            this.ruleForm.communications_img = '';
             this.logoUrl_4 = ''; // 清空图片 URL
         },
+        handleDelete5() {
+            // 删除图片
+            this.form.qr_code = '';
+            this.logoUrl_5 = ''; // 清空图片 URL
+        },
+        handleDelete6() {
+            // 删除图片
+            this.form.index_img = '';
+            this.logoUrl_6 = ''; // 清空图片 URL
+        },
         //取消添加或编辑
         goCancel() {
             this.$message({
@@ -756,6 +919,8 @@ export default {
             //还原表单
             this.form.website_name = "";
             this.form.website_column_arr_id = "";
+            this.form.web_type = null;
+            this.form.is_core = null;
             this.form.website_url = [
                 { url: "", show: true },
                 { url: "", show: false },
@@ -780,6 +945,11 @@ export default {
             this.form.keywords = "";
             this.tags = [];
             this.form.ad_key = ""; // 网站名称缩写
+            this.form.index_img = ""; // 网站二维码
+            this.form.qr_code = ""; // 网站首页图片
+            this.logoUrl_5 = "";
+            this.logoUrl_6 = "";
+
         },
         //3.1 获得所有网系
         getwebsiteColumn() {
@@ -877,7 +1047,7 @@ export default {
                     //循环完毕 重置提交的url
                     this.form.website_url = webSiteArray;
                     //console.log(webSiteArray)
-                    console.log(this.form)
+                    console.log('3333',this.form)
                     //提交表单
                     this.$store.dispatch('pool/addWebsite', this.form).then(res => {
                         
@@ -1100,6 +1270,12 @@ export default {
                 //回显logo
                 this.form.logo = res.data.logo;
                 this.logoUrl = res.data.logo;
+                // 回显网站二维码
+                this.form.qr_code = res.data.qr_code;
+                this.logoUrl_5 = res.data.qr_code;
+                // 回显网站首页图片
+                this.form.index_img = res.data.index_img;
+                this.logoUrl_6 = res.data.index_img;
                 //回显url
                 let that = this;
                 if (res.data.website_url == null) {
@@ -1119,10 +1295,14 @@ export default {
                 console.log(res.data.title, res.data.keywords, res.data.description)
                 this.form.title = res.data.title;
                 this.form.keywords = res.data.keywords;
+                this.form.web_type = res.data.web_type;
+                this.form.is_core = res.data.is_core;
                 this.tags = res.data.keywords ? res.data.keywords.split(',') : [];
                 this.form.description = res.data.description;
                 this.form.suffix = res.data.suffix;
                 this.form.ad_key = res.data.ad_key; // 网站名称缩写
+                // this.form.ad_key = res.data.ad_key; // 网站名称缩写
+                // this.form.ad_key = res.data.ad_key; // 网站名称缩写
                 //回显模板信息
                 // this.form.template_id = res.data.template_id;
                 // this.TemplateName = res.data.template_name;