“zhuo”
2023-08-10 312b055ee75a14d90201e9de9024927de49d7d8b
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; */