123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- <template>
- <!-- 教研中心录入 -->
- <div class="teacher-devEntering">
- <Header />
- <Nav />
- <div class="top">
- <div class="seek" @keydown="downSeekdata">
- <input
- v-model="keyWord"
- @change="keyWord = keyWord.trim()"
- placeholder="请输入内容"
- />
- <img
- @click="seekData"
- src="../../assets/teacherdev/Group2149.png"
- alt=""
- />
- </div>
- <div class="btn">
- <!-- <el-button type="primary">批量上传</el-button> -->
- <div style="margin: 0 23px">
- <!--
- :fileList="fileList"
- -->
- <Upload
- type="批量上传"
- :changeFillId="changeFillId"
- :filleNumber="20"
- :accept="'.doc,.docx,.xls,.xlsx,.pdf,.ppt,.pptx'"
- />
- </div>
- <el-button type="primary" @click="newDocument">新建文档</el-button>
- </div>
- </div>
- <div class="table" v-loading="loading">
- <el-table :data="tableData.data" stripe style="width: 100%">
- <el-table-column
- label="文档名称"
- prop="name"
- width="300"
- ></el-table-column>
- <el-table-column
- label="文档类型"
- prop="type"
- width="150"
- :formatter="handlefileType"
- ></el-table-column>
- <el-table-column
- label="发布时间"
- prop="updateTime"
- width="200"
- ></el-table-column>
- <el-table-column
- :formatter="handledownload"
- label="下载"
- prop="download"
- width="150"
- ></el-table-column>
- <el-table-column
- label="状态"
- prop="status"
- width="150"
- :formatter="handleStatus"
- ></el-table-column>
- <el-table-column label="操作" prop>
- <template slot-scope="scope">
- <el-button @click="handleEdit(scope.row, scope.$index)" type="text"
- >编辑</el-button
- >
- <el-button @click="handleDel(scope.row)" type="text"
- >删除</el-button
- >
- <el-button @click="handleDiscount(scope.row)" type="text"
- >优惠码</el-button
- >
- <el-button
- v-if="scope.row.status != 4"
- @click="up(scope.row)"
- type="text"
- >上架</el-button
- >
- <el-button
- v-if="scope.row.status != 3"
- @click="down(scope.row)"
- type="text"
- >下架</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- @current-change="handleCurrentChange"
- layout="prev, pager, next"
- :page-size="pageSize"
- :total="tableData.total"
- :current-page="pageNum"
- >
- </el-pagination>
- </div>
- </div>
- </template>
- <script>
- import Header from "@/components/Header";
- import Nav from "@/components/teacher-devEntering/Nav";
- import Upload from "@/components/Upload";
- import { getToken } from "@/utils/auth";
- import { usertenant } from "@/api/api";
- import {
- VerifyLogin,
- materiallist,
- materialdelete,
- materialinsert,
- attachmentinsert,
- materialoutOfStockAction,
- materialinStockAction,
- } from "@/api/api";
- import Cookies from "js-cookie";
- export default {
- name: "teacher-devEntering",
- components: {
- Header,
- Nav,
- Upload,
- },
- data() {
- return {
- tableData: [
- {
- name: "教师培训公开课1",
- type: "ppt",
- creadTime: "2021-10-10 15:30",
- download: 1,
- },
- {
- name: "教师培训公开课2",
- type: "pdf",
- creadTime: "2021-10-10 15:30",
- download: 0,
- },
- ],
- fileList: null,
- loading: false,
- keyWord: "",
- pageNum: 1,
- pageSize: 10,
- institutionList: null,
- };
- },
- methods: {
- // 生成优惠码
- handleDiscount(row) {
- this.$router.push(
- "/discountCodeList?bookId=" + row.id + "&goods_type=" + 401
- );
- },
- // 批量上传
- changeFillId(file, fileList) {
- this.loading = true;
- let name = file.file_name.split(".")[0];
- let type = file.file_name.split(".")[1];
- let tag = ["downloadable", "TEXTBOOK", type];
- let attachmentList = [];
- attachmentList.push({
- name: file.file_name,
- fileId: file.file_id,
- fileType: type,
- });
- attachmentinsert({
- attachmentList: attachmentList,
- type: "3",
- tenantId: this.institutionList[0].tenantId,
- })
- .then((res) => {
- materialinsert({
- name: name,
- price: "-1",
- teacherList: [""],
- tenantId: this.institutionList[0].tenantId,
- tagList: tag,
- attachmentIdList: res.data.attachmentIdList,
- })
- .then((ress) => {
- this.loading = false;
- this.getdata();
- })
- .catch((res) => {
- this.loading = false;
- });
- })
- .catch((res) => {
- this.loading = false;
- });
- // let fileList1 = JSON.parse(JSON.stringify(fileList));
- // this.fileList = fileList1;
- },
- // 搜索
- seekData() {
- this.pageNum = 1;
- this.getdata();
- },
- downSeekdata(e) {
- if (e.keyCode == 13) {
- this.pageNum = 1;
- this.getdata();
- }
- },
- // 换页
- async handleCurrentChange(pagesize) {
- this.pageNum = pagesize;
- this.getdata();
- },
- // 编辑
- handleEdit(item) {
- if (item.status == 4) {
- this.$message.warning("上架状态下不可以进行编辑操作");
- return;
- }
- this.$router.push({
- path: "/creadDocument",
- query: {
- materialId: item.id,
- },
- });
- },
- // 删除
- handleDel(item) {
- if (item.status == 4) {
- this.$message.warning("上架状态下不可以进行删除操作");
- return;
- }
- this.$confirm("确定要删除此学习资料吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- this.loading = true;
- materialdelete({
- id: `${item.id}`,
- })
- .then((res) => {
- this.getdata();
- this.$message({
- type: "success",
- message: "删除成功",
- });
- })
- .catch((res) => {
- this.loading = false;
- });
- })
- .catch(() => {
- this.loading = false;
- });
- },
- // 上架
- up(item) {
- if (item.status == 4) {
- this.$message.warning("该课程已经上架了");
- return;
- }
- if (!item.price || !item.teacher[0]) {
- this.$message.warning("请先去完善信息再上架");
- return;
- }
- this.loading = true;
- materialinStockAction({
- id: `${item.id}`,
- })
- .then((res) => {
- this.getdata();
- this.$message({
- type: "success",
- message: "上架成功",
- });
- })
- .catch(() => {
- this.loading = false;
- });
- },
- // 下架
- down(item) {
- if (item.status == 3) {
- this.$message.warning("该课程已经下架了");
- return;
- }
- this.loading = true;
- materialoutOfStockAction({
- id: `${item.id}`,
- })
- .then((res) => {
- this.getdata();
- this.$message({
- type: "success",
- message: "下架成功",
- });
- })
- .catch(() => {
- this.loading = false;
- });
- },
- // 处理下载
- handledownload(row) {
- let index = row.tag.indexOf("downloadable");
- if (index != -1) {
- return "开启";
- } else {
- return "关闭";
- }
- },
- // 处理文档类型
- handlefileType(row) {
- let index = row.tag.indexOf("downloadable");
- if (index != -1) {
- return row.tag[2];
- } else {
- return row.tag[1];
- }
- },
- // 处理发布状态
- handleStatus(row) {
- if (row.status == 4) {
- return "已上架";
- } else if (row.status == 3) {
- return "已下架";
- }
- },
- // 新建文档
- newDocument() {
- this.$router.push({ path: "/creadDocument" });
- },
- getdata() {
- this.loading = true;
- materiallist({
- pageNum: this.pageNum,
- pageSize: this.pageSize,
- keyWord: this.keyWord,
- isSelectForUpdate: true,
- orderType: "DESC",
- orderColumn: "2",
- })
- .then((res) => {
- this.tableData = res.data;
- this.loading = false;
- })
- .catch(() => {
- this.loading = false;
- });
- },
- },
- created() {
- // 获取当前可编辑机构
- usertenant({})
- .then((res) => {
- if (res.status == 1) {
- this.institutionList = res.data.tenantIdAndNameListEditable;
- this.loading = false;
- }
- })
- .catch((res) => {
- this.loading = false;
- });
- },
- mounted() {
- this.getdata();
- // this.loading = true;
- // let userInfor = JSON.parse(getToken());
- // let userCode = "",
- // userType = "",
- // sessionId = "";
- // if (userInfor) {
- // userCode = userInfor.user_code;
- // userType = userInfor.user_type;
- // sessionId = userInfor.session_id;
- // }
- // // 验证登录拿到JSESSIONID放到cookies中后面的接口用来验证用户身份
- // VerifyLogin({
- // userCode,
- // userType,
- // sessionId,
- // })
- // .then((res) => {
- // if (res.code != -1) {
- // Cookies.set("JSESSIONID", res.data.JSESSSIONID);
- //
- // }
- // })
- // .catch(() => {
- // this.loading = false;
- // });
- },
- };
- </script>
- <style lang="scss" scoped>
- .teacher-devEntering {
- .top {
- width: 1200px;
- margin: 0 auto;
- margin-top: 40px;
- display: flex;
- justify-content: space-between;
- padding: 0 90px;
- .seek {
- width: 400px;
- height: 40px;
- background: #ffffff;
- border: 1px solid #d9d9d9;
- box-sizing: border-box;
- border-radius: 8px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 16px;
- input {
- width: 90%;
- border: none;
- outline: none;
- margin-left: 5px;
- }
- img {
- width: 18px;
- height: 18px;
- }
- }
- .btn {
- display: flex;
- text-align: right;
- }
- }
- .table {
- width: 1200px;
- margin: 0 auto;
- margin-top: 50px;
- }
- }
- </style>
|