From 4522ab3fe8bd45ee753ef187448c1e884bbc601f Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 18 Apr 2024 11:09:27 +0800
Subject: [PATCH] Merge branch 'master' of http://s16s652780.51mypc.cn:49896/r/jczz_web

---
 src/views/article/discussionManage.vue |  190 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 144 insertions(+), 46 deletions(-)

diff --git a/src/views/article/discussionManage.vue b/src/views/article/discussionManage.vue
index 15dc7dd..0d961b0 100644
--- a/src/views/article/discussionManage.vue
+++ b/src/views/article/discussionManage.vue
@@ -19,8 +19,14 @@
           编辑议题
         </el-button>
 
-        <el-button icon="el-icon-user" :size="size" :type="type" @click.stop="openUserPopup(row, 1)">
+        <el-button icon="el-icon-user" :size="size" v-if="row.articleType != 4" :type="type"
+          @click.stop="openUserPopup(row, 0)">
           参与用户
+        </el-button>
+
+        <el-button icon="el-icon-user" v-if="row.articleType == 4" :size="size" :type="type"
+          @click.stop="handleExport(row)">
+          导出投票结果
         </el-button>
 
         <el-button v-if="row.publish == '1'" icon="el-icon-close" :size="size" :type="type" @click.stop="updateFb(row)">
@@ -32,14 +38,15 @@
         </el-button>
       </template>
 
-      <template slot-scope="{ row }" slot="publish">
-        <el-tag>{{ row.publish == "1" ? "已发布" : row.publish == "0" ? "未发布" : "未发布" }}
+      <template slot-scope="{ row, size }" slot="publish">
+        <el-tag :size="size" :type="showStatus(row.publish, 1).type" v-text="showStatus(row.publish, 1).text">
         </el-tag>
       </template>
 
-      <template slot-scope="{ row }" slot="iscomment">
-        <el-tag>{{ row.iscomment == "1" ? "开启" : row.iscomment == "0" ? "关闭" : "关闭" }}
-        </el-tag>
+      <template slot-scope="{ row, size }" slot="iscomment">
+        <el-switch @change="iscommentInput($event, row)" v-model="row.iscomment" :active-value="'1'"
+          :inactive-value="'0'" active-color="#13ce66" inactive-color="#ccc">
+        </el-switch>
       </template>
     </avue-crud>
 
@@ -78,6 +85,21 @@
   } from "vuex"
   import deitDiscussion from "./components/deitDiscussion"
   import discussionManageChild from "./components/discussionManageChild"
+  import NProgress from 'nprogress'
+  import 'nprogress/nprogress.css'
+  import Qs from "qs"
+  import {
+    exportBlob
+  } from "@/api/common"
+  import {
+    getToken
+  } from '@/util/auth'
+  import {
+    downloadXls
+  } from "@/util/util"
+  import {
+    dateNow
+  } from "@/util/date"
 
   export default {
     components: {
@@ -117,14 +139,17 @@
         datetime: "",
         selectionList: [],
         option: {
+          labelWidth: 96,
+          searchLabelWidth: 96,
+          searchShow: true,
+          searchMenuSpan: 3,
+          menuWidth: 500,
+
           height: "auto",
           calcHeight: 54,
           dialogWidth: 950,
           tip: false,
-          searchShow: true,
-          searchMenuSpan: 3,
-          menuWidth: 500,
-          border: false,
+          border: true,
           //stripe:true,
           index: true,
           viewBtn: false,
@@ -132,12 +157,14 @@
           excelBtn: true,
           dialogClickModal: false,
           column: [{
+              overHidden: true,
               label: "议事标题",
               prop: "title",
               span: 24,
               row: true,
               searchSpan: 4,
               search: true,
+              searchLabelWidth: 76,
               rules: [{
                 required: true,
                 message: "请输入议事标题",
@@ -151,6 +178,7 @@
               minRows: 2,
               tags: true,
               type: "tree",
+              dataType: "string",
               multiple: true,
               dicData: [],
               rules: [{
@@ -162,32 +190,13 @@
                 label: "name",
                 value: 'id'
               },
-              hide: true,
+              // hide: true,
             },
             {
-              label: "发布时间",
-              prop: "dateTime",
-              type: "datetime",
-              format: "yyyy-MM-dd",
-              valueFormat: "yyyy-MM-dd",
-              searchSpan: 5,
-              searchRange: true,
-              hide: true,
-              addDisplay: false,
-              editDisplay: false,
-              viewDisplay: false,
-              search: true,
-              rules: [{
-                required: true,
-                message: "请选择发布时间",
-                trigger: "blur",
-              }, ],
-            },
-            {
+              width: 110,
               label: "封面",
               prop: "url",
               // align:'center',
-              width: 80,
               type: "upload",
               listType: "picture-img",
               action: "/api/blade-resource/oss/endpoint/put-file",
@@ -199,12 +208,13 @@
               span: 24,
             },
             {
-              label: "文章类型",
+              width: 110,
+              label: "议事类型",
               prop: "articleType",
               addDisplay: true,
               editDisplay: true,
               viewDisplay: true,
-              searchSpan: 3,
+              searchSpan: 4,
               checkStrictly: true,
               dicUrl: "/api/blade-system/dict-biz/dictionary?code=investigateType",
               props: {
@@ -215,22 +225,46 @@
               type: "tree",
               rules: [{
                 required: true,
-                message: "请选择文章类型",
+                message: "请选择议事类型",
                 trigger: "blur",
               }, ],
             },
+            // {
+            //   label: "发布时间",
+            //   prop: "dateTime",
+            //   type: "daterange",
+            //   format: "yyyy-MM-dd",
+            //   valueFormat: "yyyy-MM-dd",
+            //   searchSpan: 6,
+            //   searchRange: true,
+            //   hide: true,
+            //   addDisplay: false,
+            //   editDisplay: false,
+            //   viewDisplay: false,
+            //   search: true,
+            //   rules: [{
+            //     required: true,
+            //     message: "请选择发布时间",
+            //     trigger: "blur",
+            //   }, ],
+            // },
             {
+              width: 100,
               label: "发布时间",
               prop: "createTime",
               type: "date",
               format: "yyyy-MM-dd",
               valueFormat: "yyyy-MM-dd HH:mm:ss",
+              search: true,
+              addDisplay: false,
+              editDisplay: false,
+              viewDisplay: false,
             },
             {
+              width: 100,
               label: "发布状态",
               prop: "publish",
-              searchSpan: 3,
-              width: 80,
+              searchSpan: 4,
               value: "0",
               slot: true,
               search: true,
@@ -450,6 +484,7 @@
           editBtn: this.vaildData(this.permission.article_edit, true),
         }
       },
+
       ids() {
         let ids = []
         this.selectionList.forEach((ele) => {
@@ -457,14 +492,74 @@
         })
         return ids.join(",")
       },
+
+      showStatus() {
+        return (data, type) => {
+          if (data == 0) {
+            return {
+              text: type == 1 ? '未发布' : '关闭',
+              type: 'info'
+            }
+          } else if (data == 1) {
+            return {
+              text: type == 1 ? '已发布' : '开启',
+              type: 'success'
+            }
+          }
+        }
+      }
     },
     methods: {
-      openEditPopup(row) {
-        this.$refs.DeitDiscussion.initData(row)
+      handleExport(row) {
+        this.$confirm("是否导出投票结果数据?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(() => {
+          NProgress.start()
+          this.query = {}
+          this.query.articleId = row.id
+          this.query.districtId = row.articleRange
+          var data = {
+            ...this.query
+          }
+          data = Qs.stringify(data)
+          exportBlob(
+              `/api/blade-userTopics/userTopics/exportDataIndex?${this.website.tokenHeader}=${getToken()}&` + data)
+            .then(
+              res => {
+                downloadXls(res.data, `投票结果${dateNow()}.xlsx`)
+                NProgress.done()
+              })
+        })
+      },
+      iscommentInput(e, data) {
+        upcomment(data.id, e).then(() => {
+          this.$message({
+            type: "success",
+            message: "操作成功!",
+          })
+        })
       },
 
-      openUserPopup(row) {
-        this.$refs.DeitDiscussion.openUser(row)
+      openEditPopup(row) {
+        getListPd(1, 10, {
+          eventType: 1,
+          articleId: row.id
+        }).then(res => {
+          if (res.data.data.records.length == 0) {
+            this.$message.warning('请先设置议事规则!')
+            setTimeout(() => {
+              this.openDilog(row, 1)
+            }, 200)
+          } else {
+            this.$refs.DeitDiscussion.initData(row)
+          }
+        })
+      },
+
+      openUserPopup(row, type) {
+        this.$refs.DeitDiscussion.openUser(row, type)
       },
 
       openDilog(row, type) {
@@ -479,7 +574,7 @@
           row.videoUrl = ""
         }
         row.userid = this.userInfo.user_id
-        row.articleRange = JSON.stringify(row.articleList)
+        row.articleRange = row.articleList
         if (row.url.length > 0) {
           var urls = []
           var split = row.url.split(",")
@@ -491,7 +586,7 @@
         }
         // 类型  0:文章 1经营性收支,2:物业招标 3:公益报名 4:选举调查
         row.type = 4
-        row.publish = 1
+        // row.publish = 1
 
         add(row).then(
           () => {
@@ -509,7 +604,7 @@
         )
       },
       rowUpdate(row, index, done, loading) {
-        row.articleRange = JSON.stringify(row.articleList)
+        row.articleRange = row.articleList
         if (row.url.length > 0) {
           var urls = []
           var split = row.url.split(",")
@@ -607,7 +702,7 @@
             // })
             this.form = {
               ...data,
-              articleList: JSON.parse(data.articleRange)
+              articleList: data.articleRange
             }
           })
         }
@@ -647,6 +742,7 @@
           this.page.total = data.total
           this.data = data.records
           this.data.forEach(item => {
+            item.articleList = item.articleRange
             if (item.url.length > 0) {
               var urls = []
               var names = item.url.split(",")
@@ -659,7 +755,9 @@
           this.loading = false
           this.selectionClear()
         })
-        getDistrictTree(params = {}).then((res) => {
+        getDistrictTree(params = {
+          filterFlag: 1
+        }).then((res) => {
           const data = res.data.data
           this.districtTree = data
           const column = this.findObject(this.option.column, "articleList")
@@ -747,4 +845,4 @@
   .avue-upload__icon {
     line-height: 6;
   }
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3