xixi联动

This commit is contained in:
zhonghua.li
2026-04-06 21:22:21 +08:00
parent 96d0f2aa7d
commit bd0850da4d
2 changed files with 115 additions and 38 deletions

View File

@@ -196,40 +196,9 @@ export default {
}
},
created() {
const q = this.$route.query
if (q.openCreate === '1' && q.parentId) {
this.listQuery.parentId = String(q.parentId)
}
this.getList()
},
mounted() {
this.applyOpenCreateFromQuery(this.$route, false)
},
watch: {
'$route'(to) {
if (to.name === 'XixiInspectionStory') {
this.applyOpenCreateFromQuery(to, true)
}
}
},
methods: {
applyOpenCreateFromQuery(route, fetchList) {
const q = route.query
if (q.openCreate !== '1' || !q.parentId) return
this.listQuery.parentId = String(q.parentId)
this.listQuery.page = 1
if (fetchList) {
this.getList()
}
this.resetTemp()
this.temp.parentId = String(q.parentId)
this.temp.projectName = q.projectName ? String(q.projectName) : ''
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs.dataForm && this.$refs.dataForm.clearValidate()
})
},
formatDateTime(val) {
if (!val) return '—'
const d = new Date(val)

View File

@@ -128,6 +128,46 @@
@pagination="getList"
/>
<el-dialog
title="新增场景话术"
:visible.sync="storyDialogVisible"
width="720px"
top="5vh"
append-to-body
@close="onStoryDialogClose"
>
<el-form ref="storyDataForm" :rules="storyRules" :model="storyTemp" label-width="110px" class="story-form">
<el-form-item label="父项目ID" prop="parentId">
<el-input v-model="storyTemp.parentId" readonly placeholder="关联检查项 ID" class="story-readonly-input" />
</el-form-item>
<el-form-item label="父项目名称" prop="projectName">
<el-input v-model="storyTemp.projectName" readonly placeholder="检查项项目名称" class="story-readonly-input" />
</el-form-item>
<el-form-item label="场景" prop="scenario">
<el-input v-model="storyTemp.scenario" placeholder="场景" maxlength="200" />
</el-form-item>
<el-form-item label="话术" prop="talkScript">
<el-input v-model="storyTemp.talkScript" type="textarea" :rows="3" placeholder="话术" maxlength="2000" show-word-limit />
</el-form-item>
<el-form-item label="引导故事" prop="guideStory">
<el-input v-model="storyTemp.guideStory" type="textarea" :rows="3" placeholder="引导故事" maxlength="2000" show-word-limit />
</el-form-item>
<el-form-item label="加分标准" prop="bonusStandard">
<el-input v-model="storyTemp.bonusStandard" type="textarea" :rows="2" placeholder="加分标准" maxlength="1000" show-word-limit />
</el-form-item>
<el-form-item label="减分标准" prop="deductionStandard">
<el-input v-model="storyTemp.deductionStandard" type="textarea" :rows="2" placeholder="减分标准" maxlength="1000" show-word-limit />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="storyTemp.remark" type="textarea" :rows="2" placeholder="备注" maxlength="500" show-word-limit />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="storyDialogVisible = false"> </el-button>
<el-button type="primary" @click="createStoryData"> </el-button>
</div>
</el-dialog>
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="560px" @close="onDialogClose">
<el-form ref="dataForm" :rules="rules" :model="temp" label-width="100px">
<el-form-item label="父级ID" prop="parentId">
@@ -146,7 +186,9 @@
<span class="rate-hint">15 5 星危害最大</span>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-input v-model="temp.type" placeholder="类型" maxlength="100" />
<el-select v-model="temp.type" placeholder="请选择类型" clearable style="width: 100%;">
<el-option v-for="item in typeOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="简述" prop="brief">
<el-input v-model="temp.brief" type="textarea" :rows="3" placeholder="简述" maxlength="500" show-word-limit />
@@ -171,6 +213,7 @@ import {
updateXixiInspection,
deleteXixiInspection
} from '@/api/xixi-inspection'
import { addInspectionStory } from '@/api/xixi-inspection-story'
import waves from '@/directive/waves'
import Pagination from '@/components/Pagination'
@@ -184,6 +227,17 @@ const emptyForm = () => ({
remark: ''
})
const emptyStoryForm = () => ({
parentId: '',
projectName: '',
scenario: '',
talkScript: '',
guideStory: '',
bonusStandard: '',
deductionStandard: '',
remark: ''
})
export default {
name: 'XixiInspection',
components: { Pagination },
@@ -222,10 +276,17 @@ export default {
update: '编辑检查项',
create: '新增检查项'
},
typeOptions: ['三观底线', '日常与生活', '情绪与感受', '未来与期待', '避雷'],
starTexts: ['1星', '2星', '3星', '4星', '5星'],
rules: {
projectName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
hazardStars: [{ required: true, validator: validateHazardStars, trigger: 'change' }]
},
storyDialogVisible: false,
storyTemp: emptyStoryForm(),
storyRules: {
parentId: [{ required: true, message: '缺少父项目 ID', trigger: 'blur' }],
projectName: [{ required: true, message: '缺少父项目名称', trigger: 'blur' }]
}
}
},
@@ -348,17 +409,56 @@ export default {
this.$refs.dataForm && this.$refs.dataForm.clearValidate()
})
},
resetStoryTemp() {
this.storyTemp = emptyStoryForm()
},
buildStorySubmitPayload() {
const trim = (s) => (s || '').trim()
return {
parentId: trim(this.storyTemp.parentId) || null,
projectName: trim(this.storyTemp.projectName),
scenario: trim(this.storyTemp.scenario) || null,
talkScript: trim(this.storyTemp.talkScript) || null,
guideStory: trim(this.storyTemp.guideStory) || null,
bonusStandard: trim(this.storyTemp.bonusStandard) || null,
deductionStandard: trim(this.storyTemp.deductionStandard) || null,
remark: trim(this.storyTemp.remark) || null
}
},
handleAddStory(row) {
if (!row || row.id == null || row.id === '') {
this.$message.warning('无法获取检查项 ID')
return
}
this.$router.push({
name: 'XixiInspectionStory',
query: {
parentId: String(row.id),
projectName: row.projectName || '',
openCreate: '1'
this.resetStoryTemp()
this.storyTemp.parentId = String(row.id)
this.storyTemp.projectName = (row.projectName || '').trim() || '(未命名)'
this.storyDialogVisible = true
this.$nextTick(() => {
this.$refs.storyDataForm && this.$refs.storyDataForm.clearValidate()
})
},
createStoryData() {
this.$refs.storyDataForm.validate((valid) => {
if (!valid) return
const payload = this.buildStorySubmitPayload()
addInspectionStory(payload)
.then((response) => {
if (response && (response.code === 20000 || response.code === 200)) {
this.$message.success(response.message || '新增成功')
this.storyDialogVisible = false
} else {
this.$message.error(response?.message || '新增失败')
}
})
.catch(() => {})
})
},
onStoryDialogClose() {
this.resetStoryTemp()
this.$nextTick(() => {
if (this.$refs.storyDataForm) {
this.$refs.storyDataForm.clearValidate()
}
})
},
@@ -499,4 +599,12 @@ export default {
.dialog-footer {
text-align: right;
}
.story-form .el-textarea {
max-width: 100%;
}
.story-readonly-input >>> .el-input__inner {
cursor: default;
color: #606266;
background-color: #f5f7fa;
}
</style>