AddEditSnapshotClusterDialog.vue
5.83 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
<template>
<a-modal v-model:visible="visible" title="新增抓拍记录" :width="800" @ok="handleSubmitData">
<a-form ref="formRef" :model="submitForm" :rules="formRules" labelAlign="right">
<a-row>
<a-col :span="12">
<a-form-item label="集团" name="accountId">
<strong>{{ filterMapName(submitForm.accountId, optionsMap['accountList']) }}</strong>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="广场" name="mallId">
<strong>{{ filterMapName(submitForm.mallId, optionsMap['mallList']) }}</strong>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="出入口地点" name="gateId">
<a-select
v-model:value="submitForm.gateId"
placeholder="请选择"
optionFilterProp="label"
show-search
:options="optionsMap['gateList']"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="人员类型" name="personType">
<a-select
v-model:value="submitForm.personType"
placeholder="请选择"
optionFilterProp="label"
show-search
:options="optionsMap['personTypeList']"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="方向" name="direction">
<a-select
v-model:value="submitForm.direction"
placeholder="请选择"
optionFilterProp="label"
show-search
:options="optionsMap['directionList']"
/>
</a-form-item>
</a-col>
<a-col :span="12"></a-col>
<a-col :span="12">
<a-form-item label="性别" name="gender">
<a-select
v-model:value="submitForm.gender"
placeholder="请选择"
optionFilterProp="label"
show-search
:options="optionsMap['genderList']"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="年龄" name="age">
<a-select
v-model:value="submitForm.age"
placeholder="请选择"
optionFilterProp="label"
show-search
:options="optionsMap['ageList']"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="所属统计日期" name="countdate">
<a-date-picker
v-model:value="submitForm.countdate"
format="YYYY-MM-DD"
valueFormat="YYYY-MM-DD"
:allowClear="false"
style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="抓拍时间" name="counttime">
<a-date-picker
v-model:value="submitForm.counttime"
show-time
format="YYYY-MM-DD HH:mm:ss"
valueFormat="YYYY-MM-DD HH:mm:ss"
:allowClear="false"
style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="是否是新人">
<a-radio-group v-model:value="isNewPerson">
<a-radio :value="false">否</a-radio>
<a-radio :value="true">是</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col :span="24" v-if="!isNewPerson">
<a-form-item label="人Id" name="personUnid">
<a-input v-model:value="submitForm.personUnid" placeholder="请输入" />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-modal>
</template>
<script setup>
import { defineExpose, ref } from 'vue'
import { cloneDeep } from 'lodash'
import { message } from 'ant-design-vue'
import clusterResultApi from '../ClusterResultApi'
const submitForm = ref({})
const optionsMap = ref({})
const visible = ref(false)
const isNewPerson = ref(false)
/**
* 表单校验相关
*/
const formRef = ref()
const formRules = {
gateId: [{ required: true, message: '请选择出入口地点' }],
personType: [{ required: true, message: '请选择人员类型' }],
direction: [{ required: true, message: '请选择方向' }],
age: [{ required: true, message: '请选择年龄'}],
gender: [{ required: true, message: '请选择性别' }],
countdate: [{ required: true, message: '请选择所属统计日期' }],
counttime: [{ required: true, message: '请选择抓拍时间' }],
personUnid: [{ required: true, message: '请输入人Id' }]
}
// 提交数据
const handleSubmitData = async () => {
try{
await formRef.value.validate()
const params = {
...submitForm.value,
countdate:`${submitForm.value.countdate} 00:00:00`,
personUnid: isNewPerson.value ? null : submitForm.value.personUnid,
}
const res = await clusterResultApi.addFaceRecognitionsApi(params)
if(res.msg_code === 200) {
message.success("提交成功,当前不会修正统计数据,需手动重跑数据")
visible.value = false
}else{
message.error(res.msg_info || '请求异常')
}
}catch (e) {
console.log(e)
}
}
// 初始化弹窗
const initDialog = (form, selectOptionsMap) => {
submitForm.value = cloneDeep(form)
optionsMap.value = selectOptionsMap
visible.value = true
}
// 筛选固定值字段
const filterMapName = (id, list) => {
return list.find(item => item.value === id)?.label || '--'
}
defineExpose({
initDialog
})
</script>
<style scoped lang="less">
:deep(.ant-col.ant-form-item-label) {
width: 120px;
}
// 确保选择框宽度充满容器
.ant-select, .ant-picker {
width: 100%;
}
</style>