123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236 |
- <template>
- <section class="content">
- <div class="box box-info">
- <div
- v-loading.body="fileLoading"
- element-loading-text="课程上传中,请稍后..."
- >
- <el-form
- inline
- :model="formSearch"
- label-width="70px"
- ref="primaryForm"
- >
- <el-form-item label="课程名称">
- <el-input
- class="input_width_lg"
- placeholder="请输入课程名称"
- v-model="formSearch.name"
- />
- </el-form-item>
- <el-form-item label="课程代码">
- <el-input
- class="input_width_lg"
- placeholder="请输入课程代码"
- v-model="formSearch.code"
- />
- </el-form-item>
- <el-form-item label="课程状态">
- <el-select
- class="input_width_lg"
- v-model="formSearch.enable"
- placeholder="请选择"
- clearable
- >
- <el-option
- v-for="item in statusList"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="层次">
- <el-select
- class="input_width_lg"
- v-model="formSearch.level"
- placeholder="请选择"
- clearable
- >
- <el-option
- v-for="item in levelList"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="专业" prop="specialtyId">
- <el-select
- class="input_width_lg"
- remote
- :remote-method="getSpecialtyList4Search"
- :loading="specialtyLoading4Search"
- filterable
- clearable
- v-model="formSearch.specialtyId"
- placeholder="请选择"
- >
- <el-option
- v-for="item in specialtyList4SearchWrapper"
- :label="item.name"
- :value="item.id"
- :key="item.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item class="d-block">
- <el-button
- size="small"
- type="primary"
- icon="el-icon-search"
- @click="handleSearchBtn"
- >查询</el-button
- >
- <el-button
- size="small"
- @click="resetPrimaryForm"
- icon="el-icon-refresh"
- >
- 重置
- </el-button>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- @click="insertCourse"
- >新增</el-button
- >
- </el-form-item>
- </el-form>
- <div class="block-seperator"></div>
- <span>操作:</span>
- <el-button
- size="small"
- type="success"
- @click="enableByIds"
- :disabled="noBatchSelected"
- icon="el-icon-check"
- >
- 启用
- </el-button>
- <el-button
- size="small"
- type="warning"
- @click="disableByIds"
- :disabled="noBatchSelected"
- icon="el-icon-close"
- >
- 禁用
- </el-button>
- <el-button
- size="small"
- type="primary"
- @click="impCourse"
- icon="el-icon-upload2"
- >
- 导入
- </el-button>
- <el-button
- size="small"
- type="primary"
- @click="exportCourse"
- icon="el-icon-download"
- >
- 导出
- </el-button>
- <div style="width: 100%;margin-bottom: 10px;"></div>
- <!-- 添加或新增课程弹出框 -->
- <el-dialog
- title="课程"
- width="420px"
- :visible.sync="courseDialog"
- @close="dialogBeforeClose"
- >
- <el-form
- :inline="true"
- inline-message
- :model="courseForm"
- ref="courseForm"
- :rules="rules"
- label-width="90px"
- >
- <el-row>
- <el-form-item label="课程代码" prop="code">
- <el-input
- :disabled="null != courseForm.id"
- class="pull_length"
- v-model="courseForm.code"
- auto-complete="off"
- placeholder="请输入课程代码"
- />
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="课程名称" prop="name">
- <el-input
- class="pull_length"
- v-model="courseForm.name"
- auto-complete="off"
- placeholder="请输入课程名称"
- />
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="层次" prop="level">
- <el-select
- class="pull_length"
- v-model="courseForm.level"
- placeholder="请选择"
- >
- <el-option
- v-for="item in levelList"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- />
- </el-select>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="课程状态" prop="enable">
- <el-radio-group class="pull_length" v-model="courseForm.enable">
- <el-radio label="true">开启</el-radio>
- <el-radio label="false">禁用</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-row>
- <el-row class="pull-center">
- <el-button type="primary" @click="submitForm">保 存</el-button>
- <el-button @click="courseDialog = false">取 消</el-button>
- </el-row>
- </el-form>
- </el-dialog>
- <!-- 导入弹窗 -->
- <el-dialog title="导入窗口" width="420px" :visible.sync="impDialog">
- <el-form>
- <el-row>
- <el-form-item style="margin-left:20px">
- <el-upload
- class="form_left"
- ref="upload"
- accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
- :action="uploadAction"
- :headers="uploadHeaders"
- :data="uploadData"
- :before-upload="beforeUpload"
- :on-progress="uploadProgress"
- :on-success="uploadSuccess"
- :on-error="uploadError"
- :file-list="fileList"
- :auto-upload="false"
- :multiple="false"
- >
- <el-button size="small" slot="trigger" type="primary">
- 选择文件
- </el-button>
-
- <el-button size="small" type="success" @click="submitUpload">
- 确认上传
- </el-button>
- <el-button size="small" type="danger" @click="removeFile">
- 清空文件
- </el-button>
- <el-button size="small" type="info" @click="exportFile">
- 下载模板
- </el-button>
- <div slot="tip" class="el-upload__tip">只能上传xlsx文件</div>
- </el-upload>
- </el-form-item>
- </el-row>
- </el-form>
- </el-dialog>
- <!-- 导入错误信息列表 -->
- <el-dialog title="错误提示" :visible.sync="errDialog">
- <div
- class="text-danger"
- v-for="errMessage in errMessages"
- :key="errMessage.lineNum"
- >
- 第{{ errMessage.lineNum }}行:{{ errMessage.msg }}
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="errDialog = false">确定</el-button>
- </span>
- </el-dialog>
- <!-- 关联专业弹出框 -->
- <el-dialog
- :title="specialtyDialogTitle"
- :visible.sync="specialtyDialog"
- width="800px"
- >
- <!-- 表单 -->
- <el-form :inline="true" :model="specialtySearchForm">
- <el-form-item label="专业名称">
- <el-input
- class="input_width_lg"
- placeholder="请输入专业名称"
- v-model="specialtySearchForm.name"
- />
- </el-form-item>
- <el-form-item label="专业代码">
- <el-input
- class="input_width_lg"
- placeholder="请输入专业代码"
- v-model="specialtySearchForm.code"
- />
- </el-form-item>
- <el-form-item>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-search"
- @click="searchSpecialtyPage"
- >
- 查询
- </el-button>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- @click="addRelation"
- >
- 新增
- </el-button>
- </el-form-item>
- </el-form>
- <!-- 专业列表 -->
- <el-table :data="specialtyTableData" border>
- <el-table-column prop="id" label="ID" width="100" />
- <el-table-column prop="name" label="专业名称" width="250" />
- <el-table-column prop="code" label="专业代码" />
- <el-table-column prop="updateTime" label="更新时间" width="170" />
- <el-table-column label="操作">
- <div slot-scope="scope">
- <span>
- <el-button
- size="mini"
- type="primary"
- @click="deleteRelation(scope.row)"
- icon="el-icon-edit"
- plain
- >
- 取消关联
- </el-button>
- </span>
- </div>
- </el-table-column>
- </el-table>
- <div class="page pull-right">
- <el-pagination
- @current-change="handleSpecialtyCurrentChange"
- :current-page="currentSpecialtyPage"
- :page-size="10"
- :total="specialtyTotal"
- />
- </div>
- <div style="margin-bottom: 20px"></div>
- </el-dialog>
- <!-- 添加关联 -->
- <el-dialog
- title="添加关联专业"
- :visible.sync="addRelationDialog"
- width="420px"
- >
- <el-form
- :inline="true"
- inline-message
- :model="addRelationForm"
- ref="addRelationForm"
- label-width="100px"
- :rules="addRelationRules"
- >
- <el-row>
- <el-form-item label="专业" class="pull-left" prop="specialtyId">
- <el-select
- class="input"
- remote
- :remote-method="getSpecialtyList4AddRelation"
- :loading="specialtyLoading4AddRelation"
- filterable
- clearable
- v-model="addRelationForm.specialtyId"
- placeholder="请选择"
- >
- <el-option
- v-for="item in specialtyList4AddRelationWrapper"
- :label="item.name"
- :value="item.id"
- :key="item.id"
- />
- </el-select>
- </el-form-item>
- </el-row>
- <el-row class="d-flex justify-content-center">
- <el-button type="primary" @click="submitAddRelationForm">
- 保 存
- </el-button>
- <el-button @click="addRelationDialog = false">取 消</el-button>
- </el-row>
- </el-form>
- </el-dialog>
- <!-- 页面列表 -->
- <el-table
- :data="tableData"
- border
- resizable
- stripe
- @selection-change="selectChange"
- >
- <el-table-column type="selection" width="35" />
- <el-table-column prop="id" label="课程ID" width="80" />
- <el-table-column prop="name" label="课程名称" width="180" />
- <el-table-column prop="code" label="课程代码" />
- <el-table-column label="层次">
- <span slot-scope="scope">{{ getLevel(scope.row.level) }}</span>
- </el-table-column>
- <el-table-column width="50" label="状态">
- <span slot-scope="scope">
- <span v-if="scope.row.enable">
- <el-tooltip
- class="item"
- effect="dark"
- content="启用"
- placement="left"
- >
- <i class="el-icon-success" style="color:green;"></i>
- </el-tooltip>
- </span>
- <span v-else>
- <el-tooltip
- class="item"
- effect="dark"
- content="禁用"
- placement="left"
- >
- <i class="el-icon-error" style="color:red;"></i>
- </el-tooltip>
- </span>
- </span>
- </el-table-column>
- <el-table-column prop="updateTime" label="更新时间" width="170" />
- <el-table-column label="操作" width="290">
- <div slot-scope="scope">
- <el-button
- size="mini"
- type="primary"
- plain
- icon="el-icon-share"
- @click="relation(scope.row)"
- >
- 关联专业
- </el-button>
- <el-button
- size="mini"
- type="primary"
- plain
- @click="editCourse(scope.row)"
- >
- <i class="el-icon-edit"></i> 编辑
- </el-button>
- <el-button
- size="mini"
- v-if="!scope.row.enable"
- plain
- type="primary"
- @click="enableById(scope.row)"
- icon="el-icon-check"
- >
- 启用
- </el-button>
- <el-button
- size="mini"
- v-if="scope.row.enable"
- type="danger"
- @click="disableById(scope.row)"
- icon="el-icon-close"
- >
- 禁用
- </el-button>
- </div>
- </el-table-column>
- </el-table>
- <div class="page pull-right">
- <el-pagination
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-size="10"
- :page-sizes="[10, 20, 50, 100]"
- @size-change="handleSizeChange"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- >
- </el-pagination>
- </div>
- </div>
- </div>
- </section>
- </template>
- <script>
- import { CORE_API } from "@/constants/constants.js";
- import { ENABLE_TYPE, LEVEL_TYPE } from "../constants/constants.js";
- import { mapState } from "vuex";
- export default {
- name: "Course",
- data() {
- return {
- specialtyLoading4Search: false,
- specialtyList4Search: [],
- formSearch: {
- name: "",
- code: "",
- enable: "",
- level: "",
- specialtyId: ""
- },
- courseForm: {
- id: null,
- name: "",
- code: "",
- level: "ALL",
- enable: "true"
- },
- statusList: ENABLE_TYPE,
- levelList: LEVEL_TYPE,
- selectedCourseIds: [],
- tableData: [],
- currentPage: 1,
- pageSize: 10,
- total: 10,
- specialtyAllList: [],
- specialtyList: [],
- selectedSpecialtyList: [],
- specialtys: [],
- specialtyAll: [],
- impDialog: false,
- uploadAction: CORE_API + "/course/import",
- uploadHeaders: {},
- uploadData: {},
- errMessages: [],
- errDialog: false,
- fileLoading: false,
- fileList: [],
- courseDialog: false,
- relationDialog: false,
- rules: {
- name: [
- {
- required: true,
- message: "请输入课程名称",
- trigger: "blur"
- }
- ],
- code: [
- {
- required: true,
- message: "请输入课程代码",
- trigger: "blur"
- }
- ],
- level: [
- {
- required: true,
- message: "请选择层次",
- trigger: "change"
- }
- ],
- status: [
- {
- required: true,
- message: "请选择状态",
- trigger: "change"
- }
- ]
- },
- specialtyDialog: false,
- specialtyDialogTitle: null,
- specialtySearchForm: {
- courseId: null,
- code: "",
- name: ""
- },
- specialtyTableData: [],
- currentSpecialtyPage: 1,
- specialtyPageSize: 10,
- specialtyTotal: 10,
- addRelationDialog: false,
- addRelationForm: {
- specialtyId: null,
- courseId: null
- },
- specialtyLoading4AddRelation: false,
- specialtyList4AddRelation: [],
- addRelationRules: {
- specialtyId: [
- {
- required: true,
- type: "number",
- message: "请选择专业",
- trigger: "change"
- }
- ]
- }
- };
- },
- computed: {
- ...mapState({
- user: state => state.user
- }),
- noBatchSelected() {
- return this.selectedCourseIds.length === 0;
- },
- courseIds() {
- var courseIds = "";
- for (let courseId of this.selectedCourseIds) {
- if (!courseIds) {
- courseIds += courseId;
- } else {
- courseIds += "," + courseId;
- }
- }
- return courseIds;
- },
- specialtyAllListSelect() {
- let specialtyList = [];
- for (let specialty of this.specialtyAllList) {
- let specialtyInfo = specialty.name + "(" + specialty.code + ")";
- specialtyList.push({ id: specialty.id, specialtyInfo: specialtyInfo });
- }
- return specialtyList;
- },
- getSpecialtyAllSelect4Search() {
- let specialtyList4Search = [];
- for (let specialty of this.specialtys) {
- let specialtyInfo = specialty.name + "(" + specialty.code + ")";
- specialtyList4Search.push({
- id: specialty.id,
- specialtyInfo: specialtyInfo
- });
- }
- return specialtyList4Search;
- },
- specialtyList4SearchWrapper() {
- var specialtyList = [];
- for (let course of this.specialtyList4Search) {
- var name = course.name + " - " + course.code;
- var id = course.id;
- specialtyList.push({ id: id, name: name });
- }
- return specialtyList;
- },
- specialtyList4AddRelationWrapper() {
- var specialtyList = [];
- for (let course of this.specialtyList4AddRelation) {
- var name = course.name + " - " + course.code;
- var id = course.id;
- specialtyList.push({ id: id, name: name });
- }
- return specialtyList;
- }
- },
- methods: {
- handleSizeChange(val) {
- this.pageSize = val;
- this.currentPage = 1;
- this.searchForm();
- },
- dialogBeforeClose() {
- this.$refs.courseForm.clearValidate();
- },
- deleteRelation(row) {
- var specialtyId = row.id;
- var courseId = this.specialtySearchForm.courseId;
- var param = new URLSearchParams({
- courseId: courseId,
- specialtyId: specialtyId
- });
- var url = CORE_API + "/courseSpeciatlyRelation/delete?" + param;
- this.$http
- .delete(url)
- .then(() => {
- this.$notify({
- type: "success",
- message: "取消关联成功!"
- });
- this.searchSpecialtyPage();
- })
- .catch(response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- });
- },
- submitAddRelationForm() {
- this.$refs.addRelationForm.validate(valid => {
- if (valid) {
- var param = new URLSearchParams(this.addRelationForm);
- var url = CORE_API + "/courseSpeciatlyRelation/add?" + param;
- this.$http.post(url, this.speciallyForm).then(
- () => {
- this.$notify({
- type: "success",
- message: "添加成功!"
- });
- this.searchSpecialtyPage();
- this.addRelationDialog = false;
- },
- response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- }
- );
- } else {
- console.log("error submit!");
- return false;
- }
- });
- },
- getSpecialtyList4AddRelation(query) {
- this.specialtyLoading4AddRelation = true;
- this.$http
- .get(CORE_API + "/specialty/query?name=" + query)
- .then(response => {
- this.specialtyList4AddRelation = response.data;
- this.specialtyLoading4AddRelation = false;
- });
- },
- addRelation() {
- this.addRelationForm.specialtyId = null;
- this.addRelationForm.courseId = this.specialtySearchForm.courseId;
- this.addRelationDialog = true;
- if (this.$refs.addRelationForm) {
- this.$refs.addRelationForm.resetFields();
- }
- },
- handleSpecialtyCurrentChange(val) {
- this.currentSpecialtyPage = val;
- this.searchSpecialtyPage();
- },
- searchSpecialtyPage() {
- var param = new URLSearchParams(this.specialtySearchForm);
- var url =
- CORE_API +
- "/specialty/specialtyPage/" +
- (this.currentPage - 1) +
- "/" +
- this.pageSize +
- "?" +
- param;
- this.$http.get(url).then(response => {
- this.specialtyTableData = response.data.content;
- this.specialtyTotal = response.data.totalElements;
- });
- },
- getTag(status) {
- if (status == true) {
- return "success";
- } else if (status == false) {
- return "danger";
- }
- return status;
- },
- getLevel(level) {
- if (level == "ZSB") {
- return "专升本";
- } else if (level == "GQZ") {
- return "高起专";
- } else if (level == "GQB") {
- return "高起本";
- } else {
- return "不限";
- }
- },
- getSpecialtyList4Search(query) {
- this.specialtyLoading4Search = true;
- this.$http
- .get(CORE_API + "/specialty/query?name=" + query)
- .then(response => {
- this.specialtyList4Search = response.data;
- this.specialtyLoading4Search = false;
- });
- },
- handleSearchBtn() {
- this.currentPage = 1;
- this.searchForm();
- },
- searchForm() {
- var param = new URLSearchParams(this.formSearch);
- var url =
- CORE_API +
- "/course/coursePage/" +
- (this.currentPage - 1) +
- "/" +
- this.pageSize +
- "?" +
- param;
- this.$http.get(url).then(response => {
- this.tableData = response.data.content;
- this.total = response.data.totalElements;
- });
- },
- handleCurrentChange(val) {
- this.currentPage = val;
- this.searchForm();
- },
- selectChange(row) {
- this.selectedCourseIds = [];
- row.forEach(element => {
- this.selectedCourseIds.push(element.id);
- });
- console.log(this.selectedCourseIds);
- },
- //新增
- insertCourse() {
- this.courseForm.id = null;
- this.courseForm.name = null;
- this.courseForm.code = null;
- this.courseForm.level = "ALL";
- this.courseForm.enable = "true";
- this.courseDialog = true;
- },
- //修改
- editCourse(row) {
- this.courseForm = Object.assign({}, row);
- this.courseForm.enable = row.enable ? "true" : "false";
- this.courseId = row.id;
- this.courseDialog = true;
- },
- exportCourse() {
- var param = new URLSearchParams(this.formSearch);
- window.open(
- CORE_API +
- "/course/export?$key=" +
- this.user.key +
- "&$token=" +
- this.user.token +
- "&" +
- param
- );
- },
- //关联课程
- relation(row) {
- this.specialtyDialogTitle =
- "关联专业列表 【课程名称:" +
- row.name +
- "】【 课程代码:" +
- row.code +
- "】";
- this.specialtySearchForm.courseId = row.id;
- this.specialtySearchForm.name = "";
- this.specialtySearchForm.code = "";
- this.searchSpecialtyPage();
- this.specialtyDialog = true;
- },
- closeCourse() {
- this.courseDialog = false;
- },
- saveRelation() {},
- //保存(新增/修改)
- submitForm() {
- var url = CORE_API + "/course";
- if (null != this.courseForm.id) {
- //修改
- this.$refs.courseForm.validate(valid => {
- if (valid) {
- this.$http.put(url, this.courseForm).then(
- () => {
- this.$notify({
- type: "success",
- message: "修改成功!"
- });
- this.searchForm();
- this.resetForm();
- this.courseDialog = false;
- },
- response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- }
- );
- } else {
- console.log("error submit!");
- return false;
- }
- });
- } else {
- this.$refs.courseForm.validate(valid => {
- if (valid) {
- this.$http.post(url, this.courseForm).then(
- () => {
- this.$notify({
- type: "success",
- message: "添加成功"
- });
- this.searchForm();
- this.resetForm();
- this.courseDialog = false;
- },
- response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- }
- );
- } else {
- console.log("error submit!");
- return false;
- }
- });
- }
- },
- //重置
- resetForm() {
- this.$refs.courseForm.resetFields();
- },
- resetPrimaryForm() {
- this.formSearch = {
- name: "",
- code: "",
- enable: "",
- level: "",
- specialtyId: ""
- };
- this.$refs.primaryForm.resetFields();
- },
- //删除单个数据
- deleteById(row) {
- this.$confirm("是否删除该课程?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- var url = CORE_API + "/course/" + row.id;
- this.$http
- .delete(url)
- .then(() => {
- this.$notify({
- type: "success",
- message: "删除成功!"
- });
- this.searchForm();
- })
- .catch(response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- });
- });
- },
- //删除多条数据
- deleteByIds() {
- if (this.selectedCourseIds.length === 0) {
- this.$notify({
- type: "warning",
- message: "请选择要删除的课程"
- });
- } else {
- this.$confirm("是否删除这些课程?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "error"
- }).then(() => {
- var url = CORE_API + "/course/" + this.courseIds;
- this.$http
- .delete(url)
- .then(() => {
- this.$notify({
- type: "success",
- message: "删除成功!"
- });
- this.searchForm();
- })
- .catch(response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- });
- });
- }
- },
- //启用
- enableByIds() {
- if (this.selectedCourseIds.length === 0) {
- this.$notify({
- type: "warning",
- message: "请选择要开启的课程"
- });
- } else {
- this.$confirm("是否启用这些课程?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- var url = CORE_API + "/course/enable/" + this.courseIds;
- this.$http
- .put(url, {})
- .then(() => {
- this.$notify({
- type: "success",
- message: "开启成功!"
- });
- this.searchForm();
- })
- .catch(response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- });
- });
- }
- },
- enableById(row) {
- this.$confirm("是否启用该课程?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- var url = CORE_API + "/course/enable/" + row.id;
- this.$http
- .put(url, {})
- .then(() => {
- this.$notify({
- type: "success",
- message: "开启成功!"
- });
- this.searchForm();
- })
- .catch(response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- });
- });
- },
- //禁用
- disableByIds() {
- if (this.selectedCourseIds.length === 0) {
- this.$notify({
- type: "warning",
- message: "请选择要禁用的课程"
- });
- } else {
- this.$confirm("是否禁用这些课程?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "error"
- }).then(() => {
- var url = CORE_API + "/course/disable/" + this.courseIds;
- this.$http
- .put(url, {})
- .then(() => {
- this.$notify({
- type: "success",
- message: "禁用成功!"
- });
- this.searchForm();
- })
- .catch(response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- });
- });
- }
- },
- //禁用
- disableById(row) {
- this.$confirm("是否禁用该课程?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "error"
- }).then(() => {
- var url = CORE_API + "/course/disable/" + row.id;
- this.$http
- .put(url, {})
- .then(() => {
- this.$notify({
- type: "success",
- message: "禁用成功!"
- });
- this.searchForm();
- })
- .catch(response => {
- if (response.status == 500) {
- this.$notify({
- showClose: true,
- message: response.data.desc,
- type: "error"
- });
- }
- });
- });
- },
- //导入
- impCourse() {
- this.impDialog = true;
- this.initUpload();
- },
- initUpload() {
- this.fileList = [];
- },
- beforeUpload(file) {
- console.log(file);
- },
- uploadProgress() {
- console.log("uploadProgress");
- },
- uploadSuccess(response) {
- if (!response.hasError) {
- this.$notify({
- message: "上传成功",
- type: "success"
- });
- this.fileLoading = false;
- this.impDialog = false;
- this.searchForm();
- } else {
- this.fileLoading = false;
- this.impDialog = false;
- this.errMessages = response.failRecords;
- this.errDialog = true;
- }
- },
- uploadError(response) {
- var json = JSON.parse(response.message);
- if (response.status == 500) {
- this.$notify({
- message: json.desc,
- type: "error"
- });
- }
- this.fileLoading = false;
- },
- //确定上传
- submitUpload() {
- if (!this.checkUpload()) {
- return false;
- }
- this.$refs.upload.submit();
- this.fileLoading = true;
- },
- checkUpload() {
- var fileList = this.$refs.upload.uploadFiles;
- if (fileList.length == 0) {
- this.$notify({
- message: "上传文件不能为空",
- type: "error"
- });
- return false;
- }
- if (fileList.length > 1) {
- this.$notify({
- message: "每次只能上传一个文件",
- type: "error"
- });
- return false;
- }
- for (let file of fileList) {
- if (!file.name.endsWith(".xlsx")) {
- this.$notify({
- message: "上传文件必须为xlsx格式",
- type: "error"
- });
- this.initUpload();
- return false;
- }
- }
- return true;
- },
- //清空文件
- removeFile() {
- // this.fileList = [];
- this.$refs.upload.clearFiles();
- },
- //下载模板
- exportFile() {
- window.location.href =
- CORE_API +
- "/course/importTemplate?$key=" +
- this.user.key +
- "&$token=" +
- this.user.token;
- }
- },
- //初始化查询
- created() {
- this.searchForm();
- this.uploadHeaders = {
- key: this.user.key,
- token: this.user.token
- };
- }
- };
- </script>
- <style scoped>
- .input_width_lg {
- width: 180px;
- }
- .pull_length {
- width: 180px;
- }
- .pull-center {
- margin-left: 30%;
- }
- </style>
|