From 312b055ee75a14d90201e9de9024927de49d7d8b Mon Sep 17 00:00:00 2001 From: “zhuo” <“zhuo@itcast.cn”> Date: 星期四, 10 八月 2023 18:00:38 +0800 Subject: [PATCH] 8.10 --- src/views/experiment/planAssignments/index.vue | 87 ++++++++++++++++++++++++++++++++----------- 1 files changed, 65 insertions(+), 22 deletions(-) diff --git a/src/views/experiment/planAssignments/index.vue b/src/views/experiment/planAssignments/index.vue index f5bdf13..ad051ce 100644 --- a/src/views/experiment/planAssignments/index.vue +++ b/src/views/experiment/planAssignments/index.vue @@ -6,7 +6,7 @@ <el-select v-model="searchData.devicename" placeholder="鍏ㄩ儴" - style="width: 100px" + style="width: 120px" > <el-option v-for="item in options1" @@ -21,6 +21,7 @@ <el-date-picker v-model="searchData.time" type="daterange" + value-format="yyyy-MM-dd" range-separator="~" start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡" @@ -31,7 +32,7 @@ <el-select v-model="searchData.person" placeholder="鍏ㄩ儴" - style="width: 80px; margin-right: 100px" + style="width: 100px; margin-right: 100px" > <el-option v-for="item in options2" @@ -43,10 +44,14 @@ </el-select> </el-form-item> <el-form-item> - <el-button type="primary" plain style="margin-right: 10px" + <el-button + type="primary" + plain + style="margin-right: 10px" + @click="resetData()" >閲嶇疆</el-button > - <el-button type="primary">鏌ヨ</el-button> + <el-button type="primary" @click="getData()">鏌ヨ</el-button> </el-form-item> </el-form> </div> @@ -154,38 +159,76 @@ return { searchData: { devicename: "", - time: "", + time: [], person: "", }, options1: [], options2: [], planTable: [], + planTableView: [], }; }, created() { this.getData(); }, + methods: { // 鏌ヨ鍒楄〃 async getData() { - const params = {}; + const params = { + device: this.searchData.devicename + ? this.searchData.devicename + : undefined, + user: this.searchData.person ? this.searchData.person : undefined, + beginTime: + this.searchData.time && this.searchData.time.length > 0 + ? this.searchData.time[0] + : undefined, + endTime: + this.searchData.time && this.searchData.time.length > 0 + ? this.searchData.time[1] + : undefined, + }; const { data } = await selectAllPlan(params); this.planTable = data; - this.planTable.forEach((res) => { - let o1 = { - value: res.device, - label: res.device, - }; - this.options1.push(o1); - - if(res.userId == undefined) { - - } - }); - let d=this.options1.filter((val,index,self)=>{ - return self.indexOf(val)==index; - }) - console.log(d); + if (this.options1.length === 0) { + //娣诲姞璁惧鍚嶇О + const deviceData = []; + this.planTable.forEach((res) => { + if (!deviceData.includes(res.device)) { + deviceData.push(res.device); + } + }); + deviceData.forEach((item) => { + this.options1.push({ + value: item, + label: item, + }); + }); + //娣诲姞鐢ㄦ埛 + const userData = []; + this.planTable.forEach((res) => { + if (res.checker != undefined && !userData.includes(res.checker)) { + userData.push(res.checker); + } + }); + userData.forEach((item) => { + this.options2.push({ + value: item, + label: item, + }); + }); + console.log(this.options2); + } + }, + // 閲嶇疆鎸夐挳 + resetData() { + (this.searchData = { + devicename: "", + time: [], + person: "", + }), + this.getData(); }, }, }; @@ -216,7 +259,7 @@ height: 78vh; .formwrapper { padding: 0px 20px; - margin-top: 0px; + margin-top: 20px; flex: 1; background: #fff; /* padding: 20px 20px 10px 20px; */ -- Gitblit v1.9.3