Subject.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. // 上传
  78. /deep/.avatar-uploader .el-upload {
  79. width: 148px;
  80. height: 148px;
  81. line-height: 148px;
  82. border: 1px dashed #d9d9d9;
  83. border-radius: 6px;
  84. cursor: pointer;
  85. position: relative;
  86. overflow: hidden;
  87. .avatar {
  88. width: 100%;
  89. height: auto;
  90. }
  91. }
  92. .avatar-uploader .el-upload:hover {
  93. border-color: #409eff;
  94. }
  95. .avatar-uploader-icon {
  96. font-size: 28px;
  97. color: #8c939d;
  98. width: 68px;
  99. height: 68px;
  100. line-height: 68px;
  101. text-align: center;
  102. }
  103. .avatar {
  104. width: 68px;
  105. height: 68px;
  106. display: block;
  107. }
  108. /deep/.speaker_avatar .el-upload {
  109. width: 80px;
  110. height: 80px;
  111. line-height: 80px;
  112. }
  113. .hotel_imgs {
  114. /deep/.el-upload--picture-card {
  115. width: 79px;
  116. height: 79px;
  117. line-height: 79px;
  118. }
  119. }
  120. </style>
  121. <template>
  122. <section>
  123. <p><span>刊群导览></span>学科</p>
  124. <div class="content">
  125. <div class="filter">
  126. <el-form
  127. size="small"
  128. label-width="70px"
  129. :inline="true"
  130. label-position="left"
  131. >
  132. <el-form-item label="">
  133. <el-input
  134. clearable
  135. placeholder="请输入标题"
  136. v-model="form.name"
  137. @clear="getData"
  138. ></el-input>
  139. </el-form-item>
  140. <el-form-item>
  141. <el-button type="primary" @click="search">搜索</el-button>
  142. </el-form-item>
  143. <el-form-item style="float:right" >
  144. <el-button @click="dialogVisible1=true" plain icon="el-icon-upload" type="primary">导入</el-button>
  145. </el-form-item>
  146. <el-form-item style="float:right" >
  147. <el-button @click="download" plain icon="el-icon-download" type="primary">导出</el-button>
  148. </el-form-item>
  149. <el-form-item style="float: right">
  150. <el-button @click="add" type="primary">添加学科</el-button>
  151. </el-form-item>
  152. </el-form>
  153. </div>
  154. <el-table
  155. class="table"
  156. :data="list"
  157. height="57vh"
  158. border
  159. v-loading="loading"
  160. default-expand-all
  161. row-key="id"
  162. style="width: 100%"
  163. >
  164. <el-table-column prop="name" label="学科名称" width="180"> </el-table-column>
  165. <el-table-column prop="desc" label="学科简介"></el-table-column>
  166. <el-table-column prop="journal_count" label="期刊数量" width="80"></el-table-column>
  167. <el-table-column prop="zip" fixed="right" align="center" width="150" label="操作">
  168. <template slot-scope="scope">
  169. <el-button type="text" @click="$router.push({path:'/journal/subject/detail',query:{id:scope.row.id}})"
  170. >查看</el-button>
  171. <el-button class="edit" type="text" @click="edit(scope.row)"
  172. >编辑</el-button>
  173. <el-button class="del" @click="del(scope.row.id)" type="text"
  174. >删除</el-button>
  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. </div>
  186. <!--新增编辑-->
  187. <el-dialog
  188. class='fu-dialog'
  189. :title="dialogTitle"
  190. :close-on-click-modal="false"
  191. :visible.sync="dialogVisible"
  192. >
  193. <el-form
  194. size="small"
  195. class="preview"
  196. :inline="false"
  197. label-width="80px"
  198. :model="form1"
  199. ref="form1"
  200. :rules="rules"
  201. >
  202. <el-form-item label="学科名称" prop="name">
  203. <el-input v-model="form1.name" placeholder="请输入学科名称" maxlength="50" show-word-limit></el-input>
  204. </el-form-item>
  205. <el-form-item label="学科简介" prop="desc">
  206. <el-input type="textarea" v-model="form1.desc" placeholder="请输入学科简介"></el-input>
  207. </el-form-item>
  208. </el-form>
  209. <span slot="footer" class="dialog-footer">
  210. <el-button size="small" type="primary" @click="save">确 定</el-button>
  211. </span>
  212. </el-dialog>
  213. <el-dialog
  214. class="fu-dialog"
  215. title="导入" width="400px"
  216. :close-on-click-modal="false"
  217. :visible.sync="dialogVisible1"
  218. >
  219. <el-upload
  220. class="upload-demo"
  221. action="/api/admin/subject/upload"
  222. :show-file-list="false"
  223. :on-success="handleAvatarSuccess1">
  224. <el-button size="small" type="primary">点击上传</el-button>
  225. <div slot="tip" class="el-upload__tip">只能上传.xls/.xlsx文件,且不超过500M</div>
  226. </el-upload>
  227. <a href="http://caos.scxjc.club/journal_template.xls" style="display:block;text-decoration:none;padding:0px;line-height:25px;">点击下载模板</a>
  228. <div>{{file}}</div>
  229. <span slot="footer" class="dialog-footer">
  230. <el-button size="small" type="normal" @click="dialogVisible1=false">取消</el-button>
  231. <el-button size="small" type="primary" @click="upload">确 定</el-button>
  232. </span>
  233. </el-dialog>
  234. </section>
  235. </template>
  236. <script>
  237. import Page from "../../components/Page";
  238. import fuEditor from '../../components/fuEditor'
  239. export default {
  240. components: {
  241. Page,
  242. fuEditor
  243. },
  244. data() {
  245. return {
  246. form: { name: "", page: 1, page_size: 20 },
  247. total: 1,
  248. list: [{ name: "2333" }],
  249. loading: false,
  250. dialogTitle:"",
  251. dialogVisible:false,
  252. dialogVisible1:false,
  253. rules: {
  254. name: [{ required: true, message: "请输入学科名称", trigger: "blur" }],
  255. desc: [{ required: true, message: "请输入学科简介", trigger: "blur" }]
  256. },
  257. form1:{},
  258. file:''
  259. };
  260. },
  261. methods: {
  262. upload(){
  263. this.dialogVisible1=false;
  264. this.getData();
  265. return
  266. this.$api.upSubjectData({file:this.file}).then(res=>{
  267. this.dialogVisible1=false;
  268. this.getData();
  269. this.$message({
  270. message: "上传成功",
  271. type: "success",
  272. });
  273. })
  274. },
  275. download(){
  276. this.$api.getSubjectData().then(res=>{
  277. var elink = document.createElement("a");
  278. let blob = new Blob([res.data], {
  279. type: "application/vnd.ms-excel,charset=UTF-8",
  280. });
  281. let objUrl = URL.createObjectURL(blob);
  282. let file_name = decodeURIComponent(
  283. res.headers["content-disposition"].split("=")[1]
  284. );
  285. console.log(file_name);
  286. elink.download = file_name;
  287. elink.style.display = "none";
  288. elink.href = objUrl;
  289. document.body.appendChild(elink);
  290. elink.click();
  291. document.body.removeChild(elink);
  292. })
  293. },
  294. handleAvatarSuccess1(res, file) {
  295. // this.file=file.response.data;
  296. },
  297. //封面
  298. handleAvatarSuccess(res, file) {
  299. this.form1.img = file.response.data;
  300. console.log(this.form1.img);
  301. },
  302. search() {
  303. this.getData();
  304. },
  305. add() {
  306. this.form1 = {};
  307. this.dialogVisible = true;
  308. this.dialogTitle = "添加学科";
  309. },
  310. addArticle(){
  311. this.$router.push({path:'/article/article/add'})
  312. },
  313. gopage(size) {
  314. if (size) {
  315. this.form.page_size = size;
  316. }
  317. this.form.page = this.$refs.pageButton.page;
  318. this.getData();
  319. },
  320. getData() {
  321. var parm = this.form;
  322. this.loading = true;
  323. this.$api.getSubjectList(parm).then((res) => {
  324. console.log(res)
  325. this.list = res.data.data.list;
  326. this.loading = false;
  327. });
  328. },
  329. del(id) {
  330. this.$confirm("确定删除吗?关联数据都会被删除!", "提示", {
  331. type: "warning",
  332. }).then(() => {
  333. this.$api.delSubject({ id: id }).then((res) => {
  334. this.$message({
  335. message: "删除成功",
  336. type: "success",
  337. });
  338. this.getData();
  339. });
  340. });
  341. },
  342. edit(row) {
  343. this.form1 = row
  344. this.dialogVisible = true
  345. },
  346. save() {
  347. this.$refs["form1"].validate((valid) => {
  348. if (valid) {
  349. let parm = this.form1;
  350. let id = this.form1.id;
  351. parm.receiver_id = JSON.stringify(parm.receiver_id);
  352. if (id) {
  353. this.$api.updateSubject(parm).then((res) => {
  354. if (res.data.code == 0) {
  355. this.$message({
  356. type: "success",
  357. message: "保存成功!",
  358. });
  359. this.getData();
  360. // this.dialogVisible = false;
  361. } else {
  362. this.$message.error(res.data.message);
  363. }
  364. });
  365. } else {
  366. this.$api.addSubject(parm).then((res) => {
  367. if (res.data.code == 0) {
  368. this.$message({
  369. type: "success",
  370. message: "保存成功!",
  371. });
  372. this.getData();
  373. // this.dialogVisible = false;
  374. } else {
  375. this.$message.error(res.data.message);
  376. }
  377. });
  378. }
  379. }
  380. });
  381. },
  382. },
  383. created() {
  384. this.getData();
  385. },
  386. };
  387. </script>