Browse Source

设置班次页面查询问题,重置问题等修改

yejian016332 3 years ago
parent
commit
80dba02657
1 changed files with 82 additions and 49 deletions
  1. 82 49
      imcs-ui/src/views/zuihou/classScheduleMgr/settingClassSchedul/Index.vue

+ 82 - 49
imcs-ui/src/views/zuihou/classScheduleMgr/settingClassSchedul/Index.vue

@@ -8,22 +8,20 @@
     	</span>
     	<span style="margin-left: 15px;">
     		<span>{{$t("calssSchedule.searchForm.deptName")}}:</span>
-    		<el-select v-model="queryParams.model.status" :placeholder='$t("common.pleaseSelect")' size="medium" style="width: 150px;">
-        	<el-option
-			      v-for="item in audioStatus"
-			      :key="item.value"
-			      :label="item.label"
-			      :value="item.value">
-			    </el-option>
-      	</el-select>
+        <el-cascader
+          v-model="queryParams.deptId"
+          placeholder="请选择"
+          :options="depts"
+          :props="props"
+          filterable
+          change-on-select
+          ref="cascader"
+          @change="handleChange"
+        ></el-cascader>
     	</span>
     	<span style="margin-left: 15px;">
     		<span>{{$t("calssSchedule.searchForm.userName")}}:</span>
-    		<el-input v-model="queryParams.model.userName" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
-    	</span>
-    	<span style="margin-left: 15px;">
-    		<span>{{$t("calssSchedule.searchForm.numb")}}:</span>
-    		<el-input v-model="queryParams.model.no" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
+    		<el-input v-model="queryParams.userName" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
     	</span>
       <span style="margin-left: 15px;">
 	      <el-button plain type="primary" icon="el-icon-search" size="medium" @click="search">
@@ -34,12 +32,12 @@
 	      </el-button>
       </span>
     </div>
-    
+
     <!-- 功能按钮 -->
     <el-row class="filter-container">
     	<el-col>
     		<el-button type="primary" icon="el-icon-setting" size="medium" @click="add">{{ $t("common.setting") }}</el-button>
-    		<el-button type="primary" icon="el-icon-view" size="medium" @click="viewOne">
+    		<el-button type="primary" icon="el-icon-view" size="medium" @click="viewOne(null)">
 	        {{ $t("common.view") }}
 	      </el-button>
 	      <!--<el-button type="success" icon="el-icon-edit" size="medium" @click="editOne">
@@ -122,7 +120,7 @@
         <div v-html="preview.context" />
       </el-scrollbar>
     </el-dialog>
-    
+
     <!-- 【日历-查看】组件 -->
     <calendar-user
       ref="calendar"
@@ -142,9 +140,10 @@
 	import CalendarUser from "./components/CalendarUser"
 	// 【设置班表】-API
 	import settingClassSchedulApi from "@/api/classScheduleMgr/settingClassSchedul"
+  // 【部门】-API
+  import orgApi from '@/api/Org'
 	import elDragDialog from '@/directive/el-drag-dialog'
-	import { downloadFile, initEnums, initDicts, initQueryParams } from '@/utils/commons'
-	import axios from 'axios'
+	import {initDicts, initQueryParams } from '@/utils/commons'
 	export default {
 	  name: "ShiftChangeMgr",
 	  directives: { elDragDialog },
@@ -155,7 +154,8 @@
 	  data () {
 	    return {
 	    	tags: ['','warning','success','danger'],
-	    	audioStatus: [],
+	    	depts: [],
+        deptId:null,
 	      dialog: {
 	        isVisible: false,
 	        title: ""
@@ -209,6 +209,11 @@
               picker.$emit('pick', [start, end]);
             }
           }]
+        },
+        props: {  // 配置数据格式
+            checkStrictly: true, // 是否严格的遵守父子节点不互相关联(官网配置项)
+            value: 'id',
+            label: 'label',
         }
 	    }
 	  },
@@ -225,16 +230,14 @@
     },
 	  // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
 	  created() {
-	  	// 调用常量-审核状态
-	  	this.audioStatus = this.$constWKS.AUDIOLIST
 	  	// 加载【字典】
 	  	initDicts(['NATION'], this.dicts);
+        this.getTreeData()
 	  	// 加载列表数据
 	  	this.fetch()
 		},
 	  computed: {
 	  	settingColunm(e){
-	  		console.log("值是什么:", e)
 	  		return "1111"
 	  	},
 	    currentUser () {
@@ -252,7 +255,6 @@
 	  		let str = ""
 	  		// 如果值存在
 	  		if(!!cellValue){
-	  			console.log("渲染的值!",row, column, cellValue, index)
 	  			let arr = cellValue.split(",")
 	  			arr.map(item => {
 	  				let list = item.split(";")
@@ -262,6 +264,8 @@
 	  		return str
 	  	},
 	  	resetInit(){
+        // 加载Tree数据
+        this.getTreeData()
 	  		// 加载列表数据
 	  		this.fetch()
 	  	},
@@ -274,7 +278,7 @@
 	    },
 	    // 【日历-查看】确认-事件
 	    editUserSuccess(){
-	    	
+
 	    },
 	    editClose () {
 	      this.dialog.isVisible = false
@@ -291,7 +295,8 @@
 	      })
 	    },
 	    reset () {
-	      this.queryParams = initQueryParams({})
+	  	  this.objData.deptId = null
+        this.queryParams = initQueryParams({})
 	      this.$refs.table.clearSort()
 	      this.$refs.table.clearFilter()
 	      this.search()
@@ -315,7 +320,7 @@
 	        })
 	        return
 	      }
-	
+
 	      this.$confirm(this.$t("calssSchedule.tips.settingTips"), this.$t("common.tips"), {
 	      	distinguishCancelAndClose: true,
 	        confirmButtonText: this.$t("common.confirm"),
@@ -406,28 +411,30 @@
 	    },
 	    // 【查看】表头上Btn-事件
 	    viewOne(row) {
-	    	if(row){
-		    	this.viewCalendar(row);
+	    	if(null === row){
+            if (!this.selection.length) {
+                this.$message({
+                    message: this.$t("tips.noDataSelected"),
+                    type: "warning"
+                })
+                return
+            }
+            if (this.selection.length > 1) {
+                this.$message({
+                    message: this.$t("tips.mustOne"),
+                    type: "warning"
+                })
+                return
+            }
+            this.viewCalendar(this.selection[0]);
+
 	    	}else{
-	    		if (!this.selection.length) {
-		        this.$message({
-		          message: this.$t("tips.noDataSelected"),
-		          type: "warning"
-		        })
-		        return
-		      }
-		    	if (this.selection.length > 1) {
-		        this.$message({
-		          message: this.$t("tips.mustOne"),
-		          type: "warning"
-		        })
-		        return
-		      }
-		    	this.viewCalendar(this.selection[0]);
+            this.viewCalendar(row);
 	    	}
 	    },
 	    // 打开【日历-查看】组件
 	    viewCalendar(row){
+	  	  console.log(row)
 	    	this.$refs.calendar.setTenant(row, this.objData)
 	      this.userDialog.title = this.$t("calssSchedule.common.userSchul")
 	      this.userDialog.isVisible = true
@@ -444,10 +451,21 @@
 	        this.queryParams.map.createTime_st = this.queryParams.timeRange[0]
 	        this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]
 	      }
-	
+
 	      this.queryParams.current = params.current ? params.current : this.queryParams.current
 	      this.queryParams.size = params.size ? params.size : this.queryParams.size
-	      
+
+        const selectDeptId = []
+        if(null != this.queryParams.deptId || this.queryParams.deptId === "undefined"){
+            this.queryParams.deptId.forEach(item => {
+                selectDeptId.push(item)
+            });
+            if(selectDeptId.length > 0){
+                this.objData.deptId = selectDeptId[selectDeptId.length-1]
+            }
+        }
+        this.objData.userName = this.queryParams.userName
+
 	      this.queryParams.model = this.objData
 	      settingClassSchedulApi.pageList(this.queryParams).then(response => {
 	        const res = response.data
@@ -457,7 +475,7 @@
 	        }
 	        // eslint-disable-next-line no-return-assign
 	      }).finally(() => this.loading = false)
-	     
+
 	    },
 	    // 格式化,自己需要的渲染数据
 	    formatData(data){
@@ -492,7 +510,6 @@
 	    		})
 	    		data.data = list
 	    	}
-	    	console.log("数据后的内容:", data)
 	    	this.tableData = data
 	    },
 	    cellClick (row, column) {
@@ -506,11 +523,27 @@
 	          this.$refs.table.toggleRowSelection(row)
 	        }
 	      })
-	
+
 	      if (!flag) {
 	        this.$refs.table.toggleRowSelection(row, true)
 	      }
-	    }
+	    },
+      // 加载Tree数据
+      getTreeData(){
+          orgApi.allTree({}).then((response) => {
+              const res = response.data
+              this.depts = res.data
+          })
+      },
+      handleChange() {
+          const el = this.$refs.cascader;
+          // 官方文档中有提供获取子节点的方法 getCheckedNodes;
+          // 通过监听当前的点击事件,判断是否还有子节点,如果没有,则关闭选项卡;
+          const mark = el.getCheckedNodes()[0].children.length;
+          if(!mark) {
+              el.dropDownVisible = false;
+          }
+      }
 	  }
 	}
 </script>