jstd-web/src/views/fileTransfer/accept.vue

286 lines
7.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #receiveStatus="{ row }">
<span
class="clickable-status"
@click="handleTProgress(row)"
>
{{ getProgressStatusText(row.receiveStatus) }}
</span>
</template>
<template #deptId="{ row }">
{{ row.deptName }}
</template>
<!-- 接收清单操作 -->
<template #transferIssue="{ row }">
<span
class="clickable-status"
@click="handleTList(row)"
>
查看清单
</span>
</template>
</avue-crud>
</basic-container>
<RecordList
v-model="recordListVisible"
:title="recordListTitle"
:row-data="recordListRow"
:jump-type="recordListJumpType"
@handle-query="onLoad(page, query)"
@close="recordListVisible = false"
/>
</template>
<script>
import RecordList from '@/views/fileTransfer/components/recordAcceptList.vue'
import {
getTransferReceiceListApi,
} from '@/api/filesTransfer/accept';
import { mapGetters } from 'vuex';
import website from '@/config/website';
import { getDeptSelectApi } from '@/api/select';
export default {
components: {
RecordList
},
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
editBtn: false,
delBtn: false,
selection: false,
addBtn:true,
dialogClickModal: false,
column: [
{
label: '项目名称',
prop: 'proName',
search: true,
},
{
label: '单项工程名称',
prop: 'singleProName',
search: true,
},
{
label: '移交时间',
prop: 'transferTime',
search: true,
type: 'date',
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
dataType: 'string'
},
{
label: '接收单位',
prop: 'deptId',
search: true,
type: 'tree',
dicData: [], // 初始空,后面动态赋值
props: {
label: 'label',
value: 'id',
children: 'children'
},
// 显示时用插槽展示 deptName因为 row.deptName 是名称)
slot: true
},
{
label: '接收清单',
prop: 'transferIssue',
slot: true // 启用插槽
},
{
label: '接收进度',
prop: 'receiveStatus',
slot: true,
},
],
},
data: [],
recordListVisible: false,
recordListTitle: '',
recordListRow: null,
recordListJumpType: 'list'
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.post_add, false),
viewBtn: this.validData(this.permission.post_view, false),
delBtn: this.validData(this.permission.post_delete, false),
editBtn: this.validData(this.permission.post_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
/* 查看接收进度 */
getProgressStatusText(status) {
switch (status) {
case '0':
return '进行中'
case '1':
return '已完成'
default:
return '未知状态'
}
},
loadDeptOptions() {
getDeptSelectApi().then(res => {
this.treeDataList = this.convertToVueTree(res.data.data);
// 找到 deptId 列并更新 dicData
const deptColumn = this.option.column.find(col => col.prop === 'deptId');
if (deptColumn) {
deptColumn.dicData = this.treeDataList; // Vue 3 可直接赋值Vue 2 建议用 this.$set
}
}).catch(err => {
console.error('加载部门列表失败', err);
});
},
// 树数据过滤 - 支持无限层级转换
convertToVueTree(data, level = 1) {
if (!data || !Array.isArray(data)) {
return []
}
return data.map(item => {
const node = {
id: item.deptId,
label: item.deptName,
}
if (item.children && Array.isArray(item.children) && item.children.length > 0) {
if (level < 3) {
const children = this.convertToVueTree(item.children, level + 1)
if (children.length > 0) node.children = children
}
}
return node
})
},
beforeOpen(done, type, row) {
done(); // 必须调用 done()
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
this.loadDeptOptions();
let data = {
...params,
pageNum:page.currentPage,
pageSize:page.pageSize
};
getTransferReceiceListApi(data).then(res => {
const data = res.data;
this.page.total = data.total;
this.data = data.rows;
this.loading = false;
this.selectionClear();
});
},
handleTList(row) {
this.recordListTitle = '移交清单';
this.recordListRow = row;
this.recordListJumpType = 'list';
this.recordListVisible = true;
},
handleTProgress(row) {
this.recordListTitle = '移交进度';
this.recordListRow = row;
this.recordListJumpType = 'progress';
this.recordListVisible = true;
}
},
};
</script>
<style scoped>
.clickable-status {
color: #409eff;
cursor: pointer;
text-decoration: none;
}
.clickable-status:hover {
text-decoration: underline;
}
</style>