Merge branch 'develop' of https://gitee.com/siwa-team/dawa-vue into develop

This commit is contained in:
Yuanjianghong 2021-11-28 23:51:39 +08:00
commit 200538d486
5 changed files with 70 additions and 51 deletions

View File

@ -44,6 +44,7 @@ export function deleteCourse (params) {
// 查询课程列表 // 查询课程列表
export function getCourseList (params) { export function getCourseList (params) {
if(params.tag) params.tag = params.tag.toString();
return request({ return request({
url: courseApi.list, url: courseApi.list,
method: 'get', method: 'get',

View File

@ -7,15 +7,18 @@
<a-input v-if="item.type === 'input'" v-model="form[item.key]" :type="item.type || 'text'" :placeholder="item.placeholder || '请输入'" :allowClear="true" /> <a-input v-if="item.type === 'input'" v-model="form[item.key]" :type="item.type || 'text'" :placeholder="item.placeholder || '请输入'" :allowClear="true" />
<!-- select-common --> <!-- select-common -->
<a-select v-if="item.type === 'select'" v-model="form[item.key]" placeholder="请选择" :allowClear="true"> <a-select v-if="item.type === 'select'" v-model="form[item.key]" placeholder="请选择" :allowClear="true" :mode="item.mode ? item.mode : 'default'">
<a-select-option v-for="(j, k) in item.options" :key="`${index}-${k}`" :value="j.id">{{ j.name }}</a-select-option> <a-select-option v-for="(j, k) in item.options" :key="`${index}-${k}`" :value="j.id">{{ j.name }}</a-select-option>
</a-select> </a-select>
<!-- select-dictionary --> <!-- select-dictionary -->
<a-select v-if="item.type === 'select-dic'" v-model="form[item.key]" placeholder="请选择" :allowClear="true"> <a-select v-if="item.type === 'select-dic'" v-model="form[item.key]" placeholder="请选择" :allowClear="true" :mode="item.mode ? item.mode : 'default'">
<a-select-option v-for="(j, k) in item.options" :key="`${index}-${k}`" :value="j.value">{{ j.name }}</a-select-option> <a-select-option v-for="(j, k) in item.options" :key="`${index}-${k}`" :value="j.value">{{ j.name }}</a-select-option>
</a-select> </a-select>
<!-- select-dictionary-tree -->
<a-tree-select v-if="item.type === 'select-dic-tree'" v-model="form[item.key]" :tree-data="item.options" placeholder="请选择" :allowClear="true" :multiple="item.mode ? true : false"></a-tree-select>
<!-- date --> <!-- date -->
<a-date-picker v-if="item.type === 'date'" v-model="form[item.key]" style="width: 100%" :format="item.format" :valueFormat="item.format" :placeholder="item.placeholder || '请输入日期'" /> <a-date-picker v-if="item.type === 'date'" v-model="form[item.key]" style="width: 100%" :format="item.format" :valueFormat="item.format" :placeholder="item.placeholder || '请输入日期'" />

View File

@ -86,6 +86,30 @@ export function listToTree(list, tree, parentId) {
return tree return tree
} }
// 词典集合转树
export function dictToTree(list, tree, parentId) {
list.forEach(item => {
if (item.parentid === parentId) {
let item_ = {};
item_.title = item.name;
item_.value = item.value;
item_.key = item.id;
const child = { ...item_, children: [] };
dictToTree(list, child.children, item.value);
if (child.children.length <= 0) {
delete child.children
}else{
child.selectable = false;
}
tree.push(child)
}
})
return tree
}
//列表转🌲 //列表转🌲
// export function list2Tree(list, parentId) { // export function list2Tree(list, parentId) {
// let obj = [] // let obj = []

View File

@ -9,35 +9,27 @@
<!-- 课程名称 --> <!-- 课程名称 -->
<a-col :span="18" :offset="3"> <a-col :span="18" :offset="3">
<a-form-model-item label="课程名称" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }"> <a-form-model-item label="课程名称" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-input <a-input v-model="form.courseName" v-decorator="['courseName', { rules: [{ required: true, message: '请填写课程名称' }] }]" />
v-model="form.courseName"
v-decorator="['courseName', { rules: [{ required: true, message: '请填写课程名称' }] }]"
/>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<!-- 课程类别 --> <!-- 课程类别 -->
<a-col :span="9" :offset="3"> <a-col :span="9" :offset="3">
<a-form-model-item label="课程类别" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }"> <a-form-model-item label="课程类别" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-select v-model="form.courseType" placeholder="--请选择--"> <a-tree-select v-model="form.courseType" :tree-data="dictCourseType" placeholder="请选择课程类别"></a-tree-select>
<!-- <a-select v-model="form.courseType" placeholder="--请选择--">
<a-select-option v-for="(item, index) in dictCourseType" :key="index" :value="item.value"> <a-select-option v-for="(item, index) in dictCourseType" :key="index" :value="item.value">
{{ item.name }} {{ item.name }}
</a-select-option> </a-select-option>
</a-select> </a-select> -->
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<!-- 课件大小 --> <!-- 课件大小 -->
<a-col :span="9"> <a-col :span="9">
<a-form-item label="课时" :label-col="{ span: 4 }" :wrapper-col="{ span: 10 }"> <a-form-item label="课时" :label-col="{ span: 4 }" :wrapper-col="{ span: 10 }">
<a-input-number <a-input-number id="hour" v-model="dataValue" :min="1" :max="1000" @change="onChange" :style="{ display: 'ln', width: '100%' }" />
id="hour"
v-model="dataValue"
:min="1"
:max="1000"
@change="onChange"
:style="{ display: 'ln', width: '100%' }"
/>
{{ dataValue }}分钟 {{ dataValue }}分钟
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -91,14 +83,7 @@
<!-- 上传封面图片 --> <!-- 上传封面图片 -->
<a-col :span="18" :offset="3"> <a-col :span="18" :offset="3">
<a-form-model-item label="上传封面图片" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }"> <a-form-model-item label="上传封面图片" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-upload <a-upload action="/dawa/sys/oss/upload?sourceId=course" list-type="picture-card" :file-list="fileList" :headers="getToken()" @change="handleChange" @preview="handlePreview">
action="/dawa/sys/oss/upload?sourceId=course"
list-type="picture-card"
:file-list="fileList"
:headers="getToken()"
@change="handleChange"
@preview="handlePreview"
>
<div v-if="fileList.length < 1"> <div v-if="fileList.length < 1">
<a-icon type="plus" /> <a-icon type="plus" />
<div class="ant-upload-text">上传</div> <div class="ant-upload-text">上传</div>
@ -114,7 +99,7 @@
<a-col :span="18" :offset="3"> <a-col :span="18" :offset="3">
<a-form-model-item label="课程标签" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }"> <a-form-model-item label="课程标签" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-select mode="tags" style="width: 100%" placeholder="标签选择或新增" @change="handleTagChange" :value="this.form.tags"> <a-select mode="tags" style="width: 100%" placeholder="标签选择或新增" @change="handleTagChange" :value="this.form.tags">
<a-select-option v-for="(item,index) in dictCourseTag" :key="index" :value="item.value"> <a-select-option v-for="(item,index) in dictCourseTag" :key="index" :value="item.value">
{{ item.name }} {{ item.name }}
</a-select-option> </a-select-option>
</a-select> </a-select>
@ -132,6 +117,7 @@ import { courseAdd, getCourseDetails } from '@/api/course/course'
import storage from 'store' import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN } from '@/store/mutation-types'
import { dictionaryDropDown } from '@/api/sys/dictionaryItem' import { dictionaryDropDown } from '@/api/sys/dictionaryItem'
import { dictToTree } from '@/utils/util'
export default { export default {
name: 'step1', name: 'step1',
@ -140,17 +126,17 @@ export default {
dataValue: 1, dataValue: 1,
form: { form: {
coverPath: '', coverPath: '',
tags:[], tags: [],
courseTags:[] courseTags: [],
}, },
url: '', url: '',
previewVisible: false, previewVisible: false,
fileList: [], fileList: [],
previewImage: [], previewImage: [],
dictPerson: [], dictPerson: [],
dictCourseType: [], dictCourseType: [], //
industry: [], industry: [],
dictCourseTag:[], dictCourseTag: [],
} }
}, },
components: { components: {
@ -161,21 +147,20 @@ export default {
this.dictionaryDropDown() this.dictionaryDropDown()
if (this.$route.query.id) { if (this.$route.query.id) {
getCourseDetails({ id: this.$route.query.id }).then((res) => { getCourseDetails({ id: this.$route.query.id }).then((res) => {
this.form = res.data; this.form = res.data
this.form.isRequired = this.form.isRequired + ''; this.form.isRequired = this.form.isRequired + ''
this.form.tags = []; this.form.tags = []
this.form.courseTags.forEach((item,index) => { this.form.courseTags.forEach((item, index) => {
this.form.tags.push(item.dictValue.toString()); this.form.tags.push(item.dictValue.toString())
}); })
}) })
} }
}, },
methods: { methods: {
// //
onChange(dataValue) { onChange(dataValue) {},
},
save() { save() {
courseAdd(this.form).then((res) => { courseAdd(this.form).then((res) => {
if (res.code == 200) { if (res.code == 200) {
@ -194,17 +179,18 @@ export default {
}) })
// //
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => { dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
this.dictCourseType = res.data //
this.dictCourseType = dictToTree(res.data, [], 0)
}) })
// //
dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => { dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => {
this.dictPerson = res.data this.dictPerson = res.data
}) })
// //
dictionaryDropDown({dictionaryCode: '0008'}).then((res) => { dictionaryDropDown({ dictionaryCode: '0008' }).then((res) => {
const tagList = res.data const tagList = res.data
for ( let i = 0; i < tagList.length; i++) { for (let i = 0; i < tagList.length; i++) {
tagList[i].value = tagList[i].value.toString() tagList[i].value = tagList[i].value.toString()
} }
this.dictCourseTag = tagList this.dictCourseTag = tagList
}) })
@ -225,8 +211,7 @@ export default {
hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN) hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN)
return hreader return hreader
}, },
onSuccess(file) { onSuccess(file) {},
},
handleCancel() { handleCancel() {
this.previewVisible = false this.previewVisible = false
}, },
@ -246,7 +231,7 @@ export default {
// //
handleTagChange(value) { handleTagChange(value) {
this.form.tags = value; this.form.tags = value
}, },
}, },
} }

View File

@ -32,6 +32,7 @@
import { STable, SearchCom } from '@/components' import { STable, SearchCom } from '@/components'
import { getCourseList, deleteCourse } from '@/api/course/course' import { getCourseList, deleteCourse } from '@/api/course/course'
import { dictionaryDropDown } from '@/api/sys/dictionaryItem' import { dictionaryDropDown } from '@/api/sys/dictionaryItem'
import { dictToTree } from '@/utils/util'
export default { export default {
components: { components: {
@ -41,10 +42,11 @@ export default {
data() { data() {
return { return {
dictCourseTag: [], dictCourseTag: [],
queryParam: { courseName: this.$route.query.courseName || '' }, queryParam: { courseName: this.$route.query.courseName || '', tag: [] },
queryOptions: [ queryOptions: [
{ type: 'input', placeholder: '课程名称', key: 'courseName' }, { type: 'input', placeholder: '课程名称', key: 'courseName' },
{ type: 'select', placeholder: '请选择标签', key: 'tag', options: [] }, { type: 'select-dic-tree', placeholder: '请选择课程类别', key: 'courseType' , options: [] },
{ type: 'select-dic', placeholder: '请选择标签', key: 'tag', mode: 'multiple', options: [] },
], ],
loadData: (parameter) => { loadData: (parameter) => {
return getCourseList(Object.assign(parameter, this.queryParam)).then((res) => { return getCourseList(Object.assign(parameter, this.queryParam)).then((res) => {
@ -54,6 +56,7 @@ export default {
columns: [ columns: [
{ title: '课程编号', width: '160px', align: 'center', dataIndex: 'courseCode', key: 'courseCode' }, { title: '课程编号', width: '160px', align: 'center', dataIndex: 'courseCode', key: 'courseCode' },
{ title: '课程名称', width: 'auto', align: 'center', dataIndex: 'courseName', key: 'courseName' }, { title: '课程名称', width: 'auto', align: 'center', dataIndex: 'courseName', key: 'courseName' },
{ title: '课程类别', width: 'auto', align: 'center', dataIndex: 'courseType', key: 'courseType' },
{ title: '课时/分', width: '160px', align: 'center', dataIndex: 'hour', key: 'hour' }, { title: '课时/分', width: '160px', align: 'center', dataIndex: 'hour', key: 'hour' },
{ title: '数量', width: '160px', align: 'center', dataIndex: 'questionCount', key: 'questionCount' }, { title: '数量', width: '160px', align: 'center', dataIndex: 'questionCount', key: 'questionCount' },
{ title: '操作', key: 'operation', width: '300px', align: 'center', scopedSlots: { customRender: 'action' } }, { title: '操作', key: 'operation', width: '300px', align: 'center', scopedSlots: { customRender: 'action' } },
@ -68,13 +71,16 @@ export default {
dictionaryDropDown() { dictionaryDropDown() {
this.formLoading = false this.formLoading = false
//
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
this.queryOptions[1].options = dictToTree(res.data, [], 0);
})
// //
dictionaryDropDown({ dictionaryCode: '0008' }).then((res) => { dictionaryDropDown({ dictionaryCode: '0008' }).then((res) => {
const tagList = res.data this.queryOptions[2].options = res.data
for (let i = 0; i < tagList.length; i++) {
tagList[i].id = tagList[i].value.toString()
}
this.queryOptions[1].options = tagList
}) })
}, },
handleRefresh() { handleRefresh() {