提交 40f043fc authored 作者: pengxiaohui's avatar pengxiaohui

feat: 案例产品分析模块开发

上级 abc2055b
VITE_LOGIN_URL=https://login.ezijing.com/auth/login/index
VITE_SECRET_ID=ezijing_3ab2242d9ed709256181821cc9c05880
VITE_SECRET_KEY=aec7836687fb9cb4a67e15a493aca4f9
\ No newline at end of file
VITE_LOGIN_URL=https://login2.ezijing.com/auth/login/index
VITE_SECRET_ID=ezijing_2c9592e083613825abf2cc8ea94ee9f6
VITE_SECRET_KEY=e28af679d0def36b93275d66cccf098c
\ No newline at end of file
VITE_LOGIN_URL=https://login2.ezijing.com/auth/login/index
VITE_SECRET_ID=ezijing_2c9592e083613825abf2cc8ea94ee9f6
VITE_SECRET_KEY=e28af679d0def36b93275d66cccf098c
\ No newline at end of file
......@@ -142,7 +142,7 @@ export default {
// 是否含有翻页
hasPagination: { type: Boolean, default: true },
// 每页多少条数据
limit: { type: Number, default: 20 }
limit: { type: Number, default: 10 }
},
data() {
return {
......@@ -205,7 +205,15 @@ export default {
this.loading = true
httpRequest(params)
.then(res => {
const { data = [], total = 0 } = res.data || {}
let data, total
if (Array.isArray(res.data)) {
data = res.data
total = res.total || 0
} else {
data = res.data.data || []
total = res.data.total || 0
}
// const { data = [], total = 0 } = res.data || {}
this.page.total = total
this.dataList = callback ? callback(data) : data
})
......
......@@ -29,4 +29,79 @@ export function updateCase(id, data) {
*/
export function deleteCase(id) {
return httpRequest.delete(`/api/xtraining/admin/v1/case/${id}`)
}
\ No newline at end of file
}
/**
* 获取案例详情
*/
export function getCaseDetails(id) {
return httpRequest.get(`/api/xtraining/admin/v1/case/${id}`)
}
/* ********** 产品分析 ************ */
/**
* 获取题干列表
*/
export function getStemList(params) {
return httpRequest.get('/api/xtraining/admin/v1/completion/question-stems', { params })
}
/**
* 获取题目列表
*/
export function getQuesList(id) {
return httpRequest.get(`/api/xtraining/admin/v1/completion/questions/${id}`)
}
/**
* 创建题干
*/
export function createStem(data) {
return httpRequest.post('/api/xtraining/admin/v1/completion/question-stem', data)
}
/**
* 删除题干
*/
export function deleteStem(id) {
return httpRequest.delete(`/api/xtraining/admin/v1/completion/question-stem/${id}`)
}
/**
* 新建题目
*/
export function createQues(data) {
return httpRequest.post('/api/xtraining/admin/v1/completion/question', data)
}
/**
* 更新题目
*/
export function updateQues(id, data) {
return httpRequest.put(`/api/xtraining/admin/v1/completion/question/${id}`, data)
}
/**
* 删除题目
*/
export function deleteQues(id) {
return httpRequest.delete(`/api/xtraining/admin/v1/completion/question/${id}`)
}
/**
* 获取题目答案列表
*/
export function getQuesAnswerList(params) {
return httpRequest.get(`/api/xtraining/admin/v1/completion/rules/${params.id}`)
}
/**
* 新建题目答案
*/
export function createQuesAnswer(id, data) {
return httpRequest.post(`/api/xtraining/admin/v1/completion/rule/${id}`, data)
}
/**
* 更新题目答案
*/
export function updateQuesAnswer(id, data) {
return httpRequest.put(`/api/xtraining/admin/v1/completion/rule/${id}`, data)
}
/**
* 删除题目答案
*/
export function deleteQuesAnswer(id) {
return httpRequest.delete(`/api/xtraining/admin/v1/completion/rule/${id}`)
}
<template>
<el-descriptions class="margin-top" title="" :column="1" size="" border>
<el-descriptions-item>
<template slot="label">案件名称</template>{{ form.name }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">案件ID</template>{{ form.id }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">唯一标识</template>{{ form.tag }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">创建时间</template>{{ form.created_at }}
</el-descriptions-item>
</el-descriptions>
</template>
<script>
import { getCaseDetails } from '../api'
export default {
props: {
id: {
type: String
}
},
data() {
return {
form: {
id: '11111111111111',
name: '22222',
tag: '3111111111111111111',
created_at: '2021-11-16 09:30:00'
}
}
},
computed: {
},
filters: {
},
mounted() {
this.getBaseInfo()
},
methods: {
getBaseInfo() {
getCaseDetails(this.id).then(res => {
this.form = res.data
})
}
}
}
</script>
<style scoped>
.bar {
padding-bottom: 10px;
}
.item {
font-size: 16px;
line-height: 48px;
color: #494949;
}
</style>
\ No newline at end of file
......@@ -103,8 +103,7 @@ export default {
url: it
}
})
}
else this.form[key] = this.options.data[key]
} else this.form[key] = this.options.data[key]
}
})
}
......@@ -155,7 +154,6 @@ export default {
this.form.pdf_uris.splice(index, 1)
}
})
console.log(this.form.pdf_uris)
},
fetchCreateCase() {
const params = Object.assign({}, this.form)
......
<template>
<app-card>
<app-list v-bind="tableOptions" ref="list">
<template #header-aside>
<el-button type="primary" @click="handleCreate">创建答案</el-button>
</template>
<template v-slot:table-x="{ row }">
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="danger" plain @click="handleDelete(row)">删除</el-button>
</template>
</app-list>
<el-dialog :title="isCreate ? '创建答案':'编辑答案'" :visible.sync="dialogVisible" width="460px" append-to-body :destroy-on-close="true">
<el-form :model="form" :rules="rules" ref="ruleForm" label-width="120px">
<el-form-item label="答案" prop="answer">
<el-input v-model="form.answer" size="small" placeholder="请输入答案"/>
</el-form-item>
<el-form-item label="唯一标识" prop="tag">
<el-input v-model="form.tag" size="small" placeholder="请输入唯一标识" :disabled="!isCreate"/>
</el-form-item>
<el-form-item label="分数" prop="score">
<el-input-number v-model="form.score" :precision="2" :step="1" label="请输入分数" />
</el-form-item>
<el-form-item label="答案匹配度" prop="matching_degree">
<el-input-number v-model="form.matching_degree" :precision="2" :step="1" label="请输入分数" :min="0" :max="100" />
</el-form-item>
<el-form-item>
<el-button size="mini" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleSubmit" size="mini">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
</app-card>
</template>
<script>
import { getQuesAnswerList, createQuesAnswer, updateQuesAnswer, deleteQuesAnswer } from '../api'
const defaultForm = {
answer: '',
tag: '',
score: 0,
matching_degree: 0
}
export default {
props: {
id: {
type: String,
defaulut: ''
}
},
data() {
return {
form: Object.assign({}, defaultForm),
rules: {
answer: { required: true, message: '请输入答案', trigger: 'blur' },
tag: { required: true, message: '请输入唯一标识', trigger: 'blur' }
},
isCreate: true,
dialogVisible: false,
updateId: ''
}
},
computed: {
// 列表配置
tableOptions() {
return {
remote: {
httpRequest: getQuesAnswerList,
params: { id: this.id }
},
columns: [
{ label: '答案', prop: 'answer' },
{ label: '唯一标识', prop: 'tag' },
{ label: '分数', prop: 'score' },
{ label: '答案匹配度', prop: 'matching_degree' },
{ label: '创建时间', prop: 'created_at' },
{ label: '操作', slots: 'table-x', align: 'right', width: 160 }
]
}
}
},
methods: {
handleCreate() {
this.form = Object.assign({}, defaultForm)
this.dialogVisible = true
this.isCreate = true
},
handleEdit(item) {
this.dialogVisible = true
this.isCreate = false
this.updateId = item.id
this.form.answer = item.answer
this.form.tag = item.tag
this.form.score = item.score
this.form.matching_degree = item.matching_degree
},
handleDelete(item) {
this.$confirm('删除题干请谨慎操作,确定删除?', '删除题干', {
confirmButtonText: '删除',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.fetchDeleteAnswer(item)
}).catch(() => {})
},
handleSubmit() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
this.isCreate ? this.fetchCreateAnswer(): this.fetchUpdateAnswer()
}
})
},
fetchCreateAnswer() {
createQuesAnswer(this.id, this.form).then(res => {
if (res.data && res.data.id) {
this.$message.success('新建答案成功')
this.$refs.list.refetch(true)
this.dialogVisible = false
}
})
},
fetchUpdateAnswer() {
updateQuesAnswer(this.updateId, this.form).then(res => {
if (res.data && res.data.status) {
this.$message.success('更新答案成功')
this.$refs.list.refetch(true)
this.dialogVisible = false
}
})
},
fetchDeleteAnswer(item) {
deleteQuesAnswer(item.id).then(res => {
if (res.data && res.data.status) {
this.$message.success('删除答案成功')
this.$refs.list.refetch(true)
}
})
}
}
}
</script>
......@@ -4,7 +4,10 @@ const routes = [
{
path: '/case',
component: AppLayout,
children: [{ path: '', component: () => import('./views/List.vue') }]
children: [
{ path: '', component: () => import('./views/List.vue') },
{ path: 'details', component: () => import('./views/Details.vue') }
]
}
]
......
<template>
<app-card>
<h4 class="title">{{title || ''}}</h4>
<base-info :id="id" />
<el-tabs v-model="tabActive" style="margin-top:20px;">
<el-tab-pane label="产品分析" name="productAnalysis">
<product-analysis :id="id" />
</el-tab-pane>
</el-tabs>
</app-card>
</template>
<script>
// 组件
import BaseInfo from '../components/BaseInfo.vue'
import ProductAnalysis from '../components/ProductAnalysis.vue'
export default {
components: { BaseInfo, ProductAnalysis },
data() {
return {
tabActive: 'productAnalysis'
}
},
computed: {
id() {
return this.$route.query.id
},
title() {
return this.$route.query.name
}
}
}
</script>
<style lang="scss" scoped>
::v-deep.app-card{
padding-top:20px;
}
.title{
font-size:20px;
line-height:36px;
padding-bottom:10px;
}
</style>
\ No newline at end of file
......@@ -5,7 +5,7 @@
<el-button type="primary" @click="handleCreate">新建</el-button>
</template>
<template v-slot:table-x="{ row }">
<el-button plain>查看</el-button>
<el-button plain @click="handleDetails(row)">查看</el-button>
<el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="danger" plain @click="handleRemove(row)">删除</el-button>
</template>
......@@ -51,28 +51,6 @@ export default {
{ label: '唯一标识', prop: 'tag' },
{ label: '创建时间', prop: 'created_at' },
{ label: '操作', slots: 'table-x', align: 'right', width: 220 }
],
data: [
{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
},
{
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
},
{
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
},
{
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}
]
}
}
......@@ -88,6 +66,15 @@ export default {
this.formData.type = 'edit'
this.formData.data = item
},
handleDetails(item) {
this.$router.push({
path: '/case/details',
query: {
id: item.id,
name: item.name
}
})
},
handleClose() {},
handleSubmit() {
this.drawerVisible = false
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论