|
@@ -9,44 +9,46 @@
|
|
|
<hc-card>
|
|
|
<template #header>
|
|
|
<div class="w-32">
|
|
|
- <el-select v-model="searchForm.tasksType" clearable block placeholder="任务类型">
|
|
|
- <el-option label="暂无接口" value=" 1" />
|
|
|
+ <el-select v-model="searchForm.taskType" clearable block placeholder="任务类型">
|
|
|
+ <el-option v-for="item in tasksType" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div class="ml-2 w-32">
|
|
|
- <el-select v-model="searchForm.smsType" clearable block placeholder="消息类型">
|
|
|
- <el-option label="暂无接口" value=" 1" />
|
|
|
+ <el-select v-model="searchForm.messageType" clearable block placeholder="消息类型">
|
|
|
+ <el-option label="未读" :value="1" />
|
|
|
+ <el-option label="已读" :value="2" />
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div class="ml-2 w-64">
|
|
|
<hc-date-picker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
|
|
|
</div>
|
|
|
<div class="ml-2 w-64">
|
|
|
- <hc-search-input v-model="searchForm.queryValue" @search="searchClick" />
|
|
|
+ <hc-search-input v-model="searchForm.searchValue" @search="searchClick" />
|
|
|
</div>
|
|
|
</template>
|
|
|
<template #extra>
|
|
|
- <el-button hc-btn type="danger">
|
|
|
+ <el-button hc-btn type="danger" @click="delClick">
|
|
|
<hc-icon name="delete-bin-3" />
|
|
|
<span>删除</span>
|
|
|
</el-button>
|
|
|
- <el-button hc-btn type="primary">
|
|
|
+ <el-button hc-btn type="primary" @click="batchReadClick">
|
|
|
<hc-icon name="check" />
|
|
|
- <span>批量确认</span>
|
|
|
+ <span>标记已读</span>
|
|
|
</el-button>
|
|
|
</template>
|
|
|
<hc-table
|
|
|
- :column="tableColumn" :datas="tableData" :loading="tableLoading"
|
|
|
+ ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading"
|
|
|
:index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
|
|
|
@selection-change="tableSelection"
|
|
|
>
|
|
|
- <template #key8="{ row }">
|
|
|
- <span class="text-red-5">未读</span>
|
|
|
- <span class="text-green-5">已读</span>
|
|
|
+ <template #messageStatusName="{ row }">
|
|
|
+ <span v-if="row.messageStatusName === '未读'" class="text-red-5">未读</span>
|
|
|
+ <span v-else-if="row.messageStatusName === '已读'" class="text-green-5">已读</span>
|
|
|
+ <span v-else>未知</span>
|
|
|
</template>
|
|
|
<template #action="{ row }">
|
|
|
- <el-link type="primary">确认</el-link>
|
|
|
- <el-link type="info" disabled>已确认</el-link>
|
|
|
+ <el-link v-if="row.messageStatusName === '未读'" type="primary" @click="rowReadClick(row)">确认</el-link>
|
|
|
+ <el-link v-else type="info" disabled>已确认</el-link>
|
|
|
</template>
|
|
|
</hc-table>
|
|
|
<template #action>
|
|
@@ -58,13 +60,38 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onActivated, ref } from 'vue'
|
|
|
+import { HcDelMsg } from 'hc-vue3-ui'
|
|
|
+import { onActivated, ref, watch } from 'vue'
|
|
|
+import { useAppStore } from '~src/store'
|
|
|
+import { arrToId, getArrValue } from 'js-fast-way'
|
|
|
+import taskApi from '~api/tasks/hc-data'
|
|
|
+import mainApi from '~api/tasks/message'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ msgCount: {
|
|
|
+ type: [Number, String],
|
|
|
+ default: 0,
|
|
|
+ },
|
|
|
+})
|
|
|
|
|
|
//渲染完成
|
|
|
onActivated(() => {
|
|
|
+ queryTaskType()
|
|
|
searchClick()
|
|
|
})
|
|
|
|
|
|
+//获取项目合同段ID
|
|
|
+const store = useAppStore()
|
|
|
+const projectId = ref(store.getProjectId)
|
|
|
+const contractId = ref(store.getContractId)
|
|
|
+
|
|
|
+//监听菜单数据
|
|
|
+const taskCount = ref(props.msgCount)
|
|
|
+watch(() => props.msgCount, (val) => {
|
|
|
+ taskCount.value = val ?? 0
|
|
|
+ menuOptions.value[0].badge = taskCount.value
|
|
|
+}, { deep: true })
|
|
|
+
|
|
|
//搜索和分页数据
|
|
|
const searchForm = ref({ current: 1, size: 20, total: 0 })
|
|
|
|
|
@@ -73,7 +100,7 @@ const menuKey = ref('3')
|
|
|
const menuOptions = ref([
|
|
|
//{ key: '1', label: '任务催办', icon: 'alarm-warning', badge: 0 },
|
|
|
//{ key: '2', label: '监测预警', icon: 'eye', badge: 0 },
|
|
|
- { key: '3', label: '废除通知', icon: 'delete-bin-3', badge: 0 },
|
|
|
+ { key: '3', label: '废除通知', icon: 'delete-bin-3', badge: taskCount.value },
|
|
|
//{ key: '4', label: '工单反馈', icon: 'question-answer', badge: 0 },
|
|
|
//{ key: '5', label: '系统消息', icon: 'chat-settings', badge: 0 },
|
|
|
])
|
|
@@ -83,16 +110,23 @@ const handleMenuValue = (item) => {
|
|
|
searchClick()
|
|
|
}
|
|
|
|
|
|
+//获取任务类型
|
|
|
+const tasksType = ref([])
|
|
|
+const queryTaskType = async () => {
|
|
|
+ const { data } = await taskApi.queryTaskType()
|
|
|
+ tasksType.value = getArrValue(data)
|
|
|
+}
|
|
|
+
|
|
|
//日期时间被选择
|
|
|
const betweenTime = ref(null)
|
|
|
const betweenTimeUpdate = ({ val, arr }) => {
|
|
|
betweenTime.value = arr
|
|
|
if (val && val.length > 0) {
|
|
|
- searchForm.value.startTime = val['start']
|
|
|
- searchForm.value.endTime = val['end']
|
|
|
+ searchForm.value.startDate = val['start']
|
|
|
+ searchForm.value.endDate = val['end']
|
|
|
} else {
|
|
|
- searchForm.value.startTime = null
|
|
|
- searchForm.value.endTime = null
|
|
|
+ searchForm.value.startDate = null
|
|
|
+ searchForm.value.endDate = null
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -110,25 +144,37 @@ const pageChange = ({ current, size }) => {
|
|
|
}
|
|
|
|
|
|
//表格
|
|
|
+const tableRef = ref(null)
|
|
|
const tableColumn = [
|
|
|
- { key: 'key1', name: '任务类型' },
|
|
|
- { key: 'key2', name: '任务名称' },
|
|
|
- { key: 'key3', name: '开始时间' },
|
|
|
- { key: 'key4', name: '废除时间' },
|
|
|
- { key: 'key5', name: '任务流程' },
|
|
|
- { key: 'key6', name: '驳回人' },
|
|
|
- { key: 'key7', name: '驳回原因' },
|
|
|
- { key: 'key8', name: '消息状态' },
|
|
|
- { key: 'action', name: '操作', width: 94 },
|
|
|
+ { key: 'meterTaskTypeName', name: '任务类型' },
|
|
|
+ { key: 'taskName', name: '任务名称' },
|
|
|
+ { key: 'startDate', name: '开始时间' },
|
|
|
+ { key: 'repealDate', name: '废除时间' },
|
|
|
+ { key: 'taskFlowName', name: '任务流程' },
|
|
|
+ { key: 'rejectPersonName', name: '驳回人' },
|
|
|
+ { key: 'rejectReason', name: '驳回原因' },
|
|
|
+ { key: 'messageStatusName', name: '消息状态', width: 80, align: 'center' },
|
|
|
+ { key: 'action', name: '操作', width: 80, align: 'center' },
|
|
|
]
|
|
|
-const tableData = ref([
|
|
|
- {},
|
|
|
-])
|
|
|
+const tableData = ref([])
|
|
|
|
|
|
//获取消息数据
|
|
|
const tableLoading = ref(false)
|
|
|
-const getTableData = () => {
|
|
|
-
|
|
|
+const getTableData = async () => {
|
|
|
+ tableLoading.value = true
|
|
|
+ //清空数据
|
|
|
+ tableData.value = []
|
|
|
+ tableRef.value?.clearSelection()
|
|
|
+ tableCheckedKeys.value = []
|
|
|
+ //发起请求
|
|
|
+ const { data } = await mainApi.repealPage({
|
|
|
+ ...searchForm.value,
|
|
|
+ projectId: projectId.value,
|
|
|
+ contractId: contractId.value,
|
|
|
+ })
|
|
|
+ tableLoading.value = false
|
|
|
+ tableData.value = getArrValue(data?.records)
|
|
|
+ searchForm.value.total = data.total || 0
|
|
|
}
|
|
|
|
|
|
//多选
|
|
@@ -136,6 +182,47 @@ const tableCheckedKeys = ref([])
|
|
|
const tableSelection = (rows) => {
|
|
|
tableCheckedKeys.value = rows
|
|
|
}
|
|
|
+
|
|
|
+//单个查看
|
|
|
+const rowReadClick = ({ id }) => {
|
|
|
+ batchReadApi(id)
|
|
|
+}
|
|
|
+
|
|
|
+//批量查看
|
|
|
+const batchReadClick = () => {
|
|
|
+ const rows = tableCheckedKeys.value
|
|
|
+ if (rows.length <= 0) {
|
|
|
+ window.$message.warning('请先勾选要已读的数据')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const ids = arrToId(rows, 'id')
|
|
|
+ batchReadApi(ids)
|
|
|
+}
|
|
|
+
|
|
|
+//统一查看
|
|
|
+const batchReadApi = async (id) => {
|
|
|
+ const { isRes } = await mainApi.batchRead(id)
|
|
|
+ if (!isRes) return
|
|
|
+ window.$message.success('删除成功')
|
|
|
+ getTableData().then()
|
|
|
+}
|
|
|
+
|
|
|
+//批量删除
|
|
|
+const delClick = () => {
|
|
|
+ const rows = tableCheckedKeys.value
|
|
|
+ if (rows.length <= 0) {
|
|
|
+ window.$message.warning('请先勾选要删除的数据')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ HcDelMsg(async (resolve) => {
|
|
|
+ const ids = arrToId(rows, 'id')
|
|
|
+ const { isRes } = await mainApi.batchDelete(ids)
|
|
|
+ if (!isRes) return
|
|
|
+ window.$message.success('删除成功')
|
|
|
+ getTableData().then()
|
|
|
+ resolve() //关闭弹窗的回调
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|