提交 6cf762b3 authored 作者: matian's avatar matian

feat:获取所有项目列表接口

上级 1f814c47
...@@ -27,3 +27,7 @@ export function uploadFile(data) { ...@@ -27,3 +27,7 @@ export function uploadFile(data) {
headers: { 'Content-Type': 'multipart/form-data' } headers: { 'Content-Type': 'multipart/form-data' }
}) })
} }
// 获取可访问的所有项目
export function getPermissionProject() {
return httpRequest.get('/qbs/admin/v1/projects')
}
import httpRequest from '@/utils/axios' import httpRequest from '@/utils/axios'
/** /**
* 获取应用列表 * 获取知识点/标签
*/ */
export function getAppList(params) { export function getKnowledge(params) {
return httpRequest.get('/api/permissions/admin/v1/applications', { params }) return httpRequest.get('/admin/v1/knowledge-point/search/x1', { params })
}
/**
* 获取应用详情
*/
export function getApp(id, params) {
return httpRequest.get(`/api/permissions/admin/v1/${id}/application`, { params })
}
/**
* 创建应用
*/
export function createApp(data) {
return httpRequest.post('/api/permissions/admin/v1/application', data)
}
/**
* 更新应用
*/
export function updateApp(id, data) {
return httpRequest.put(`/api/permissions/admin/v1/${id}/application`, data)
}
/**
* 删除应用
*/
export function deleteApp(id, data) {
return httpRequest.delete(`/api/permissions/admin/v1/${id}/application`, data)
}
/**
* 更新应用签名秘钥
*/
export function updateAppSecretKey(id, data) {
return httpRequest.patch(`/api/permissions/admin/v1/${id}/application/secret-key`, data)
}
/**
* 获取应用管理员
*/
export function getAppAdminUsers(params) {
return httpRequest.get(`/api/permissions/admin/v1/${params.app_id}/application/assign/app-users`, { params })
}
/**
* 删除应用管理员
*/
export function deleteAppAdminUsers(appid, data) {
return httpRequest.post(`/api/permissions/admin/v1/${appid}/application/assign/remove-app-users`, data)
}
/**
* 创建成员
*/
export function createUser(appid, data) {
return httpRequest.post(`/api/permissions/admin/v1/${appid}/application/user`, data)
}
/**
* 创建应用管理员
*/
export function createAppAdminUsers(appid, data) {
return httpRequest.post(`/api/permissions/admin/v1/${appid}/application/assign/users-to-app`, data)
}
/**
* 获取事件列表
*/
export function getEventList(params) {
return httpRequest.get(`/api/permissions/admin/v1/${params.app_id}/events`, { params })
}
/**
* 创建事件
*/
export function createEvent(appid, data) {
return httpRequest.post(`/api/permissions/admin/v1/${appid}/event/create`, data)
}
/**
* 更新事件
*/
export function updateEvent(id, data) {
return httpRequest.put(`/api/permissions/admin/v1/event/${id}/update`, data)
}
/**
* 删除事件
*/
export function deleteEvents(data) {
return httpRequest.post('/api/permissions/admin/v1/event/batch-delete', data)
}
/**
* 获取事件详情
*/
export function getEvent(params) {
return httpRequest.get(`/api/permissions/admin/v1/event/${params.id}/detail`, { params })
}
/**
* 刷新事件token
*/
export function refreshEventToken(params) {
return httpRequest.patch(`/api/permissions/admin/v1/event/${params.id}/refresh-token`, { params })
}
/**
* 获取获取事件回调记录列表
*/
export function getEventRecordList(params) {
return httpRequest.get(`/api/permissions/admin/v1/${params.app_id}/event/records`, { params })
} }
<template> <template>
<div style="margin-top: 32px"> <div style="margin-top: 32px">
<el-row :gutter="20"> <el-row :gutter="60">
<!-- 试题列表 --> <!-- 试题列表 -->
<el-col :span="18"> <el-col :span="18">
<el-card id="questionMain" <el-card id="questionMain"
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
/> />
<!-- 选题组卷无数据情况下显示 --> <!-- 选题组卷无数据情况下显示 -->
<div class="nonePaper" v-show="questionList.length === 0"> <div class="nonePaper" v-show="questionList.length === 0">
<!-- <el-result icon="info" subTitle="该试卷无试题,去添加试题吧"></el-result> --> <el-result icon="info" subTitle="该试卷无试题,去添加试题吧"></el-result>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
...@@ -42,8 +42,9 @@ ...@@ -42,8 +42,9 @@
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
<AutomaticPaper :visible.sync="visible" v-if="paperMode === '自动组卷'" /> <!-- 选题组卷弹框 -->
<AutomaticPaper :visible.sync="visible" v-if="paperMode === '选题组卷'" />
<!-- 手动组卷弹框 -->
<addPaper :visible.sync="visible" v-else /> <addPaper :visible.sync="visible" v-else />
</div> </div>
</template> </template>
...@@ -62,6 +63,10 @@ export default { ...@@ -62,6 +63,10 @@ export default {
paperMode: { paperMode: {
type: String, type: String,
default: '' default: ''
},
paperTotalScore: {
type: Number,
default: 0
} }
}, },
data() { data() {
...@@ -91,7 +96,8 @@ export default { ...@@ -91,7 +96,8 @@ export default {
], ],
question_answer: '示向功能', question_answer: '示向功能',
group_id: '1001', group_id: '1001',
score: 2 score: 2,
question_order: 2
}, },
{ {
question_title: '多选题', question_title: '多选题',
...@@ -119,7 +125,8 @@ export default { ...@@ -119,7 +125,8 @@ export default {
} }
], ],
question_answer: '示向功能、示向----', question_answer: '示向功能、示向----',
group_id: '1002' group_id: '1002',
question_order: 1
}, },
{ {
question_title: '判断题', question_title: '判断题',
...@@ -142,7 +149,8 @@ export default { ...@@ -142,7 +149,8 @@ export default {
} }
], ],
question_answer: '正确', question_answer: '正确',
group_id: '1003' group_id: '1003',
question_order: 3
}, },
{ {
question_title: '简答题', question_title: '简答题',
...@@ -153,7 +161,8 @@ export default { ...@@ -153,7 +161,8 @@ export default {
child_question_type: 0, child_question_type: 0,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔', question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1004', group_id: '1004',
score: 2 score: 2,
question_order: 4
}, },
{ {
question_title: '案例题', question_title: '案例题',
...@@ -164,7 +173,8 @@ export default { ...@@ -164,7 +173,8 @@ export default {
child_question_type: 0, child_question_type: 0,
question_answer: null, question_answer: null,
group_id: '1005', group_id: '1005',
score: 8 score: 8,
question_order: 5
}, },
{ {
question_title: '单选题', question_title: '单选题',
...@@ -186,7 +196,8 @@ export default { ...@@ -186,7 +196,8 @@ export default {
], ],
question_answer: '2000', question_answer: '2000',
group_id: '1005', group_id: '1005',
score: 2 score: 2,
question_order: 1
}, },
{ {
question_title: '多选题', question_title: '多选题',
...@@ -214,7 +225,8 @@ export default { ...@@ -214,7 +225,8 @@ export default {
], ],
question_answer: '示向功能、示向----', question_answer: '示向功能、示向----',
group_id: '1005', group_id: '1005',
score: 2 score: 2,
question_order: 2
}, },
{ {
question_title: '判断题', question_title: '判断题',
...@@ -237,7 +249,8 @@ export default { ...@@ -237,7 +249,8 @@ export default {
], ],
question_answer: '正确', question_answer: '正确',
group_id: '1005', group_id: '1005',
score: 2 score: 2,
question_order: 3
}, },
{ {
question_title: '简答题', question_title: '简答题',
...@@ -248,9 +261,21 @@ export default { ...@@ -248,9 +261,21 @@ export default {
child_question_type: 3, child_question_type: 3,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔', question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1005', group_id: '1005',
score: 2 score: 2,
question_order: 4
},
{
question_title: '简答题',
question_content:
'<p>1111复购率在金融数字化营销中是反应用户对品牌忠诚度的一个重要指标,锡盟高钙奶是一家专门生产乳制品的企业,其中脱脂牛奶的销量一直不太理想,2021年一季度华北市场的脱脂牛奶交易笔数为12000笔,4000人实现二次购买,而这4000人当中2000人实现了三次购买。</p>',
question_type: 5,
is_parent: 0,
child_question_type: 3,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1005',
score: 2,
question_order: 5
}, },
{ {
question_title: '情景题', question_title: '情景题',
question_content: question_content:
...@@ -260,7 +285,8 @@ export default { ...@@ -260,7 +285,8 @@ export default {
child_question_type: 0, child_question_type: 0,
question_answer: null, question_answer: null,
group_id: '1006', group_id: '1006',
score: 8 score: 8,
question_order: 6
}, },
{ {
question_title: '单选题', question_title: '单选题',
...@@ -282,7 +308,8 @@ export default { ...@@ -282,7 +308,8 @@ export default {
], ],
question_answer: '2000', question_answer: '2000',
group_id: '1006', group_id: '1006',
score: 2 score: 2,
question_order: 1
}, },
{ {
question_title: '多选题', question_title: '多选题',
...@@ -310,7 +337,8 @@ export default { ...@@ -310,7 +337,8 @@ export default {
], ],
question_answer: '示向功能、示向----', question_answer: '示向功能、示向----',
group_id: '1006', group_id: '1006',
score: 2 score: 2,
question_order: 2
}, },
{ {
question_title: '判断题', question_title: '判断题',
...@@ -333,7 +361,8 @@ export default { ...@@ -333,7 +361,8 @@ export default {
], ],
question_answer: '正确', question_answer: '正确',
group_id: '1006', group_id: '1006',
score: 2 score: 2,
question_order: 3
}, },
{ {
question_title: '简答题', question_title: '简答题',
...@@ -344,7 +373,8 @@ export default { ...@@ -344,7 +373,8 @@ export default {
child_question_type: 3, child_question_type: 3,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔', question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1006', group_id: '1006',
score: 2 score: 2,
question_order: 4
}, },
{ {
...@@ -356,7 +386,8 @@ export default { ...@@ -356,7 +386,8 @@ export default {
child_question_type: 0, child_question_type: 0,
question_answer: null, question_answer: null,
group_id: '1007', group_id: '1007',
score: 8 score: 8,
question_order: 7
}, },
{ {
question_title: '单选题', question_title: '单选题',
...@@ -378,7 +409,8 @@ export default { ...@@ -378,7 +409,8 @@ export default {
], ],
question_answer: '2000', question_answer: '2000',
group_id: '1007', group_id: '1007',
score: 2 score: 2,
question_order: 4
}, },
{ {
question_title: '多选题', question_title: '多选题',
...@@ -406,7 +438,8 @@ export default { ...@@ -406,7 +438,8 @@ export default {
], ],
question_answer: '示向功能、示向----', question_answer: '示向功能、示向----',
group_id: '1007', group_id: '1007',
score: 2 score: 2,
question_order: 3
}, },
{ {
question_title: '判断题', question_title: '判断题',
...@@ -429,7 +462,8 @@ export default { ...@@ -429,7 +462,8 @@ export default {
], ],
question_answer: '正确', question_answer: '正确',
group_id: '1007', group_id: '1007',
score: 2 score: 2,
question_order: 2
}, },
{ {
question_title: '简答题', question_title: '简答题',
...@@ -440,7 +474,8 @@ export default { ...@@ -440,7 +474,8 @@ export default {
child_question_type: 3, child_question_type: 3,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔', question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1007', group_id: '1007',
score: 2 score: 2,
question_order: 1
} }
] ]
} }
...@@ -468,6 +503,7 @@ export default { ...@@ -468,6 +503,7 @@ export default {
return '情' return '情'
} }
}, },
// 试题列表数据组装
getlist() { getlist() {
const newQuestionList = [] const newQuestionList = []
const bigData = this.questionList.filter(item => item.is_parent === 1) // 大题 const bigData = this.questionList.filter(item => item.is_parent === 1) // 大题
...@@ -478,17 +514,25 @@ export default { ...@@ -478,17 +514,25 @@ export default {
if (bigData[i].group_id === smallData[j].group_id) { if (bigData[i].group_id === smallData[j].group_id) {
// 如果大题的group_id和小题group_id相等就push listArray数组中,然后赋值给bigData[i].list 相当于加个list属性 // 如果大题的group_id和小题group_id相等就push listArray数组中,然后赋值给bigData[i].list 相当于加个list属性
listArray.push(smallData[j]) // 符合就push listArray数组暂存 listArray.push(smallData[j]) // 符合就push listArray数组暂存
listArray.sort(compare('question_order')) // 小题排序
bigData[i].list = listArray bigData[i].list = listArray
} }
} }
newQuestionList.push(bigData[i]) newQuestionList.push(bigData[i])
console.log(newQuestionList)
} }
this.questionList = newQuestionList newQuestionList.sort(compare('question_order')) // 大题排序
this.questionList = newQuestionList // 组装完成的试题列表
// 根据属性值大小进行排序
function compare(property) {
return function (a, b) {
const v1 = a[property]
const v2 = b[property]
return v1 - v2
}
}
}, },
// 增加试题 // 增加试题
addPaper() { addPaper() {
console.log('dfjsf')
this.visible = true this.visible = true
}, },
// 切换题目编号 // 切换题目编号
...@@ -503,12 +547,17 @@ export default { ...@@ -503,12 +547,17 @@ export default {
}, },
// 保存试卷 // 保存试卷
savePaper() { savePaper() {
// 校验小题分数和总分数是否相等 // 校验单个小题分数是否等于大题分数
const arr = this.questionList.map(item => item.score)
// 校验大题分数和总分数是否相等
const arr = this.questionList.map(item => parseInt(item.score))
const r2 = arr.reduce((pre, item) => (pre += item), 0) const r2 = arr.reduce((pre, item) => (pre += item), 0)
if (r2 !== this.paperTotalScore) {
this.$message.warning('请校验分数')
}
console.log(r2) console.log(r2)
console.log(arr) console.log(arr)
console.log(this.questionList) // console.log(this.questionList)
}, },
// 删除所选试题 // 删除所选试题
delCheckedQuestion() { delCheckedQuestion() {
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="intricacyBoxMain" v-for="(v, index) in item.list" :key="index" style="margintop: 20px"> <div class="intricacyBoxMain" v-for="(v, index) in item.list" :key="index" style="margin-top: 20px">
<div class="intricacyHeader"> <div class="intricacyHeader">
<div class="intricacyDsc"> <div class="intricacyDsc">
<div class="intricacyTitle">{{ index + 1 }}{{ v.question_title }}</div> <div class="intricacyTitle">{{ index + 1 }}{{ v.question_title }}</div>
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</el-descriptions> </el-descriptions>
</el-card> </el-card>
<!-- 试卷列表 --> <!-- 试卷列表 -->
<QuestionList :paperMode="paperDetail.paperMode" /> <QuestionList :paperMode="paperDetail.paperMode" :paperTotalScore="paperDetail.paperTotalScore" />
</div> </div>
</template> </template>
...@@ -33,16 +33,16 @@ export default { ...@@ -33,16 +33,16 @@ export default {
return JSON.parse(this.$route.query.paperDetail) return JSON.parse(this.$route.query.paperDetail)
} }
}, },
watch: { // watch: {
paperDetail: { // paperDetail: {
paperDetail: { // paperDetail: {
immediate: true, // immediate: true,
handler(data) { // handler(data) {
this.form = Object.assign({}, this.form, data) // this.form = Object.assign({}, this.form, data)
} // }
} // }
} // }
}, // },
methods: { methods: {
// 编辑试卷 // 编辑试卷
editPaper() { editPaper() {
......
<template> <template>
<app-card> <app-card>
<app-list v-bind="tableOptions" ref="list" @selection-change="handleSelectionChange"> <app-list v-bind="tableOptions" ref="list" @selection-change="handleSelectionChange">
<template #header-aside> <div class="btn_operate">
<el-button type="primary" icon="el-icon-plus" @click="handleCreatePaper">新建试卷</el-button> <el-button type="primary" icon="el-icon-plus" @click="handleCreatePaper">新建试卷</el-button>
<el-button type="primary" icon="el-icon-plus" @click="batchDelete">批量删除</el-button> <el-button type="primary" icon="el-icon-plus" @click="batchDelete">批量删除</el-button>
</template> </div>
<template v-slot:table-x="{ row }"> <template v-slot:table-x="{ row }">
<el-button type="text" @click="handleDdit(row)">编辑</el-button> <el-button type="text" @click="handleDdit(row)">编辑</el-button>
<el-button type="text" @click="handleDetail(row)">查看详情</el-button> <el-button type="text" @click="handleDetail(row)">查看详情</el-button>
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
</template> </template>
<script> <script>
// import { getAppList } from '../api'
const paperMode = [ const paperMode = [
{ label: '选题组卷', value: 0 }, { label: '选题组卷', value: 0 },
{ label: '自动组卷', value: 1 } { label: '自动组卷', value: 1 }
...@@ -104,7 +103,7 @@ export default { ...@@ -104,7 +103,7 @@ export default {
this.$router.push({ this.$router.push({
path: 'newPapers', path: 'newPapers',
query: { query: {
paperDetail: row, rowDetail: row,
isEdit: true isEdit: true
} }
}) })
...@@ -133,3 +132,10 @@ export default { ...@@ -133,3 +132,10 @@ export default {
} }
} }
</script> </script>
<style lang="scss" scoped>
.btn_operate {
display: flex;
justify-content: flex-end;
margin-bottom: 30px;
}
</style>
<template> <template>
<el-form ref="form" :model="form" label-width="160px" :label-position="labelPosition"> <el-form ref="form" :model="form" label-width="160px" :label-position="labelPosition">
<el-row> <el-row>
<el-col :span="8"> <el-col :span="12">
<el-form-item <el-form-item
label="试卷名称" label="试卷名称"
prop="paperName" prop="paperName"
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="12">
<el-form-item label="试卷分类" prop="classification"> <el-form-item label="试卷分类" prop="classification">
<el-select v-model="form.classification" placeholder="请选择试卷分类" style="width: 100%"> <el-select v-model="form.classification" placeholder="请选择试卷分类" style="width: 100%">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="12">
<el-form-item label="组卷模式" prop="paperMode"> <el-form-item label="组卷模式" prop="paperMode">
<el-select v-model="form.paperMode" placeholder="请选择组卷模式" style="width: 100%"> <el-select v-model="form.paperMode" placeholder="请选择组卷模式" style="width: 100%">
<el-option label="自动组卷" :value="0"> </el-option> <el-option label="自动组卷" :value="0"> </el-option>
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="10">
<el-form-item <el-form-item
label="试题顺序" label="试题顺序"
:rules="[{ message: '请选择试题顺序', required: true, trigger: 'change' }]" :rules="[{ message: '请选择试题顺序', required: true, trigger: 'change' }]"
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="12">
<el-form-item <el-form-item
label="试卷总分" label="试卷总分"
prop="paperTotalScore" prop="paperTotalScore"
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
></el-input-number> ></el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="10">
<el-form-item <el-form-item
label="及格分数" label="及格分数"
prop="paperPassScore" prop="paperPassScore"
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="12">
<el-form-item <el-form-item
label="考试时长" label="考试时长"
prop="examDuration" prop="examDuration"
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
>&nbsp;分钟 >&nbsp;分钟
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="12">
<el-form-item <el-form-item
label="最短交卷时长" label="最短交卷时长"
prop="minSubtime" prop="minSubtime"
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="12">
<el-form-item label="多次考试" :rules="[{ required: true, trigger: 'blur' }]"> <el-form-item label="多次考试" :rules="[{ required: true, trigger: 'blur' }]">
<el-radio-group v-model="form.moreExam"> <el-radio-group v-model="form.moreExam">
<el-radio label="0"></el-radio> <el-radio label="0"></el-radio>
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="12">
<el-form-item label="多次考试成绩计算规则" style="padding-left: 20px" v-if="form.moreExam === '1'"> <el-form-item label="多次考试成绩计算规则" style="padding-left: 20px" v-if="form.moreExam === '1'">
<el-radio-group v-model="form.rule"> <el-radio-group v-model="form.rule">
<el-radio label="0">平均计算法</el-radio> <el-radio label="0">平均计算法</el-radio>
...@@ -204,6 +204,12 @@ export default { ...@@ -204,6 +204,12 @@ export default {
} }
}, },
watch: { watch: {
rowDetail: {
immediate: true,
handler(data) {
this.form = Object.assign({}, this.form, data)
}
},
paperDetail: { paperDetail: {
immediate: true, immediate: true,
handler(data) { handler(data) {
...@@ -226,10 +232,12 @@ export default { ...@@ -226,10 +232,12 @@ export default {
history.go(-1) history.go(-1)
}) })
} else { } else {
// 表单校验不通过聚焦至第一个不通过的输入框 setTimeout(() => {
// const isError = document.getElementsByClassName('is-error') // 表单校验不通过聚焦至第一个不通过的输入框
// isError[0].querySelector('input').focus() const isError = document.getElementsByClassName('is-error')
// return false isError[0].querySelector('input').focus()
}, 100)
return false
} }
}) })
}, },
...@@ -240,13 +248,19 @@ export default { ...@@ -240,13 +248,19 @@ export default {
this.$confirm('保存成功!', { this.$confirm('保存成功!', {
confirmButtonText: '确定' confirmButtonText: '确定'
}).then(() => { }).then(() => {
// 待确认 // 调用接口
// this.$router.push({
// path: 'detail'
// })
}) })
} else { } else {
// // 表单校验不通过聚焦至第一个不通过的输入框 setTimeout(() => {
// const isErrors = document.getElementsByClassName('is-error') // 表单校验不通过聚焦至第一个不通过的输入框
// isErrors[0].querySelector('el-input').focus() const isError = document.getElementsByClassName('is-error')
// return false isError[0].querySelector('input').focus()
}, 100)
return false
} }
}) })
} }
......
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import { getUser, logout } from '@/api/base' import { getUser, logout, getPermissionProject } from '@/api/base'
Vue.use(Vuex) Vue.use(Vuex)
const store = new Vuex.Store({ const store = new Vuex.Store({
state: { state: {
user: {} user: {},
projects: []
}, },
mutations: { mutations: {
setUser(state, user) { setUser(state, user) {
state.user = user state.user = user
},
setProject(state, projects) {
state.projects = projects
} }
}, },
actions: { actions: {
...@@ -43,8 +47,16 @@ const store = new Vuex.Store({ ...@@ -43,8 +47,16 @@ const store = new Vuex.Store({
return false return false
}) })
return isLogin return isLogin
},
getPermissionProject({ commit }) {
getPermissionProject().then(response => {
const { projects = [] } = response.data
commit('setProject', projects)
return response.data
})
} }
} }
}) })
store.dispatch('getPermissionProject')
export default store export default store
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论