liuhj 8 months ago
parent
commit
8e97b12ddd
1 changed files with 232 additions and 0 deletions
  1. 232 0
      src/components/OP/GroupsTaskAssignment.vue

+ 232 - 0
src/components/OP/GroupsTaskAssignment.vue

@@ -3,6 +3,49 @@
         <div class="communal-title">
             <div>团组任务分配</div>
         </div>
+        <el-dialog title="批量分配" :visible.sync="batchVisible">
+            <el-form ref="batch" :rules="batchs" :model="batch">
+                <div class="batchbox">
+                    <el-form-item prop="TimePeriod" label="时间段" :label-width="formLabelWidth">
+                        <el-date-picker
+                        style="width:250px;"
+                        v-model="batch.TimePeriod"
+                        @change="TimePeriodchange"
+                        type="daterange"
+                        align="right"
+                        unlink-panels
+                        range-separator="至"
+                        start-placeholder="开始日期"
+                        end-placeholder="结束日期"
+                        :picker-options="pickerOptions">
+                        </el-date-picker>
+                    </el-form-item>
+                    <el-form-item prop="category" label="权限类型" :label-width="formLabelWidth">
+                        <el-select multiple collapse-tags v-model="batch.category" placeholder="请选择权限类型">
+                            <el-option v-for=" item1 in setData" :key=item1.id :label=item1.name :value=item1.id></el-option>
+                        </el-select>
+                    </el-form-item>
+                    <el-form-item prop="person" label="人员" :label-width="formLabelWidth">
+                        <el-select multiple collapse-tags v-model="batch.person" placeholder="请选择人员">
+                          <el-option v-for="(  item, index  ) in   user  " :key="index"  :label="item.name" :value="item.id"></el-option>
+                        </el-select>
+                    </el-form-item>
+                </div>
+                <div class="batch">
+                    <el-button @click="CancelselectAll" size="mini">取消选择</el-button>
+                    <el-button @click="selectAll" type="primary" size="mini">全选</el-button>
+                </div>
+                <div class="checkbox-box">
+                    <el-checkbox-group @change="checkListchange" class="group-box" v-model="checkList">
+                        <el-checkbox style="width:45%;margin-bottom: 5px;" v-for="(item,index) in protogenesischeckList" :key="index" :label="item.teamName"></el-checkbox>
+                    </el-checkbox-group>
+                </div>
+            </el-form>
+            <div slot="footer" class="dialog-footer">
+                <el-button @click="batchVisible = false">取 消</el-button>
+                <el-button type="primary" @click="submitForm('batch')">确 定</el-button>
+            </div>
+        </el-dialog>
         <div class="konzh" style="display: flex;justify-content: space-between;">
             <el-form style="display: flex;" label-width="70px" class="demo-form-inline">
                 <el-form-item style="width: 300px;margin-right: 20px;" label="团组名称">
@@ -34,6 +77,7 @@
                 </div> -->
   
             <div style="width: 30%;text-align: right;">
+                <el-button type="primary" style="margin-left: 10px;" @click="batchbtn">批量添加</el-button>
                 <el-button type="primary" style="margin-left: 10px;" @click="btn">保存</el-button>
             </div>
         </div>
@@ -88,6 +132,41 @@
 export default {
     data() {
         return {
+            pickerOptions: {
+                shortcuts: [{
+                    text: '最近一周',
+                    onClick(picker) {
+                    const end = new Date();
+                    const start = new Date();
+                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
+                    picker.$emit('pick', [start, end]);
+                    }
+                }, {
+                    text: '最近一个月',
+                    onClick(picker) {
+                    const end = new Date();
+                    const start = new Date();
+                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
+                    picker.$emit('pick', [start, end]);
+                    }
+                }, {
+                    text: '最近三个月',
+                    onClick(picker) {
+                    const end = new Date();
+                    const start = new Date();
+                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
+                    picker.$emit('pick', [start, end]);
+                    }
+                }, {
+                    text: '最近一年',
+                    onClick(picker) {
+                    const end = new Date();
+                    const start = new Date();
+                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
+                    picker.$emit('pick', [start, end]);
+                    }
+                }]
+            },
             rules: {},
             token: '',
             userId: 0,
@@ -100,6 +179,27 @@ export default {
             TaskAssignment: {},
             DelegationInfo: {},
             fullscreenLoading:false,
+            formLabelWidth:"80px",
+            batch:{
+                TimePeriod:[],
+                person:[],
+                category:[]
+            },
+            batchs: {
+                TimePeriod: [
+                    { required: true, message: '请选着日期', trigger: 'blur' },
+                ],
+                person: [
+                    { required: true, message: '请选择人员', trigger: 'blur' },
+                ],
+                category: [
+                    { required: true, message: '请选择权限类型', trigger: 'blur' },
+                ],
+            },
+            batchVisible:false,
+            checkList:[],
+            protogenesischeckList:[],
+            uploadingcheckList:[]
         }
     },
     methods: {
@@ -128,6 +228,119 @@ export default {
                 }
             })
         },
+        //处理时间
+        getdate(val){
+            var date=new Date(val);
+            var y=date.getFullYear();
+            var m=date.getMonth()+1<10?'0'+(date.getMonth()+1):date.getMonth()+1;
+            var d=date.getDate()<10?'0'+date.getDate():date.getDate();
+            return y+'-'+m+'-'+d
+        },
+        //取消全选
+        CancelselectAll(){
+            this.checkList=[];
+            this.uploadingcheckList=[];
+        },
+        //全选
+        selectAll(){
+            for(let i=0;i<this.protogenesischeckList.length;i++){
+                this.checkList.push(this.protogenesischeckList[i].teamName)
+            }
+            this.acquireid()
+        },
+        //团组checkbox值改变
+        checkListchange(){
+            this.acquireid();
+        },
+        //时间段切换
+        TimePeriodchange(){
+            this.TaskAllocationGroupSelect()
+        },
+        //获取时间段数组
+        TaskAllocationGroupSelect() {
+            var that = this
+            var url = "/api/Groups/TaskAllocationGroupSelect";
+            this.$axios({
+                method: 'post',
+                url: url,
+                data: {
+                    portType: 1,
+                    visitBeginDt: that.getdate(that.batch.TimePeriod[0]),
+                    visitEndDt: that.getdate(that.batch.TimePeriod[1]),
+                },
+                headers: {
+                    Authorization: 'Bearer '
+                },
+            }).then(function (res) {
+                if (res.data.code == 200) {
+                    that.protogenesischeckList=res.data.data;
+                } else {
+                    
+                }
+            })
+        },
+        //获取选择团组id
+        acquireid(){
+            this.uploadingcheckList=[];
+            for(let j=0;j<this.checkList.length;j++){
+                for(let i=0;i<this.protogenesischeckList.length;i++){
+                    if(this.checkList[j]==this.protogenesischeckList[i].teamName){
+                        this.uploadingcheckList.push(this.protogenesischeckList[i].id)
+                    }
+                }
+            }
+        },
+        batchbtn(){
+            this.batchVisible=true;
+            this.batch.TimePeriod=[];
+            this.batch.person=[];
+            this.batch.category=[];
+            this.checkList=[];
+            this.protogenesischeckList=[];
+            this.uploadingcheckList=[];
+        },
+        //保存api
+        TaskAllocationBulkAdd() {
+            if(this.uploadingcheckList.length<1){
+                this.$message.error('保存失败!未选择团组。');
+                return
+            }
+            var that = this
+            var url = "/api/Groups/TaskAllocationBulkAdd";
+            this.$axios({
+                method: 'post',
+                url: url,
+                data: {
+                    userIds: that.batch.person,
+                    permissionTypeIds: that.batch.category,
+                    groupIds: that.uploadingcheckList,
+                    currUserId: that.userId,
+                },
+                headers: {
+                    Authorization: 'Bearer ' + this.token
+                },
+            }).then(function (res) {
+                if (res.data.code == 200) {
+                    that.$message({
+                        message: res.data.msg,
+                        type: 'success'
+                    });
+                } else {
+                    that.$message.error(res.data.msg);
+                }
+            })
+        },
+        //保存
+        submitForm(batch) {
+            this.$refs[batch].validate((valid) => {
+                if (valid) {
+                    this.TaskAllocationBulkAdd()
+                } else {
+                    console.log('error submit!!');
+                    return false;
+                }
+            });
+        },
         TaskAssignmenQuery() {
             var that = this
             var url = "/api/Groups/TaskAssignmenQuery";
@@ -273,4 +486,23 @@ export default {
 .konzh .el-form-item{
     margin-bottom: 0;
 }
+.batchbox{
+    display: flex;
+    justify-content: space-between;
+}
+.checkbox-box{
+    padding: 10px;
+    border: 1px solid #DCDFE6 ;
+    height: 360px;
+    overflow-y: auto;
+}
+.batch{
+    text-align: right;
+    margin-bottom: 10px;
+}
+.group-box{
+    display: flex;
+    flex-wrap: wrap;
+    
+}
 </style>