Article.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <style lang="scss" scoped>
  2. .preview {
  3. .el-form-item {
  4. margin-bottom: 15px;
  5. }
  6. label,
  7. p {
  8. line-height: 25px !important;
  9. }
  10. }
  11. .el-cascader {
  12. width: 100%;
  13. }
  14. a {
  15. text-decoration: none;
  16. color: #409eff;
  17. cursor: pointer;
  18. }
  19. // 右边
  20. .item-main {
  21. // margin:34px;
  22. // height:600px;
  23. // background: #FFFFFF;
  24. border: 1px solid #dddddd;
  25. box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.13);
  26. border-radius: 20px;
  27. .el-form.over_y {
  28. max-height: calc(100vh - 340px);
  29. }
  30. /deep/.el-form-item__label {
  31. float: none;
  32. }
  33. }
  34. // label样式
  35. .edit_label {
  36. /deep/.el-input__inner {
  37. background: #f5faff;
  38. border: 0px;
  39. padding: 0px;
  40. }
  41. }
  42. /deep/.opicon {
  43. font-weight: bold;
  44. padding: 5px;
  45. color: #3895fe;
  46. }
  47. .tpl_title {
  48. font-size: 18px;
  49. margin: 20px 0;
  50. }
  51. .tpl_form {
  52. margin: 20px;
  53. border: 1px solid #ccc;
  54. border-radius: 20px;
  55. /deep/.el-form-item {
  56. background: none;
  57. }
  58. /deep/.el-form-item__content {
  59. width: 100%;
  60. }
  61. }
  62. .survey_logo {
  63. position: relative;
  64. top: 15px;
  65. left: 20px;
  66. }
  67. .result_dialog .el-dialog {
  68. width: 40%;
  69. margin-top: 20vh !important;
  70. }
  71. .result-item {
  72. height: 35px;
  73. .label {
  74. font-weight: 600;
  75. }
  76. }
  77. .syncitem {
  78. display: flex;
  79. justify-content: space-between;
  80. border-bottom: 1px solid #f4f4f4;
  81. background: #ffffff;
  82. }
  83. .syncitem img {
  84. margin: 10px;
  85. }
  86. .syncbtn {
  87. margin-top: 20px;
  88. text-align: center;
  89. }
  90. /deep/.el-dialog__body {
  91. padding: 10px 12px!important;
  92. background: #ececec;
  93. p {
  94. height: 45px;
  95. overflow: hidden!important;
  96. display: -webkit-box;
  97. -webkit-line-clamp: 2;
  98. -webkit-box-orient: vertical;
  99. padding:10px 10px;
  100. }
  101. }
  102. </style>
  103. <template>
  104. <section>
  105. <p><span>作业管理></span>所有作业</p>
  106. <div class="content">
  107. <div class="filter">
  108. <el-form
  109. size="small"
  110. label-width="70px"
  111. :inline="true"
  112. label-position="left"
  113. >
  114. <el-form-item label="">
  115. <el-input
  116. clearable
  117. placeholder="请输入姓名"
  118. v-model="form.name"
  119. ></el-input>
  120. </el-form-item>
  121. <el-form-item>
  122. <el-button type="primary" @click="getData">搜索</el-button>
  123. </el-form-item>
  124. <el-form-item label="课程">
  125. <el-select
  126. v-model="form.journal_id"
  127. placeholder="请选择"
  128. filterable
  129. clearable
  130. @change="getData()"
  131. @clear="getData()"
  132. >
  133. <el-option
  134. v-for="item in journalSearch"
  135. :key="item.id"
  136. :label="item.name"
  137. :value="item.id"
  138. >
  139. </el-option>
  140. </el-select>
  141. </el-form-item>
  142. <el-form-item style="float: right">
  143. <el-button @click="syncToMP" type="primary">同步作业</el-button>
  144. </el-form-item>
  145. <!-- <el-form-item style="float: right" v-if="form.journal_id">
  146. <el-button @click="$router.go(-1)" type="info">返回</el-button>
  147. </el-form-item> -->
  148. </el-form>
  149. </div>
  150. <el-table
  151. class="table"
  152. :data="list"
  153. height="57vh"
  154. border
  155. v-loading="loading"
  156. default-expand-all
  157. row-key="id"
  158. style="width: 100%"
  159. @selection-change="handleSelectionChange"
  160. >
  161. <el-table-column type="selection" width="55"> </el-table-column>
  162. <el-table-column prop="name" label="姓名" width="380px"> </el-table-column>
  163. <el-table-column prop="filename" label="作业文件"></el-table-column>
  164. <el-table-column prop="lesson" label="课程"></el-table-column>
  165. <el-table-column prop="ctime" label="提交时间"></el-table-column>
  166. <el-table-column prop="status" label="状态" width="80"></el-table-column>
  167. <el-table-column prop="zip" width="150" label="操作">
  168. <template slot-scope="scope">
  169. <el-button class="edit" type="text" @click="edit(scope.row)"
  170. >查看</el-button
  171. >
  172. <el-button class="del" @click="del(scope.row.id)" type="text"
  173. >删除</el-button
  174. >
  175. </template>
  176. </el-table-column>
  177. </el-table>
  178. <Page
  179. ref="pageButton"
  180. :current="form.page"
  181. :page_size="form.page_size"
  182. :total="total"
  183. @pageChange="gopage"
  184. />
  185. <!-- 同步到微信公众号 -->
  186. <el-dialog
  187. class="fu-dialog"
  188. title="同步到微信公众号"
  189. width="414px"
  190. :close-on-click-modal="false"
  191. :visible.sync="dialogVisible"
  192. >
  193. <!-- <div>
  194. <img :src="journalLogo" alt="">
  195. </div> -->
  196. <div v-loading="loading1">
  197. <div v-if="multipleSelection.length" style="position: relative">
  198. <img
  199. :src="multipleSelection[0].img"
  200. alt=""
  201. width="390px"
  202. height="170px"
  203. />
  204. <p
  205. style="
  206. position: absolute;
  207. bottom: 20px;
  208. left: 10px;
  209. font-weight: bold;
  210. color: #ffffff;
  211. right: 10px;
  212. "
  213. >
  214. {{ multipleSelection[0].name }}
  215. </p>
  216. </div>
  217. <div v-if="multipleSelection.length">
  218. <div
  219. class="syncitem"
  220. v-for="(item, index) in multipleSelection.slice(1, 8)"
  221. :key="index"
  222. >
  223. <p>{{ item.name.substring(0,43) }}</p>
  224. <img :src="item.img" alt="" width="48px" height="48px" />
  225. </div>
  226. </div>
  227. </div>
  228. <div class="syncbtn">
  229. <el-button type="normal" size="small" @click="dialogVisible = false"
  230. >取消</el-button
  231. >
  232. <el-button type="primary" size="small" @click="saveSyncToMP()"
  233. >确定</el-button
  234. >
  235. </div>
  236. </el-dialog>
  237. </div>
  238. </section>
  239. </template>
  240. <script>
  241. import Page from "../../components/Page";
  242. import fuEditor from "../../components/fuEditor";
  243. export default {
  244. components: {
  245. Page,
  246. fuEditor,
  247. },
  248. data() {
  249. return {
  250. loading: false,
  251. loading1: false,
  252. form: { name: "", page: 1, page_size: 20 },
  253. total: 1,
  254. list: [{ name: "2333" }],
  255. loading: false,
  256. rules: {
  257. name: [{ required: true, message: "请输入标题", trigger: "blur" }],
  258. },
  259. dialogVisible: false,
  260. journalLogo: "",
  261. multipleSelection: [],
  262. journalSearch: [],
  263. };
  264. },
  265. methods: {
  266. syncToMP() {
  267. if (!this.multipleSelection) {
  268. this.$message.error("请勾选需要同步到公众号的文章!");
  269. return;
  270. }
  271. this.dialogVisible = true;
  272. },
  273. saveSyncToMP() {
  274. let ids = "";
  275. this.multipleSelection.forEach((item, index) => {
  276. if (index == 0) {
  277. ids += item.id.toString();
  278. } else {
  279. ids += "," + item.id.toString();
  280. }
  281. });
  282. this.loading1 = true;
  283. this.$api.syncToMP({ ids: ids }).then((res) => {
  284. this.loading1 = false;
  285. if (res.data.code == 0) {
  286. this.$confirm(
  287. "同步成功,已发送到微信公众号图文消息,即可前往微信公众号预览!",
  288. "提示",
  289. {
  290. confirmButtonText: "确定",
  291. showCancelButton: false,
  292. type: "success",
  293. }
  294. ).then(() => {
  295. this.dialogVisible = false;
  296. });
  297. } else {
  298. this.$confirm("同步失败!" + res.data.message, "提示", {
  299. confirmButtonText: "确定",
  300. showCancelButton: false,
  301. type: "error",
  302. });
  303. }
  304. });
  305. },
  306. handleSelectionChange(val) {
  307. console.log(val);
  308. this.multipleSelection = val;
  309. },
  310. search() {
  311. let parm = this.form;
  312. this.getData();
  313. },
  314. openDiag() {
  315. this.form1 = {};
  316. this.dialogVisible = true;
  317. this.dialogTitle = "发送消息";
  318. },
  319. addArticle() {
  320. this.$router.push({ path: "/article/article/add" });
  321. },
  322. gopage(size) {
  323. if (size) {
  324. this.form.page_size = size;
  325. }
  326. this.form.page = this.$refs.pageButton.page;
  327. this.getData();
  328. },
  329. getData() {
  330. var parm = this.form;
  331. this.loading = true;
  332. this.$api.searchJournalList().then((res) => {
  333. this.journalSearch = res.data.data;
  334. });
  335. this.$api.getWorkList(parm).then((res) => {
  336. this.$api.getHomeWorkList(parm).then((res) => {
  337. console.log(res);
  338. this.list = res.data.data.list;
  339. this.total = res.data.data.total;
  340. this.loading = false;
  341. });
  342. });
  343. },
  344. del(id) {
  345. this.$confirm("确定删除吗", "提示", {
  346. type: "warning",
  347. }).then(() => {
  348. this.$api.delArticle({ id: id }).then((res) => {
  349. this.$message({
  350. message: "删除成功",
  351. type: "success",
  352. });
  353. this.getData();
  354. });
  355. });
  356. },
  357. edit(row) {
  358. this.$router.push({
  359. path: "/article/article/add",
  360. query: { id: row.id },
  361. });
  362. },
  363. save() {
  364. this.$refs["form1"].validate((valid) => {
  365. if (valid) {
  366. let parm = this.form1;
  367. let id = this.form1.id;
  368. parm.receiver_id = JSON.stringify(parm.receiver_id);
  369. if (id) {
  370. this.$api.editMessage(parm).then((res) => {
  371. if (res.data.code == 0) {
  372. this.$message({
  373. type: "success",
  374. message: "保存成功!",
  375. });
  376. } else {
  377. this.$message.error("保存失败!");
  378. }
  379. this.getData();
  380. this.dialogVisible = false;
  381. });
  382. } else {
  383. this.$api.addMessage(parm).then((res) => {
  384. if (res.data.code == 0) {
  385. this.$message({
  386. type: "success",
  387. message: "保存成功!",
  388. });
  389. } else {
  390. this.$message.error("保存失败!");
  391. }
  392. this.getData();
  393. this.dialogVisible = false;
  394. });
  395. }
  396. }
  397. });
  398. },
  399. },
  400. created() {
  401. if (this.$route.query.id) {
  402. this.form.journal_id = this.$route.query.id;
  403. }
  404. this.getData();
  405. },
  406. beforeRouteEnter(to, from, next) {
  407. next((vm) => {
  408. if (from.path.indexOf("add") >= 0) {
  409. vm.getData();
  410. }
  411. });
  412. },
  413. };
  414. </script>