productApplicationEdit.vue
7.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<template>
<div class="container_wrap full" v-loading="fullscreenLoading">
<div class="content_main">
<ContentWrap id="id-baseInfo" title="数据申请信息" description="" :isExpand="baseInfoExpand" :expand-swicth="true"
class="mb16" @expand="(v) => baseInfoExpand = v">
<Form ref="baseInfoFormRef" :itemList="baseInfoFormItems" formId="base-info-form" :rules="baseInfoFormRules"
col="col3" />
</ContentWrap>
<ContentWrap id="id-approveInfo" title="流程审批" expandSwicth style="margin-top: 15px" :isExpand="expandApprove"
@expand="(v) => expandApprove = v">
<ApprovalProcess ref="approvalProcessRef" v-if="deploymentId" :deploymentId="deploymentId"
:processInstanceId="processInstanceId">
</ApprovalProcess>
</ContentWrap>
</div>
<div class="bottom_tool_wrap">
<el-button @click="cancel">取消</el-button>
<el-button @click="save" v-preReClick>保存</el-button>
<el-button type="primary" @click="submit" v-preReClick>提交审批</el-button>
</div>
</div>
</template>
<script lang="ts" setup name="productApplicationEdit">
import { getCamundaDeploymentId } from "@/api/modules/workFlowService";
import {
getRegisterCatalogDetail
} from "@/api/modules/dataAsset";
import useUserStore from "@/store/modules/user";
import useDataProductApplicationStore from "@/store/modules/productApplication";
import { useValidator } from '@/hooks/useValidator';
const { required } = useValidator();
const { proxy } = getCurrentInstance() as any;
const userStore = useUserStore();
const productApplicationStore = useDataProductApplicationStore();
const route = useRoute();
const router = useRouter();
const userData = JSON.parse(localStorage.userData);
const fullPath = route.fullPath;
const fullscreenLoading = ref(false);
const baseInfoExpand = ref(true);
const expandApprove = ref(true);
const deploymentId = ref('');
const processInstanceId = ref('');
const baseInfoFormRef = ref();
const baseInfoFormItems = ref([{
label: '产品名称',
type: 'label',
field: 'damName',
col: 'link',
default: '-',
click: () => {
//TODO
debugger
router.push({
name: 'productDetail',
query: {
id: route.query.id,
type: 'view'
}
})
}
},
{
label: '产品编码',
type: 'input',
placeholder: '请输入',
field: 'productCode',
default: '-',
disabled: true
},
{
label: '产品类型',
type: 'input',
placeholder: '请输入',
field: 'damTypeName',
default: '-',
disabled: true
},
{
label: "预计使用期限",
type: "date-picker",
field: "useDateRange",
default: null,
placeholder: "开始时间~结束时间",
clearable: true,
disabledDate: (date) => {
const today = new Date();
// 将 today 设置为 00:00:00,只比较日期部分(本地时间)
const todayStart = new Date(
today.getFullYear(),
today.getMonth(),
today.getDate()
);
// 将 date 也转换为本地日期的开始时间(避免 UTC 问题)
const dateStart = new Date(
date.getFullYear(),
date.getMonth(),
date.getDate()
);
// 禁用 dateStart < todayStart 的日期(即今天之前)
return dateStart.getTime() < todayStart.getTime();
},
required: true,
},
{
label: "数据范围",
type: "date-picker",
field: "useDataDateRange",
default: null,
placeholder: "开始时间~结束时间",
clearable: true,
required: true,
},
{
label: '产品发布机构',
type: 'input',
placeholder: '请输入',
field: 'productPublisherName',
default: '',
disabled: true
},
{
label: '数据粒度说明',
type: 'textarea',
placeholder: '请输入需要的需求字段',
field: 'dataDescription',
default: '',
block: true,
maxlength: 500,
clearable: true,
required: true,
},
{
label: '使用场景描述',
type: 'textarea',
placeholder: '请输入使用该数据产品的场景描述信息',
field: 'useDescription',
default: '',
block: true,
maxlength: 500,
clearable: true,
required: true,
},
])
const baseInfoFormRules = ref({
useDateRange: [{
type: 'array', required: true, message: '请选择预计使用期限', trigger: 'change',
}],
useDataDateRange: [{
type: 'array', required: true, message: '请选择数据范围', trigger: 'change',
}],
dataDescription: [required('请输入数据粒度说明')],
useDescription: [required('请输入使用场景描述')]
})
const cancel = () => {
proxy.$openMessageBox("当前页面尚未保存,确定放弃修改吗?", () => {
userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
router.push({
name: 'productApplicationManage'
});
}, () => {
proxy.$ElMessage.info("已取消");
});
}
const save = () => {
// 保存不检验。
}
const submit = () => {
baseInfoFormRef.value?.ruleFormRef?.validate().then((valid, errorItem) => {
if (valid) {
let formInline = baseInfoFormRef.value.formInline;
// fullscreenLoading.value = true;
// listingSavePortal(params).then((res: any) => {
// fullscreenLoading.value = false;
// if (res?.code == proxy.$passCode) {
// proxy.$ElMessage.success('提交审批成功');
// userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
// productApplicationStore.setIsRefresh(true);
// router.push({
// name: "productApplicationManage",
// });
// } else {
// res?.msg && proxy.$ElMessage.error(res.msg);
// }
// }).catch((res) => {
// fullscreenLoading.value = false;
// });
} else {
var obj = Object.keys(errorItem);
baseInfoFormRef.value.ruleFormRef.scrollToField(obj[0]);
}
})
}
onActivated(() => {
let tab: any = userStore.tabbar.find((tab: any) => tab.fullPath == fullPath);
let detailType = route.query.type;
let name = route.query.name;
if (tab) {
switch (detailType) {
case 'edit':
tab.meta.title = `编辑-${name}`;
break;
case 'redit':
tab.meta.title = `编辑-${name}`;
break;
default:
tab.meta.title = '新增数据申请';
}
document.title = tab.meta.title;
};
})
onBeforeMount(() => {
// getCamundaDeploymentId('10016', userData.tenantGuid, userData.staffGuid).then((res: any) => {
// if (res.code == proxy.$passCode) {
// deploymentId.value = res.data;
// } else {
// proxy.$ElMessage.error(res.msg);
// }
// })
fullscreenLoading.value = true;
getRegisterCatalogDetail(route.query.guid).then((res: any) => {
fullscreenLoading.value = false;
if (res?.code == proxy.$passCode) {
let detail = res.data || {};
baseInfoFormItems.value[0].default = <string>route.query.damName;
baseInfoFormItems.value[1].default = detail.productCode;
baseInfoFormItems.value[2].default = detail.damTypeName;
} else {
res?.msg && proxy.$ElMessage.error(res.msg);
}
})
})
</script>
<style lang="scss" scoped>
.content_main {
height: calc(100% - 40px);
padding: 16px;
overflow: hidden auto;
position: sticky;
}
.bottom_tool_wrap {
height: 40px;
padding: 0 16px;
border-top: 1px solid #d9d9d9;
display: flex;
justify-content: center;
align-items: center;
}
:deep(.el-form) {
.link {
color: var(--el-color-primary);
cursor: pointer;
line-height: 32px;
}
}
</style>