1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import Config from '@/config'
- import Store from '@/store'
- export const webSocket = {
- methods: {
- connectWebSocket(userId) {
- // let webSocket = new WebSocket(`ws://192.168.1.3:8877/api/xiaoshi/ws/` + userId)
- let webSocket = new WebSocket(`${this.$c.WebSocketPath}/api/xiaoshi/ws/` + userId)
- Store.commit('SET_WEB_SOCKET', webSocket)
- webSocket.onopen = () => {
- console.log('WebSocket连接成功')
- }
- webSocket.onmessage = async (e) => {
- if (e.data.indexOf('{') == -1) {
- return false
- }
- const { code, data, message } = JSON.parse(e.data)
- if (code == 903 || code == 600) {
- if (data.complete) {
- this.$message.success(`导入完成`)
- } else {
- }
- }
- // 603导出专利完成605导出PDF完成
- if (code == 603 || code == 605) {
- if (data.complete) {
- this.$message.success(`导出完成`)
- } else {
- }
- }
- }
- webSocket.onerror = () => {
- console.log('WebSocket连接失败')
- }
- webSocket.onclose = () => {
- console.log('WebSocket连接关闭')
- }
- }
- }
- }
- export const commonData = {
- mounted() {
- // this.DictMessage()
- // this.getUserInfo()
- // this.getScenario()
- },
- methods: {
- //获取个人信息
- async getUserInfo() {
- // var userinfo = this.$s.getObj('userinfo')
- // if(userinfo){
- // this.$store.commit('SET_USERINFO', {})
- // }
-
- await this.$api.getUserInfo().then(response => {
- localStorage.tenant = response.data.tenantId
- this.$store.commit('SET_USERINFO', response.data)
- })
- },
- //获取字典项
- async DictMessage() {
- await this.$api.getOsSystemDict([]).then(response => {
- this.$store.commit("SET_DictMessage", response.data)
- })
- },
- //获取应用场景
- getScenario() {
- this.$api.getScenario().then(response => {
- this.$store.commit("SET_Scenario", response.data.data)
- })
- },
- //获取调查类型
- getMatter() {
- this.$api.getMatter([]).then(response => {
- this.$store.commit("SET_Matter", response.data.data)
- })
- },
- //获取权限
- async getPermissionList() {
- var code = "e424f3cc4f8138f0f68bef092b92212f;6a8d3f4d1d5f11eda41c00163e2f0200"
- await this.$api.getPermissionList({ code: code }).then(response => {
- this.$store.commit('SET_PERMISSION', response.data)
- }).catch(error => {
- this.$store.commit('SET_PERMISSION', [])
- })
- },
- }
- }
|