Subject.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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="200"> </el-table-column>
  165. <el-table-column prop="desc" label="学科简介" width="500"></el-table-column>
  166. <el-table-column prop="journal_count" label="期刊数量"></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/uploadfile"
  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. <div>{{file}}</div>
  228. <span slot="footer" class="dialog-footer">
  229. <el-button size="small" type="normal" @click="dialogVisible1=false">取消</el-button>
  230. <el-button size="small" type="primary" @click="upload">确 定</el-button>
  231. </span>
  232. </el-dialog>
  233. </section>
  234. </template>
  235. <script>
  236. import Page from "../../components/Page";
  237. import fuEditor from '../../components/fuEditor'
  238. export default {
  239. components: {
  240. Page,
  241. fuEditor
  242. },
  243. data() {
  244. return {
  245. form: { name: "", page: 1, page_size: 20 },
  246. total: 1,
  247. list: [{ name: "2333" }],
  248. loading: false,
  249. dialogTitle:"",
  250. dialogVisible:false,
  251. dialogVisible1:false,
  252. rules: {
  253. name: [{ required: true, message: "请输入学科名称", trigger: "blur" }],
  254. desc: [{ required: true, message: "请输入学科简介", trigger: "blur" }]
  255. },
  256. form1:{},
  257. file:''
  258. };
  259. },
  260. methods: {
  261. upload(){
  262. this.$api.upSubjectData({file:this.file}).then(res=>{
  263. this.dialogVisible1=false;
  264. this.getData();
  265. this.$message({
  266. message: "上传成功",
  267. type: "success",
  268. });
  269. })
  270. },
  271. download(){
  272. this.$api.getSubjectData().then(res=>{
  273. var elink = document.createElement("a");
  274. let blob = new Blob([res.data], {
  275. type: "application/vnd.ms-excel,charset=UTF-8",
  276. });
  277. let objUrl = URL.createObjectURL(blob);
  278. let file_name = decodeURIComponent(
  279. res.headers["content-disposition"].split("=")[1]
  280. );
  281. console.log(file_name);
  282. elink.download = file_name;
  283. elink.style.display = "none";
  284. elink.href = objUrl;
  285. document.body.appendChild(elink);
  286. elink.click();
  287. document.body.removeChild(elink);
  288. })
  289. },
  290. handleAvatarSuccess1(res, file) {
  291. this.file=file.response.data;
  292. },
  293. //封面
  294. handleAvatarSuccess(res, file) {
  295. this.form1.img = file.response.data;
  296. console.log(this.form1.img);
  297. },
  298. search() {
  299. this.getData();
  300. },
  301. add() {
  302. this.form1 = {};
  303. this.dialogVisible = true;
  304. this.dialogTitle = "添加学科";
  305. },
  306. addArticle(){
  307. this.$router.push({path:'/article/article/add'})
  308. },
  309. gopage(size) {
  310. if (size) {
  311. this.form.page_size = size;
  312. }
  313. this.form.page = this.$refs.pageButton.page;
  314. this.getData();
  315. },
  316. getData() {
  317. var parm = this.form;
  318. this.loading = true;
  319. this.$api.getSubjectList(parm).then((res) => {
  320. console.log(res)
  321. this.list = res.data.data.list;
  322. this.loading = false;
  323. });
  324. },
  325. del(id) {
  326. this.$confirm("确定删除吗", "提示", {
  327. type: "warning",
  328. }).then(() => {
  329. this.$api.delSubject({ id: id }).then((res) => {
  330. this.$message({
  331. message: "删除成功",
  332. type: "success",
  333. });
  334. this.getData();
  335. });
  336. });
  337. },
  338. edit(row) {
  339. this.form1 = row
  340. this.dialogVisible = true
  341. },
  342. save() {
  343. this.$refs["form1"].validate((valid) => {
  344. if (valid) {
  345. let parm = this.form1;
  346. let id = this.form1.id;
  347. parm.receiver_id = JSON.stringify(parm.receiver_id);
  348. if (id) {
  349. this.$api.updateSubject(parm).then((res) => {
  350. if (res.data.code == 0) {
  351. this.$message({
  352. type: "success",
  353. message: "保存成功!",
  354. });
  355. this.getData();
  356. this.dialogVisible = false;
  357. } else {
  358. this.$message.error(res.data.message);
  359. }
  360. });
  361. } else {
  362. this.$api.addSubject(parm).then((res) => {
  363. if (res.data.code == 0) {
  364. this.$message({
  365. type: "success",
  366. message: "保存成功!",
  367. });
  368. this.getData();
  369. this.dialogVisible = false;
  370. } else {
  371. this.$message.error(res.data.message);
  372. }
  373. });
  374. }
  375. }
  376. });
  377. },
  378. },
  379. created() {
  380. this.getData();
  381. },
  382. };
  383. </script>