Browse Source

部分修改

yuanrf 3 days ago
parent
commit
47f28e1422
1 changed files with 228 additions and 82 deletions
  1. 228 82
      src/components/Finance/ConferenceCost.vue

+ 228 - 82
src/components/Finance/ConferenceCost.vue

@@ -1,10 +1,27 @@
 <template>
     <div class="conferencecost-all" v-loading.fullscreen.lock="conferencecostLoading">
+
+        <el-dialog width="650px" title="设置查看权限" class="permissionsbox" :visible.sync="permissionSettingDialog"
+            :close-on-click-modal="false">
+            <el-checkbox-group v-model="viewUsers">
+                <div style="display: flex;flex-wrap: wrap;">
+                    <div style="width: 24%;margin: 3px;" v-for="item in viewUsersarr" :key="item.id">
+                        <el-checkbox :label="item.id">{{ item.cnName }}</el-checkbox>
+                    </div>
+                </div>
+            </el-checkbox-group>
+            <div style="text-align: right;margin-top: 15px;">
+                <el-button size="mini" @click="permissionSettingSet" type="primary">分配</el-button>
+                <el-button size="mini" @click="permissionSettingDialog = false">取消</el-button>
+            </div>
+        </el-dialog>
+
+
         <div class="conferencecost-header">
             <div class="conferencecost-header-left">
                 <div class="conferencecost-header-left-item">
                     <label style="width:40px;">会务: </label>
-                    <el-select @change="conferenceidchange" size="small" v-model="conferenceid" filterable clearable
+                    <el-select @change="conferenceidchange" size="small" v-model="conferenceid" filterable
                         placeholder="请选择">
                         <el-option v-for="item in conferenceidarr" :key="item.id" :label="item.teamName"
                             :value="item.id">
@@ -18,13 +35,19 @@
                 </div>
             </div>
             <div class="conferencecost-header-right">
-                <el-select size="small" v-model="fileSelect" clearable placeholder="请选择" style="width: 150px;">
+                <el-button v-if="control.isGM" size="small" type="primary"
+                    @click="permissionSettingDialog = true">权限分配</el-button>
+                <el-select v-if="control.isReview" size="small" v-model="fileSelect" clearable placeholder="请选择"
+                    style="width: 150px;margin-left: 10px;">
                     <el-option v-for="item in filetype" :key="item.id" :label="item.name" :value="item.id">
                     </el-option>
                 </el-select>
-                <el-button size="small" type="primary" @click="FileDown">生成表格</el-button>
-                <el-button size="small" @click="ConferenceAffairsSave(true)" type="primary">保存</el-button>
-                <el-button size="small" @click="ConferenceAffairsAudit(1)" type="primary">审核通过</el-button>
+                <el-button v-if="control.isReview" style="margin-left: 10px;" size="small" type="primary"
+                    @click="FileDown">生成表格</el-button>
+                <el-button v-if="control.isReview" size="small" @click="ConferenceAffairsAudit(1)"
+                    type="primary">审核通过</el-button>
+                <el-button v-if="canSave" size="small" @click="ConferenceAffairsSave(true)"
+                    type="primary">保存</el-button>
             </div>
         </div>
         <div class="conferencecost-content">
@@ -34,7 +57,7 @@
                 </el-table-column>
                 <el-table-column label="序号" prop="index" width="55">
                 </el-table-column>
-                <el-table-column prop="name" label="类型" width="120">
+                <el-table-column prop="name" label="类型" width="150">
                     <template slot-scope="scope">
                         <el-select size="small" v-model="scope.row.priceType" clearable placeholder="请选择">
                             <el-option v-for="item in typearr" :key="item.id" :label="item.text" :value="item.id">
@@ -42,7 +65,7 @@
                         </el-select>
                     </template>
                 </el-table-column>
-                <el-table-column prop="name" label="单项内容" width="160">
+                <el-table-column prop="name" label="单项内容" width="140">
                     <template slot-scope="scope">
                         <el-input type="textarea" :rows="3" placeholder="请输入内容"
                             v-model="scope.row.priceName"></el-input>
@@ -57,7 +80,7 @@
                 <el-table-column prop="name" label="币种" width="100">
                     <template slot-scope="scope">
                         <el-select size="small" @change="currencychange(scope.row)" v-model="scope.row.currency"
-                            clearable>
+                            clearable filterable placeholder="请选择币种">
                             <el-option v-for="item in options" :key="item.currencyId" :label="item.currencyCode"
                                 :value="item.currencyId">
                             </el-option>
@@ -76,7 +99,7 @@
                             :controls="false" v-model="scope.row.count"></el-input-number>
                     </template>
                 </el-table-column>
-                <el-table-column prop="name" label="单位" width="80">
+                <el-table-column prop="name" label="单位" width="100">
                     <template slot-scope="scope">
                         <el-select size="small" v-model="scope.row.unit" placeholder="" clearable>
                             <el-option v-for="item in units" :key="item.id" :label="item.text" :value="item.id">
@@ -97,10 +120,10 @@
                     </template>
                 </el-table-column>
 
-                <el-table-column prop="name" label="附加值">
+                <el-table-column prop="name" label="附加值" width="100">
                     <template slot-scope="scope">
-                        <el-input type="textarea" :rows="3" placeholder="请输入内容"
-                            v-model="scope.row.addedValue"></el-input>
+                        <el-input-number :precision="2" :controls="false" placeholder="请输入内容" size="mini"
+                            v-model="scope.row.addedValue"></el-input-number>
                     </template>
                 </el-table-column>
                 <el-table-column prop="name" label="明细">
@@ -108,7 +131,7 @@
                         <el-input type="textarea" :rows="3" placeholder="请输入内容" v-model="scope.row.details"></el-input>
                     </template>
                 </el-table-column>
-                <el-table-column prop="name" label="备注">
+                <el-table-column prop="name" label="备注" width="150">
                     <template slot-scope="scope">
                         <el-input type="textarea" :rows="3" placeholder="请输入内容" v-model="scope.row.remark"></el-input>
                     </template>
@@ -123,16 +146,20 @@
                         <div class="conferencecost-content-btn">
                             <el-button size="mini" @click="removeRow(scope.$index, scope.row)" type="danger">移
                                 除</el-button>
-                            <el-button size="mini" @click="ConferenceAffairsAudits(1, scope.row.id)" type="primary">通
-                                过</el-button>
-                            <el-button size="mini" @click="ConferenceAffairsAudits(-1, scope.row.id)" type="danger">撤
-                                销</el-button>
+                            <div v-if="control.isReview" style="margin-top: 5px;">
+                                <el-button size="mini" @click="ConferenceAffairsAudits(1, scope.row.id)"
+                                    type="primary">通
+                                    过</el-button>
+                                <el-button size="mini" @click="ConferenceAffairsAudits(-1, scope.row.id)"
+                                    type="danger">撤
+                                    销</el-button>
+                            </div>
                         </div>
                     </template>
                 </el-table-column>
             </el-table>
             <div class="Addline">
-                <el-button size="small" @click="addlineclick" type="primary">添加一行</el-button>
+                <el-button v-if="canSave" size="small" @click="addlineclick" type="primary">添加一行</el-button>
             </div>
         </div>
         <div class="conferencecost-foot">
@@ -234,11 +261,18 @@ export default {
             conferenceAffairsCostChildids: [],
             conferencecostLoading: false,
             filetype: [],
-            fileSelect: ''
+            fileSelect: '',
+            control: {
+                isGM: false, //权限分配
+                isReview: false, //复审
+            },
+            permissionSettingDialog: false,
+            viewUsersarr: [],
+            viewUsers: [],
         }
     },
     updated() {
-        console.log(1);
+        //console.log(1);
         if (this.restriction) {
             this.$emit('transfer', true)
             this.restriction = false;
@@ -252,17 +286,15 @@ export default {
             handler(val) {
                 var _this = this
                 _this.rateStatistics = [];
-                var obj = {}
-                obj = _this.options.find(function (i) {
-                    val.forEach((item, index) => {
-                        if (i.currencyId === item.currency) {
-                            _this.rateStatistics.push(i);
+                var obj = {};
+                _this.options.forEach(currency => {
+                    val.forEach(item => {
+                        if (item.currency === currency.currencyId && !obj[currency.currencyId]) {
+                            obj[currency.currencyId] = true;
+                            _this.rateStatistics.push(currency);
                         }
                     });
                 });
-                _this.rateStatistics = _this.rateStatistics.filter((value, index, self) => {
-                    return self.indexOf(value) === index;
-                });
                 if (_this.rateStatistics.length > 1) {
                     _this.danwei = 'CNY';
                     _this.danweiId = 836;
@@ -271,10 +303,16 @@ export default {
                     _this.danweiId = _this.rateStatistics.length == 1 ? _this.rateStatistics[0].currencyId : 836;
                 }
                 _this.updateTotals();
+                console.log("tableDatas");
             },
             deep: true
         }
     },
+    computed: {
+        canSave() {
+            return this.control.isReview || this.control.isGM || this.viewUsers.includes(this.userId);
+        }
+    },
     methods: {
         //保留两位小数
         townum(val) {
@@ -290,53 +328,61 @@ export default {
             }
         },
         //获取基础数据
-        ConferenceAffairsInIt() {
-            var url = "/api/Groups/ConferenceAffairsInIt"
-            var that = this
-            this.$axios({
-                method: 'post',
-                url: url,
-                headers: {
-                    Authorization: 'Bearer ' + that.token
-                },
-                data: {
-                    userId: that.userId,
-                    groupId: that.conferenceid,
-                }
-            }).then(function (res) {
-                that.conferenceidarr = res.data.data.groupList;
-                that.conferenceid = that.conferenceidarr[0].id;
-                that.options = res.data.data.typeData;
-                that.ConferenceAffairsInIts();
-            })
-        },
-        //获取数据
-        ConferenceAffairsInIts() {
-            this.conferencecostLoading = true;
-            var url = "/api/Groups/ConferenceAffairsInIt"
-            var that = this
-            this.$axios({
-                method: 'post',
-                url: url,
-                headers: {
-                    Authorization: 'Bearer ' + that.token
-                },
-                data: {
-                    userId: 21,
-                    groupId: that.conferenceid,
-                }
-            }).then(function (res) {
-                let AffairsInIt = res.data.data;
-                that.options = AffairsInIt.currenyList.teamRates;
-                that.tableDatas = AffairsInIt.conferenceAffairsCostChi;
-                that.typearr = AffairsInIt.typeData;
-                that.units = AffairsInIt.units;
-                that.conferenceAffairsCost = AffairsInIt.conferenceAffairsCost;
-                that.conferencecostLoading = false;
-                that.filetype = res.data.data.fileType;
-                that.fileSelect = that.filetype[0].id;
-            })
-        },
+        // ConferenceAffairsInIt() {
+        //     var url = "/api/Groups/ConferenceAffairsInIt"
+        //     var that = this
+        //     this.$axios({
+        //         method: 'post',
+        //         url: url,
+        //         headers: {
+        //             Authorization: 'Bearer ' + that.token
+        //         },
+        //         data: {
+        //             userId: that.userId,
+        //             groupId: that.conferenceid,
+        //         }
+        //     }).then(function (res) {
+        //         if (res.data.code == 200) {
+        //             that.conferenceidarr = res.data.data.groupList;
+        //             that.conferenceid = that.conferenceidarr[0].id;
+        //             that.options = res.data.data.typeData;
+        //             that.ConferenceAffairsInIts();
+        //         }
+        //         else if (res.data.code == 201) {
+        //             that.$message({
+        //                 type: 'error',
+        //                 message: "暂无权限"
+        //             });
+        //         }
+        //     })
+        // },
+        // //获取数据
+        // ConferenceAffairsInIts() {
+        //     this.conferencecostLoading = true;
+        //     var url = "/api/Groups/ConferenceAffairsInIt"
+        //     var that = this
+        //     this.$axios({
+        //         method: 'post',
+        //         url: url,
+        //         headers: {
+        //             Authorization: 'Bearer ' + that.token
+        //         },
+        //         data: {
+        //             userId: that.userId, //21
+        //             groupId: that.conferenceid,
+        //         }
+        //     }).then(function (res) {
+        //         let AffairsInIt = res.data.data;
+        //         that.options = AffairsInIt.currenyList.teamRates;
+        //         that.tableDatas = AffairsInIt.conferenceAffairsCostChi;
+        //         that.typearr = AffairsInIt.typeData;
+        //         that.units = AffairsInIt.units;
+        //         that.conferenceAffairsCost = AffairsInIt.conferenceAffairsCost;
+        //         that.conferencecostLoading = false;
+        //         that.filetype = res.data.data.fileType;
+        //         that.fileSelect = that.filetype[0].id;
+        //     })
+        // },
         //币种切换
         currencychange(val) {
             var obj = this.options.find(function (i) {
@@ -349,7 +395,8 @@ export default {
         },
         //会务切换
         conferenceidchange(val) {
-            this.ConferenceAffairsInIts();
+            //this.ConferenceAffairsInIts();
+            this.ConferenceAffairsLoad();
         },
         //添加一行
         addlineclick() {
@@ -433,7 +480,7 @@ export default {
                     Authorization: 'Bearer ' + that.token
                 },
                 data: {
-                    userId: 21,
+                    userId: this.userId,
                     ids: [row.id],
                 }
             }).then(function (res) {
@@ -444,7 +491,8 @@ export default {
                     });
                     that.updateTotals()
                     that.ConferenceAffairsSave(false);
-                    that.ConferenceAffairsInIts();
+                    //that.ConferenceAffairsInIts();
+                    that.ConferenceAffairsLoad();
                 } else {
                     that.$message({
                         type: 'error',
@@ -473,7 +521,8 @@ export default {
                         type: 'success',
                         message: res.data.msg
                     });
-                    that.ConferenceAffairsInIts();
+                    //that.ConferenceAffairsInIts();
+                    that.ConferenceAffairsLoad();
                 } else {
                     that.$message({
                         type: 'error',
@@ -509,7 +558,8 @@ export default {
                         type: 'success',
                         message: '审核成功!'
                     });
-                    that.ConferenceAffairsInIts();
+                    //that.ConferenceAffairsInIts();
+                    that.ConferenceAffairsLoad();
                 } else {
                     that.$message({
                         type: 'error',
@@ -545,7 +595,8 @@ export default {
                             type: 'success',
                             message: res.data.msg,
                         });
-                        that.ConferenceAffairsInIts();
+                        //that.ConferenceAffairsInIts();
+                        that.ConferenceAffairsLoad();
                     }
                 } else {
                     that.$message({
@@ -595,11 +646,106 @@ export default {
                 }
             })
         },
+        // 合并为单一函数,移除冗余API调用
+        ConferenceAffairsLoad() {
+            this.conferencecostLoading = true;
+            const url = '/api/Groups/ConferenceAffairsInIt';
+            this.$axios({
+                method: 'post',
+                url,
+                headers: { Authorization: 'Bearer ' + this.token },
+                data: {
+                    userId: this.userId, // 统一使用动态userId,移除硬编码
+                    groupId: this.conferenceid
+                }
+            }).then(res => {
+                const data = res.data.data;
+
+                if (res.data.code == 201 || res.data.code == 200) {
+                    // 原ConferenceAffairsInIt逻辑
+                    this.conferenceidarr = data.groupList;
+                    if (!this.conferenceid) {
+                        this.conferenceid = this.conferenceidarr.length > 0 ? this.conferenceidarr[0].id : '';
+                    }
+
+                    // 原ConferenceAffairsInIts逻辑
+                    this.options = data.currenyList.teamRates;
+                    this.typearr = data.typeData;
+                    this.units = data.units;
+                    this.filetype = data.fileType;
+                    this.fileSelect = this.filetype.length > 0 ? this.filetype[0].id : '';
+                    this.control.isGM = data.isGM;
+                    this.control.isReview = data.isReview;
+                    console.log(this.control, "权限分配----------");
+                    this.viewUsersarr = data.userList;
+                    this.viewUsers = data.operatorUser;
+
+
+                    if (res.data.code == 200) {
+                        this.conferenceAffairsCost = data.conferenceAffairsCost;
+                        this.tableDatas = data.conferenceAffairsCostChi;
+                    }
+
+                    if (res.data.code == 201) {
+
+                        this.conferenceAffairsCost = {};
+                        this.tableDatas = [];
+
+                        //弹出暂无权限
+                        this.$message({
+                            type: 'warning',
+                            message: '暂无权限!'
+                        });
+                    }
+                }
+
+                this.conferencecostLoading = false;
+            });
+        },
+        permissionSettingSet() {
+
+            const userids = this.viewUsers;
+
+            if (userids.length == 0) {
+                this.$message({
+                    type: 'warning',
+                    message: '请选择用户!'
+                });
+                return;
+            }
+
+            const url = '/api/Groups/PermissionSetting';
+            this.$axios({
+                method: 'post',
+                url,
+                headers: { Authorization: 'Bearer ' + this.token },
+                data: {
+                    UserIds: userids,
+                    GroupId: this.conferenceid,
+                    CreateUserId: this.userId,
+                }
+            }).then(res => {
+                if (res.data.code == 200) {
+                    this.$message({
+                        type: 'success',
+                        message: '权限分配成功!'
+                    });
+                    this.permissionSettingDialog = false;
+                    this.ConferenceAffairsLoad();
+                } else {
+                    this.$message({
+                        type: 'error',
+                        message: res.data.msg
+                    });
+                }
+            })
+        }
     },
     mounted() {
         this.token = JSON.parse(localStorage.getItem('userinif')).token;
         this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
-        this.ConferenceAffairsInIt()
+        //this.ConferenceAffairsInIt()
+        this.ConferenceAffairsLoad();
     }
 }
 </script>