export question
This commit is contained in:
parent
aa9a6852bb
commit
dcd77ce65b
|
@ -114,4 +114,11 @@ export function importQuestion(data) {
|
|||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function exportQuestion(query) {
|
||||
return request({
|
||||
url: '/question/question/export/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
|
@ -66,6 +66,7 @@
|
|||
|
||||
<el-button slot="reference">Excel导入</el-button>
|
||||
</el-popover>
|
||||
<el-button type="primary" icon="el-icon-download" @click="exportQuestion">导出Excel</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-table
|
||||
|
@ -153,7 +154,8 @@ import {
|
|||
getQuestioncatAll,
|
||||
getQuestionList,
|
||||
deleteQuestion,
|
||||
importQuestion
|
||||
importQuestion,
|
||||
exportQuestion
|
||||
} from "@/api/question";
|
||||
import { genTree, deepClone } from "@/utils";
|
||||
import checkPermission from "@/utils/permission";
|
||||
|
@ -291,6 +293,15 @@ export default {
|
|||
// console.error(err);
|
||||
});
|
||||
},
|
||||
exportQuestion() {
|
||||
const loading = this.$loading({
|
||||
text:'正在准备..'
|
||||
});
|
||||
exportQuestion(this.listQuery).then(response => {
|
||||
loading.close()
|
||||
window.open(response.data.path, "_blank");
|
||||
}).catch(e=>{loading.close()});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -57,9 +57,9 @@ App({
|
|||
globalData: {
|
||||
userInfo: {},
|
||||
userinfo: {}, // 服务器传回的消费者信息
|
||||
//host: 'https://apitest.ahctc.cn',
|
||||
host: 'https://apitest.ahctc.cn',
|
||||
mediahost: 'https://apitest.ahctc.cn',
|
||||
host: 'http://127.0.0.1:8011',
|
||||
//host: 'http://127.0.0.1:8011',
|
||||
//mediahost: 'http://127.0.0.1:8000',
|
||||
token : '',
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ from openpyxl.workbook import Workbook
|
|||
from django.conf import settings
|
||||
from datetime import datetime
|
||||
from openpyxl.styles import Font, Fill
|
||||
|
||||
import json
|
||||
|
||||
BASE_DIR = settings.BASE_DIR
|
||||
|
||||
|
@ -22,7 +22,7 @@ def export_question(questions):
|
|||
# options=''
|
||||
# for key in i.options:
|
||||
# pass
|
||||
ws1.append([i.questioncat.name, i.type, i.name, i.options, i.right, i.resolution])
|
||||
ws1.append([i.questioncat.name, i.type, i.name, json.dumps(i.options, ensure_ascii=False), ''.join(sorted(i.right)), i.resolution])
|
||||
filename = 'questions' + datetime.now().strftime("%Y%m%d%H%M%S") +'.xlsx'
|
||||
path = '/media/export/' + filename
|
||||
wb.save((BASE_DIR + path).replace('\\', '/'))
|
||||
|
|
|
@ -16,7 +16,7 @@ from crm.models import PaySubject
|
|||
from examtest.models import WorkScope
|
||||
from server import settings
|
||||
from utils.custom import CommonPagination
|
||||
from exports import export_question
|
||||
from .exports import export_question
|
||||
|
||||
|
||||
from .models import Question, Questioncat
|
||||
|
|
Loading…
Reference in New Issue