|
@@ -99,8 +99,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import {getCurrentInstance, reactive} from "vue";
|
|
|
+import {getCurrentInstance, onMounted, reactive} from "vue";
|
|
|
import RelationChart from "./relation-chart.vue";
|
|
|
+import {ElLoading, ElMessage} from "element-plus";
|
|
|
|
|
|
const {proxy} = getCurrentInstance()
|
|
|
const state: any = reactive({
|
|
@@ -134,11 +135,114 @@ const state: any = reactive({
|
|
|
result: {
|
|
|
total: 0,
|
|
|
data: []
|
|
|
- }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ws: {
|
|
|
+ instance: null,
|
|
|
+ listFix: () => {},
|
|
|
+ loading: null,
|
|
|
+ loadingTimer: null
|
|
|
},
|
|
|
})
|
|
|
-
|
|
|
+const loadingBg = 'rgba(0, 0, 0, 0.4)'
|
|
|
const onPage = (pageNum, pageSize) => {}
|
|
|
+const initWS = () => {
|
|
|
+ const ws: any = new WebSocket('/ws-api/smart-ws?userId=1388061846031220738')
|
|
|
+ let sessionId = ''
|
|
|
+ let lastListFixParams = ''
|
|
|
+ ws.onopen = (e) => {
|
|
|
+ state.ws.loading?.close()
|
|
|
+ state.ws.loading = null
|
|
|
+ state.ws.listFix = () => {
|
|
|
+ // 如果有的话,终止上一次请求
|
|
|
+ if (lastListFixParams) {
|
|
|
+ const p = JSON.parse(lastListFixParams)
|
|
|
+ p.flag = 'stop'
|
|
|
+ ws.send(JSON.stringify(p))
|
|
|
+ lastListFixParams = ''
|
|
|
+ }
|
|
|
+ const params = {
|
|
|
+ pageNumber: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ type: 'list-fix',
|
|
|
+ sessionId: sessionId,
|
|
|
+ timestamp: new Date().getTime(),
|
|
|
+ flag: 'run',
|
|
|
+ orderBy: {},
|
|
|
+ "builder":[
|
|
|
+ {
|
|
|
+ "tagCode":"对象标签",
|
|
|
+ "datas":[
|
|
|
+ {
|
|
|
+ "typeCode":"人员分类代码",
|
|
|
+ "datas":[
|
|
|
+ {
|
|
|
+ "indexCode":"index_seat_smartes_document",
|
|
|
+ "orderBy":{"aaa":"desc","bbb":"asc"},
|
|
|
+ "datas":[
|
|
|
+ {"fieldCode":"sub_title","fieldQueryType":"MATCH","fieldQueryValue":"佛祖fozu-111"},
|
|
|
+ // {"fieldCode":"title","fieldType":"text","fieldSort":"asc","fieldAnalyzer":"ngram","fieldQueryType":"PREFIX"},
|
|
|
+ // {"fieldCode":"star_num","fieldType":"text","fieldSort":"asc","fieldAnalyzer":"ngram","fieldQueryType":"GT"}
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "indexCode":"index_seat_smartes_document",
|
|
|
+ "orderBy":{"aaa":"desc","bbb":"asc"},
|
|
|
+ "datas":[
|
|
|
+ {"fieldCode":"sub_title","fieldQueryType":"MATCH","fieldQueryValue":"佛祖fozu-111"},
|
|
|
+ // {"fieldCode":"title","fieldType":"text","fieldSort":"asc","fieldAnalyzer":"ngram","fieldQueryType":"PREFIX"},
|
|
|
+ // {"fieldCode":"star_num","fieldType":"text","fieldSort":"asc","fieldAnalyzer":"ngram","fieldQueryType":"GT"}
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ lastListFixParams = JSON.stringify(params)
|
|
|
+ ws.send(lastListFixParams)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ws.onmessage = (e) => {
|
|
|
+ try {
|
|
|
+ const json = JSON.parse(e.data)
|
|
|
+ if (json.type === 'session') {
|
|
|
+ sessionId = json.sessionId
|
|
|
+ setTimeout(() => {
|
|
|
+ state.ws.listFix()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ switch (json.type) {
|
|
|
+ case 'list-fix': {
|
|
|
+ const p = JSON.parse(lastListFixParams)
|
|
|
+ // 返回为最新批次的
|
|
|
+ if (json.timestamp == p.timestamp) {
|
|
|
+ state.tableParams.total = json.records
|
|
|
+ state.tableParams.data = json.datas
|
|
|
+ state.tableParams.loading = false
|
|
|
+ lastListFixParams = ''
|
|
|
+ }
|
|
|
+ } break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ws.onclose = function (){
|
|
|
+ state.ws.loading = ElLoading.service({
|
|
|
+ lock: true,
|
|
|
+ text: '智搜服务重新连接中……',
|
|
|
+ background: loadingBg,
|
|
|
+ })
|
|
|
+ setTimeout(initWS, 5000);
|
|
|
+ }
|
|
|
+ state.ws.instance = ws
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ initWS()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|