riku
2023-12-12 a35ff1ca423e2fea33dc11f37b54d076acaab3c5
src/views/baseinfo/fysp/scene/SceneInfo.vue
@@ -1,73 +1,24 @@
<template>
  <el-row ref="searchRef">
    <el-form :inline="true" :model="formSearch">
      <el-form-item label="省/市/区/镇" prop="_locations">
        <!-- <el-cascader
          v-model="formSearch._locations"
          :options="locations"
          placeholder="省/市/区/镇"
          :props="props"
          style="width: 280px"
        /> -->
        <OptionLocation
  <FYTable @search="onSearch">
    <template #options>
      <FYOptionLocation
          :allOption="true"
          :level="4"
          v-model:value="formSearch._locations"
        ></OptionLocation>
      </el-form-item>
      <el-form-item label="场景类型" prop="scensetype">
        <OptionScene
      ></FYOptionLocation>
      <FYOptionScene
          :allOption="true"
          :type="2"
          v-model:value="formSearch.scensetype"
        ></OptionScene>
        <!-- <el-select
          v-model="formSearch.scensetypeid"
          placeholder="场景类型"
          style="width: 150px"
        >
          <el-option
            v-for="s in sceneTypes"
            :key="s.value"
            :label="s.label"
            :value="s.value"
          />
        </el-select> -->
      </el-form-item>
      <el-form-item label="上线状态" prop="online">
        <OptionOnlineStatus
      ></FYOptionScene>
      <FYOptionOnlineStatus
          :allOption="true"
          v-model:value="formSearch.online"
        ></OptionOnlineStatus>
        <!-- <el-select
          v-model="formSearch.online"
          placeholder="上线状态"
          style="width: 75px"
        >
          <el-option
            v-for="s in onlineStatus"
            :key="s.value"
            :label="s.label"
            :value="s.value"
          />
        </el-select> -->
      </el-form-item>
      <el-form-item>
        <el-button icon="Search" type="primary" @click="onSearch"
          >查询</el-button
        >
      </el-form-item>
    </el-form>
  </el-row>
      ></FYOptionOnlineStatus>
    </template>
  <el-table
    :data="tableData"
    v-loading="loading"
    table-layout="fixed"
    :row-class-name="tableRowClassName"
    :height="tableHeight"
  >
    <el-table-column prop="name" label="名称" width="400">
    <template #table-column>
      <el-table-column fixed="left" prop="name" label="名称" width="400">
      <template #default="scope">
        <el-tooltip
          effect="dark"
@@ -105,18 +56,8 @@
        >
      </template>
    </el-table-column>
  </el-table>
  <el-pagination
    ref="paginationRef"
    class="el-pagination"
    v-model:current-page="currentPage"
    v-model:page-size="pageSize"
    :page-sizes="[10, 20, 50, 100]"
    :background="true"
    layout="total, sizes, prev, pager, next, jumper"
    :total="total"
  />
    </template>
  </FYTable>
</template>
<script>
@@ -129,78 +70,40 @@
  data() {
    return {
      formSearch: {
        _locations: [],
        _locations: {},
        scensetype: {},
        online: {},
      },
      tableData: [],
      tableHeight: '500',
      loading: false,
      currentPage: 1,
      pageSize: 20,
      total: 0,
    };
  },
  watch: {
    currentPage(nValue, oValue) {
      if (nValue != oValue) {
        this.onSearch();
      }
    },
    pageSize(nValue, oValue) {
      if (nValue != oValue) {
        this.onSearch();
      }
    },
  },
  computed: {
    ...mapStores(useLoadingStore),
  },
  methods: {
    onSearch() {
      this.loading = true;
    onSearch(page, func) {
      const f = this.formSearch;
      const area = {};
      // 行政区划
      f._locations.length > 0
        ? (area.provincecode = f._locations[0][0])
        : (area.provincecode = null);
      if (area.provincecode == '0') area.provincecode = null;
      f._locations.length > 1
        ? (area.citycode = f._locations[1][0])
        : (area.citycode = null);
      f._locations.length > 2
        ? (area.districtcode = f._locations[2][0])
        : (area.districtcode = null);
      f._locations.length > 3
        ? (area.towncode = f._locations[3][0])
        : (area.towncode = null);
      area.provincecode = f._locations.pCode
      area.citycode = f._locations.cCode
      area.districtcode = f._locations.dCode
      area.towncode = f._locations.tCode
      // 场景类型
      area.scensetypeid = f.scensetype.value;
      if (area.scensetypeid == '0') area.scensetypeid = null;
      // 上下线状态
      area.online = f.online.value;
      sceneApi
        .searchScene(area, this.currentPage, this.pageSize)
      return sceneApi
        .searchScene(area, page.currentPage, page.pageSize)
        .then((res) => {
          if (res.success) {
            this.tableData = res.data;
            this.currentPage = res.head.page;
            this.total = res.head.totalCount;
          }
        })
        .finally(() => {
          this.loading = false;
            func({
              data: res.data,
              total: res.head.totalCount,
        });
    },
    calcTableHeight() {
      const h1 = this.$refs.searchRef.$el.offsetHeight;
      const h2 = this.$refs.paginationRef.$el.offsetHeight;
      // return `calc(100vh - ${h1}px - ${h2}px - var(--el-main-padding) * 2 - var(--el-header-height))`;
      return `calc(100vh - ${h1}px - ${h2}px - 60px - var(--el-main-padding) * 2)`;
          }
        });
    },
    itemEdit(scope) {
      scope.row.loading1 = true;
@@ -217,7 +120,7 @@
        confirmTitle: msg,
        onConfirm: () => {
          scope.row.loading2 = true;
          sceneApi
          return sceneApi
            .updateScene(rb)
            .then((res) => {
              if (res == 1) {
@@ -230,35 +133,8 @@
        },
      });
    },
    tableRowClassName({ row }) {
      return row.extension1 != '0' ? 'online-row' : 'offline-row';
    },
  },
  mounted() {
    this.tableHeight = this.calcTableHeight();
    this.onSearch();
  },
};
</script>
<style>
.el-table .online-row {
  /* background-color: rgb(4, 202, 21); */
}
.el-table .offline-row {
  background-color: var(--el-disabled-bg-color);
  color: var(--el-disabled-text-color);
}
.el-table .cell {
  white-space: nowrap;
}
.el-pagination {
  background-color: var(--el-color-white);
  padding-top: 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.096);
  /* margin-top: 2px; */
}
</style>
<style></style>