index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <div class="manage-root organize-manage">
  3. <Header />
  4. <div class="manage-root-contain">
  5. <nav-menu class="manage-root-contain-left" :activeMenuIndex="activeMenuIndex"></nav-menu>
  6. <div class="manage-root-contain-right personnel-manage-right">
  7. <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
  8. <div class="personal-inner">
  9. <div class="common-title-box">
  10. <h3>报纸管理</h3>
  11. <div class="btn-box">
  12. <el-button type="primary" size="small" @click="handleEdit">创建报纸</el-button>
  13. </div>
  14. </div>
  15. <div class="search-box">
  16. <div class="search-item">
  17. <label>搜索</label>
  18. <el-input
  19. placeholder="输入搜索内容"
  20. v-model="searchInput">
  21. <i slot="suffix" class="el-input__icon el-icon-search" @click="getList(1)" style="cursor: pointer;"></i>
  22. </el-input>
  23. </div>
  24. <div class="search-item">
  25. <label>状态</label>
  26. <el-select v-model="searchStatus" @change="getList" placeholder="请选择">
  27. <el-option
  28. v-for="item in $checkStatusList"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value">
  32. </el-option>
  33. </el-select>
  34. </div>
  35. <div class="search-item">
  36. <label>年份</label>
  37. <el-select v-model="searchYear" @change="getList" placeholder="请选择">
  38. <el-option
  39. v-for="(itemy,indexy) in yearList"
  40. :key="indexy"
  41. :label="itemy.label"
  42. :value="itemy.value">
  43. </el-option>
  44. </el-select>
  45. </div>
  46. <div class="search-item">
  47. <label>学段</label>
  48. <el-select v-model="searchStudy" @change="getList" placeholder="请选择">
  49. <el-option
  50. v-for="item in $studyTypeAll"
  51. :key="item.study_phase"
  52. :label="item.study_phase_name"
  53. :value="item.study_phase">
  54. </el-option>
  55. </el-select>
  56. </div>
  57. </div>
  58. <el-table
  59. class="search-table"
  60. :data="tableData"
  61. style="width: 100%"
  62. @sort-change="handleSort"
  63. :default-sort = dataSort
  64. :max-height="tableHeight">
  65. <el-table-column
  66. type="index"
  67. label="#"
  68. sortable
  69. width="56">
  70. </el-table-column>
  71. <el-table-column
  72. prop="iss_name"
  73. label="名称"
  74. sortable
  75. min-width="226">
  76. </el-table-column>
  77. <el-table-column
  78. prop="iss_no"
  79. label="期数"
  80. width="84"
  81. sortable>
  82. </el-table-column>
  83. <el-table-column
  84. prop="study_phase"
  85. label="学段"
  86. width="72">
  87. <template slot-scope="scope">
  88. {{formatterStudy(scope.row)}}
  89. </template>
  90. </el-table-column>
  91. <el-table-column
  92. prop="status"
  93. label="状态"
  94. width="104" >
  95. <template slot-scope="scope">
  96. <div class="status-box">
  97. <span :style="{background:$checkStatusColorList[scope.row.iss_status].bg}"></span>
  98. <b :style="{color:$checkStatusColorList[scope.row.iss_status].color}">{{$checkStatusColorList[scope.row.iss_status].text}}</b>
  99. </div>
  100. </template>
  101. </el-table-column>
  102. <el-table-column
  103. prop="creator_real_name"
  104. label="创建人"
  105. width="88"
  106. sortable>
  107. </el-table-column>
  108. <el-table-column
  109. prop="create_time"
  110. label="创建时间"
  111. width="144"
  112. sortable>
  113. <template slot-scope="scope">
  114. {{scope.row.create_time?scope.row.create_time.substring(0,16):'-'}}
  115. </template>
  116. </el-table-column>
  117. <el-table-column
  118. prop="updater_real_name"
  119. label="最近编辑"
  120. min-width="96">
  121. </el-table-column>
  122. <el-table-column
  123. prop="update_time"
  124. label="最近编辑时间"
  125. width="144"
  126. sortable>
  127. <template slot-scope="scope">
  128. {{scope.row.update_time?scope.row.update_time.substring(0,16):'-'}}
  129. </template>
  130. </el-table-column>
  131. <el-table-column
  132. fixed="right"
  133. label="操作"
  134. width="220">
  135. <template slot-scope="scope">
  136. <el-button
  137. @click.native.prevent="handleEdit(scope.row)"
  138. type="text"
  139. size="small"
  140. class="primary-btn">
  141. 编辑
  142. </el-button>
  143. <el-button
  144. @click.native.prevent="handleCheck(scope.row, scope.$index)"
  145. type="text"
  146. size="small"
  147. class="primary-btn"
  148. v-if="scope.row.iss_status===0||scope.row.iss_status===3">
  149. 审核
  150. </el-button>
  151. <el-button
  152. @click.native.prevent="handleUp(scope.row, scope.$index)"
  153. type="text"
  154. size="small"
  155. class="primary-btn"
  156. v-if="scope.row.iss_status===1">
  157. 上架
  158. </el-button>
  159. <el-button
  160. @click.native.prevent="handleUp(scope.row, scope.$index)"
  161. type="text"
  162. size="small"
  163. class="red-btn"
  164. v-else-if="scope.row.iss_status===2">
  165. 下架
  166. </el-button>
  167. <el-button
  168. @click.native.prevent="handleDelete(scope.row, scope.$index)"
  169. type="text"
  170. size="small"
  171. class="red-btn">
  172. 删除
  173. </el-button>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <el-pagination
  178. background
  179. @size-change="handleSizeChange"
  180. @current-change="handleCurrentChange"
  181. :current-page="pageNumber"
  182. :page-sizes="[10, 20, 30, 40]"
  183. :page-size="pageSize"
  184. layout="total, prev, pager, next, sizes, jumper"
  185. :total="total_count">
  186. </el-pagination>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </template>
  192. <script>
  193. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  194. //例如:import 《组件名称》from ‘《组件路径》';
  195. import Header from "../../../components/Header.vue";
  196. import NavMenu from "../../../components/NavMenu.vue"
  197. import Breadcrumb from '../../../components/Breadcrumb.vue';
  198. import {
  199. provinceAndCityData
  200. } from "element-china-area-data";
  201. import { getLogin } from "@/api/ajax";
  202. export default {
  203. //import引入的组件需要注入到对象中才能使用
  204. components: { Header, NavMenu, Breadcrumb },
  205. props: {},
  206. data() {
  207. //这里存放数据
  208. return {
  209. provinceAndCityData,
  210. activeMenuIndex: "newspaper_manage",
  211. breadcrumbList:[
  212. {
  213. icon:'file-list-line',
  214. url:'',
  215. text:''
  216. },
  217. {
  218. icon:'',
  219. url:'',
  220. notLink: true,
  221. text:'内容管理'
  222. },
  223. {
  224. icon:'',
  225. url:'',
  226. text:'报纸管理'
  227. }
  228. ],
  229. searchInput: '',
  230. searchStudy: -1,
  231. searchStatus: -1,
  232. searchYear: -1,
  233. typeList:[
  234. {
  235. value:'',
  236. label:'全部'
  237. },
  238. {
  239. value:'0',
  240. label:'小学'
  241. },
  242. {
  243. value:'1',
  244. label:'初中'
  245. },
  246. {
  247. value:'2',
  248. label:'高中'
  249. },
  250. {
  251. value:'3',
  252. label:'大学'
  253. }
  254. ],
  255. studyList:[
  256. {
  257. value:'',
  258. label:'全部'
  259. },
  260. {
  261. value:'0',
  262. label:'初一'
  263. },
  264. {
  265. value:'1',
  266. label:'初二'
  267. },
  268. {
  269. value:'2',
  270. label:'初三'
  271. },
  272. {
  273. value:'3',
  274. label:'高一'
  275. }
  276. ],
  277. yearList:[
  278. {
  279. value: -1,
  280. label: '全部'
  281. }
  282. ],
  283. tableData:[],
  284. pageSize: window.localStorage.getItem('pageSize')?Number(window.localStorage.getItem('pageSize')):10,
  285. pageNumber: window.localStorage.getItem('pageNumber')?Number(window.localStorage.getItem('pageNumber')):1,
  286. tableHeight: "", // 表格高度
  287. total_count: 0,
  288. dataSort: {}
  289. }
  290. },
  291. //计算属性 类似于data概念
  292. computed: {
  293. },
  294. //监控data中数据变化
  295. watch: {},
  296. //方法集合
  297. methods: {
  298. handleSort(value){
  299. let dataSort = {
  300. prop: value.prop,
  301. order: value.order
  302. }
  303. this.dataSort = dataSort
  304. this.getList()
  305. },
  306. // 处理学段
  307. formatterStudy(row){
  308. let studyCn = ''
  309. let list = this.$studyTypeAll
  310. if(row.study_phase){
  311. for(let i=0;i<list.length;i++){
  312. if(row.study_phase===list[i].study_phase){
  313. studyCn = list[i].study_phase_name
  314. }
  315. }
  316. }else{
  317. studyCn = '未知'
  318. }
  319. return studyCn
  320. },
  321. // 创建机构或者编辑信息
  322. handleEdit(row){
  323. // 根据登录用户判断当前用户是不是超管 在table里加上disabled
  324. // 点击时记录页码和每页条数
  325. window.localStorage.setItem('pageSize',this.pageSize)
  326. window.localStorage.setItem('pageNumber',this.pageNumber)
  327. this.$router.push({
  328. path: "/createNewspaper",
  329. query: {
  330. id: row?row.id:''
  331. },
  332. });
  333. },
  334. // 停用 启用
  335. handleUp(row, index) {
  336. let Mname = "/PaperServer/Manager/IssueManager/EditIssueStatus";
  337. let updataData = JSON.parse(JSON.stringify(row));
  338. let data = {
  339. id: row.id
  340. };
  341. if (row.iss_status === 1) {
  342. // 下架状态
  343. data.iss_status = 2;
  344. updataData.iss_status = 2;
  345. } else if (row.iss_status === 2) {
  346. data.iss_status = 1;
  347. updataData.iss_status = 1;
  348. }
  349. getLogin(Mname, data).then(res => {
  350. this.$message.success("操作成功");
  351. this.$set(this.tableData, index, updataData);
  352. });
  353. },
  354. // 审核
  355. handleCheck(row, index){
  356. let Mname = "/PaperServer/Manager/IssueManager/EditIssueStatus";
  357. let updataData = JSON.parse(JSON.stringify(row));
  358. let data = {
  359. id: row.id
  360. };
  361. this.$confirm('审核', '提示', {
  362. confirmButtonText: '审核通过',
  363. cancelButtonText: '驳回',
  364. type: 'warning'
  365. }).then(() => {
  366. data.iss_status = 1;
  367. updataData.iss_status = 1;
  368. getLogin(Mname, data).then(res => {
  369. this.$message.success("操作成功");
  370. this.$set(this.tableData, index, updataData);
  371. });
  372. }).catch(() => {
  373. data.iss_status = 3;
  374. updataData.iss_status = 3;
  375. getLogin(Mname, data).then(res => {
  376. this.$message.success("操作成功");
  377. this.$set(this.tableData, index, updataData);
  378. });
  379. });
  380. },
  381. // 删除
  382. handleDelete(row){
  383. this.$confirm('确定删除吗?', '提示', {
  384. confirmButtonText: '确定',
  385. cancelButtonText: '取消',
  386. type: 'warning'
  387. }).then(() => {
  388. let Mname = "/PaperServer/Manager/IssueManager/DelIssueById";
  389. let data = {
  390. id: row.id,
  391. };
  392. getLogin(Mname, data).then(res => {
  393. this.$message({
  394. type: 'success',
  395. message: '删除成功!'
  396. });
  397. this.getList(1)
  398. });
  399. }).catch(() => {
  400. this.$message({
  401. type: 'info',
  402. message: '已取消删除'
  403. });
  404. });
  405. },
  406. handleSizeChange(val) {
  407. this.pageSize = val
  408. this.pageNumber = 1
  409. this.getList()
  410. },
  411. handleCurrentChange(val) {
  412. this.pageNumber = val
  413. this.getList()
  414. },
  415. //计算table高度(动态设置table高度)
  416. getTableHeight() {
  417. let tableH = 370; //距离页面下方的高度
  418. let tableHeightDetil = window.innerHeight - tableH;
  419. if (tableHeightDetil <= 300) {
  420. this.tableHeight = 300;
  421. } else {
  422. this.tableHeight = window.innerHeight - tableH;
  423. }
  424. },
  425. getList(val){
  426. if(val){
  427. this.pageNumber = val
  428. }
  429. let MethodName = "/PaperServer/Manager/IssueManager/PageQueryIssue"
  430. let order_column_list = []
  431. if(this.dataSort != {}){
  432. if(this.dataSort.order=='descending'){
  433. order_column_list.push({
  434. name: this.dataSort.prop,
  435. asc: false
  436. })
  437. }else if(this.dataSort.order=='ascending'){
  438. order_column_list.push({
  439. name: this.dataSort.prop,
  440. asc: true
  441. })
  442. }
  443. }
  444. let data = {
  445. key_word: this.searchInput.trim(),
  446. iss_status: this.searchStatus===-1?null:this.searchStatus,
  447. study_phase: this.searchStudy===-1?null:this.searchStudy,
  448. release_year: this.searchYear===-1?null:this.searchYear,
  449. page_capacity:this.pageSize,
  450. cur_page:this.pageNumber,
  451. order_bys: order_column_list
  452. }
  453. getLogin(MethodName, data)
  454. .then((res) => {
  455. if(res.status===1){
  456. this.tableData = res.data.list
  457. this.total_count = res.data.total_count
  458. }
  459. })
  460. .catch(() => {
  461. this.loading = false
  462. });
  463. },
  464. // 获取年份列表
  465. getYearList(){
  466. let nowYear = new Date().getFullYear()
  467. let yearList = []
  468. for(let i = 0; i < 20; i++){
  469. let obj = {
  470. value: nowYear - i,
  471. label: nowYear - i
  472. }
  473. yearList.push(obj)
  474. }
  475. this.yearList = this.yearList.concat(yearList)
  476. }
  477. },
  478. //生命周期 - 创建完成(可以访问当前this实例)
  479. created() {
  480. this.getYearList()
  481. this.getTableHeight();
  482. this.getList()
  483. },
  484. //生命周期 - 挂载完成(可以访问DOM元素)
  485. mounted() {
  486. },
  487. //生命周期-创建之前
  488. beforeCreated() { },
  489. //生命周期-挂载之前
  490. beforeMount() { },
  491. //生命周期-更新之前
  492. beforUpdate() { },
  493. //生命周期-更新之后
  494. updated() { },
  495. //生命周期-销毁之前
  496. beforeDestory() { },
  497. //生命周期-销毁完成
  498. destoryed() { },
  499. //如果页面有keep-alive缓存功能,这个函数会触发
  500. activated() { }
  501. }
  502. </script>
  503. <style lang="scss" scoped>
  504. /* @import url(); 引入css类 */
  505. </style>
  506. <style lang="scss">
  507. .organize-manage{
  508. .el-cascader{
  509. width: 160px;
  510. height: 32px;
  511. line-height: 32px;
  512. .el-input{
  513. width: 100%;
  514. height: 32px;
  515. }
  516. }
  517. }
  518. </style>