瀏覽代碼

消息推送修改

chrislee 2 月之前
父節點
當前提交
4dc12c0881

+ 62 - 0
src/utils/msg.js

@@ -25,6 +25,68 @@ export function routeMsg (that, row) {
   }
 }
 
+/**
+ * 通过路由跳转页面
+ */
+export function routeMsgs (that, row) {
+  if (!row || !row.route) {
+    console.log('row = ', row)
+    that.$message && that.$message.warning && that.$message.warning('消息未配置跳转地址')
+    return
+  }
+
+  // 携带的消息参数(列表页可通过 $route.params.notice 或 $route.query 获取)
+  const notice = {
+    noticeId: row.noticeId,
+    businessId: row.businessId
+  }
+
+  // 展平路由用于匹配名称或路径
+  const flattenRoutes = (routes, acc = []) => {
+    if (!routes) return acc
+    routes.forEach(r => {
+      acc.push(r)
+      if (r.children && r.children.length) flattenRoutes(r.children, acc)
+    })
+    return acc
+  }
+
+  const routesConfig = (that.$router && that.$router.options && that.$router.options.routes) || []
+  let allRoutes = flattenRoutes(routesConfig)
+
+  // 合并动态菜单路由(运行时注入的 children 会存进 sessionStorage.dynamicMenuRoutes)
+  try {
+    const dynamicMenuRoutes = JSON.parse(sessionStorage.getItem('dynamicMenuRoutes') || '[]')
+    allRoutes = allRoutes.concat(flattenRoutes(dynamicMenuRoutes))
+  } catch (e) {}
+
+  // 兼容较新版本的 vue-router(如支持 getRoutes)
+  if (that.$router && typeof that.$router.getRoutes === 'function') {
+    try {
+      allRoutes = allRoutes.concat(that.$router.getRoutes())
+    } catch (e) {}
+  }
+  const hasName = allRoutes.some(r => r && r.name === row.route)
+  const hasPath = allRoutes.some(r => r && r.path === row.route)
+
+  // 优先按路由名跳转(可传 params),否则按路径跳转(用 query 兜底)
+  if (hasName) {
+    that.$router.push({ name: row.route, params: { notice } }).catch(() => {})
+    return
+  }
+  if (hasPath) {
+    that.$router.push({ path: row.route, query: { ...notice } }).catch(() => {})
+    return
+  }
+
+  // 未匹配到配置时的兜底:无斜杠则作为 name,有斜杠当作 path
+  if (row.path.indexOf('/') === -1) {
+    that.$router.push({ name: row.route, params: { notice } }).catch(() => {})
+  } else {
+    that.$router.push({ path: row.route, query: { ...notice } }).catch(() => {})
+  }
+}
+
 /**
  * 发送通知已读反馈
  */

+ 2 - 1
src/views/common/msg.vue

@@ -17,6 +17,7 @@ export default {
     }
   },
   mounted() {
+    // 添加一条测试消息
     // this.test()
   },
   computed: {
@@ -33,7 +34,7 @@ export default {
     listenWebsocket: function (data) {
       if (!data) return
       let json = parseJsonStr(data)
-      // console.log('json = ' + JSON.stringify(json))
+      console.log('json = ' + JSON.stringify(json))
       if (data.indexOf('{"approved') > -1) {
         readNotices(this, json['approved'])
         return

+ 307 - 0
src/views/modules/msg-center/approve-list.vue

@@ -0,0 +1,307 @@
+<!-- 任务单 -->
+<template>
+  <div class="order">
+    <template v-if="!addOrUpdateVisible">
+      <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
+        <el-form-item label="业务类型">
+          <el-select v-model="dataForm.businessType" placeholder="请选择">
+            <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-select v-model="dataForm.state" placeholder="请选择">
+            <el-option v-for="item in optionsState" :key="item.code" :label="item.value" :value="item.code">
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="申请日期">
+          <el-date-picker v-model="dataForm.createTime" value-format="yyyy-MM-dd" type="date">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="queryData()">查询</el-button>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="batchApprove()">批量审批</el-button>
+        </el-form-item>
+      </el-form>
+      <el-tabs v-model="dataForm.type" @tab-click="queryData">
+        <el-tab-pane label="待审批" name="1"></el-tab-pane>
+        <el-tab-pane label="审批历史" name="2"></el-tab-pane>
+        <el-tab-pane label="我的申请" name="3"></el-tab-pane>
+      </el-tabs>
+      <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
+        style="width: 100%;">
+        <el-table-column type="selection" :selectable="selected" width="55">
+        </el-table-column>
+        <el-table-column label="序号" type="index" width="50" align="center">
+        </el-table-column>
+        <el-table-column prop="businessTypeName" header-align="center" align="center" min-width="180" label="流程类别">
+        </el-table-column>
+        <el-table-column prop="createTime" header-align="center" align="center" min-width="160"
+          :show-overflow-tooltip="true" label="申请时间">
+        </el-table-column>
+        <el-table-column prop="updateTime" header-align="center" align="center" min-width="160"
+          :show-overflow-tooltip="true" label="更新时间">
+        </el-table-column>
+        <el-table-column prop="state" header-align="center" align="center" min-width="100" label="状态">
+          <template slot-scope="scope">
+            <span>{{(optionsState.find(t => t.code === scope.row.state.toString())).value}}</span>
+          </template>
+        </el-table-column>
+        <el-table-column prop="creatorName" header-align="center" align="center" min-width="120" label="申请人">
+        </el-table-column>
+        <el-table-column prop="orgName" header-align="center" align="center" min-width="140"
+          :show-tooltip-when-overflow="true" label="申请部门">
+        </el-table-column>
+        <el-table-column fixed="right" header-align="center" align="center" width="80" label="操作">
+          <template slot-scope="scope">
+            <el-button v-if="isAuth('business:approval:approval') && Number(dataForm.type) === 1" type="text"
+              size="small" @click="addOrUpdateHandle(scope.row)">处理</el-button>
+            <el-button v-if="isAuth('business:approval:info') && Number(dataForm.type) !== 1" type="text" size="small"
+              @click="detailHandle(scope.row)">查看</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
+        :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
+        layout="total, sizes, prev, pager, next, jumper">
+      </el-pagination>
+    </template>
+    <!-- 弹窗, 新增 / 修改 -->
+    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getApprovalList" @onChose="onChose" />
+    <el-dialog width="1000px" :visible.sync="approveDialogVisible">
+      <approve-component-batch ref="approve" @approveFinished="approveChose" />
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import AddOrUpdate from './approve-add-or-update'
+import { getApprovalList } from '@/api/msg'
+import { readNotices } from '@/utils/msg'
+import { getCusList } from '@/api/cus'
+import { checkStr } from '@/api/util'
+import ApproveComponentBatch from '../common/approve-component-batch'
+export default {
+  name: 'approve-list',
+  components: {
+    // Detail,
+    AddOrUpdate,
+    ApproveComponentBatch
+  },
+  created() {
+    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 {
+      approveDialogVisible: false,
+      addOrUpdateVisible: false,
+      dataForm: {
+        type: '1'
+      },
+      dataList: [],
+      pageIndex: 1,
+      pageSize: 10,
+      totalPage: 0,
+      dataListLoading: false,
+      dataListSelections: [],
+      optionsState: [],
+      optionsType: [
+        {
+          code: null, value: '全部'
+        },
+        {
+          code: 'warehouse_flow_in', value: '入库申请'
+        },
+        {
+          code: 'warehouse_flow_out', value: '出库申请'
+        },
+        {
+          code: 'contract_review', value: '合同评审'
+        },
+        {
+          code: 'sale_order_flow', value: '任务单评审'
+        },
+        {
+          code: 'sale_purchase_flow', value: '采购申请'
+        },
+        {
+          code: 'wh_template_record_flow', value: '模板出库'
+        },
+        {
+          code: 'pro_technology_flow', value: '工艺评审'
+        },
+        {
+          code: 'pro_product_flow', value: '物料评审'
+        },
+        {
+          code: 'wh_inventory_record_flow', value: '盘点评审'
+        },
+        {
+          code: 'supplier_review_flow', value: '供应商评审'
+        },
+        {
+          code: 'submit_expense_flow', value: '报销审批'
+        },
+        {
+          code: 'pur_commission_flow', value: '委外审批'
+        },
+        {
+          code: 'work_damage_flow', value: '报损审批'
+        },
+        {
+          code: 'cus_communicate_flow', value: '沟通审批'
+        },
+        {
+          code: 'project_estimate', value: '项目评估'
+        },
+        {
+          code: 'first_identify_flow', value: '首件鉴定'
+        },
+        {
+          code: 'nonconforming_hear_flow', value: '不合格品审理'
+        }
+      ],
+      optionsCustomer: []
+    }
+  },
+  methods: {
+    onChose() {
+      this.addOrUpdateVisible = false
+    },
+    // 查询
+    queryData() {
+      this.pageIndex = 1
+      this.getApprovalList()
+    },
+    // 获取数据列表
+    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,
+        'type': this.dataForm.type ? Number(this.dataForm.type) : 1,
+        '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') {
+          this.dataList = data.data.records
+          this.totalPage = Number(data.data.total)
+        } else {
+          this.dataList = []
+          this.totalPage = 0
+        }
+        this.dataListLoading = false
+      })
+    },
+    // 每页数
+    sizeChangeHandle(val) {
+      this.pageSize = val
+      this.pageIndex = 1
+      this.getApprovalList()
+    },
+    // 当前页
+    currentChangeHandle(val) {
+      this.pageIndex = val
+      this.getApprovalList()
+    },
+    // 多选
+    selectionChangeHandle(val) {
+      this.dataListSelections = val
+    },
+    // 远程方法:获取客户列表
+    async remoteCustomer(query) {
+      if (!query) {
+        query = ''
+      }
+      await getCusList({ 'customerName': query }).then(({ data }) => {
+        if (data && data.code === '200') {
+          this.optionsCustomer = []
+          data.data.records.forEach((item) => {
+            this.optionsCustomer.push({
+              code: item.customerId,
+              value: item.customerName
+            })
+          })
+        }
+      })
+    },
+    checkUser(row) {
+      let currentUser = this.$store.state.user.id
+      return checkStr(currentUser, row.currentApprover)
+    },
+    // 新增 / 修改
+    addOrUpdateHandle(row) {
+      this.addOrUpdateVisible = true
+      // 已查看
+      if (row.noticeIds) {
+        readNotices(this, row.noticeIds)
+      }
+      this.$nextTick(() => {
+        this.$refs.addOrUpdate.init(row.businessType, row.businessId)
+      })
+    },
+    // 详情
+    detailHandle(row) {
+      this.addOrUpdateVisible = true
+      this.$nextTick(() => {
+        this.$refs.addOrUpdate.init(row.businessType, row.businessId, true)
+      })
+      // 已查看
+      if (row.noticeIds) {
+        readNotices(this, row.noticeIds)
+      }
+    },
+    batchApprove() {
+      if (this.dataListSelections && this.dataListSelections.length > 0) {
+        this.approveDialogVisible = true
+        let businessIds = this.dataListSelections.map(item => item.businessId)
+
+        this.$nextTick(() => {
+          this.$refs.approve.init(this.dataListSelections[0].businessType, businessIds)
+        })
+      } else {
+        this.$message.warning('请选择后再提交审批!')
+      }
+    },
+    approveChose() {
+      this.approveDialogVisible = false
+      this.queryData()
+    },
+    selected(row, index) {
+      if (this.isAuth('business:approval:approval') && Number(row.state) !== 3 && Number(row.state) !== 0 && this.checkUser(row)) {
+        return true
+      }
+      return false
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.batch-dialog-class {
+  min-width: 1000px;
+}
+</style>

+ 237 - 301
src/views/modules/msg-center/approve.vue

@@ -4,40 +4,25 @@
     <template v-if="!addOrUpdateVisible">
       <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
         <el-form-item label="业务类型">
-          <el-select
-            v-model="dataForm.businessType"
-            placeholder="请选择">
-            <el-option
-              v-for="item in optionsType"
-              :key="item.code"
-              :label="item.value"
-              :value="item.code">
+          <el-select v-model="dataForm.businessType" placeholder="请选择">
+            <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-select
-            v-model="dataForm.state"
-            placeholder="请选择">
-          <el-option
-            v-for="item in optionsState"
-            :key="item.code"
-            :label="item.value"
-            :value="item.code">
-          </el-option>
-        </el-select>
+          <el-select v-model="dataForm.state" placeholder="请选择">
+            <el-option v-for="item in optionsState" :key="item.code" :label="item.value" :value="item.code">
+            </el-option>
+          </el-select>
         </el-form-item>
         <el-form-item label="申请日期">
-          <el-date-picker
-            v-model="dataForm.createTime"
-            value-format="yyyy-MM-dd"
-            type="date">
+          <el-date-picker v-model="dataForm.createTime" value-format="yyyy-MM-dd" type="date">
           </el-date-picker>
         </el-form-item>
         <el-form-item>
           <el-button @click="queryData()">查询</el-button>
         </el-form-item>
-         <el-form-item>
+        <el-form-item>
           <el-button @click="batchApprove()">批量审批</el-button>
         </el-form-item>
       </el-form>
@@ -46,95 +31,46 @@
         <el-tab-pane label="审批历史" name="2"></el-tab-pane>
         <el-tab-pane label="我的申请" name="3"></el-tab-pane>
       </el-tabs>
-      <el-table
-        :data="dataList"
-        border
-        v-loading="dataListLoading"
-        @selection-change="selectionChangeHandle"
+      <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
         style="width: 100%;">
-         <el-table-column
-          type="selection"
-          :selectable="selected"
-          width="55">
+        <el-table-column type="selection" :selectable="selected" width="55">
         </el-table-column>
-        <el-table-column
-          label="序号"
-          type="index"
-          width="50"
-          align="center">
+        <el-table-column label="序号" type="index" width="50" align="center">
         </el-table-column>
-        <el-table-column
-          prop="businessTypeName"
-          header-align="center"
-          align="center"
-          min-width="180"
-          label="流程类别">
+        <el-table-column prop="businessTypeName" header-align="center" align="center" min-width="180" label="流程类别">
         </el-table-column>
-        <el-table-column
-          prop="createTime"
-          header-align="center"
-          align="center"
-          min-width="160"
-          :show-overflow-tooltip="true"
-          label="申请时间">
+        <el-table-column prop="createTime" header-align="center" align="center" min-width="160"
+          :show-overflow-tooltip="true" label="申请时间">
         </el-table-column>
-        <el-table-column
-          prop="updateTime"
-          header-align="center"
-          align="center"
-          min-width="160"
-          :show-overflow-tooltip="true"
-          label="更新时间">
+        <el-table-column prop="updateTime" header-align="center" align="center" min-width="160"
+          :show-overflow-tooltip="true" label="更新时间">
         </el-table-column>
-        <el-table-column
-          prop="state"
-          header-align="center"
-          align="center"
-          min-width="100"
-          label="状态">
+        <el-table-column prop="state" header-align="center" align="center" min-width="100" label="状态">
           <template slot-scope="scope">
-            <span>{{(optionsState.find(t=>t.code === scope.row.state.toString())).value}}</span>
+            <span>{{(optionsState.find(t => t.code === scope.row.state.toString())).value}}</span>
           </template>
         </el-table-column>
-        <el-table-column
-          prop="creatorName"
-          header-align="center"
-          align="center"
-          min-width="120"
-          label="申请人">
+        <el-table-column prop="creatorName" header-align="center" align="center" min-width="120" label="申请人">
         </el-table-column>
-        <el-table-column
-          prop="orgName"
-          header-align="center"
-          align="center"
-          min-width="140"
-          :show-tooltip-when-overflow="true"
-          label="申请部门">
+        <el-table-column prop="orgName" header-align="center" align="center" min-width="140"
+          :show-tooltip-when-overflow="true" label="申请部门">
         </el-table-column>
-        <el-table-column
-          fixed="right"
-          header-align="center"
-          align="center"
-          width="80"
-          label="操作">
+        <el-table-column fixed="right" header-align="center" align="center" width="80" label="操作">
           <template slot-scope="scope">
-            <el-button v-if="isAuth('business:approval:approval') && Number(dataForm.type) === 1" type="text" size="small" @click="addOrUpdateHandle(scope.row)">处理</el-button>
-            <el-button v-if="isAuth('business:approval:info')  && Number(dataForm.type) !== 1" type="text" size="small" @click="detailHandle(scope.row)">查看</el-button>
+            <el-button v-if="isAuth('business:approval:approval') && Number(dataForm.type) === 1" type="text"
+              size="small" @click="addOrUpdateHandle(scope.row)">处理</el-button>
+            <el-button v-if="isAuth('business:approval:info') && Number(dataForm.type) !== 1" type="text" size="small"
+              @click="detailHandle(scope.row)">查看</el-button>
           </template>
         </el-table-column>
       </el-table>
-      <el-pagination
-        @size-change="sizeChangeHandle"
-        @current-change="currentChangeHandle"
-        :current-page="pageIndex"
-        :page-sizes="[10, 20, 50, 100]"
-        :page-size="pageSize"
-        :total="totalPage"
+      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
+        :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
         layout="total, sizes, prev, pager, next, jumper">
       </el-pagination>
     </template>
     <!-- 弹窗, 新增 / 修改 -->
-    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getApprovalList" @onChose="onChose"/>
+    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getApprovalList" @onChose="onChose" />
     <el-dialog width="1000px" :visible.sync="approveDialogVisible">
       <approve-component-batch ref="approve" @approveFinished="approveChose" />
     </el-dialog>
@@ -142,230 +78,230 @@
 </template>
 
 <script>
-  import AddOrUpdate from './approve-add-or-update'
-  import { getApprovalList } from '@/api/msg'
-  import { readNotices } from '@/utils/msg'
-  import { getCusList } from '@/api/cus'
-  import { checkStr } from '@/api/util'
-  import ApproveComponentBatch from '../common/approve-component-batch'
-  export default {
-    name: 'order',
-    components: {
-      // Detail,
-      AddOrUpdate,
-      ApproveComponentBatch
-    },
-    created () {
-      this.optionsState = this.$store.state.common.approveStates
+import AddOrUpdate from './approve-add-or-update'
+import { getApprovalList } from '@/api/msg'
+import { readNotices } from '@/utils/msg'
+import { getCusList } from '@/api/cus'
+import { checkStr } from '@/api/util'
+import ApproveComponentBatch from '../common/approve-component-batch'
+export default {
+  name: 'approve',
+  components: {
+    // Detail,
+    AddOrUpdate,
+    ApproveComponentBatch
+  },
+  created() {
+    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 {
+      approveDialogVisible: false,
+      addOrUpdateVisible: false,
+      dataForm: {
+        type: '1'
+      },
+      dataList: [],
+      pageIndex: 1,
+      pageSize: 10,
+      totalPage: 0,
+      dataListLoading: false,
+      dataListSelections: [],
+      optionsState: [],
+      optionsType: [
+        {
+          code: null, value: '全部'
+        },
+        {
+          code: 'warehouse_flow_in', value: '入库申请'
+        },
+        {
+          code: 'warehouse_flow_out', value: '出库申请'
+        },
+        {
+          code: 'contract_review', value: '合同评审'
+        },
+        {
+          code: 'sale_order_flow', value: '任务单评审'
+        },
+        {
+          code: 'sale_purchase_flow', value: '采购申请'
+        },
+        {
+          code: 'wh_template_record_flow', value: '模板出库'
+        },
+        {
+          code: 'pro_technology_flow', value: '工艺评审'
+        },
+        {
+          code: 'pro_product_flow', value: '物料评审'
+        },
+        {
+          code: 'wh_inventory_record_flow', value: '盘点评审'
+        },
+        {
+          code: 'supplier_review_flow', value: '供应商评审'
+        },
+        {
+          code: 'submit_expense_flow', value: '报销审批'
+        },
+        {
+          code: 'pur_commission_flow', value: '委外审批'
+        },
+        {
+          code: 'work_damage_flow', value: '报损审批'
+        },
+        {
+          code: 'cus_communicate_flow', value: '沟通审批'
+        },
+        {
+          code: 'project_estimate', value: '项目评估'
+        },
+        {
+          code: 'first_identify_flow', value: '首件鉴定'
+        },
+        {
+          code: 'nonconforming_hear_flow', value: '不合格品审理'
+        }
+      ],
+      optionsCustomer: []
+    }
+  },
+  methods: {
+    onChose() {
+      this.addOrUpdateVisible = false
     },
-    computed: {
-      // 监听消息ID
-      listenNotice () {
-        return this.$route.params.notice
-      }
+    // 查询
+    queryData() {
+      this.pageIndex = 1
+      this.getApprovalList()
     },
-    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()
+    // 获取数据列表
+    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,
+        'type': this.dataForm.type ? Number(this.dataForm.type) : 1,
+        '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') {
+          this.dataList = data.data.records
+          this.totalPage = Number(data.data.total)
+        } else {
+          this.dataList = []
+          this.totalPage = 0
+        }
+        this.dataListLoading = false
+      })
     },
-    data () {
-      return {
-        approveDialogVisible: false,
-        addOrUpdateVisible: false,
-        dataForm: {
-          type: '1'
-        },
-        dataList: [],
-        pageIndex: 1,
-        pageSize: 10,
-        totalPage: 0,
-        dataListLoading: false,
-        dataListSelections: [],
-        optionsState: [],
-        optionsType: [
-          {
-            code: null, value: '全部'
-          },
-          {
-            code: 'warehouse_flow_in', value: '入库申请'
-          },
-          {
-            code: 'warehouse_flow_out', value: '出库申请'
-          },
-          {
-            code: 'contract_review', value: '合同评审'
-          },
-          {
-            code: 'sale_order_flow', value: '任务单评审'
-          },
-          {
-            code: 'sale_purchase_flow', value: '采购申请'
-          },
-          {
-            code: 'wh_template_record_flow', value: '模板出库'
-          },
-          {
-            code: 'pro_technology_flow', value: '工艺评审'
-          },
-          {
-            code: 'pro_product_flow', value: '物料评审'
-          },
-          {
-            code: 'wh_inventory_record_flow', value: '盘点评审'
-          },
-          {
-            code: 'supplier_review_flow', value: '供应商评审'
-          },
-          {
-            code: 'submit_expense_flow', value: '报销审批'
-          },
-          {
-            code: 'pur_commission_flow', value: '委外审批'
-          },
-          {
-            code: 'work_damage_flow', value: '报损审批'
-          },
-          {
-            code: 'cus_communicate_flow', value: '沟通审批'
-          },
-          {
-            code: 'project_estimate', value: '项目评估'
-          },
-          {
-            code: 'first_identify_flow', value: '首件鉴定'
-          },
-          {
-            code: 'nonconforming_hear_flow', value: '不合格品审理'
-          }
-        ],
-        optionsCustomer: []
-      }
+    // 每页数
+    sizeChangeHandle(val) {
+      this.pageSize = val
+      this.pageIndex = 1
+      this.getApprovalList()
     },
-    methods: {
-      onChose () {
-        this.addOrUpdateVisible = false
-      },
-      // 查询
-      queryData () {
-        this.pageIndex = 1
-        this.getApprovalList()
-      },
-      // 获取数据列表
-      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,
-          'type': this.dataForm.type ? Number(this.dataForm.type) : 1,
-          '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') {
-            this.dataList = data.data.records
-            this.totalPage = Number(data.data.total)
-          } else {
-            this.dataList = []
-            this.totalPage = 0
-          }
-          this.dataListLoading = false
-        })
-      },
-      // 每页数
-      sizeChangeHandle (val) {
-        this.pageSize = val
-        this.pageIndex = 1
-        this.getApprovalList()
-      },
-      // 当前页
-      currentChangeHandle (val) {
-        this.pageIndex = val
-        this.getApprovalList()
-      },
-      // 多选
-      selectionChangeHandle (val) {
-        this.dataListSelections = val
-      },
-      // 远程方法:获取客户列表
-      async remoteCustomer (query) {
-        if (!query) {
-          query = ''
-        }
-        await getCusList({'customerName': query}).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsCustomer = []
-            data.data.records.forEach((item) => {
-              this.optionsCustomer.push({
-                code: item.customerId,
-                value: item.customerName
-              })
+    // 当前页
+    currentChangeHandle(val) {
+      this.pageIndex = val
+      this.getApprovalList()
+    },
+    // 多选
+    selectionChangeHandle(val) {
+      this.dataListSelections = val
+    },
+    // 远程方法:获取客户列表
+    async remoteCustomer(query) {
+      if (!query) {
+        query = ''
+      }
+      await getCusList({ 'customerName': query }).then(({ data }) => {
+        if (data && data.code === '200') {
+          this.optionsCustomer = []
+          data.data.records.forEach((item) => {
+            this.optionsCustomer.push({
+              code: item.customerId,
+              value: item.customerName
             })
-          }
-        })
-      },
-      checkUser (row) {
-        let currentUser = this.$store.state.user.id
-        return checkStr(currentUser, row.currentApprover)
-      },
-      // 新增 / 修改
-      addOrUpdateHandle (row) {
-        this.addOrUpdateVisible = true
-        // 已查看
-        if (row.noticeIds) {
-          readNotices(this, row.noticeIds)
+          })
         }
+      })
+    },
+    checkUser(row) {
+      let currentUser = this.$store.state.user.id
+      return checkStr(currentUser, row.currentApprover)
+    },
+    // 新增 / 修改
+    addOrUpdateHandle(row) {
+      this.addOrUpdateVisible = true
+      // 已查看
+      if (row.noticeIds) {
+        readNotices(this, row.noticeIds)
+      }
+      this.$nextTick(() => {
+        this.$refs.addOrUpdate.init(row.businessType, row.businessId)
+      })
+    },
+    // 详情
+    detailHandle(row) {
+      this.addOrUpdateVisible = true
+      this.$nextTick(() => {
+        this.$refs.addOrUpdate.init(row.businessType, row.businessId, true)
+      })
+      // 已查看
+      if (row.noticeIds) {
+        readNotices(this, row.noticeIds)
+      }
+    },
+    batchApprove() {
+      if (this.dataListSelections && this.dataListSelections.length > 0) {
+        this.approveDialogVisible = true
+        let businessIds = this.dataListSelections.map(item => item.businessId)
+
         this.$nextTick(() => {
-          this.$refs.addOrUpdate.init(row.businessType, row.businessId)
-        })
-      },
-      // 详情
-      detailHandle (row) {
-        this.addOrUpdateVisible = true
-        this.$nextTick(() => {
-          this.$refs.addOrUpdate.init(row.businessType, row.businessId, true)
+          this.$refs.approve.init(this.dataListSelections[0].businessType, businessIds)
         })
-        // 已查看
-        if (row.noticeIds) {
-          readNotices(this, row.noticeIds)
-        }
-      },
-      batchApprove () {
-        if (this.dataListSelections && this.dataListSelections.length > 0) {
-          this.approveDialogVisible = true
-          let businessIds = this.dataListSelections.map(item => item.businessId)
-
-          this.$nextTick(() => {
-            this.$refs.approve.init(this.dataListSelections[0].businessType, businessIds)
-          })
-        } else {
-          this.$message.warning('请选择后再提交审批!')
-        }
-      },
-      approveChose () {
-        this.approveDialogVisible = false
-        this.queryData()
-      },
-      selected (row, index) {
-        if (this.isAuth('business:approval:approval') && Number(row.state) !== 3 && Number(row.state) !== 0 && this.checkUser(row)) {
-          return true
-        }
-        return false
+      } else {
+        this.$message.warning('请选择后再提交审批!')
+      }
+    },
+    approveChose() {
+      this.approveDialogVisible = false
+      this.queryData()
+    },
+    selected(row, index) {
+      if (this.isAuth('business:approval:approval') && Number(row.state) !== 3 && Number(row.state) !== 0 && this.checkUser(row)) {
+        return true
       }
+      return false
     }
   }
+}
 </script>
 
 <style lang="scss" scoped>
-.batch-dialog-class{
+.batch-dialog-class {
   min-width: 1000px;
 }
 </style>

+ 75 - 116
src/views/modules/msg-center/notice.vue

@@ -4,86 +4,44 @@
     <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 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-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>
+      <p>未读消息数量:<span style="color: red">{{ dataList.length }}</span>(请点击 “ 查询 ” 获取最新列表)</p>
     </div>
-    <el-table
-      :data="dataList"
-      border
-      v-loading="dataListLoading"
-      style="width: 100%;">
-      <el-table-column
-        label="序号"
-        type="index"
-        width="50"
-        align="center">
+    <el-table :data="dataList" border v-loading="dataListLoading" 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="200"
-        :show-tooltip-when-overflow="true"
+      <el-table-column prop="title" header-align="center" align="center" width="200" :show-tooltip-when-overflow="true"
         label="消息标题">
       </el-table-column>
-      <el-table-column
-        prop="content"
-        header-align="center"
-        align="center"
-        width="300"
-        :show-tooltip-when-overflow="true"
-        label="消息内容">
+      <el-table-column prop="content" header-align="center" align="center" width="300"
+        :show-tooltip-when-overflow="true" label="消息内容">
       </el-table-column>
-      <el-table-column
-        prop="type"
-        header-align="center"
-        align="center"
-        width="100"
-        :show-tooltip-when-overflow="true"
+      <el-table-column prop="type" header-align="center" align="center" width="100" :show-tooltip-when-overflow="true"
         label="消息类型">
         <template slot-scope="scope">
-          <span>{{scope.row.type? optionsType[scope.row.type].value:'' }}</span>
+          <span>{{ scope.row.type ? optionsType[scope.row.type].value : '' }}</span>
         </template>
       </el-table-column>
-      <el-table-column
-        prop="publisherName"
-        header-align="center"
-        align="center"
-        width="120"
-        :show-tooltip-when-overflow="true"
-        label="发布人">
+      <el-table-column prop="publisherName" header-align="center" align="center" width="120"
+        :show-tooltip-when-overflow="true" label="发布人">
       </el-table-column>
-      <el-table-column
-        header-align="center"
-        align="center"
-        width="160"
-        :show-tooltip-when-overflow="true"
-        label="发布时间">
+      <el-table-column header-align="center" align="center" width="160" :show-tooltip-when-overflow="true" label="发布时间">
         <template slot-scope="scope">
-          <span>{{timestampToTime(scope.row.publishTime)}}</span>
+          <span>{{ timestampToTime(scope.row.publishTime) }}</span>
         </template>
       </el-table-column>
-      <el-table-column
-        fixed="right"
-        header-align="center"
-        align="center"
-        min-width="150"
-        label="操作">
+      <el-table-column fixed="right" header-align="center" align="center" min-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>
@@ -94,69 +52,70 @@
 </template>
 
 <script>
-  import {readNotice, routeMsg} from '@/utils/msg'
-  import {dateTimeToString} from '@/api/util'
-  export default {
-    name: 'notice',
-    created () {
-      this.queryData()
+import { readNotice, routeMsgs } from '@/utils/msg'
+import { dateTimeToString } from '@/api/util'
+export default {
+  name: 'notice',
+  created() {
+    this.queryData()
+  },
+  data() {
+    return {
+      checkedVisible: false,
+      dataForm: {},
+      dataList: [],
+      dataListLoading: false,
+      optionsType: [
+        {
+          code: null, value: '全部'
+        },
+        {
+          code: 1, value: '公告消息'
+        },
+        {
+          code: 2, value: '审批消息'
+        },
+        {
+          code: 3, value: '我的工作台'
+        }
+      ]
+    }
+  },
+  methods: {
+    // 查询
+    queryData() {
+      this.getNoticeList()
     },
-    data () {
-      return {
-        checkedVisible: false,
-        dataForm: {},
-        dataList: [],
-        dataListLoading: false,
-        optionsType: [
-          {
-            code: null, value: '全部'
-          },
-          {
-            code: 1, value: '公告消息'
-          },
-          {
-            code: 2, value: '审批消息'
-          },
-          {
-            code: 3, value: '我的工作台'
-          }
-        ]
+    // 获取数据列表
+    getNoticeList() {
+      let msg = Object.assign([], this.$store.state.common.msgCollection)
+      if (!msg) return
+      this.dataList = msg.sort(item => item.publishTime).reverse()
+      if (this.dataForm.title) {
+        this.dataList = this.dataList.filter(item => item.title && item.title.indexOf(this.dataForm.title) !== -1)
       }
-    },
-    methods: {
-      // 查询
-      queryData () {
-        this.getNoticeList()
-      },
-      // 获取数据列表
-      getNoticeList () {
-        let msg = Object.assign([], this.$store.state.common.msgCollection)
-        if (!msg) return
-        this.dataList = msg.sort(item => item.publishTime).reverse()
-        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)
-        }
-      },
-      // 设为已读
-      checkHandle (noticeId) {
-        readNotice(this, noticeId)
-        this.getNoticeList()
-      },
-      // 查看消息
-      detailHandle (row) {
-        // this.checkHandle(row.noticeId)
-        routeMsg(this, row)
-      },
-      timestampToTime (l) {
-        if (!l) return ''
-        return dateTimeToString(l)
+      if (this.dataForm.type) {
+        this.dataList = this.dataList.filter(item => item.type && item.type === this.dataForm.type)
       }
+    },
+    // 设为已读
+    checkHandle(noticeId) {
+      readNotice(this, noticeId)
+      this.getNoticeList()
+    },
+    // 查看消息
+    detailHandle(row) {
+      // this.checkHandle(row.noticeId)
+      // routeMsg(this, row)
+      // row.path = 'msg-center-approve-list'
+      routeMsgs(this, row)
+    },
+    timestampToTime(l) {
+      if (!l) return ''
+      return dateTimeToString(l)
     }
   }
+}
 </script>
 
-<style scoped>
-</style>
+<style scoped></style>