index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <!-- 教研中心录入 -->
  3. <div class="teacher-devEntering">
  4. <Header />
  5. <Nav />
  6. <div class="top">
  7. <div class="seek" @keydown="downSeekdata">
  8. <input
  9. v-model="keyWord"
  10. @change="keyWord = keyWord.trim()"
  11. placeholder="请输入内容"
  12. />
  13. <img
  14. @click="seekData"
  15. src="../../assets/teacherdev/Group2149.png"
  16. alt=""
  17. />
  18. </div>
  19. <div class="btn">
  20. <!-- <el-button type="primary">批量上传</el-button> -->
  21. <div style="margin: 0 23px">
  22. <!--
  23. :fileList="fileList"
  24. -->
  25. <Upload
  26. type="批量上传"
  27. :changeFillId="changeFillId"
  28. :filleNumber="20"
  29. :accept="'.doc,.docx,.xls,.xlsx,.pdf,.ppt,.pptx'"
  30. />
  31. </div>
  32. <el-button type="primary" @click="newDocument">新建文档</el-button>
  33. </div>
  34. </div>
  35. <div class="table" v-loading="loading">
  36. <el-table :data="tableData.data" stripe style="width: 100%">
  37. <el-table-column
  38. label="文档名称"
  39. prop="name"
  40. width="300"
  41. ></el-table-column>
  42. <el-table-column
  43. label="文档类型"
  44. prop="type"
  45. width="150"
  46. :formatter="handlefileType"
  47. ></el-table-column>
  48. <el-table-column
  49. label="发布时间"
  50. prop="updateTime"
  51. width="200"
  52. ></el-table-column>
  53. <el-table-column
  54. :formatter="handledownload"
  55. label="下载"
  56. prop="download"
  57. width="150"
  58. ></el-table-column>
  59. <el-table-column
  60. label="状态"
  61. prop="status"
  62. width="150"
  63. :formatter="handleStatus"
  64. ></el-table-column>
  65. <el-table-column label="操作" prop>
  66. <template slot-scope="scope">
  67. <el-button @click="handleEdit(scope.row, scope.$index)" type="text"
  68. >编辑</el-button
  69. >
  70. <el-button @click="handleDel(scope.row)" type="text"
  71. >删除</el-button
  72. >
  73. <el-button @click="handleDiscount(scope.row)" type="text"
  74. >优惠码</el-button
  75. >
  76. <el-button
  77. v-if="scope.row.status != 4"
  78. @click="up(scope.row)"
  79. type="text"
  80. >上架</el-button
  81. >
  82. <el-button
  83. v-if="scope.row.status != 3"
  84. @click="down(scope.row)"
  85. type="text"
  86. >下架</el-button
  87. >
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <el-pagination
  92. @current-change="handleCurrentChange"
  93. layout="prev, pager, next"
  94. :page-size="pageSize"
  95. :total="tableData.total"
  96. :current-page="pageNum"
  97. >
  98. </el-pagination>
  99. </div>
  100. </div>
  101. </template>
  102. <script>
  103. import Header from "@/components/Header";
  104. import Nav from "@/components/teacher-devEntering/Nav";
  105. import Upload from "@/components/Upload";
  106. import { getToken } from "@/utils/auth";
  107. import { usertenant } from "@/api/api";
  108. import {
  109. VerifyLogin,
  110. materiallist,
  111. materialdelete,
  112. materialinsert,
  113. attachmentinsert,
  114. materialoutOfStockAction,
  115. materialinStockAction,
  116. } from "@/api/api";
  117. import Cookies from "js-cookie";
  118. export default {
  119. name: "teacher-devEntering",
  120. components: {
  121. Header,
  122. Nav,
  123. Upload,
  124. },
  125. data() {
  126. return {
  127. tableData: [
  128. {
  129. name: "教师培训公开课1",
  130. type: "ppt",
  131. creadTime: "2021-10-10 15:30",
  132. download: 1,
  133. },
  134. {
  135. name: "教师培训公开课2",
  136. type: "pdf",
  137. creadTime: "2021-10-10 15:30",
  138. download: 0,
  139. },
  140. ],
  141. fileList: null,
  142. loading: false,
  143. keyWord: "",
  144. pageNum: 1,
  145. pageSize: 10,
  146. institutionList: null,
  147. };
  148. },
  149. methods: {
  150. // 生成优惠码
  151. handleDiscount(row) {
  152. this.$router.push(
  153. "/discountCodeList?bookId=" + row.id + "&goods_type=" + 401
  154. );
  155. },
  156. // 批量上传
  157. changeFillId(file, fileList) {
  158. this.loading = true;
  159. let name = file.file_name.split(".")[0];
  160. let type = file.file_name.split(".")[1];
  161. let tag = ["downloadable", "TEXTBOOK", type];
  162. let attachmentList = [];
  163. attachmentList.push({
  164. name: file.file_name,
  165. fileId: file.file_id,
  166. fileType: type,
  167. });
  168. attachmentinsert({
  169. attachmentList: attachmentList,
  170. type: "3",
  171. tenantId: this.institutionList[0].tenantId,
  172. })
  173. .then((res) => {
  174. materialinsert({
  175. name: name,
  176. price: "-1",
  177. teacherList: [""],
  178. tenantId: this.institutionList[0].tenantId,
  179. tagList: tag,
  180. attachmentIdList: res.data.attachmentIdList,
  181. })
  182. .then((ress) => {
  183. this.loading = false;
  184. this.getdata();
  185. })
  186. .catch((res) => {
  187. this.loading = false;
  188. });
  189. })
  190. .catch((res) => {
  191. this.loading = false;
  192. });
  193. // let fileList1 = JSON.parse(JSON.stringify(fileList));
  194. // this.fileList = fileList1;
  195. },
  196. // 搜索
  197. seekData() {
  198. this.pageNum = 1;
  199. this.getdata();
  200. },
  201. downSeekdata(e) {
  202. if (e.keyCode == 13) {
  203. this.pageNum = 1;
  204. this.getdata();
  205. }
  206. },
  207. // 换页
  208. async handleCurrentChange(pagesize) {
  209. this.pageNum = pagesize;
  210. this.getdata();
  211. },
  212. // 编辑
  213. handleEdit(item) {
  214. if (item.status == 4) {
  215. this.$message.warning("上架状态下不可以进行编辑操作");
  216. return;
  217. }
  218. this.$router.push({
  219. path: "/creadDocument",
  220. query: {
  221. materialId: item.id,
  222. },
  223. });
  224. },
  225. // 删除
  226. handleDel(item) {
  227. if (item.status == 4) {
  228. this.$message.warning("上架状态下不可以进行删除操作");
  229. return;
  230. }
  231. this.$confirm("确定要删除此学习资料吗?", "提示", {
  232. confirmButtonText: "确定",
  233. cancelButtonText: "取消",
  234. type: "warning",
  235. })
  236. .then(() => {
  237. this.loading = true;
  238. materialdelete({
  239. id: `${item.id}`,
  240. })
  241. .then((res) => {
  242. this.getdata();
  243. this.$message({
  244. type: "success",
  245. message: "删除成功",
  246. });
  247. })
  248. .catch((res) => {
  249. this.loading = false;
  250. });
  251. })
  252. .catch(() => {
  253. this.loading = false;
  254. });
  255. },
  256. // 上架
  257. up(item) {
  258. if (item.status == 4) {
  259. this.$message.warning("该课程已经上架了");
  260. return;
  261. }
  262. if (!item.price || !item.teacher[0]) {
  263. this.$message.warning("请先去完善信息再上架");
  264. return;
  265. }
  266. this.loading = true;
  267. materialinStockAction({
  268. id: `${item.id}`,
  269. })
  270. .then((res) => {
  271. this.getdata();
  272. this.$message({
  273. type: "success",
  274. message: "上架成功",
  275. });
  276. })
  277. .catch(() => {
  278. this.loading = false;
  279. });
  280. },
  281. // 下架
  282. down(item) {
  283. if (item.status == 3) {
  284. this.$message.warning("该课程已经下架了");
  285. return;
  286. }
  287. this.loading = true;
  288. materialoutOfStockAction({
  289. id: `${item.id}`,
  290. })
  291. .then((res) => {
  292. this.getdata();
  293. this.$message({
  294. type: "success",
  295. message: "下架成功",
  296. });
  297. })
  298. .catch(() => {
  299. this.loading = false;
  300. });
  301. },
  302. // 处理下载
  303. handledownload(row) {
  304. let index = row.tag.indexOf("downloadable");
  305. if (index != -1) {
  306. return "开启";
  307. } else {
  308. return "关闭";
  309. }
  310. },
  311. // 处理文档类型
  312. handlefileType(row) {
  313. let index = row.tag.indexOf("downloadable");
  314. if (index != -1) {
  315. return row.tag[2];
  316. } else {
  317. return row.tag[1];
  318. }
  319. },
  320. // 处理发布状态
  321. handleStatus(row) {
  322. if (row.status == 4) {
  323. return "已上架";
  324. } else if (row.status == 3) {
  325. return "已下架";
  326. }
  327. },
  328. // 新建文档
  329. newDocument() {
  330. this.$router.push({ path: "/creadDocument" });
  331. },
  332. getdata() {
  333. this.loading = true;
  334. materiallist({
  335. pageNum: this.pageNum,
  336. pageSize: this.pageSize,
  337. keyWord: this.keyWord,
  338. isSelectForUpdate: true,
  339. orderType: "DESC",
  340. orderColumn: "2",
  341. })
  342. .then((res) => {
  343. this.tableData = res.data;
  344. this.loading = false;
  345. })
  346. .catch(() => {
  347. this.loading = false;
  348. });
  349. },
  350. },
  351. created() {
  352. // 获取当前可编辑机构
  353. usertenant({})
  354. .then((res) => {
  355. if (res.status == 1) {
  356. this.institutionList = res.data.tenantIdAndNameListEditable;
  357. this.loading = false;
  358. }
  359. })
  360. .catch((res) => {
  361. this.loading = false;
  362. });
  363. },
  364. mounted() {
  365. this.getdata();
  366. // this.loading = true;
  367. // let userInfor = JSON.parse(getToken());
  368. // let userCode = "",
  369. // userType = "",
  370. // sessionId = "";
  371. // if (userInfor) {
  372. // userCode = userInfor.user_code;
  373. // userType = userInfor.user_type;
  374. // sessionId = userInfor.session_id;
  375. // }
  376. // // 验证登录拿到JSESSIONID放到cookies中后面的接口用来验证用户身份
  377. // VerifyLogin({
  378. // userCode,
  379. // userType,
  380. // sessionId,
  381. // })
  382. // .then((res) => {
  383. // if (res.code != -1) {
  384. // Cookies.set("JSESSIONID", res.data.JSESSSIONID);
  385. //
  386. // }
  387. // })
  388. // .catch(() => {
  389. // this.loading = false;
  390. // });
  391. },
  392. };
  393. </script>
  394. <style lang="scss" scoped>
  395. .teacher-devEntering {
  396. .top {
  397. width: 1200px;
  398. margin: 0 auto;
  399. margin-top: 40px;
  400. display: flex;
  401. justify-content: space-between;
  402. padding: 0 90px;
  403. .seek {
  404. width: 400px;
  405. height: 40px;
  406. background: #ffffff;
  407. border: 1px solid #d9d9d9;
  408. box-sizing: border-box;
  409. border-radius: 8px;
  410. display: flex;
  411. align-items: center;
  412. justify-content: space-between;
  413. padding: 0 16px;
  414. input {
  415. width: 90%;
  416. border: none;
  417. outline: none;
  418. margin-left: 5px;
  419. }
  420. img {
  421. width: 18px;
  422. height: 18px;
  423. }
  424. }
  425. .btn {
  426. display: flex;
  427. text-align: right;
  428. }
  429. }
  430. .table {
  431. width: 1200px;
  432. margin: 0 auto;
  433. margin-top: 50px;
  434. }
  435. }
  436. </style>