|
|
@@ -15,13 +15,13 @@
|
|
|
<el-option label="女" :value="2" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="用户身份">
|
|
|
- <el-select v-model="queryForm.userType" placeholder="全部" clearable style="width:120px">
|
|
|
+ <el-form-item label="用户分类">
|
|
|
+ <el-select v-model="queryForm.userCategoryId" placeholder="全部" clearable style="width:120px">
|
|
|
<el-option
|
|
|
v-for="item in userCategoryOptions"
|
|
|
- :key="item.code"
|
|
|
+ :key="item.id"
|
|
|
:label="item.name"
|
|
|
- :value="item.code"
|
|
|
+ :value="item.id"
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
@@ -129,11 +129,9 @@
|
|
|
<template #default="{ row }">{{ row.age != null ? row.age + '岁' : '-' }}</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="phone" label="手机号" width="130" />
|
|
|
- <el-table-column prop="userType" label="用户身份" width="95" align="center">
|
|
|
+ <el-table-column prop="userCategoryName" label="用户分类" width="110" align="center">
|
|
|
<template #default="{ row }">
|
|
|
- <el-tag :type="userTypeTagType(row.userType)" size="small" v-if="row.userType">
|
|
|
- {{ userTypeText(row.userType) }}
|
|
|
- </el-tag>
|
|
|
+ <el-tag v-if="row.userCategoryName" type="primary" size="small">{{ row.userCategoryName }}</el-tag>
|
|
|
<span v-else>-</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
@@ -232,13 +230,13 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col v-if="formData.id" :span="12">
|
|
|
- <el-form-item label="用户身份" prop="userType">
|
|
|
- <el-select v-model="formData.userType" placeholder="请选择用户身份" style="width:100%">
|
|
|
+ <el-form-item label="用户分类" prop="userCategoryId">
|
|
|
+ <el-select v-model="formData.userCategoryId" placeholder="请选择用户分类" style="width:100%">
|
|
|
<el-option
|
|
|
v-for="item in userCategoryOptions"
|
|
|
- :key="item.code"
|
|
|
+ :key="item.id"
|
|
|
:label="item.name"
|
|
|
- :value="item.code"
|
|
|
+ :value="item.id"
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
@@ -354,6 +352,7 @@ import { regionData, codeToText } from 'element-china-area-data'
|
|
|
import ExcelExport from '@/components/ExcelExport.vue'
|
|
|
import ExcelImport from '@/components/ExcelImport.vue'
|
|
|
import { dateTimeFormatter } from '@/utils/date'
|
|
|
+import { getUserCategoryList } from '@/api/userCategory'
|
|
|
import {
|
|
|
getProfilePage,
|
|
|
addProfile,
|
|
|
@@ -371,7 +370,7 @@ const queryForm = reactive({
|
|
|
keyword: '',
|
|
|
deviceCode: '',
|
|
|
gender: null,
|
|
|
- userType: null,
|
|
|
+ userCategoryId: null,
|
|
|
provinceCode: '',
|
|
|
cityCode: '',
|
|
|
districtCode: '',
|
|
|
@@ -393,7 +392,7 @@ const exportHeaders = [
|
|
|
{ label: '性别', prop: 'genderText' },
|
|
|
{ label: '年龄', prop: 'age' },
|
|
|
{ label: '手机号', prop: 'phone' },
|
|
|
- { label: '用户身份', prop: 'userTypeLabel' },
|
|
|
+ { label: '用户分类', prop: 'userCategoryText' },
|
|
|
{ label: '所在地区', prop: 'regionText' },
|
|
|
{ label: '详细地址', prop: 'address' },
|
|
|
{ label: '设备编号', prop: 'deviceCodes' },
|
|
|
@@ -493,26 +492,8 @@ function onQueryCityChange(val) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/** 用户身份固定选项(user_type 主分类) */
|
|
|
-const userCategoryOptions = [
|
|
|
- { code: 1, name: '用户', tagType: 'primary' },
|
|
|
- { code: 2, name: '专家', tagType: 'warning' },
|
|
|
- { code: 3, name: '管理员', tagType: 'danger' }
|
|
|
-]
|
|
|
-
|
|
|
-/** 用户身份文本 */
|
|
|
-function userTypeText(type) {
|
|
|
- if (type == null) return '-'
|
|
|
- const item = userCategoryOptions.find(c => c.code === type)
|
|
|
- return item ? item.name : '-'
|
|
|
-}
|
|
|
-
|
|
|
-/** 用户身份标签颜色 */
|
|
|
-function userTypeTagType(type) {
|
|
|
- if (type == null) return 'info'
|
|
|
- const item = userCategoryOptions.find(c => c.code === type)
|
|
|
- return item?.tagType || 'primary'
|
|
|
-}
|
|
|
+/** 用户分类选项 */
|
|
|
+const userCategoryOptions = ref([])
|
|
|
|
|
|
/** 根据行政区划编码还原为 “省/市/区” 文本 */
|
|
|
function formatRegion(row) {
|
|
|
@@ -530,7 +511,7 @@ async function loadData() {
|
|
|
keyword: queryForm.keyword || undefined,
|
|
|
deviceCode: queryForm.deviceCode || undefined,
|
|
|
gender: queryForm.gender,
|
|
|
- userType: queryForm.userType,
|
|
|
+ userCategoryId: queryForm.userCategoryId,
|
|
|
provinceCode: queryForm.provinceCode || undefined,
|
|
|
cityCode: queryForm.cityCode || undefined,
|
|
|
districtCode: queryForm.districtCode || undefined,
|
|
|
@@ -545,7 +526,7 @@ async function loadData() {
|
|
|
const records = (res.data?.records || []).map(r => ({
|
|
|
...r,
|
|
|
genderText: r.gender === 1 ? '男' : r.gender === 2 ? '女' : '-',
|
|
|
- userTypeLabel: userTypeText(r.userType),
|
|
|
+ userCategoryText: r.userCategoryName || '-',
|
|
|
regionText: formatRegion(r),
|
|
|
acupointText: r.acupointTableId ? '已生成' : '未生成'
|
|
|
}))
|
|
|
@@ -565,7 +546,7 @@ function handleReset() {
|
|
|
queryForm.keyword = ''
|
|
|
queryForm.deviceCode = ''
|
|
|
queryForm.gender = null
|
|
|
- queryForm.userType = null
|
|
|
+ queryForm.userCategoryId = null
|
|
|
queryForm.provinceCode = ''
|
|
|
queryForm.cityCode = ''
|
|
|
queryForm.districtCode = ''
|
|
|
@@ -592,6 +573,7 @@ const formData = reactive({
|
|
|
age: null,
|
|
|
phone: '',
|
|
|
userType: 1,
|
|
|
+ userCategoryId: null,
|
|
|
regionCodes: [],
|
|
|
address: '',
|
|
|
shoulderWidth: null,
|
|
|
@@ -678,7 +660,7 @@ const formRules = {
|
|
|
function handleAdd() {
|
|
|
Object.assign(formData, {
|
|
|
id: null, name: '', gender: null, age: null, phone: '',
|
|
|
- userType: 1, regionCodes: [], address: '',
|
|
|
+ userType: 1, userCategoryId: null, regionCodes: [], address: '',
|
|
|
shoulderWidth: null, bodyHeight: null, spineLength: null, height: null, weight: null,
|
|
|
fingerWidth1: null, fingerWidth15: null, fingerWidth3: null
|
|
|
})
|
|
|
@@ -694,6 +676,7 @@ function handleEdit(row) {
|
|
|
age: row.age,
|
|
|
phone: row.phone,
|
|
|
userType: row.userType ?? 1,
|
|
|
+ userCategoryId: row.userCategoryId || null,
|
|
|
regionCodes: [row.provinceCode, row.cityCode, row.districtCode].filter(c => !!c),
|
|
|
address: row.address || '',
|
|
|
shoulderWidth: row.shoulderWidth,
|
|
|
@@ -780,6 +763,15 @@ function handleDeviceManager(row) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+async function loadUserCategories() {
|
|
|
+ try {
|
|
|
+ const res = await getUserCategoryList()
|
|
|
+ userCategoryOptions.value = res.data || []
|
|
|
+ } catch (e) {
|
|
|
+ userCategoryOptions.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// ======================== 生成用户穴位 ========================
|
|
|
|
|
|
/**
|
|
|
@@ -802,6 +794,7 @@ async function handleGenerateAcupoint() {
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
+ loadUserCategories()
|
|
|
loadData()
|
|
|
})
|
|
|
</script>
|