123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <div>
- <div class="query mg-b-8">
- <div class="query-items">
- <div class="query-item">
- <div class="lable">开始日期:</div>
- <div class="search-input">
- <el-date-picker
- v-model="value1"
- @change="BeginChange(value1)"
- type="date"
- value-format="YYYY-MM-DD"
- placeholder="选择日期"
- popper-class="date-select"
- >
- </el-date-picker>
- </div>
- </div>
- <div class="query-item">
- <div class="lable">结束日期:</div>
- <div class="search-input">
- <el-date-picker
- v-model="value2"
- @change="EndChange(value2)"
- type="date"
- value-format="YYYY-MM-DD"
- placeholder="选择日期"
- popper-class="date-select"
- >
- </el-date-picker>
- <div class="unit svg-icon svg-icon-gray">
- <svg-icon :svgid="''" />
- </div>
- </div>
- </div>
- </div>
- <div class="query-actions">
- <button class="btn green" @click="handleSubmit">计算</button>
- </div>
- </div>
- <div class="table-box">
- <ComTable
- :data="tableData"
- :pageSize="20"
- height="85vh"
- v-loading="tableLoading"
- element-loading-text="拼命加载中"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- ></ComTable>
- </div>
- </div>
- </template>
- <script>
- import ComTable from "@/components/coms/table/table.vue";
- export default {
- name: "fwjsl",
- components: { ComTable },
- data() {
- return {
- value1: "",
- value2: "",
- tableLoading: true,
- tableData: {
- column: [
- {
- name: "风电场",
- field: "wpid",
- is_num: false,
- is_light: false,
- sortable: true
- },
- {
- name: "故障次数",
- field: "gzCount",
- is_num: false,
- is_light: false,
- sortable: true
- },
- {
- name: "消缺及时次数",
- field: "xqCount",
- is_num: false,
- is_light: false,
- sortable: true
- },
- {
- name: "消缺及时次数",
- field: "xqjsl",
- is_num: false,
- is_light: false,
- sortable: true
- }
- ],
- date: []
- }
- };
- },
- mounted() {
- this.getTable();
- },
- created() {
- this.value1 = this.getTime(1);
- this.value2 = this.getTime(2);
- },
- methods: {
- // 获取表格数据
- getTable() {
- let that = this;
- that.tableLoading = true;
- that.API.requestData({
- method: "GET",
- baseURL: "http://10.155.32.4:8034/",
- subUrl: "/threerate/xqjsl",
- data: {
- beginDate: this.value1,
- endDate: this.value2
- },
- success(res) {
- that.tableLoading = false;
- console.log(res);
- if (res.code === 200) {
- that.tableData.data = res.data;
- }
- }
- });
- },
- // 开始日期:
- BeginChange(vl) {
- this.value1 = vl;
- },
- // 结束日期
- EndChange(vl) {
- this.value1 = vl;
- },
- // 计算
- handleSubmit() {
- if (this.value1 == "" || this.value1 == null) {
- this.$message.error("请选择开始时间");
- } else if (this.value2 == "" || this.value2 == null) {
- this.$message.error("请选择结束时间");
- } else {
- this.getTable();
- }
- },
- // 默认开始时间
- getTime(val) {
- //时间戳处理,val=1是默认开始时间(当前月第一天),val=2是默认结束时间(今天)
- var date = new Date();
- var year = date.getFullYear(),
- month = date.getMonth() + 1,
- day = date.getDate();
- month >= 1 && month <= 9 ? (month = "0" + month) : "";
- day >= 0 && day <= 9 ? (day = "0" + day) : "";
- var begin = year + "-" + month + "-01";
- var end = year + "-" + month + "-" + day;
- if (val == 1) {
- return begin;
- } else if (val == 2) {
- return end;
- }
- }
- }
- };
- </script>
|