164 lines
4.7 KiB
Vue
164 lines
4.7 KiB
Vue
<template>
|
|
<!-- 列表 -->
|
|
<ContentWrap>
|
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
<!-- <el-table-column label="唯一主键" align="center" prop="id" /> -->
|
|
<!-- <el-table-column label="项目ID" align="center" prop="projectId" /> -->
|
|
<el-table-column label="任务标题" align="center" prop="taskName" />
|
|
<el-table-column label="任务优先级" align="center" prop="taskLevel">
|
|
<template #default="scope">
|
|
<dict-tag :type="DICT_TYPE.TTS_TASK_LEVEL" :value="scope.row.taskLevel" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="任务负责人" align="center" prop="userId">
|
|
<template #default="scope">
|
|
{{getName(userOptions, scope.row.userId)}}
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="任务描述" align="center" prop="taskDescribe" />
|
|
<el-table-column label="操作" align="center" min-width="120px" v-if="!type">
|
|
<template #default="scope">
|
|
<el-button
|
|
link
|
|
type="danger"
|
|
@click="handleDelete(scope.$index)"
|
|
v-hasPermi="['task:selectTask:delete']"
|
|
>
|
|
删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<el-row justify="center" class="mt-3" v-if="!type">
|
|
<el-button @click="openForm" round>+ 添加</el-button>
|
|
</el-row>
|
|
|
|
</ContentWrap>
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
<TaskForm ref="formRef" @success="getList" :id="id" :userOptions="userOptions" />
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
import download from '@/utils/download'
|
|
import { ProjectBonusApi, ProjectBonusVO } from '@/api/task/bonus'
|
|
import TaskForm from '@/components/Task/index.vue'
|
|
import { propTypes } from '@/utils/propTypes'
|
|
import { DICT_TYPE } from '@/utils/dict'
|
|
import * as UserApi from '@/api/system/user'
|
|
import { useUserStore } from '@/store/modules/user'
|
|
|
|
/** 项目奖金 列表 */
|
|
defineOptions({ name: 'ProjectBonus' })
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
const userOptions = ref<UserApi.UserVO[]>([]) // 用户列表
|
|
const { t } = useI18n() // 国际化
|
|
const props = defineProps({
|
|
id: propTypes.number.def(undefined),
|
|
type: propTypes.number.def(undefined),
|
|
})
|
|
const loading = ref(false) // 列表的加载中
|
|
const list = ref<ProjectBonusVO[]>([]) // 列表的数据
|
|
const total = ref(0) // 列表的总页数
|
|
const queryParams = reactive({
|
|
pageNo: 1,
|
|
pageSize: 999,
|
|
projectId: undefined,
|
|
userId: useUserStore().getUser.id,
|
|
bonusPercentage: undefined,
|
|
bonusAmount: undefined,
|
|
bonusIssueDate: [],
|
|
bonusState: undefined,
|
|
createTime: []
|
|
})
|
|
const queryFormRef = ref() // 搜索的表单
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
|
/** 查询列表 */
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
const getList = (val: []) => {
|
|
for(let i = val.length - 1; i >= 0; i--) {
|
|
let obj = val[i]
|
|
if(list.value.some(v => v.id === obj.id)) val.splice(i, 1)
|
|
}
|
|
val.forEach(item => {
|
|
if(!list.value.some(v => v.id === item.id)) {
|
|
val.forEach(item => {
|
|
list.value.push({
|
|
"taskName": item.taskName,
|
|
"userId": item.userId,
|
|
"taskLevel": item.taskLevel,
|
|
"taskDescribe": item.taskDescribe,
|
|
"id": item.id,
|
|
})
|
|
})
|
|
}
|
|
})
|
|
|
|
|
|
}
|
|
|
|
/** 搜索按钮操作 */
|
|
const handleQuery = () => {
|
|
queryParams.pageNo = 1
|
|
// getList()
|
|
}
|
|
|
|
/** 重置按钮操作 */
|
|
const resetQuery = () => {
|
|
queryFormRef.value.resetFields()
|
|
handleQuery()
|
|
}
|
|
|
|
/** 添加/修改操作 */
|
|
const formRef = ref()
|
|
const openForm = () => {
|
|
formRef.value.open(list.value)
|
|
}
|
|
|
|
/** 删除按钮操作 */
|
|
const handleDelete = async (i: number) => {
|
|
try {
|
|
// 删除的二次确认
|
|
await message.delConfirm()
|
|
// 发起删除
|
|
list.value.splice(i, 1)
|
|
message.success(t('common.delSuccess'))
|
|
// 刷新列表
|
|
// await getList()
|
|
} catch {}
|
|
}
|
|
|
|
/** 导出按钮操作 */
|
|
const handleExport = async () => {
|
|
try {
|
|
// 导出的二次确认
|
|
await message.exportConfirm()
|
|
// 发起导出
|
|
exportLoading.value = true
|
|
const data = await ProjectBonusApi.exportProjectBonus(queryParams)
|
|
download.excel(data, '项目奖金.xls')
|
|
} catch {
|
|
} finally {
|
|
exportLoading.value = false
|
|
}
|
|
}
|
|
|
|
const getName = (opt, val) => {
|
|
const arr = opt.filter(v => v.id == val)
|
|
return arr.length ? arr[0]['nickname'] : ''
|
|
}
|
|
|
|
const getData = (data) => {
|
|
return list.value
|
|
}
|
|
defineExpose({ getData })
|
|
|
|
/** 初始化 **/
|
|
onMounted(async() => {
|
|
// getList() // 获得用户列表
|
|
userOptions.value = await UserApi.getSimpleUserList()
|
|
})
|
|
</script> |