riku
2024-04-26 60b5fd30e81a51ad0299179782fbf515b855f32c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
  <FYTable @search="onSearch">
    <template #options>
      <FYOptionLocation
        :allOption="true"
        :level="4"
        v-model:value="formSearch._locations"
      ></FYOptionLocation>
      <FYOptionText
        label="场景名称"
        placeholder="输入名称关键字"
        v-model:value="formSearch.searchText"
      ></FYOptionText>
      <FYOptionScene
        :allOption="true"
        :type="2"
        v-model:value="formSearch._scenetype"
      ></FYOptionScene>
      <FYOptionOnlineStatus
        :allOption="true"
        v-model:value="formSearch.online"
      ></FYOptionOnlineStatus>
    </template>
 
    <template #buttons>
      <CompSceneImport></CompSceneImport>
    </template>
 
    <template #table-column>
      <el-table-column fixed="left" prop="name" label="名称" width="400">
        <template #default="scope">
          <el-tooltip
            effect="dark"
            :content="scope.row.name"
            placement="top-start"
            :show-after="500"
          >
            {{ scope.row.name }}
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column prop="type" label="类型" width="130" />
      <el-table-column prop="provincename" label="省" width="90" />
      <el-table-column prop="cityname" label="市" width="90" />
      <el-table-column prop="districtname" label="区县" width="90" />
      <el-table-column prop="townname" label="街道" width="110" />
      <el-table-column prop="location" label="地址" min-width="400" />
      <el-table-column prop="longitude" label="经度" width="110" />
      <el-table-column prop="latitude" label="纬度" width="110" />
      <el-table-column fixed="right" label="操作" width="160">
        <template #default="scope">
          <el-button
            :loading="scope.row.loading1"
            type="default"
            size="small"
            @click="itemEdit(scope)"
            >编辑</el-button
          >
          <el-button
            :loading="scope.row.loading2"
            :type="scope.row.extension1 != '0' ? 'danger' : 'primary'"
            size="small"
            @click="itemActive(scope)"
            >{{ scope.row.extension1 != '0' ? '下线' : '上线' }}</el-button
          >
        </template>
      </el-table-column>
    </template>
  </FYTable>
</template>
 
<script>
import sceneApi from '@/api/fysp/sceneApi';
import { useLoadingStore } from '@/stores/loadingStore';
import { mapStores } from 'pinia';
import { useMessageBoxTip } from '@/composables/messageBox';
import CompSceneImport from "./CompSceneImport.vue";
 
export default {
  components: {
    CompSceneImport,
  },
  data() {
    return {
      formSearch: {
        _locations: {},
        searchText: '',
        _scenetype: {},
        online: {}
      }
    };
  },
  computed: {
    ...mapStores(useLoadingStore)
  },
  methods: {
    onSearch(page, func) {
      const f = this.formSearch;
      const area = {};
      // 行政区划
      area.provincecode = f._locations.pCode;
      area.citycode = f._locations.cCode;
      area.districtcode = f._locations.dCode;
      area.towncode = f._locations.tCode;
      // 场景类型
      area.scensetypeid = f._scenetype.value;
      if (area.scensetypeid == '0') area.scensetypeid = null;
      // 上下线状态
      area.online = f.online.value;
      // 查询关键字(场景名称)
      area.sceneName = f.searchText
 
      return sceneApi.searchScene(area, page.currentPage, page.pageSize).then((res) => {
        if (res.success) {
          func({
            data: res.data,
            total: res.head.totalCount
          });
        }
      });
    },
    itemEdit(scope) {
      scope.row.loading1 = true;
      this.loadingStore.pushLoading(() => (scope.row.loading1 = false));
      this.$router.push(`sceneEdit/${scope.row.guid}`);
    },
    itemActive(scope) {
      const rb = {};
      rb.guid = scope.row.guid;
      rb.extension1 = scope.row.extension1 != '0' ? '0' : '1';
      const msg = scope.row.extension1 != '0' ? '下线' : '上线';
      useMessageBoxTip({
        confirmMsg: `确认${msg}该场景?`,
        confirmTitle: msg,
        onConfirm: () => {
          scope.row.loading2 = true;
          return sceneApi
            .updateScene(rb)
            .then((res) => {
              if (res == 1) {
                scope.row.extension1 = rb.extension1;
              }
            })
            .finally(() => {
              scope.row.loading2 = false;
            });
        }
      });
    }
  }
};
</script>
 
<style></style>