春风项目四线(合箱线、总装线)
wujian
2024-01-31 c74dcb8dca7b9e3eded0d20299f19a26a6b70974
jcdm-ui/src/views/main/pr/tightenReport/index.vue
@@ -14,16 +14,17 @@
            placeholder="请输入工位号"
            @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item label-width="120"  label="采集时间" prop="startDate">
            <el-date-picker
              v-model="dateRange"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
            <button @click="fetchData">查询</button>
        <el-form-item label-width="130" label="保存日期" prop="dateConditions">
          <el-date-picker
            v-model="queryParams.dateConditions"
            type="datetimerange"
            :picker-options="pickerOptions"
            value-format="yyyy-MM-dd HH:mm:ss"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            align="right">
          </el-date-picker>
        </el-form-item>
        <el-form-item style="float: right">
          <el-button type="primary" icon="el-icon-refresh" @click="handleQuery">查询</el-button>
@@ -37,16 +38,16 @@
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="箱体编码" align="center" width="200" prop="sfcCode"></el-table-column>
        <el-table-column label="工位" align="center" prop="locationCode"></el-table-column>
        <el-table-column label="参数编码" align="center" prop="paramCode"></el-table-column>
        <el-table-column label="参数名称" align="center" prop="paramName"></el-table-column>
        <el-table-column label="参数编码" align="center" prop="paramCode"></el-table-column>
        <el-table-column label="参数值" align="center" prop="paramValue"></el-table-column>
        <el-table-column label="单位" align="center" prop="unit"></el-table-column>
        <el-table-column label="结果" align="center" prop="state"></el-table-column>
        <el-table-column label="采集时间" align="center" prop="collectionTime" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.collectionTime, '{y}-{m}-{d}') }}</span>
            <span>{{ parseTime(scope.row.collectionTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" align="center" prop="state"></el-table-column>
        <el-table-column label="单位" align="center" prop="unit"></el-table-column>
      </el-table>
      <el-empty v-else>
        <span slot="description">暂无数据</span>
@@ -112,31 +113,46 @@
        unit: null,
        type: '拧紧数据',
        startDate: null,
        endDate: null
        endDate: null,
        dateConditions: [],
      },
      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]);
          },
          class: 'custom-shortcut' // 添加class属性
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          },
          class: 'custom-shortcut' // 添加class属性
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          },
        }]
      },
    }
  },
  created() {
    this.getList();
  },
  methods:{
  methods: {
    async fetchData() {
      // 构建API请求的URL,使用选择的日期范围作为查询参数
      const url = `@/api/main/da/paramCollection/paramCollection?startDate=${this.dateRange[0]}&endDate=${this.dateRange[1]}`;
      try {
        // 发送API请求,获取查询结果
        const response = await fetch(url);
        const data = await response.json();
        console.log(data); // 处理查询结果,比如在控制台输出或显示在页面上
      } catch (error) {
        console.error('Error fetching data:', error);
      }
    },
  },
  reset() {
    reset() {
      this.form = {
        id: null,
        workOrderNo: null,
@@ -177,31 +193,12 @@
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    getList() {
      this.loading = true;
      // const startDate = new Date(this.queryParams.startDate);
      // const endDate = new Date(this.queryParams.endDate);
      // const resultList = [];
      // // 构建查询条件,使用ParamCollection表的createtime作为判断条件
      // const query = {
      //   createTime: date // 使用当前日期作为查询条件
      // };
      // for (let date = startDate; date <= endDate; date.setDate(date.getDate() + 1)) {
      //   // 根据当前日期执行查询操作,并将结果添加到结果数组中
      //   listParamCollection(query).then(response => {
      //     resultList.push(...response.rows);
      //     // 判断是否是最后一个日期,如果是,则更新页面数据
      //     if (date.getTime() === endDate.getTime()) {
      //       this.tightenReportList = resultList;
      //       this.total = resultList.length;
      //       this.loading = false;
      //     }
      //   });
      // }
      listParamCollection(this.queryParams).then(response => {
        this.tightenReportList = response.rows;
        this.total = response.total;
@@ -209,8 +206,9 @@
      });
    },
  },
}
</script>
<style scoped>
@@ -220,4 +218,6 @@
::v-deep .el-card__body{
  padding: 15px 20px 0px 20px;
}
/* 添加其他样式属性 */
</style>