bonus-ui/src/views/materialsStation/straight/straightTransferReview/index.vue

292 lines
9.5 KiB
Vue
Raw Normal View History

2025-09-27 13:29:48 +08:00
<template>
<!-- 直转审核页面 -->
<div class="app-container">
<el-form v-show="showSearch" :model="queryParams" ref="queryForm" size="small" inline>
2025-10-10 12:03:32 +08:00
<el-form-item label="申请日期" prop="startTime">
2025-09-27 13:29:48 +08:00
<el-date-picker
2025-10-10 12:03:32 +08:00
v-model="queryParams.startTime"
type="date"
placeholder="开始日期"
2025-09-27 13:29:48 +08:00
clearable
2025-10-10 12:03:32 +08:00
value-format="yyyy-MM-dd"
2025-09-27 13:29:48 +08:00
format="yyyy-MM-dd"
2025-11-24 13:17:04 +08:00
@change="() => queryParams.endTime = ''"
2025-10-10 12:03:32 +08:00
style="width: 130px"
/>
</el-form-item>
<el-form-item label="">-</el-form-item>
<el-form-item label="" prop="endTime">
<el-date-picker
v-model="queryParams.endTime"
type="date"
placeholder="结束日期"
clearable
2025-09-27 13:29:48 +08:00
value-format="yyyy-MM-dd"
2025-10-10 12:03:32 +08:00
format="yyyy-MM-dd"
2025-11-24 13:17:04 +08:00
:picker-options="{ disabledDate: (t) => t.getTime() < new Date(queryParams.startTime).getTime() - 86400000}"
2025-10-10 12:03:32 +08:00
style="width: 130px"
2025-09-27 13:29:48 +08:00
/>
</el-form-item>
<el-form-item label="关键字" prop="keyWord">
<el-input
clearable
placeholder="请输入关键字"
v-model="queryParams.keyWord"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="审核状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择审核状态" clearable>
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<!-- 表单按钮 -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出数据</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
</el-row>
<el-table :data="tableList" fit highlight-current-row style="width: 100%" :max-height="650" v-loading="isLoading">
<!-- 多选 -->
<el-table-column
type="index"
width="55"
label="序号"
align="center"
:index="indexContinuation(queryParams.pageNum, queryParams.pageSize)"
/>
<el-table-column
v-for="column in tableColumns"
:show-overflow-tooltip="column.showTooltip"
:key="column.prop"
:label="column.label"
:prop="column.prop"
:width="column.width"
align="center"
>
<!-- 插槽 -->
<template v-slot="scope" v-if="column.prop == 'status'">
<el-tag v-if="scope.row.status == '0'" type="warning" size="mini">待审核</el-tag>
<el-tag v-else-if="scope.row.status == '1'" size="mini">审核中</el-tag>
<el-tag v-else-if="scope.row.status == '2'" type="success" size="mini">已通过</el-tag>
<el-tag v-else-if="scope.row.status == '3'" type="danger" size="mini">已驳回</el-tag>
</template>
</el-table-column>
<!-- 操作 -->
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button
type="text"
size="mini"
icon="el-icon-edit"
v-if="auditingShow(scope.row)"
@click="handleReview(scope.row, 2)"
>
审核
</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-edit"
2025-09-27 23:11:10 +08:00
v-if="(scope.row.status == 0 || scope.row.status == 3) && scope.row.userId == userId"
2025-09-27 13:29:48 +08:00
@click="handleEdit(scope.row)"
>
编辑
</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
2025-09-27 23:11:10 +08:00
v-if="(scope.row.status == 0 || scope.row.status == 3) && scope.row.userId == userId"
2025-09-27 13:29:48 +08:00
@click="handleDelete(scope.row)"
style="color: red"
>
删除
</el-button>
<el-button type="text" size="mini" icon="el-icon-search" @click="handleReview(scope.row, 1)">查看</el-button>
2025-10-10 12:03:32 +08:00
<el-button type="text" size="mini" icon="el-icon-document" @click="handleStraightforward(scope.row.id)">直转单</el-button>
2025-09-27 13:29:48 +08:00
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
:total="total"
v-show="total > 0"
@pagination="getList"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
/>
2025-10-10 12:03:32 +08:00
<StraightforwardBills ref="straightforwardBills" />
2025-09-27 13:29:48 +08:00
</div>
</template>
<script>
import { getUseListApi, deleteUseApi } from '@/api/materialsStation'
import { formatTime } from '@/utils/bonus.js'
2025-10-10 12:03:32 +08:00
import StraightforwardBills from './components/StraightforwardBills.vue'
2025-09-27 13:29:48 +08:00
export default {
name: 'straightTransferReview',
2025-10-10 12:03:32 +08:00
components: { StraightforwardBills },
2025-09-27 13:29:48 +08:00
data() {
return {
isLoading: false,
showSearch: true,
userId: '',
timeRange: [],
// 表格数据
tableList: [],
queryParams: {
pageNum: 1,
pageSize: 10,
2025-10-10 12:03:32 +08:00
startTime: '',
endTime: '',
2025-09-27 13:29:48 +08:00
keyWord: '', // 关键字
status: '' // 审核状态
},
// 状态
statusOptions: [
2025-09-27 23:11:10 +08:00
{ label: '待审核', value: 0 },
{ label: '审核中', value: 1 },
{ label: '已通过', value: 2 },
{ label: '已驳回', value: 3 }
2025-09-27 13:29:48 +08:00
],
total: 0, // 总条数
// 表头
tableColumns: [
{ label: '直转单号', prop: 'code' },
{ label: '申请时间', prop: 'createTime', showToolTip: true, width: '100' },
{ label: '申请人', prop: 'createBy', showToolTip: true, width: '80' },
{ label: '转出工程', prop: 'backProName', showToolTip: false },
{ label: '转出班组', prop: 'backTeamName', showToolTip: false },
{ label: '转入工程', prop: 'leaseProName', showToolTip: false },
{ label: '转入班组', prop: 'leaseTeamName', showToolTip: false },
2025-09-27 14:20:35 +08:00
{ label: '物资类型', prop: 'typeName', showToolTip: true },
2025-09-27 13:29:48 +08:00
{ label: '状态', prop: 'status', showToolTip: true, width: '80' }
]
}
},
created() {
this.userId = sessionStorage.getItem('userId')
console.log('🚀 ~ created ~ this.userId:', this.userId)
this.getList()
},
methods: {
// 查询
handleQuery() {
this.getList()
},
// 重置
handleReset() {
this.timeRange = []
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
this.$refs.queryForm.resetFields()
this.getList()
},
// 获取列表
async getList() {
try {
this.isLoading = true
const params = {
...this.queryParams,
2025-10-10 12:03:32 +08:00
// startTime: this.timeRange ? this.timeRange[0] : '',
// endTime: this.timeRange ? this.timeRange[1] : ''
2025-09-27 13:29:48 +08:00
}
const res = await getUseListApi(params)
this.tableList = res.data.rows
this.total = res.data.total || 0
} catch (error) {
this.tableList = []
this.total = 0
} finally {
this.isLoading = false
}
},
// 审核/详情
handleReview(row, type) {
// ----type---- 1. 查看 2. 审核
// 跳转审核详情页面
this.$router.push({
path: '/materialsStation/straight/reviewDetails',
query: {
...row,
taskId: row.id,
2025-09-27 14:20:35 +08:00
type: type === 1 ? 'detail' : 'edit'
2025-09-27 13:29:48 +08:00
}
})
},
2025-10-10 12:03:32 +08:00
handleStraightforward(id) {
console.log('🚀 ~ handleStraightforward ~ id:', id)
this.$refs.straightforwardBills.openDialog(id)
},
2025-09-27 13:29:48 +08:00
// 编辑
handleEdit(row, type) {
this.$router.push({
path: '/materialsStation/straight/straightTransfer',
query: {
id: row.id,
type: 'edit'
}
})
},
// 删除
handleDelete(row) {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
try {
this.isLoading = true
await deleteUseApi({ id: row.id })
this.$message({
type: 'success',
message: '删除成功'
})
} catch (error) {
console.log('🚀 ~ handleDelete ~ error:', error)
} finally {
this.isLoading = false
this.getList()
}
})
},
// 判断审核按钮显示隐藏
auditingShow(row) {
if (row.directUserIds) {
2025-09-27 19:01:42 +08:00
return (row.status == 1 || row.status == 0) && row.directUserIds.includes(this.userId)
2025-09-27 13:29:48 +08:00
}
},
// 导出数据
handleExport() {
const formatTime = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}${month}${day}_${hours}${minutes}${seconds}`;
};
const currentTime = formatTime(new Date());
this.download(
"/material/material_direct/export",
{ ...this.queryParams },
`导出_${currentTime}.xlsx`
);
2025-09-27 13:29:48 +08:00
}
}
}
</script>