Organizer.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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="单位名称" > </el-table-column>
  165. <el-table-column prop="desc" label="主办单位简介" width="500">
  166. <template slot-scope="scope">
  167. <!-- <el-popover trigger="hover" placement="top">
  168. {{scope.row.desc}}
  169. <div slot="reference" class="name-wrapper">
  170. {{ scope.row.desc|splice}}
  171. </div>
  172. </el-popover> -->
  173. <el-tooltip effect="dark" :content="scope.row.desc" placement="top">
  174. <span>{{ scope.row.desc|splice}}</span>
  175. </el-tooltip>
  176. </template>
  177. </el-table-column>
  178. <el-table-column prop="journal_num" width="120" label="期刊数量"></el-table-column>
  179. <el-table-column prop="zip" width="150" fixed="right" align="center" label="操作">
  180. <template slot-scope="scope">
  181. <el-button type="text" @click="$router.push({path:'/journal/organizer/detail',query:{id:scope.row.id}})"
  182. >查看</el-button>
  183. <el-button class="edit" type="text" @click="edit(scope.row)"
  184. >编辑</el-button>
  185. <el-button class="del" @click="del(scope.row.id)" type="text"
  186. >删除</el-button>
  187. </template>
  188. </el-table-column>
  189. </el-table>
  190. <Page
  191. ref="pageButton"
  192. :current="form.page"
  193. :page_size="form.page_size"
  194. :total="total"
  195. @pageChange="gopage"
  196. />
  197. </div>
  198. <!--新增编辑-->
  199. <el-dialog
  200. class='fu-dialog'
  201. :title="dialogTitle"
  202. :close-on-click-modal="false"
  203. :visible.sync="dialogVisible"
  204. >
  205. <el-form
  206. size="small"
  207. class="preview"
  208. :inline="false"
  209. label-width="80px"
  210. :model="form1"
  211. ref="form1"
  212. :rules="rules"
  213. >
  214. <el-form-item label="单位名称" prop="name">
  215. <el-input v-model="form1.name" placeholder="请输入单位名称" maxlength="50" show-word-limit></el-input>
  216. </el-form-item>
  217. <el-form-item label="单位简介" prop="desc">
  218. <el-input type="textarea" v-model="form1.desc" placeholder="请输入单位简介"></el-input>
  219. </el-form-item>
  220. <el-form-item label="单位封面" prop="img">
  221. <el-upload
  222. class="avatar-uploader"
  223. action="/api/admin/uploadfile"
  224. :show-file-list="false"
  225. :on-success="handleAvatarSuccess"
  226. >
  227. <img v-if="form1.img" :src="form1.img" class="avatar" />
  228. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  229. </el-upload>
  230. <span style="font-size: 12px; color: #999999"
  231. >建议图片尺寸为:210*160</span
  232. >
  233. </el-form-item>
  234. </el-form>
  235. <span slot="footer" class="dialog-footer">
  236. <el-button size="small" type="primary" @click="save">确 定</el-button>
  237. </span>
  238. </el-dialog>
  239. <el-dialog
  240. class="fu-dialog"
  241. title="导入" width="400px"
  242. :close-on-click-modal="false"
  243. :visible.sync="dialogVisible1"
  244. >
  245. <el-upload
  246. class="upload-demo"
  247. action="/api/admin/uploadfile"
  248. :show-file-list="false"
  249. :on-success="handleAvatarSuccess1">
  250. <el-button size="small" type="primary">点击上传</el-button>
  251. <div slot="tip" class="el-upload__tip">只能上传.xls/.xlsx文件,且不超过500M</div>
  252. </el-upload>
  253. <div>{{file}}</div>
  254. <span slot="footer" class="dialog-footer">
  255. <el-button size="small" type="normal" @click="dialogVisible1=false">取消</el-button>
  256. <el-button size="small" type="primary" @click="upload">确 定</el-button>
  257. </span>
  258. </el-dialog>
  259. </section>
  260. </template>
  261. <script>
  262. import Page from "../../components/Page";
  263. import fuEditor from '../../components/fuEditor'
  264. export default {
  265. components: {
  266. Page,
  267. fuEditor
  268. },
  269. data() {
  270. return {
  271. form: { name: "", page: 1, page_size: 20 },
  272. total: 1,
  273. list: [{ name: "2333" }],
  274. loading: false,
  275. dialogTitle:"",
  276. dialogVisible:false,
  277. dialogVisible1:false,
  278. rules: {
  279. name: [{ required: true, message: "请输入单位名称", trigger: "blur" }],
  280. desc: [{ required: true, message: "请输入单位简介", trigger: "blur" }],
  281. img: [{ required: true, message: "请上传单位封面", trigger: "blur" }],
  282. },
  283. form1:{},
  284. file:''
  285. };
  286. },
  287. filters:{
  288. splice(value) {
  289. if (!value) return ''
  290. if (value.length > 50) {
  291. return value.slice(0, 50) + '...'
  292. }
  293. return value
  294. }
  295. },
  296. methods: {
  297. upload(){
  298. this.$api.upOrganizerData({file:this.file}).then(res=>{
  299. this.dialogVisible1=false;
  300. this.getData();
  301. this.$message({
  302. message: "上传成功",
  303. type: "success",
  304. });
  305. })
  306. },
  307. download(){
  308. this.$api.getOrganizerData().then(res=>{
  309. var elink = document.createElement("a");
  310. let blob = new Blob([res.data], {
  311. type: "application/vnd.ms-excel,charset=UTF-8",
  312. });
  313. let objUrl = URL.createObjectURL(blob);
  314. let file_name = decodeURIComponent(
  315. res.headers["content-disposition"].split("=")[1]
  316. );
  317. console.log(file_name);
  318. elink.download = file_name;
  319. elink.style.display = "none";
  320. elink.href = objUrl;
  321. document.body.appendChild(elink);
  322. elink.click();
  323. document.body.removeChild(elink);
  324. })
  325. },
  326. //封面
  327. handleAvatarSuccess(res, file) {
  328. this.$set(this.form1,'img',file.response.data)
  329. },
  330. handleAvatarSuccess1(res, file) {
  331. this.file=file.response.data;
  332. },
  333. search() {
  334. let parm = this.form;
  335. this.getData();
  336. },
  337. add() {
  338. this.form1 = {};
  339. this.dialogVisible = true;
  340. this.dialogTitle = "添加主办单位";
  341. },
  342. addArticle(){
  343. this.$router.push({path:'/article/article/add'})
  344. },
  345. gopage(size) {
  346. if (size) {
  347. this.form.page_size = size;
  348. }
  349. this.form.page = this.$refs.pageButton.page;
  350. this.getData();
  351. },
  352. getData() {
  353. var parm = this.form;
  354. this.loading = true;
  355. this.$api.getOrganizerList(parm).then((res) => {
  356. console.log(res)
  357. this.list = res.data.data.list;
  358. this.total = res.data.data.total;
  359. this.loading = false;
  360. });
  361. },
  362. search(){
  363. this.getData()
  364. },
  365. del(id) {
  366. this.$confirm("确定删除吗?关联数据都会被删除!", "提示", {
  367. type: "warning",
  368. }).then(() => {
  369. this.$api.delOrganizer({ id: id }).then((res) => {
  370. this.$message({
  371. message: "删除成功",
  372. type: "success",
  373. });
  374. this.getData();
  375. });
  376. });
  377. },
  378. edit(row) {
  379. this.dialogVisible = true
  380. this.form1 = row
  381. },
  382. save() {
  383. this.$refs["form1"].validate((valid) => {
  384. if (valid) {
  385. let parm = this.form1;
  386. let id = this.form1.id;
  387. parm.receiver_id = JSON.stringify(parm.receiver_id);
  388. if (id) {
  389. this.$api.updateOrganizer(parm).then((res) => {
  390. if (res.data.code == 0) {
  391. this.$message({
  392. type: "success",
  393. message: "保存成功!",
  394. });
  395. this.getData();
  396. // this.dialogVisible = false;
  397. } else {
  398. this.$message.error(res.data.message);
  399. }
  400. });
  401. } else {
  402. this.$api.addOrganizer(parm).then((res) => {
  403. if (res.data.code == 0) {
  404. this.$message({
  405. type: "success",
  406. message: "保存成功!",
  407. });
  408. this.getData();
  409. // this.dialogVisible = false;
  410. } else {
  411. this.$message.error(res.data.message);
  412. }
  413. });
  414. }
  415. }
  416. });
  417. },
  418. },
  419. created() {
  420. this.getData();
  421. },
  422. };
  423. </script>