sanmu
authored
2 years ago
1
2
3
4
5
6
7
8
9
<template>
<PageWrapper contentBackground>
<BasicTable @register="registerTable">
<template #form-custom> custom-slot </template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
sanmu
authored
2 years ago
10
label: '详情',
sanmu
authored
2 years ago
11
// icon: 'ic:outline-delete-outline',
sanmu
authored
2 years ago
12
onClick: handleDetail.bind(null, record),
sanmu
authored
2 years ago
13
14
15
16
17
18
},
]"
/>
</template>
</template>
</BasicTable>
sanmu
authored
2 years ago
19
<BasicDrawer
sanmu
authored
2 years ago
20
:showFooter="!isApproved && role === ROLE.ADMIN"
sanmu
authored
2 years ago
21
22
23
24
25
@register="registerDrawer"
title="申请信息"
okText="通过"
@ok="handleTrue"
>
sanmu
authored
2 years ago
26
<BaseInfo :baseInfos="baseInfos" />
sanmu
authored
2 years ago
27
<h2>利润分析信息</h2>
sanmu
authored
2 years ago
28
29
30
31
32
33
34
35
<div v-for="field in fieldInfos" :key="field">
<span className="w-[140px] inline-block text-right mr-3">{{ field.label }}:</span
><span>{{ field.value }}</span>
</div>
<template #appendFooter>
<a-button @click="handleFalse"> 不通过</a-button>
</template>
</BasicDrawer>
sanmu
authored
2 years ago
36
<MsgModal v-if="msgVisible" @msg-modal-close="handleMsgModalClose" />
sanmu
authored
2 years ago
37
38
39
</PageWrapper>
</template>
<script lang="ts">
sanmu
authored
2 years ago
40
import MsgModal from './MsgModal.vue';
sanmu
authored
2 years ago
41
import { computed, defineComponent, ref } from 'vue';
sanmu
authored
2 years ago
42
43
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { PageWrapper } from '/@/components/Page';
sanmu
authored
2 years ago
44
import { BasicDrawer, useDrawer } from '/@/components/Drawer';
sanmu
authored
2 years ago
45
sanmu
authored
2 years ago
46
47
import { approveAuditApi, getApprovedListApi, getWaitListApi } from '/@/api/project/approve';
import { FIELDS_BASE_INFO, FIELDS_PROFIT_INFO, FIELDS_REPORT_INFO } from '../order/tableData';
sanmu
authored
2 years ago
48
49
50
51
52
import { ROLE } from '../order//type.d';
import { useUserStoreWithOut } from '/@/store/modules/user';
import BaseInfo from './BaseInfo.vue';
const userStore = useUserStoreWithOut();
sanmu
authored
2 years ago
53
54
55
56
57
export default defineComponent({
components: {
PageWrapper,
BasicTable,
sanmu
authored
2 years ago
58
BasicDrawer,
sanmu
authored
2 years ago
59
TableAction,
sanmu
authored
2 years ago
60
BaseInfo,
sanmu
authored
2 years ago
61
MsgModal,
sanmu
authored
2 years ago
62
},
sanmu
authored
2 years ago
63
64
65
66
props: {
isApproved: { type: Boolean },
},
setup(props) {
sanmu
authored
2 years ago
67
68
// visible 用于msgModal显示隐藏
const msgVisible = ref(false);
sanmu
authored
2 years ago
69
70
const checkedKeys = ref<Array<string | number>>([]);
const currentKey = ref('1');
sanmu
authored
2 years ago
71
72
73
74
const [registerDrawer, { openDrawer, closeDrawer }] = useDrawer();
const fieldInfos = ref({});
const baseInfos = ref({});
const id = ref('');
sanmu
authored
2 years ago
75
sanmu
authored
2 years ago
76
77
78
79
80
81
82
let columns = [
{
title: '申请人',
dataIndex: 'createBy',
width: 150,
},
];
sanmu
authored
2 years ago
83
sanmu
authored
2 years ago
84
85
if (props.isApproved) {
columns = columns.concat([
sanmu
authored
2 years ago
86
{
sanmu
authored
2 years ago
87
88
title: '状态',
dataIndex: 'status',
sanmu
authored
2 years ago
89
width: 150,
sanmu
authored
2 years ago
90
91
92
93
94
customRender: (column) => {
const { record } = column || {};
return record.status === 10 ? '通过' : '拒绝';
},
sanmu
authored
2 years ago
95
},
sanmu
authored
2 years ago
96
97
98
99
100
101
102
103
104
{ title: '拒绝原因', dataIndex: 'refuseRemark', width: 250 },
]);
}
const [registerTable, { reload }] = useTable({
api: props.isApproved ? getApprovedListApi : getWaitListApi,
searchInfo: { type: 10 },
columns,
sanmu
authored
2 years ago
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// useSearchForm: true,
// formConfig: getFormConfig(),
rowKey: 'id',
actionColumn: {
width: 160,
title: 'Action',
dataIndex: 'action',
// slots: { customRender: 'action' },
},
});
function onSelect(record, selected) {
if (selected) {
checkedKeys.value = [...checkedKeys.value, record.id];
} else {
checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
}
}
function onSelectAll(selected, selectedRows, changeRows) {
const changeIds = changeRows.map((item) => item.id);
if (selected) {
checkedKeys.value = [...checkedKeys.value, ...changeIds];
} else {
checkedKeys.value = checkedKeys.value.filter((id) => {
return !changeIds.includes(id);
});
}
}
function handleEdit(record, e) {
e?.stopPropagation();
return false;
}
function handleProfitModal() {}
sanmu
authored
2 years ago
140
141
142
async function handleDetail(data) {
openDrawer(true, { data });
id.value = data.id;
sanmu
authored
2 years ago
143
144
145
146
147
148
149
150
151
152
153
154
fieldInfos.value = (FIELDS_PROFIT_INFO as any)
.concat({
label: '利润率',
field: 'profitRate',
})
.map((field) => {
if (field.field === 'profitType') {
return {
label: field.label,
value: data.fieldInfos.profitAnalysisFields[field.field] == 0 ? '方式1' : '方式2',
};
}
sanmu
authored
2 years ago
155
156
return {
label: field.label,
sanmu
authored
2 years ago
157
value: data.fieldInfos.profitAnalysisFields[field.field],
sanmu
authored
2 years ago
158
};
sanmu
authored
2 years ago
159
160
})
.filter((item) => !!item.value);
sanmu
authored
2 years ago
161
162
163
164
165
166
baseInfos.value = FIELDS_BASE_INFO.map((field) => {
return {
label: field.label,
value: data.orderBaseInfo[field.field],
};
}).filter((item) => !!item.value);
sanmu
authored
2 years ago
167
168
}
sanmu
authored
2 years ago
169
170
async function handleTrue() {
await approveAuditApi({ status: 10, id: id.value });
sanmu
authored
2 years ago
171
reload();
sanmu
authored
2 years ago
172
closeDrawer();
sanmu
authored
2 years ago
173
174
}
sanmu
authored
2 years ago
175
async function handleFalse() {
sanmu
authored
2 years ago
176
177
178
179
msgVisible.value = true;
// await approveAuditApi({ status: 20, id: id.value });
// reload();
// closeDrawer();
sanmu
authored
2 years ago
180
}
sanmu
authored
2 years ago
181
182
183
184
const role = computed(() => {
return userStore.getUserInfo?.roleSmallVO?.code;
});
sanmu
authored
2 years ago
185
186
187
188
189
190
191
192
193
194
// 定义MsgModalClose的事件,方便子组件调用
const handleMsgModalClose = async (data) => {
if (data) {
await approveAuditApi({ status: 20, id: id.value, refuseRemark: data });
reload();
closeDrawer();
}
msgVisible.value = false;
};
sanmu
authored
2 years ago
195
196
197
198
199
200
201
202
return {
handleProfitModal,
registerTable,
checkedKeys,
currentKey,
onSelect,
handleEdit,
onSelectAll,
sanmu
authored
2 years ago
203
204
205
206
handleDetail,
registerDrawer,
fieldInfos,
baseInfos,
sanmu
authored
2 years ago
207
208
handleTrue,
handleFalse,
sanmu
authored
2 years ago
209
210
role,
ROLE,
sanmu
authored
2 years ago
211
212
msgVisible,
handleMsgModalClose,
sanmu
authored
2 years ago
213
214
215
216
};
},
});
</script>