From 5e2aafeede13d337380f736567caf74f49713be7 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Fri, 09 Aug 2024 14:38:32 +0800
Subject: [PATCH] 代码优化

---
 src/views/article/components/discussionManageChild.vue |  167 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 131 insertions(+), 36 deletions(-)

diff --git a/src/views/article/components/discussionManageChild.vue b/src/views/article/components/discussionManageChild.vue
index ff314b1..0898b93 100644
--- a/src/views/article/components/discussionManageChild.vue
+++ b/src/views/article/components/discussionManageChild.vue
@@ -4,6 +4,9 @@
       @close="handleClose" @open="opens">
       <avue-form ref="DisCussFrom" :option="option" v-model="froms" @submit="handleSubmit"></avue-form>
     </el-dialog>
+
+    <userList ref="userList" @selectPersonList="selectPersonList"></userList>
+
   </div>
 </template>
 
@@ -27,6 +30,8 @@
   import {
     getDictionary
   } from '@/api/system/dict'
+  import userList from "./userList.vue";
+
 
   // import {
   //   getList as getHouseholdList,
@@ -39,6 +44,9 @@
 
   let formData = {}
   export default {
+    components: {
+      userList
+    },
     data() {
       return {
         dialogVisibles: false,
@@ -132,6 +140,28 @@
               value: 0
             },
             {
+              label: '票数公开',
+              prop: 'voteNumberPublic',
+              type: 'radio',
+              button: true,
+              row: true,
+              span: 12,
+              offset: 8,
+              dicData: [{
+                label: '不需要',
+                value: 0
+              }, {
+                label: '需要',
+                value: 1
+              }],
+              rules: [{
+                required: true,
+                message: "请选择是否票数公开",
+                trigger: "blur",
+              }, ],
+              value: 0
+            },
+            {
               label: '指定用户',
               prop: 'appointUser',
               type: 'radio',
@@ -156,9 +186,9 @@
             {
               display: false,
               label: "选择用户",
-              prop: "userIds",
+              prop: "userName",
               tags: true,
-              type: "tree",
+              type: "input",
               multiple: true,
               span: 12,
               offset: 8,
@@ -166,16 +196,40 @@
               hide: true,
               row: true,
               // dicUrl: `/api/blade-system/user/getUserlnfoByDistrictlds?districtlds={{}}`,
-              props: {
-                label: 'name',
-                value: 'id',
-              },
-              dicData: [],
+              // props: {
+              //   label: 'name',
+              //   value: 'id',
+              // },
+              // dicData: [],
               rules: [{
                 required: true,
                 message: '请输入姓名',
                 trigger: 'blur'
               }],
+              focus: ({
+                value,
+                column
+              }) => {
+                this.$refs.userList.show(this.discussion.articleRange)
+              },
+            },
+
+            {
+              label: "开始时间",
+              span: 12,
+              offset: 8,
+              row: true,
+              prop: "startTime",
+              type: "datetime",
+              format: "yyyy-MM-dd HH:mm:ss",
+              valueFormat: "yyyy-MM-dd HH:mm:ss",
+              // format: "yyyy-MM-dd hh:mm:ss",
+              // valueFormat: "yyyy-MM-dd hh:mm:ss",
+              rules: [{
+                required: true,
+                message: "请选择开始时间",
+                trigger: "blur",
+              }, ],
             },
 
             {
@@ -198,15 +252,23 @@
           ]
         },
         // 表单列表
-        froms: {},
+        froms: {
+          openFlag: 0,
+          voteRestrictions: 1,
+          signatureFlag: 1,
+          voteNumberPublic: 1,
+          appointUser: 0,
+
+        },
         dialogVisibles: false,
         articleId: '',
         discussion: {},
-        id: ""
+        id: "",
+        personList: [],
       }
     },
     created() {
-      this.getUserList()
+      // this.getUserList()
     },
 
     mounted() {
@@ -216,9 +278,10 @@
     watch: {
       'froms.appointUser': {
         handler(newData) {
-          const column = this.findObject(this.option.column, "userIds")
+          const column = this.findObject(this.option.column, "userName")
           if (newData == 1) {
             column.display = true
+            // this.$refs.userList.show()
           } else {
             column.display = false
           }
@@ -236,10 +299,18 @@
       }
     },
     methods: {
+      selectPersonList(personList) {
+        console.log(personList, "++++++++++++")
+        this.personList = personList
+        let nameList = personList.map(e => {
+          return e.name
+        })
+        this.froms.userName = nameList.join(",")
+      },
       getuserInfoByDistrictId() {
         getUserlnfoByDistrictlds(this.discussion.articleRange).then(res => {
           const column = this.findObject(this.option.column, "userIds")
-          column.dicData = res.data.data
+          column.dicData = res.data.data.records
         })
       },
       getUserList() {
@@ -249,16 +320,16 @@
       },
 
       handleSubmit(form, done) {
-        console.log("**********" + JSON.stringify(form))
         form.articleId = this.articleId
         form.eventType = 1
-        form.userIds = JSON.stringify(form.userIds)
+        form.userIds = this.personList.map(e => e.id).join(",")
+        // form.userIds = JSON.stringify(form.userIds)
         if (form.appointUser == 0) {
           form.userIds = ''
         }
-        console.log("===>", JSON.stringify(this.froms))
-        form.id = this.id;
-        console.log("formData====>", JSON.stringify(formData))
+
+        form.id = this.id
+
         addPd(form).then(
           () => {
             // this.onLoad(this.discussion)
@@ -268,7 +339,13 @@
             })
             done()
             this.$refs.DisCussFrom && this.$refs.DisCussFrom.resetForm()
-            this.froms = {}
+            this.froms = {
+              openFlag: 0,
+              voteRestrictions: 1,
+              signatureFlag: 1,
+              appointUser: 0,
+
+            }
             this.dialogVisibles = false
           },
           (error) => {
@@ -277,54 +354,72 @@
         )
       },
       init(data) {
-        // console.log("====>", data);
+        console.log("===init===", data)
         this.$refs.DisCussFrom && this.$refs.DisCussFrom.resetForm()
         this.dialogVisibles = true
-        this.froms = {}
+        this.froms = {
+          openFlag: 0,
+          voteRestrictions: 1,
+          signatureFlag: 1,
+          appointUser: 0,
+        }
         this.discussion = data
         this.articleId = data.id
         this.onLoad(data)
       },
 
       handleClose() {
-        console.log("**********************************************************************************")
+        console.log("******handleClose*******")
         this.dialogVisibles = false
         this.$refs.DisCussFrom && this.$refs.DisCussFrom.resetForm()
-        this.froms = {};
-        console.log("^^^^^", this.froms)
-        console.log(this.$refs, 90999)
+        this.froms = {
+          openFlag: 0,
+          voteRestrictions: 1,
+          signatureFlag: 1,
+          appointUser: 0,
+        }
       },
 
       opens() {
-        console.log("***************************************opens*******************************************")
+        console.log("******opens*******")
         // this.dialogVisibles = false
         this.$refs.DisCussFrom && this.$refs.DisCussFrom.resetForm()
-        this.froms = {};
-        console.log("^^^^^", this.froms)
-        console.log(this.$refs, 90999)
+        this.froms = {
+          openFlag: 0,
+          voteRestrictions: 1,
+          signatureFlag: 1,
+          appointUser: 0,
+        }
       },
 
       onLoad(row, params = {
         eventType: 1,
         articleId: row.id
       }) {
-        this.loading = true
+        // this.loading = true
         getListPd(1, 10, Object.assign(params, this.query)).then(res => {
           const data = res.data.data
           this.$refs.DisCussFrom && this.$refs.DisCussFrom.resetForm()
           if (data.records.length <= 0) {
-            console.log("----------------------------------")
-            this.froms = {}
+            console.log("--------onLoad------------")
+            this.id = ''
+            this.froms = {
+              openFlag: 0,
+              voteRestrictions: 1,
+              signatureFlag: 1,
+              appointUser: 0,
+            }
           } else {
-            console.log(">>>>>", data.records[0])
+            console.log(">>>>>onLoad", data.records[0])
             this.froms = data.records[0]
-            this.id = data.records[0].id;
-            formData = data.records[0];
+
+            this.id = data.records[0].id
+            formData = data.records[0]
             if (this.froms && this.froms.userIds) {
               this.froms.userIds = JSON.parse(this.froms.userIds)
             }
           }
-          this.getuserInfoByDistrictId()
+          // this.getuserInfoByDistrictId()
 
         })
       },
@@ -338,4 +433,4 @@
   .el-pagination {
     margin-top: 20px;
   }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3