|
|
@@ -188,21 +188,8 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="创作人" prop="authorId">
|
|
|
- <el-select
|
|
|
- v-model="formData.authorId"
|
|
|
- placeholder="请选择创作人"
|
|
|
- style="width:100%"
|
|
|
- filterable
|
|
|
- @change="onAuthorChange"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="u in sysUserOptions"
|
|
|
- :key="u.id"
|
|
|
- :label="`${u.nickname || u.username} (${userTypeLabel(u.userType)})`"
|
|
|
- :value="u.id"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
+ <el-form-item label="创作人" prop="authorName">
|
|
|
+ <el-input v-model="formData.authorName" disabled placeholder="当前登录用户" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -374,30 +361,28 @@ import {
|
|
|
} from '@/api/plan'
|
|
|
import { getAcupointList } from '@/api/acupoint'
|
|
|
import { getTechniqueList } from '@/api/moxibustion'
|
|
|
-import { getAppUserList } from '@/api/auth'
|
|
|
+import { useUserStore } from '@/store/user'
|
|
|
import { formatDateTime } from '@/utils/date'
|
|
|
// ============ 枚举常量 ============
|
|
|
const effectOptions = ['驱寒', '祛湿', '祛风', '化瘀', '活血', '化痰', '养颜', '扶阳']
|
|
|
const symptomsOptions = ['怕冷', '感冒', '咳嗽', '痰多', '疼痛', '腰酸', '失眠', '疲劳', '皮肤暗沉', '手脚冰凉', '其他']
|
|
|
+const userStore = useUserStore()
|
|
|
|
|
|
// ============ 选项列表(用于选择框) ============
|
|
|
const acupointOptions = ref([])
|
|
|
const techniqueOptions = ref([])
|
|
|
-const sysUserOptions = ref([])
|
|
|
|
|
|
/**
|
|
|
- * 加载穴位、手法、系统用户选项列表
|
|
|
+ * 加载穴位、手法选项列表
|
|
|
*/
|
|
|
async function loadOptions() {
|
|
|
try {
|
|
|
- const [acupointRes, techniqueRes, userRes] = await Promise.all([
|
|
|
+ const [acupointRes, techniqueRes] = await Promise.all([
|
|
|
getAcupointList(),
|
|
|
- getTechniqueList(),
|
|
|
- getAppUserList()
|
|
|
+ getTechniqueList()
|
|
|
])
|
|
|
acupointOptions.value = acupointRes.data || []
|
|
|
techniqueOptions.value = techniqueRes.data || []
|
|
|
- sysUserOptions.value = userRes.data || []
|
|
|
} catch (e) {
|
|
|
// 选项加载失败不影响主流程
|
|
|
}
|
|
|
@@ -525,9 +510,9 @@ const defaultForm = () => ({
|
|
|
applicableGender: 0,
|
|
|
ageMin: 1,
|
|
|
ageMax: 120,
|
|
|
- authorId: null,
|
|
|
- authorName: '',
|
|
|
- authorType: 1,
|
|
|
+ authorId: getCurrentAuthorId(),
|
|
|
+ authorName: getCurrentAuthorName(),
|
|
|
+ authorType: getCurrentAuthorType(),
|
|
|
description: '',
|
|
|
steps: [defaultStep()]
|
|
|
})
|
|
|
@@ -563,23 +548,23 @@ function onTechniqueChange(id, index) {
|
|
|
formData.steps[index].techniqueName = found ? found.name : ''
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 应用用户类型标签文字
|
|
|
- */
|
|
|
-function userTypeLabel(val) {
|
|
|
- return { 1: '普通用户', 2: '专家', 3: '管理员' }[val] || '未知'
|
|
|
+function getCurrentAuthorId() {
|
|
|
+ return userStore.userInfo?.userId || null
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 创作人选择变更:同步填充 authorName 和 authorType
|
|
|
- * AppUser.userType → Plan.authorType 映射:1(普通用户)→2,2(专家)→3,3(管理员)→1
|
|
|
- */
|
|
|
-function onAuthorChange(id) {
|
|
|
- const found = sysUserOptions.value.find(u => u.id === id)
|
|
|
- formData.authorName = found ? (found.nickname || found.username) : ''
|
|
|
- // 角色映射
|
|
|
+function getCurrentAuthorName() {
|
|
|
+ return userStore.nickname || userStore.username || 'ADMIN'
|
|
|
+}
|
|
|
+
|
|
|
+function getCurrentAuthorType() {
|
|
|
const typeMap = { 1: 2, 2: 3, 3: 1 }
|
|
|
- formData.authorType = found ? (typeMap[found.userType] || 2) : 2
|
|
|
+ return typeMap[userStore.userInfo?.userType] || 1
|
|
|
+}
|
|
|
+
|
|
|
+function applyCurrentAuthor() {
|
|
|
+ formData.authorId = getCurrentAuthorId()
|
|
|
+ formData.authorName = getCurrentAuthorName()
|
|
|
+ formData.authorType = getCurrentAuthorType()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -603,6 +588,7 @@ function removeStep(index) {
|
|
|
function handleAdd() {
|
|
|
Object.assign(formData, defaultForm())
|
|
|
formData.steps = [defaultStep()]
|
|
|
+ applyCurrentAuthor()
|
|
|
dialogTitle.value = '新增方案'
|
|
|
dialogMode.value = 'add'
|
|
|
dialogVisible.value = true
|
|
|
@@ -619,6 +605,7 @@ async function handleEdit(row) {
|
|
|
symptomsList: detail.symptoms ? detail.symptoms.split(',') : [],
|
|
|
steps: detail.steps?.length > 0 ? detail.steps : [defaultStep()]
|
|
|
})
|
|
|
+ applyCurrentAuthor()
|
|
|
dialogTitle.value = '编辑方案'
|
|
|
dialogMode.value = 'edit'
|
|
|
dialogVisible.value = true
|
|
|
@@ -629,6 +616,7 @@ async function handleEdit(row) {
|
|
|
*/
|
|
|
async function handleSubmit(publishFlag) {
|
|
|
await formRef.value.validate()
|
|
|
+ applyCurrentAuthor()
|
|
|
submitLoading.value = true
|
|
|
try {
|
|
|
const payload = {
|