Kaynağa Gözat

Merge branch 'master' of http://112.74.164.79:3000/chenying/X-web

damon227 3 yıl önce
ebeveyn
işleme
21749ed293

+ 0 - 2
src/api/production.js

@@ -26,7 +26,6 @@ export function getMonitoringList (params) {
   })
 }
 
-
 // 获取生产监控详情
 export function getMonitoringDetail (productionId) {
   return request({
@@ -35,7 +34,6 @@ export function getMonitoringDetail (productionId) {
   })
 }
 
-
 // 获取生产记录列表信息
 export function getRecordingList (params) {
   return request({

+ 1 - 1
src/mock/modules/common.js

@@ -9,7 +9,7 @@ export function login () {
     data: {
       'msg': 'success',
       'code': 0,
-      'expire': Mock.Random.natural(60 * 60 * 1, 60 * 60 * 12),
+      'expire': Mock.Random.natural(60 * 60, 60 * 60 * 12),
       'token': Mock.Random.string('abcdefghijklmnopqrstuvwxyz0123456789', 32)
     }
   }

+ 7 - 5
src/router/index.js

@@ -35,7 +35,9 @@ const mainRoutes = {
     // 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理!
     { path: '/home', component: _import('common/home'), name: 'home', meta: { title: '首页' } },
     { path: '/theme', component: _import('common/theme'), name: 'theme', meta: { title: '主题' } },
-    { path: '/msg-center', component: _import('modules/msg-center/announcement'), name: 'msgCenter', meta: { title: '我的消息中心' } }
+    { path: '/msg-center', component: _import('modules/msg-center/notice'), name: 'msgCenter', meta: { title: '我的消息中心' } },
+    { path: '/msg-announcement', component: _import('modules/msg-center/announcement'), name: 'msgAnnouncement', meta: { title: '公告消息' } },
+    { path: '/msg-approve', component: _import('modules/msg-center/approve'), name: 'msgApprove', meta: { title: '审批消息' } }
     // { path: '/demo-echarts', component: _import('demo/echarts'), name: 'demo-echarts', meta: { title: 'demo-echarts', isTab: true } },
     // { path: '/demo-ueditor', component: _import('demo/ueditor'), name: 'demo-ueditor', meta: { title: 'demo-ueditor', isTab: true } }
   ],
@@ -149,10 +151,10 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
       { path: '*', redirect: { name: '404' } }
     ])
     sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]'))
-    console.log('\n')
-    console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue')
-    console.log(mainRoutes.children)
-    console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue')
+    // console.log('\n')
+    // console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue')
+    // console.log(mainRoutes.children)
+    // console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue')
   }
 }
 

+ 1 - 1
src/store/index.js

@@ -21,5 +21,5 @@ export default new Vuex.Store({
       })
     }
   },
-  strict: process.env.NODE_ENV !== 'production'
+  strict: false
 })

+ 7 - 1
src/store/modules/common.js

@@ -17,6 +17,7 @@ export default {
     // 主入口标签页
     mainTabs: [],
     mainTabsActiveName: '',
+    // 审批状态
     approveStates: [
       {
         code: null, value: '全部'
@@ -36,7 +37,9 @@ export default {
       {
         code: '4', value: '审批不通过'
       }
-    ]
+    ],
+    // 消息集合
+    msgCollection: []
   },
   mutations: {
     updateDocumentClientHeight (state, height) {
@@ -65,6 +68,9 @@ export default {
     },
     updateMainTabsActiveName (state, name) {
       state.mainTabsActiveName = name
+    },
+    updateMsgCollection (state, lst) {
+      state.msgCollection = lst
     }
   }
 }

+ 96 - 5
src/store/modules/websocket.js

@@ -1,13 +1,104 @@
-const userId = localStorage.getItem('userId')
-const randomNum = localStorage.getItem('randomNum')
 export default {
   namespaced: true,
   state: {
-    webSocket: new WebSocket('ws://112.74.164.79:10088/web_socket/' + userId + '_' + randomNum)
+    websock: {},
+    url: '',
+    lockReconnect: false, // 是否真正建立连接
+    timeout: 30 * 1000, // 30秒一次心跳
+    timeoutObj: {}, // 心跳心跳倒计时
+    serverTimeoutObj: {}, // 心跳倒计时
+    timeoutnum: {}, // 断开 重连倒计时
+    message: {}
+  },
+  getters: {
+    message (state) {
+      return state.message
+    }
   },
   mutations: {
-    setWebSocket (state, items) {
-      state.webSocket = items
+    WEBSOCKET_INIT (state, url) {
+      if (!state || !url) return
+      let that = this
+      state.websock = new WebSocket(url)
+      state.url = url
+      state.websock.onopen = () => {
+        console.log('连接成功')
+        // 发送心跳包
+        that.commit('websocket/start')
+      }
+      state.websock.onmessage = (callBack) => {
+        // 重置心跳
+        // console.log('callBack = ' + callBack.data)
+        that.commit('websocket/reset')
+        if (callBack.data === 'heartCheck') {
+          return
+        }
+        state.message = callBack.data
+      }
+      state.websock.onerror = () => { // e错误
+        console.log('onerror')
+        that.commit('websocket/reconnect')
+      }
+      state.websock.onclose = () => { // e关闭
+        console.log('onclose')
+        that.commit('websocket/reconnect')
+      }
+    },
+    WEBSOCKET_SEND (state, message) {
+      state.websock.send(message)
+    },
+    reconnect (state) { // 重新连接
+      let that = this
+      if (state.lockReconnect) {
+        return
+      }
+      state.lockReconnect = true
+      // 没连接上会一直重连,设置延迟避免请求过多
+      state.timeoutnum && clearTimeout(state.timeoutnum)
+      state.timeoutnum = setTimeout(() => {
+        // 新连接
+        that.commit('websocket/WEBSOCKET_INIT', state.url)
+        state.lockReconnect = false
+      }, 15000)
+    },
+    reset (state) { // 重置心跳
+      // 清除时间
+      clearTimeout(state.timeoutObj)
+      clearTimeout(state.serverTimeoutObj)
+      // 心跳
+      this.commit('websocket/start')
+    },
+    start (state) {
+      // 开启心跳
+      let that = this
+      state.timeoutObj && clearTimeout(state.timeoutObj)
+      state.serverTimeoutObj && clearTimeout(state.serverTimeoutObj)
+      state.timeoutObj = setTimeout(() => {
+        // 这里发送一个心跳,后端收到后,返回一个心跳消息,
+        // console.log(state.websock)
+        if (state.websock.readyState === 1) { // 如果连接正常
+          state.websock.send('heartCheck')
+        } else { // 否则重连
+          that.commit('websocket/reconnect')
+        }
+        state.serverTimeoutObj = setTimeout(() => {
+          // 超时关闭
+          state.websock.close()
+        }, state.timeout)
+      }, state.timeout)
+    }
+  },
+  actions: {
+    WEBSOCKET_INIT ({
+      commit
+    }, url) {
+      commit('WEBSOCKET_INIT', url)
+    },
+    WEBSOCKET_SEND ({
+      commit
+    }, message) {
+      commit('WEBSOCKET_SEND', message)
     }
+
   }
 }

+ 8 - 0
src/utils/common.js

@@ -10,3 +10,11 @@ export function toPercent (val) {
 export function toNumber (rate) {
   return rate ? (Number(rate / 100)).toFixed(2) : 0
 }
+
+/**
+ * 字符串转JSON对象
+ */
+export function parseJsonStr (str) {
+  str = str.replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2')
+  return JSON.parse(str)
+}

+ 32 - 0
src/utils/msg.js

@@ -0,0 +1,32 @@
+/**
+ * 通知页面跳转
+ */
+export function routeMsg (that, row) {
+  if (row.type === 1) {
+    that.$router.push({name: 'msgAnnouncement',
+      params: {notice: {
+        noticeId: row.noticeId,
+        businessId: row.businessId
+      }}})
+  } else if (row.type === 2) {
+    that.$router.push({name: 'msgApprove',
+      params: {notice: {
+        noticeId: row.noticeId,
+        businessId: row.businessId
+      }}})
+  } else {
+    that.$message.warning('消息类型不支持')
+  }
+}
+
+/**
+ * 发送通知已读反馈
+ */
+export function readNotice (that, noticeId) {
+  let index = that.$store.state.common.msgCollection.findIndex(item => item.noticeId === noticeId)
+  if (index === -1) return
+  that.$store.state.common.msgCollection.splice(index, 1)
+  let arr = []
+  arr.push(noticeId)
+  that.$store.dispatch('websocket/WEBSOCKET_SEND', JSON.stringify({'noticeIds': arr}))
+}

+ 79 - 24
src/views/common/msg.vue

@@ -4,44 +4,89 @@
 </template>
 
 <script>
+  import {parseJsonStr} from '@/utils/common'
+  import {routeMsg} from '@/utils/msg'
   export default {
     name: 'msg',
     data () {
       return {
         visible: false,
         id: 0,
-        dataForm: {}
+        dataForm: {},
+        notify: {}
       }
     },
     mounted () {
-      const that = this
-      const h = this.$createElement
-      this.$nextTick(() => {
-        this.$store.state.websocket.webSocket.onmessage = async function (event) {
-          if (!event || !event.data) {
-            return
-          }
-          let json = JSON.parse(event.data)
-          console.log('json = ' + JSON.stringify(json))
-          if (json) {
-            that.$emit('noticeAdded', json.length)
-            json.forEach((item) => {
-              that.$notify({
-                title: item.title,
-                // dangerouslyUseHTMLString: true,
-                // message: h('i', {style: 'color: teal'}, item.content),
-                message: h('div', {}, [
-                  h('p', {}, '消息类别:' + that.getMsgType(item.type)),
-                  h('p', {}, '消息内容:' + item.content)
-                ]),
-                duration: 0
-              })
+      // this.test()
+    },
+    computed: {
+      // 监听消息变化
+      listenWebsocket () {
+        return this.$store.state.websocket.message
+      },
+      // 监听已读消息数量变化
+      listenCnt () {
+        return this.$store.state.common.msgCollection.length
+      }
+    },
+    watch: {
+      listenWebsocket: function (data) {
+        if (!data || data.indexOf('[') !== 0) {
+          return
+        }
+        let newMsgCollections = parseJsonStr(data)
+        // console.log('newMsgCollections = ' + JSON.stringify(newMsgCollections))
+        if (newMsgCollections) {
+          this.updateMsgCollections(newMsgCollections)
+          if (newMsgCollections.length <= 5) {
+            newMsgCollections.forEach((item) => {
+              this.notice(item)
             })
           }
         }
-      })
+      },
+      listenCnt: function (cnt) {
+        this.$emit('noticeAdded', cnt)
+      }
     },
     methods: {
+      test () {
+        let item = {
+          type: 1,
+          title: '测试标题',
+          content: '这是一条测试消息'
+        }
+        this.notice(item)
+      },
+      // 通知
+      notice (item) {
+        const h = this.$createElement
+        this.notify = this.$notify({
+          title: item.title,
+          message: h('div', {}, [
+            h('p', {}, '消息类别:' + this.getMsgType(item.type)),
+            h('p', {}, '消息内容:' + item.content),
+            h('p', {
+              style: 'text-align: left;margin-top: 10px;color:#43c39d',
+              on: {
+                click: () => {
+                  this.detail(item)
+                }
+              }
+            }, '点击查看详情')
+          ]),
+          duration: 0,
+          offset: 60
+        })
+      },
+      // 跳转到消息页面
+      detail (row) {
+        routeMsg(this, row)
+        if (this.notify) {
+          this.notify.close()
+        }
+      },
+      // 获取消息类型
       getMsgType (type) {
         if (!type) return '未知消息类型'
         if (type === 1) {
@@ -51,6 +96,16 @@
         } else {
           return '未知消息类型'
         }
+      },
+      // 更新通知列表
+      updateMsgCollections (newCollections) {
+        if (!newCollections || newCollections.length === 0) return
+        newCollections.forEach((item) => {
+          // 判断是否包含当前通知
+          if (this.$store.state.common.msgCollection.findIndex(item1 => item1.noticeId === item.noticeId) === -1) {
+            this.$store.state.common.msgCollection.push(item)
+          }
+        })
       }
     }
   }

+ 1 - 1
src/views/main-navbar.vue

@@ -112,7 +112,7 @@
       },
       // 通知数量变化
       noticeAdded (num) {
-        this.cnt += num
+        this.cnt = num
       }
     }
   }

+ 4 - 5
src/views/main.vue

@@ -60,9 +60,9 @@
         get () { return this.$store.state.user.orgId },
         set (val) { this.$store.commit('user/updateOrgId', val) }
       },
-      webSocket: {
-        get () { return this.$store.state.webSocket },
-        set (val) { this.$store.commit('websocket/setWebSocket', val) }
+      msgCollection: {
+        get () { return this.$store.state.common.msgCollection },
+        set (val) { this.$store.commit('common/updateMsgCollection', val) }
       }
     },
     created () {
@@ -92,8 +92,7 @@
             this.orgId = data.data.orgId
 
             // websocket初始化
-            localStorage.setItem('userId', data.data.userId)
-            localStorage.setItem('randomNum', (Math.ceil(Math.random() * 100000000)).toString())
+            this.$store.dispatch('websocket/WEBSOCKET_INIT', 'ws://112.74.164.79:10088/web_socket/' + data.data.userId + '_' + (Math.ceil(Math.random() * 100000000)).toString())
           }
         })
       }

+ 7 - 1
src/views/modules/msg-center/announcement-detail.vue

@@ -3,6 +3,7 @@
     title="查看"
     width="60%"
     :close-on-click-modal="false"
+    @close="closeDialog"
     :visible.sync="visible">
     <div style="margin-left: 20px;margin-right: 20px">
       <e-desc title="基本信息" column="2">
@@ -18,7 +19,7 @@
       </e-desc>
     </div>
     <span slot="footer" class="dialog-footer">
-      <el-button @click="visible = false">返回</el-button>
+      <el-button @click="closeDialog">返回</el-button>
     </span>
   </el-dialog>
 </template>
@@ -57,6 +58,11 @@
             this.dataForm = data.data
           }
         })
+      },
+      // 关闭页面
+      closeDialog () {
+        this.visible = false
+        this.$emit('refreshDataList')
       }
     }
   }

+ 26 - 7
src/views/modules/msg-center/announcement.vue

@@ -59,7 +59,7 @@
         align="center"
         label="是否已读">
         <template slot-scope="scope">
-          <span v-if="scope.row.isRead === 0">未读</span>
+          <span v-if="Number(scope.row.isRead) === 0" style="color: red">未读</span>
           <span v-else>已读</span>
         </template>
       </el-table-column>
@@ -91,7 +91,7 @@
         width="150"
         label="操作">
         <template slot-scope="scope">
-          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.noticeId, false)">查看</el-button>
+          <el-button type="text" size="small" @click="detailHandle(scope.row)">查看</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -105,7 +105,7 @@
       layout="total, sizes, prev, pager, next, jumper">
     </el-pagination>
     <!-- 弹窗,详情 -->
-    <detail v-if="addOrUpdateVisible" ref="addOrUpdate"></detail>
+    <detail v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getAnnouncementList"></detail>
   </div>
 </template>
 
@@ -114,6 +114,7 @@
   import { getAnnouncementList } from '@/api/msg'
   import { getCusList } from '@/api/cus'
   import { downloadUrl } from '@/api/file'
+  import {readNotice} from '@/utils/msg'
   export default {
     name: 'announcement',
     components: {
@@ -123,6 +124,21 @@
       this.optionsState = this.$store.state.common.approveStates
       this.queryData()
     },
+    computed: {
+      // 监听消息ID
+      listenNotice () {
+        return this.$route.params.notice
+      }
+    },
+    watch: {
+      listenNotice: function (notice) {
+        console.log('notice = ' + JSON.stringify(notice))
+        if (!notice) return
+        this.dataForm.noticeId = notice.noticeId
+        this.dataForm.businessId = notice.businessId
+        this.queryData()
+      }
+    },
     data () {
       return {
         addOrUpdateVisible: false,
@@ -146,12 +162,14 @@
       },
       // 获取数据列表
       getAnnouncementList () {
+        this.dataList = []
         this.dataListLoading = true
         let params = {
           'current': this.pageIndex,
           'size': this.pageSize,
           'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
-          'state': this.dataForm.state ? this.dataForm.state : null
+          'state': this.dataForm.state ? this.dataForm.state : null,
+          'businessId': this.dataForm.businessId ? this.dataForm.businessId : null
         }
         getAnnouncementList(params).then(({data}) => {
           if (data && data.code === '200') {
@@ -196,12 +214,13 @@
           }
         })
       },
-      // 新增 / 修改
-      addOrUpdateHandle (id, disable) {
+      // 详情
+      detailHandle (row) {
         this.addOrUpdateVisible = true
         this.$nextTick(() => {
-          this.$refs.addOrUpdate.init(id)
+          this.$refs.addOrUpdate.init(row.noticeId)
         })
+        readNotice(this, row.noticeId)
       }
     }
   }

+ 18 - 1
src/views/modules/msg-center/approve.vue

@@ -141,6 +141,21 @@
       this.optionsState = this.$store.state.common.approveStates
       this.queryData()
     },
+    computed: {
+      // 监听消息ID
+      listenNotice () {
+        return this.$route.params.notice
+      }
+    },
+    watch: {
+      listenNotice: function (notice) {
+        console.log('notice = ' + JSON.stringify(notice))
+        if (!notice) return
+        this.dataForm.noticeId = notice.noticeId
+        this.dataForm.businessId = notice.businessId
+        this.queryData()
+      }
+    },
     data () {
       return {
         addOrUpdateVisible: false,
@@ -195,13 +210,15 @@
       },
       // 获取数据列表
       getApprovalList () {
+        this.dataList = []
         this.dataListLoading = true
         let params = {
           'current': this.pageIndex,
           'size': this.pageSize,
           'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
           'state': this.dataForm.state ? this.dataForm.state : null,
-          'businessType': this.dataForm.businessType ? this.dataForm.businessType : null
+          'businessType': this.dataForm.businessType ? this.dataForm.businessType : null,
+          'businessId': this.dataForm.businessId ? this.dataForm.businessId : null
         }
         getApprovalList(params).then(({data}) => {
           if (data && data.code === '200') {

+ 154 - 0
src/views/modules/msg-center/notice.vue

@@ -0,0 +1,154 @@
+<!-- 订单 -->
+<template>
+  <div class="msg">
+    <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
+      <el-form-item label="消息类型">
+        <el-select v-model="dataForm.type" clearable>
+          <el-option
+            v-for="item in optionsType"
+            :key="item.code"
+            :label="item.value"
+            :value="item.code">
+          </el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="标题">
+        <el-input v-model="dataForm.title" clearable/>
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="queryData()">查询</el-button>
+      </el-form-item>
+    </el-form>
+    <div>
+      <p>未读消息数量:<span style="color: red">{{dataList.length}}</span>(请点击 “ 查询 ” 获取最新列表)</p>
+    </div>
+    <el-table
+      :data="dataList"
+      border
+      v-loading="dataListLoading"
+      @selection-change="selectionChangeHandle"
+      style="width: 100%;">
+      <el-table-column
+        label="序号"
+        type="index"
+        width="50"
+        align="center">
+      </el-table-column>
+      <el-table-column
+        prop="title"
+        header-align="center"
+        align="center"
+        width="300"
+        :show-tooltip-when-overflow="true"
+        label="消息标题">
+      </el-table-column>
+      <el-table-column
+        prop="content"
+        header-align="center"
+        align="center"
+        width="400"
+        :show-tooltip-when-overflow="true"
+        label="消息内容">
+      </el-table-column>
+      <el-table-column
+        prop="type"
+        header-align="center"
+        align="center"
+        label="消息类型">
+        <template slot-scope="scope">
+          <span>{{scope.row.type? optionsType[scope.row.type].value:'' }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column
+        prop="publisherId"
+        header-align="center"
+        align="center"
+        label="发布人">
+      </el-table-column>
+      <el-table-column
+        prop="createTime"
+        header-align="center"
+        align="center"
+        width="160"
+        :show-tooltip-when-overflow="true"
+        label="发布时间">
+      </el-table-column>
+      <el-table-column
+        fixed="right"
+        header-align="center"
+        align="center"
+        width="150"
+        label="操作">
+        <template slot-scope="scope">
+          <el-button type="text" size="small" @click="detailHandle(scope.row)">查看</el-button>
+          <el-button type="text" size="small" @click="checkHandle(scope.row.noticeId)">设为已读</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+  import {readNotice, routeMsg} from '@/utils/msg'
+  export default {
+    name: 'notice',
+    created () {
+      this.queryData()
+    },
+    data () {
+      return {
+        checkedVisible: false,
+        dataForm: {},
+        dataList: [],
+        dataListLoading: false,
+        dataListSelections: [],
+        optionsType: [
+          {
+            code: null, value: '全部'
+          },
+          {
+            code: 1, value: '公告消息'
+          },
+          {
+            code: 2, value: '审批消息'
+          }
+        ]
+      }
+    },
+    methods: {
+      // 查询
+      queryData () {
+        this.getNoticeList()
+      },
+      // 获取数据列表
+      getNoticeList () {
+        let msg = Object.assign([], this.$store.state.common.msgCollection)
+        if (!msg) return
+        this.dataList = msg
+        if (this.dataForm.title) {
+          this.dataList = this.dataList.filter(item => item.title && item.title.indexOf(this.dataForm.title) !== -1)
+        }
+        if (this.dataForm.type) {
+          this.dataList = this.dataList.filter(item => item.type && item.type === this.dataForm.type)
+        }
+      },
+      // 多选
+      selectionChangeHandle (val) {
+        this.dataListSelections = val
+      },
+      // 设为已读
+      checkHandle (noticeId) {
+        readNotice(this, noticeId)
+        this.getNoticeList()
+      },
+      // 查看消息
+      detailHandle (row) {
+        routeMsg(this, row)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 12 - 13
src/views/modules/production/monitoring-details.vue

@@ -1,8 +1,8 @@
 <template>
   <div class="production">
-    <el-dialog title="生产监控详情" 
-      width="70%" 
-      :close-on-click-modal="false" 
+    <el-dialog title="生产监控详情"
+      width="70%"
+      :close-on-click-modal="false"
       :visible.sync="visible">
       <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
         <el-row class="my-row">
@@ -123,9 +123,9 @@
           info: null,
           open: (type, info) => {
             if (info.meta.workTypeId && info.meta.prop !== 'end') {
-              this.getOperatorList(info.meta.workTypeId);
+              this.getOperatorList(info.meta.workTypeId)
             }
-            
+
             const conf = this.drawerConf
             conf.visible = true
             conf.type = type
@@ -140,7 +140,6 @@
               this.$set(this.nodeSetting, 'type', info.meta.type)
               this.$set(this.nodeSetting, 'workTypeId', info.meta.workTypeId)
               this.$set(this.nodeSetting, 'operatorIds', info.meta.operatorIds)
-              
             } else {
               conf.title = '连线'
               if (this.$refs.linkSetting) this.$refs.linkSetting.resetFields()
@@ -282,7 +281,7 @@
           mouldName: [{required: true, message: '请输入模板名称', trigger: 'blur'}]
         },
         dataRule1: {
-           operatorIds: [{ required: true, message: '操作人员不能为空', trigger: 'change' }]
+          operatorIds: [{ required: true, message: '操作人员不能为空', trigger: 'change' }]
         }
       }
     },
@@ -307,7 +306,7 @@
               await this.dataForm.proTechnologyStepList.forEach((v, i) => {
                 // eslint-disable-next-line no-unused-vars
                 const sortNo = []
-                
+
                 const datas = v.sort((a, b) => Number(a['sortNo']) - Number(b['sortNo']))
                 let length = datas.length
                 datas.forEach((item, index) => {
@@ -348,7 +347,7 @@
                   }
                 })
               })
-              
+
               this.$nextTick(() => {
                 setTimeout(() => {
                   this.nodeList = datanode
@@ -369,16 +368,16 @@
             if (this.drawerConf.type === drawerType.node) {
               if (!conf.info.meta) conf.info.meta = {}
               Object.keys(this.nodeSetting).forEach(key => {
-                if (key == 'operatorIds') {
-                  let idList = this.nodeSetting[key];
-                  let nameList = [];
+                if (key === 'operatorIds') {
+                  let idList = this.nodeSetting[key]
+                  let nameList = []
                   idList.forEach(id => {
                     let name = this.operatorList.find(item => {
                       return item.userId === id
                     }).name
                     nameList.push(name)
                   })
-                 
+
                   this.$set(conf.info.meta, 'desc', nameList.join(','))
                 }
                 this.$set(conf.info.meta, key, this.nodeSetting[key])

+ 13 - 14
src/views/modules/production/recording-details.vue

@@ -1,9 +1,9 @@
 
 <template>
   <div class="production">
-    <el-dialog title="生产记录详情" 
-      width="70%" 
-      :close-on-click-modal="false" 
+    <el-dialog title="生产记录详情"
+      width="70%"
+      :close-on-click-modal="false"
       :visible.sync="visible">
       <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
         <el-row class="my-row" style="height: 350px; background-color: #efefef;">
@@ -117,9 +117,9 @@
           info: null,
           open: (type, info) => {
             if (info.meta.workTypeId && info.meta.prop !== 'end') {
-              this.getOperatorList(info.meta.workTypeId);
+              this.getOperatorList(info.meta.workTypeId)
             }
-            
+
             const conf = this.drawerConf
             conf.visible = true
             conf.type = type
@@ -134,7 +134,6 @@
               this.$set(this.nodeSetting, 'type', info.meta.type)
               this.$set(this.nodeSetting, 'workTypeId', info.meta.workTypeId)
               this.$set(this.nodeSetting, 'operatorIds', info.meta.operatorIds)
-              
             } else {
               conf.title = '连线'
               if (this.$refs.linkSetting) this.$refs.linkSetting.resetFields()
@@ -276,7 +275,7 @@
           mouldName: [{required: true, message: '请输入模板名称', trigger: 'blur'}]
         },
         dataRule1: {
-           operatorIds: [{ required: true, message: '操作人员不能为空', trigger: 'change' }]
+          operatorIds: [{ required: true, message: '操作人员不能为空', trigger: 'change' }]
         }
       }
     },
@@ -287,7 +286,7 @@
         this.display = disable
         this.nodeList = []
         this.linkList = []
-        this.mouldId = id;
+        this.mouldId = id
 
         await getMonitoringDetail(id).then(async ({data}) => {
           if (data && data.code === '200') {
@@ -300,7 +299,7 @@
               await this.dataForm.proTechnologyStepList.forEach((v, i) => {
                 // eslint-disable-next-line no-unused-vars
                 const sortNo = []
-                
+
                 const datas = v.sort((a, b) => Number(a['sortNo']) - Number(b['sortNo']))
                 let length = datas.length
                 datas.forEach((item, index) => {
@@ -341,7 +340,7 @@
                   }
                 })
               })
-              
+
               this.$nextTick(() => {
                 setTimeout(() => {
                   this.nodeList = datanode
@@ -362,16 +361,16 @@
             if (this.drawerConf.type === drawerType.node) {
               if (!conf.info.meta) conf.info.meta = {}
               Object.keys(this.nodeSetting).forEach(key => {
-                if (key == 'operatorIds') {
-                  let idList = this.nodeSetting[key];
-                  let nameList = [];
+                if (key === 'operatorIds') {
+                  let idList = this.nodeSetting[key]
+                  let nameList = []
                   idList.forEach(id => {
                     let name = this.operatorList.find(item => {
                       return item.userId === id
                     }).name
                     nameList.push(name)
                   })
-                 
+
                   this.$set(conf.info.meta, 'desc', nameList.join(','))
                 }
                 this.$set(conf.info.meta, key, this.nodeSetting[key])

+ 25 - 25
src/views/modules/production/scheduling-details.vue

@@ -1,8 +1,8 @@
 <template>
   <div class="production">
-    <el-dialog title="排产" 
-      width="70%" 
-      :close-on-click-modal="false" 
+    <el-dialog title="排产"
+      width="70%"
+      :close-on-click-modal="false"
       :visible.sync="visible">
       <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
         <el-row class="my-row" style="height: 350px; background-color: #efefef;">
@@ -89,7 +89,7 @@
 </template>
 
 <script>
-  import { getProduct, getWorkType, getStepId } from '@/api/crafts'
+  import { getStepId } from '@/api/crafts'
   import { getInfo, plan } from '@/api/production'
   import { workTypeMasterList } from '@/api/worktype'
   import { uuid } from '../common/vue-super-flow/utils'
@@ -115,9 +115,9 @@
           info: null,
           open: (type, info) => {
             if (info.meta.workTypeId && info.meta.prop !== 'end') {
-              this.getOperatorList(info.meta.workTypeId);
+              this.getOperatorList(info.meta.workTypeId)
             }
-            
+
             const conf = this.drawerConf
             conf.visible = true
             conf.type = type
@@ -132,7 +132,6 @@
               this.$set(this.nodeSetting, 'type', info.meta.type)
               this.$set(this.nodeSetting, 'workTypeId', info.meta.workTypeId)
               this.$set(this.nodeSetting, 'operatorIds', info.meta.operatorIds)
-              
             } else {
               conf.title = '连线'
               if (this.$refs.linkSetting) this.$refs.linkSetting.resetFields()
@@ -275,7 +274,7 @@
         datas: {},
         dataRule: {},
         dataRule1: {
-           operatorIds: [{ required: true, message: '操作人员不能为空', trigger: 'change' }]
+          operatorIds: [{ required: true, message: '操作人员不能为空', trigger: 'change' }]
         }
       }
     },
@@ -285,11 +284,11 @@
         this.visible = true
         this.nodeList = []
         this.linkList = []
-        this.productionId = id;
+        this.productionId = id
 
         await getInfo(id).then(async ({data}) => {
           if (data && data.code === '200') {
-            this.dataForm = {...this.dataForm, proTechnologyStepLists :data.data}
+            this.dataForm = {...this.dataForm, proTechnologyStepLists: data.data}
             // 图纸
             if (this.dataForm.proTechnologyStepLists) {
               const dataline = []
@@ -331,7 +330,7 @@
                   }
                 })
               })
-              
+
               this.$nextTick(() => {
                 setTimeout(() => {
                   this.nodeList = datanode
@@ -343,12 +342,12 @@
         })
       },
       // 按工种ID查询操作人列表
-      getOperatorList(workTypeId) {
+      getOperatorList (workTypeId) {
         workTypeMasterList(workTypeId).then(({data}) => {
           if (data && data.code === '200') {
             this.operatorList = []
             data.data.forEach(item => {
-              this.operatorList.push(item);
+              this.operatorList.push(item)
             })
           }
         })
@@ -363,16 +362,16 @@
             if (this.drawerConf.type === drawerType.node) {
               if (!conf.info.meta) conf.info.meta = {}
               Object.keys(this.nodeSetting).forEach(key => {
-                if (key == 'operatorIds') {
-                  let idList = this.nodeSetting[key];
-                  let nameList = [];
+                if (key === 'operatorIds') {
+                  let idList = this.nodeSetting[key]
+                  let nameList = []
                   idList.forEach(id => {
                     let name = this.operatorList.find(item => {
                       return item.userId === id
                     }).name
                     nameList.push(name)
                   })
-                 
+
                   this.$set(conf.info.meta, 'desc', nameList.join(','))
                 }
                 this.$set(conf.info.meta, key, this.nodeSetting[key])
@@ -400,14 +399,15 @@
         }
 
         this.$refs['dataForm'].validate((valid) => {
-          if(valid) {
+          if (valid) {
+            // eslint-disable-next-line no-unused-vars
             const proTechnologyStepLists = []
-         
+
             let productionPlanSteps = []
             for (let index = 0; index < this.datas.nodeList.length; index++) {
-              const v = this.datas.nodeList[index];
-               let tmp = v.meta.operatorIds || []
-              if(v.meta.prop !== 'end' && tmp.length == 0){
+              const v = this.datas.nodeList[index]
+              let tmp = v.meta.operatorIds || []
+              if (v.meta.prop !== 'end' && tmp.length === 0) {
                 this.$message.error(`请选择 ${v.meta.name} 的操作人员!`)
                 return
               }
@@ -420,7 +420,7 @@
             }
             plan(submitData).then(({data}) => {
               if (data && data.code === '200') {
-                  this.$message({
+                this.$message({
                   message: '操作成功',
                   type: 'success',
                   duration: 1500,
@@ -430,7 +430,7 @@
                   }
                 })
               } else {
-                 this.$message.error(data.msg)
+                this.$message.error(data.msg)
               }
             })
           }
@@ -498,7 +498,7 @@
             }
           }
         })
-      },
+      }
     }
   }
 </script>

+ 35 - 35
src/views/modules/production/scheduling-mould-details.vue

@@ -1,8 +1,8 @@
 <template>
   <div class="production">
-    <el-dialog title="排产模板详情" 
-      width="70%" 
-      :close-on-click-modal="false" 
+    <el-dialog title="排产模板详情"
+      width="70%"
+      :close-on-click-modal="false"
       :visible.sync="visible">
       <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
         <el-row class="my-row">
@@ -143,9 +143,9 @@
           info: null,
           open: (type, info) => {
             if (info.meta.workTypeId && info.meta.prop !== 'end') {
-              this.getOperatorList(info.meta.workTypeId);
+              this.getOperatorList(info.meta.workTypeId)
             }
-            
+
             const conf = this.drawerConf
             conf.visible = true
             conf.type = type
@@ -160,7 +160,6 @@
               this.$set(this.nodeSetting, 'type', info.meta.type)
               this.$set(this.nodeSetting, 'workTypeId', info.meta.workTypeId)
               this.$set(this.nodeSetting, 'operatorIds', info.meta.operatorIds)
-              
             } else {
               conf.title = '连线'
               if (this.$refs.linkSetting) this.$refs.linkSetting.resetFields()
@@ -301,15 +300,15 @@
           mouldName: [{required: true, message: '请输入模板名称', trigger: 'blur'}]
         },
         dataRule1: {
-           operatorIds: [{ required: true, message: '操作人员不能为空', trigger: 'change' }]
+          operatorIds: [{ required: true, message: '操作人员不能为空', trigger: 'change' }]
         }
       }
     },
     methods: {
       // 初始化产品名称列表
-      async initProductList() {
+      async initProductList () {
         getProductList().then(({data}) => {
-          if(data && data.code === '200') {
+          if (data && data.code === '200') {
             data.data.forEach(item => {
               this.productList.push(item)
             })
@@ -322,15 +321,15 @@
         this.display = disable
         this.nodeList = []
         this.linkList = []
-        this.mouldId = id;
-        if(!disable){
-          await this.initProductList();
+        this.mouldId = id
+        if (!disable) {
+          await this.initProductList()
         }
 
         await getMouldDetail(id).then(async ({data}) => {
           if (data && data.code === '200') {
             this.dataForm = data.data
-            
+
             // 图纸
             if (this.dataForm.proTechnologyStepList) {
               const dataline = []
@@ -374,7 +373,7 @@
                   }
                 })
               })
-              
+
               this.$nextTick(() => {
                 setTimeout(() => {
                   this.nodeList = datanode
@@ -385,11 +384,11 @@
           }
         })
       },
-      //根据产品ID查询步骤详情
-      async productChange(productId) {
+      // 根据产品ID查询步骤详情
+      async productChange (productId) {
         getMouldDetailByProductId(productId).then(async ({data}) => {
-           if (data && data.code === '200') {
-            this.dataForm = {...this.dataForm, proTechnologyStepLists :data.data}
+          if (data && data.code === '200') {
+            this.dataForm = {...this.dataForm, proTechnologyStepLists: data.data}
             // 图纸
             if (this.dataForm.proTechnologyStepLists) {
               const dataline = []
@@ -431,7 +430,7 @@
                   }
                 })
               })
-              
+
               this.$nextTick(() => {
                 setTimeout(() => {
                   this.nodeList = datanode
@@ -443,12 +442,12 @@
         })
       },
       // 按工种ID查询操作人列表
-      getOperatorList(workTypeId) {
+      getOperatorList (workTypeId) {
         workTypeMasterList(workTypeId).then(({data}) => {
           if (data && data.code === '200') {
             this.operatorList = []
             data.data.forEach(item => {
-              this.operatorList.push(item);
+              this.operatorList.push(item)
             })
           }
         })
@@ -463,16 +462,16 @@
             if (this.drawerConf.type === drawerType.node) {
               if (!conf.info.meta) conf.info.meta = {}
               Object.keys(this.nodeSetting).forEach(key => {
-                if (key == 'operatorIds') {
-                  let idList = this.nodeSetting[key];
-                  let nameList = [];
+                if (key === 'operatorIds') {
+                  let idList = this.nodeSetting[key]
+                  let nameList = []
                   idList.forEach(id => {
                     let name = this.operatorList.find(item => {
                       return item.userId === id
                     }).name
                     nameList.push(name)
                   })
-                 
+
                   this.$set(conf.info.meta, 'desc', nameList.join(','))
                 }
                 this.$set(conf.info.meta, key, this.nodeSetting[key])
@@ -500,14 +499,15 @@
         }
 
         this.$refs['dataForm'].validate((valid) => {
-          if(valid) {
+          if (valid) {
+            // eslint-disable-next-line no-unused-vars
             const proTechnologyStepLists = []
-         
+
             let productionPlanSteps = []
             for (let index = 0; index < this.datas.nodeList.length; index++) {
-              const v = this.datas.nodeList[index];
-               let tmp = v.meta.operatorIds || []
-              if(v.meta.prop !== 'end' && tmp.length == 0){
+              const v = this.datas.nodeList[index]
+              let tmp = v.meta.operatorIds || []
+              if (v.meta.prop !== 'end' && tmp.length === 0) {
                 this.$message.error(`请选择 ${v.meta.name} 的操作人员!`)
                 return
               }
@@ -520,11 +520,11 @@
               stepList: productionPlanSteps
             }
 
-            if(this.mouldId === 0) {
+            if (this.mouldId === 0) {
               // 新增
               saveProdProductionMould(submitData).then(({data}) => {
                 if (data && data.code === '200') {
-                    this.$message({
+                  this.$message({
                     message: '操作成功',
                     type: 'success',
                     duration: 1500,
@@ -539,10 +539,10 @@
               })
             } else {
               // 更新
-              submitData.mouldId = this.mouldId;
+              submitData.mouldId = this.mouldId
               updateProdProductionMould(submitData).then(({data}) => {
                 if (data && data.code === '200') {
-                    this.$message({
+                  this.$message({
                     message: '操作成功',
                     type: 'success',
                     duration: 1500,
@@ -621,7 +621,7 @@
             }
           }
         })
-      },
+      }
     }
   }
 </script>

+ 2 - 1
src/views/modules/tech/ctafts-add-or-detail.vue

@@ -584,7 +584,8 @@
               'sortNo': 0,
               'stepId': data.id,
               'stepName': data.meta.name,
-              'workTypeId':  v.meta.prop === 'end' ? '4' : (data.meta.workTypeId || null),
+              // eslint-disable-next-line no-undef
+              'workTypeId': v.meta.prop === 'end' ? '4' : (data.meta.workTypeId || null),
               'type': data.meta.type || null,
               'coordinate': data.coordinate.join(',')
             }])

+ 5 - 0
yarn.lock

@@ -2611,6 +2611,11 @@ core-js@^2.4.0, core-js@^2.5.0:
   resolved "https://registry.nlark.com/core-js/download/core-js-2.6.12.tgz?cache=0&sync_timestamp=1622879421799&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fcore-js%2Fdownload%2Fcore-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
   integrity sha1-2TM9+nsGXjR8xWgiGdb2kIWcwuw=
 
+core-js@^3.12.1:
+  version "3.19.2"
+  resolved "https://registry.npmmirror.com/core-js/download/core-js-3.19.2.tgz#ae216d7f4f7e924d9a2e3ff1e4b1940220f9157b"
+  integrity sha512-ciYCResnLIATSsXuXnIOH4CbdfgV+H1Ltg16hJFN7/v6OxqnFr/IFGeLacaZ+fHLAm0TBbXwNK9/DNBzBUrO/g==
+
 core-js@^3.6.0, core-js@^3.8.3:
   version "3.19.1"
   resolved "https://registry.npmmirror.com/core-js/download/core-js-3.19.1.tgz#f6f173cae23e73a7d88fa23b6e9da329276c6641"