|
@@ -178,6 +178,9 @@
|
|
|
<div class="dis_plays">
|
|
|
<div>
|
|
|
<el-button size="small" @click="openBoxs">调用已有数据</el-button>
|
|
|
+ <el-button size="small" type="success" @click="dialogDRFunc"
|
|
|
+ >Excel批量新增章</el-button
|
|
|
+ >
|
|
|
<el-button size="small" @click="addChapter">自定义添加章</el-button>
|
|
|
</div>
|
|
|
<div style="color: #f56c6c">
|
|
@@ -366,11 +369,95 @@
|
|
|
>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="dialogDR"
|
|
|
+ width="660px"
|
|
|
+ :show-close="false"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ >
|
|
|
+ <div slot="title" class="hearders">
|
|
|
+ <div class="leftTitle">导入</div>
|
|
|
+ <div class="rightBoxs">
|
|
|
+ <img
|
|
|
+ src="@/assets/images/Close@2x.png"
|
|
|
+ alt=""
|
|
|
+ @click="dialogDR = false"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <div class="swq">
|
|
|
+ <img
|
|
|
+ style="width: 182px; height: 168px"
|
|
|
+ src="@/assets/images/dr.png"
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div style="padding-left: 100px">
|
|
|
+ <p>第一步:下载导入模板</p>
|
|
|
+ <p style="padding-left: 50px">
|
|
|
+ <i class="el-icon-upload"></i
|
|
|
+ ><span class="dowmStys" @click="getDowm">下载模板</span>
|
|
|
+ </p>
|
|
|
+ <p>第二步:(批量新增):点击“上传Excel”完成导入</p>
|
|
|
+ <label
|
|
|
+ for="mobles"
|
|
|
+ class="el-button el-button--primary"
|
|
|
+ style="margin-left: 50px; padding: 10px 20px"
|
|
|
+ >上传Excel</label
|
|
|
+ ><input
|
|
|
+ style="display: none"
|
|
|
+ type="file"
|
|
|
+ id="mobles"
|
|
|
+ ref="input1"
|
|
|
+ @change="importMobleadd"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogDR = false">取消</el-button>
|
|
|
+ <!-- <el-button type="primary" @click="submitChecksDR">确定</el-button> -->
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ append-to-body
|
|
|
+ :visible.sync="dialogERROR"
|
|
|
+ width="660px"
|
|
|
+ :show-close="false"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ >
|
|
|
+ <div slot="title" class="hearders">
|
|
|
+ <div class="leftTitle">提示</div>
|
|
|
+ <div class="rightBoxs">
|
|
|
+ <img
|
|
|
+ src="@/assets/images/Close@2x.png"
|
|
|
+ alt=""
|
|
|
+ @click="dialogERROR = false"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <h4 style="margin-top: 0px; font-weight: bold; text-align: center">
|
|
|
+ 导入失败原因
|
|
|
+ </h4>
|
|
|
+ <el-input
|
|
|
+ readonly
|
|
|
+ type="textarea"
|
|
|
+ :autosize="{ minRows: 6, maxRows: 24 }"
|
|
|
+ v-model="errorData"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogERROR = false">确定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
<addChapter ref="addChapter" @backData="backData" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import * as baseUrls from "@/utils/request.js";
|
|
|
import searchBoxNew from "@/components/searchBoxNew";
|
|
|
import pagination from "@/components/pagination";
|
|
|
import addChapter from "../addChapter.vue";
|
|
@@ -424,7 +511,7 @@ export default {
|
|
|
{ label: "章编码", prop: "code", width: "120" },
|
|
|
{ label: "标题前缀", prop: "prefixName", width: "180" },
|
|
|
{ label: "章标题", prop: "name" },
|
|
|
- { label: "节数量", prop: "sectionNum" , width: "120" },
|
|
|
+ { label: "节数量", prop: "sectionNum", width: "120" },
|
|
|
{
|
|
|
label: "发布状态",
|
|
|
prop: "publishStatus",
|
|
@@ -483,7 +570,10 @@ export default {
|
|
|
disCheckList: [], //已选转禁用复选列表
|
|
|
activeLists: [],
|
|
|
noStudent: true,
|
|
|
- pageId:this.$route.query.id
|
|
|
+ pageId: this.$route.query.id,
|
|
|
+ errorData: "",
|
|
|
+ dialogERROR: false,
|
|
|
+ dialogDR: false,
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -496,13 +586,11 @@ export default {
|
|
|
},
|
|
|
async mounted() {
|
|
|
this.$modal.loading("正在导入数据,请稍后...");
|
|
|
- this.$api
|
|
|
- .gradecheckGoodsChange({ moduleId: this.pageId })
|
|
|
- .then((res) => {
|
|
|
- if (res.data > 0) {
|
|
|
- this.noStudent = false;
|
|
|
- }
|
|
|
- });
|
|
|
+ this.$api.gradecheckGoodsChange({ moduleId: this.pageId }).then((res) => {
|
|
|
+ if (res.data > 0) {
|
|
|
+ this.noStudent = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
await this.getDict();
|
|
|
this.search();
|
|
|
},
|
|
@@ -523,6 +611,114 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ /**
|
|
|
+ * 下载Excel模板
|
|
|
+ */
|
|
|
+ getDowm() {
|
|
|
+ let url =
|
|
|
+ baseUrls.BASE_IMG_URL + "/oss/images/file/20220617/1655453121157.xlsx";
|
|
|
+ let link = document.createElement("a");
|
|
|
+ let fileName = "导入模板" + ".xlsx";
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.href = url;
|
|
|
+ link.dowmload = fileName;
|
|
|
+ link.click();
|
|
|
+ link.remove();
|
|
|
+ },
|
|
|
+ dialogDRFunc() {
|
|
|
+ if (!this.newSujectApis.length) {
|
|
|
+ this.$message.error("请添加科目");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.dialogDR = true;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Object} e
|
|
|
+ * @remards 导入逻辑
|
|
|
+ */,
|
|
|
+ importMobleadd(e) {
|
|
|
+ if (!this.newSujectApis.length) {
|
|
|
+ this.$message.error("请添加科目");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var self = this;
|
|
|
+ var file = e.target.files[0];
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append("businessJson", JSON.stringify(this.newSujectApis));
|
|
|
+ formData.append("file", file);
|
|
|
+ this.$api
|
|
|
+ .CoursemoduleimportData(formData)
|
|
|
+ .then(async (res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ if (!res.data.errorLog) {
|
|
|
+ await this.awaitGetFestivalList(res.data.importNo, 1)
|
|
|
+ .then((result) => {
|
|
|
+ self.dialogDR = false;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ e.target.value = "";
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ await this.awaitGetFestivalList(res.data.importNo, 2)
|
|
|
+ .then((result) => {
|
|
|
+ let ary = res.data.errorLog.split("\r\n");
|
|
|
+ ary = ary
|
|
|
+ .filter((item) => {
|
|
|
+ return item.length > 0;
|
|
|
+ })
|
|
|
+ .reverse();
|
|
|
+ self.$message({
|
|
|
+ message: `${ary.length}条数据导入失败,请查看失败原因`,
|
|
|
+ customClass: "myMessageClass",
|
|
|
+ });
|
|
|
+ ary = ary.join("\r\n");
|
|
|
+ self.errorData = ary;
|
|
|
+ self.dialogERROR = true;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ e.target.value = "";
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ e.target.value = "";
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Strings} ids 查询编码
|
|
|
+ * @param {Number} type 1为成功2为失败
|
|
|
+ * @remards 失败时也需查询是否有成功的数据导入数据库,如存在 则加列队列同时提示
|
|
|
+ */
|
|
|
+ awaitGetFestivalList(ids, type) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$api
|
|
|
+ .inquireCourseListchapter({ importNo: ids })
|
|
|
+ .then((res) => {
|
|
|
+ if (type === 2 && res.rows.length) {
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: `成功导入${res.rows.length}条数据,`,
|
|
|
+ customClass: "myMessageClass",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (res.rows.length) {
|
|
|
+ this.activeLists = res.rows;
|
|
|
+ if (type === 1) {
|
|
|
+ this.submitForm();
|
|
|
+ } else {
|
|
|
+ this.submitForm(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resolve();
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ reject();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
jumpChapter(v) {
|
|
|
const jump = () => {
|
|
|
this.$store.dispatch("changemodulePage", {
|
|
@@ -640,13 +836,11 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
getInfosList() {
|
|
|
- this.$api
|
|
|
- .inquireCourseListmodulechapter(this.pageId)
|
|
|
- .then((result) => {
|
|
|
- // this.numberAll = result.total;
|
|
|
- // this.minTimeAll = result.timeTotal;
|
|
|
- this.tableData = result.data;
|
|
|
- });
|
|
|
+ this.$api.inquireCourseListmodulechapter(this.pageId).then((result) => {
|
|
|
+ // this.numberAll = result.total;
|
|
|
+ // this.minTimeAll = result.timeTotal;
|
|
|
+ this.tableData = result.data;
|
|
|
+ });
|
|
|
},
|
|
|
init() {
|
|
|
this.getInfos(2);
|
|
@@ -947,7 +1141,12 @@ export default {
|
|
|
getRowKeys(row) {
|
|
|
return row.chapterId;
|
|
|
},
|
|
|
- submitForm() {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Number} int 导入失败标识
|
|
|
+ * @remards 合并且排列节列表数据
|
|
|
+ */
|
|
|
+ submitForm(int) {
|
|
|
if (this.activeLists.length === 0) {
|
|
|
this.dialogVisible = false;
|
|
|
return;
|
|
@@ -969,7 +1168,14 @@ export default {
|
|
|
}
|
|
|
this.tableData = this.tableData.concat(this.activeLists);
|
|
|
this.dialogVisible = false;
|
|
|
- this.$message.success("添加成功");
|
|
|
+ this.activeLists = []
|
|
|
+ if (!int) {
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: `添加成功`,
|
|
|
+ customClass: "myMessageClass",
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
delList(item) {
|
|
|
this.tableData.map((items, indexs) => {
|
|
@@ -979,7 +1185,7 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- closedFunc(){
|
|
|
+ closedFunc() {
|
|
|
this.activeLists = [];
|
|
|
},
|
|
|
},
|
|
@@ -987,6 +1193,14 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
+.swq {
|
|
|
+ text-align: center;
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
+}
|
|
|
+.dowmStys {
|
|
|
+ color: blue;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
.boxWidth {
|
|
|
width: 800px;
|
|
|
}
|