index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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(1)" 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(1)" 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(1)" 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="custom"
  75. min-width="226">
  76. </el-table-column>
  77. <el-table-column
  78. prop="iss_no"
  79. label="期数"
  80. width="84"
  81. sortable="custom">
  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="custom">
  107. </el-table-column>
  108. <el-table-column
  109. prop="create_time"
  110. label="创建时间"
  111. width="144"
  112. sortable="custom">
  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="custom">
  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="150">
  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 { mapState } from 'vuex';
  199. import {
  200. provinceAndCityData
  201. } from "element-china-area-data";
  202. import { getLogin } from "@/api/ajax";
  203. export default {
  204. //import引入的组件需要注入到对象中才能使用
  205. components: { Header, NavMenu, Breadcrumb },
  206. props: {},
  207. data() {
  208. //这里存放数据
  209. return {
  210. provinceAndCityData,
  211. activeMenuIndex: "newspaper_manage",
  212. breadcrumbList:[
  213. {
  214. icon:'file-list-line',
  215. url:'',
  216. text:''
  217. },
  218. {
  219. icon:'',
  220. url:'',
  221. notLink: true,
  222. text:'内容管理'
  223. },
  224. {
  225. icon:'',
  226. url:'',
  227. text:'报纸管理'
  228. }
  229. ],
  230. searchInput: '',
  231. searchStudy: -1,
  232. searchStatus: -1,
  233. searchYear: -1,
  234. typeList:[
  235. {
  236. value:'',
  237. label:'全部'
  238. },
  239. {
  240. value:'0',
  241. label:'小学'
  242. },
  243. {
  244. value:'1',
  245. label:'初中'
  246. },
  247. {
  248. value:'2',
  249. label:'高中'
  250. },
  251. {
  252. value:'3',
  253. label:'大学'
  254. }
  255. ],
  256. studyList:[
  257. {
  258. value:'',
  259. label:'全部'
  260. },
  261. {
  262. value:'0',
  263. label:'初一'
  264. },
  265. {
  266. value:'1',
  267. label:'初二'
  268. },
  269. {
  270. value:'2',
  271. label:'初三'
  272. },
  273. {
  274. value:'3',
  275. label:'高一'
  276. }
  277. ],
  278. yearList:[
  279. {
  280. value: -1,
  281. label: '全部'
  282. }
  283. ],
  284. tableData:[],
  285. pageSize: window.localStorage.getItem('pageSize')?Number(window.localStorage.getItem('pageSize')):10,
  286. pageNumber: window.localStorage.getItem('pageNumber')?Number(window.localStorage.getItem('pageNumber')):1,
  287. tableHeight: "", // 表格高度
  288. total_count: 0,
  289. dataSort: {}
  290. }
  291. },
  292. //计算属性 类似于data概念
  293. computed: {
  294. ...mapState(['$studyTypeAll','$checkStatusList', '$checkStatusColorList']),
  295. },
  296. //监控data中数据变化
  297. watch: {},
  298. //方法集合
  299. methods: {
  300. handleSort(value){
  301. let dataSort = {
  302. prop: value.prop,
  303. order: value.order
  304. }
  305. this.dataSort = dataSort
  306. this.getList()
  307. },
  308. // 处理学段
  309. formatterStudy(row){
  310. let studyCn = ''
  311. let list = this.$studyTypeAll
  312. if(row.study_phase){
  313. for(let i=0;i<list.length;i++){
  314. if(row.study_phase===list[i].study_phase){
  315. studyCn = list[i].study_phase_name
  316. }
  317. }
  318. }else{
  319. studyCn = '未知'
  320. }
  321. return studyCn
  322. },
  323. // 创建机构或者编辑信息
  324. handleEdit(row){
  325. // 根据登录用户判断当前用户是不是超管 在table里加上disabled
  326. // 点击时记录页码和每页条数
  327. window.localStorage.setItem('pageSize',this.pageSize)
  328. window.localStorage.setItem('pageNumber',this.pageNumber)
  329. this.$router.push({
  330. path: "/createNewspaper",
  331. query: {
  332. id: row?row.id:''
  333. },
  334. });
  335. },
  336. // 停用 启用
  337. handleUp(row, index) {
  338. let Mname = "/PaperServer/Manager/IssueManager/EditIssueStatus";
  339. let updataData = JSON.parse(JSON.stringify(row));
  340. let data = {
  341. id: row.id
  342. };
  343. if (row.iss_status === 1) {
  344. // 下架状态
  345. data.iss_status = 2;
  346. updataData.iss_status = 2;
  347. } else if (row.iss_status === 2) {
  348. data.iss_status = 1;
  349. updataData.iss_status = 1;
  350. }
  351. getLogin(Mname, data).then(res => {
  352. this.$message.success("操作成功");
  353. this.$set(this.tableData, index, updataData);
  354. });
  355. },
  356. // 审核
  357. handleCheck(row, index){
  358. let Mname = "/PaperServer/Manager/IssueManager/EditIssueStatus";
  359. let updataData = JSON.parse(JSON.stringify(row));
  360. let data = {
  361. id: row.id
  362. };
  363. this.$confirm('审核', '提示', {
  364. confirmButtonText: '审核通过',
  365. cancelButtonText: '驳回',
  366. type: 'warning'
  367. }).then(() => {
  368. data.iss_status = 1;
  369. updataData.iss_status = 1;
  370. getLogin(Mname, data).then(res => {
  371. this.$message.success("操作成功");
  372. this.$set(this.tableData, index, updataData);
  373. });
  374. }).catch(() => {
  375. data.iss_status = 3;
  376. updataData.iss_status = 3;
  377. getLogin(Mname, data).then(res => {
  378. this.$message.success("操作成功");
  379. this.$set(this.tableData, index, updataData);
  380. });
  381. });
  382. },
  383. // 删除
  384. handleDelete(row){
  385. this.$confirm('确定删除吗?', '提示', {
  386. confirmButtonText: '确定',
  387. cancelButtonText: '取消',
  388. type: 'warning'
  389. }).then(() => {
  390. let Mname = "/PaperServer/Manager/IssueManager/DelIssueById";
  391. let data = {
  392. id: row.id,
  393. };
  394. getLogin(Mname, data).then(res => {
  395. this.$message({
  396. type: 'success',
  397. message: '删除成功!'
  398. });
  399. this.getList()
  400. });
  401. }).catch(() => {
  402. });
  403. },
  404. handleSizeChange(val) {
  405. this.pageSize = val
  406. this.pageNumber = 1
  407. this.getList()
  408. },
  409. handleCurrentChange(val) {
  410. this.pageNumber = val
  411. this.getList()
  412. },
  413. //计算table高度(动态设置table高度)
  414. getTableHeight() {
  415. let tableH = 370; //距离页面下方的高度
  416. let tableHeightDetil = window.innerHeight - tableH;
  417. if (tableHeightDetil <= 300) {
  418. this.tableHeight = 300;
  419. } else {
  420. this.tableHeight = window.innerHeight - tableH;
  421. }
  422. },
  423. getList(val){
  424. if(val){
  425. this.pageNumber = val
  426. }
  427. let MethodName = "/PaperServer/Manager/IssueManager/PageQueryIssue"
  428. let order_column_list = []
  429. if(this.dataSort != {}){
  430. if(this.dataSort.order=='descending'){
  431. order_column_list.push({
  432. name: this.dataSort.prop,
  433. asc: false
  434. })
  435. }else if(this.dataSort.order=='ascending'){
  436. order_column_list.push({
  437. name: this.dataSort.prop,
  438. asc: true
  439. })
  440. }else{
  441. order_column_list = [{
  442. name: 'create_time',
  443. asc: false
  444. }]
  445. }
  446. }else{
  447. order_column_list = [{
  448. name: 'create_time',
  449. asc: false
  450. }]
  451. }
  452. let data = {
  453. key_word: this.searchInput.trim(),
  454. iss_status: this.searchStatus===-1?null:this.searchStatus,
  455. study_phase: this.searchStudy===-1?null:this.searchStudy,
  456. release_year: this.searchYear===-1?null:this.searchYear,
  457. page_capacity:this.pageSize,
  458. cur_page:this.pageNumber,
  459. order_bys: order_column_list
  460. }
  461. getLogin(MethodName, data)
  462. .then((res) => {
  463. if(res.status===1){
  464. this.tableData = res.data.list
  465. this.total_count = res.data.total_count
  466. }
  467. })
  468. .catch(() => {
  469. this.loading = false
  470. });
  471. },
  472. // 获取年份列表
  473. getYearList(){
  474. let nowYear = new Date().getFullYear()
  475. let yearList = []
  476. for(let i = 0; i < 20; i++){
  477. let obj = {
  478. value: nowYear - i,
  479. label: nowYear - i
  480. }
  481. yearList.push(obj)
  482. }
  483. this.yearList = this.yearList.concat(yearList)
  484. }
  485. },
  486. //生命周期 - 创建完成(可以访问当前this实例)
  487. created() {
  488. this.getYearList()
  489. this.getTableHeight();
  490. this.getList()
  491. },
  492. //生命周期 - 挂载完成(可以访问DOM元素)
  493. mounted() {
  494. },
  495. //生命周期-创建之前
  496. beforeCreated() { },
  497. //生命周期-挂载之前
  498. beforeMount() { },
  499. //生命周期-更新之前
  500. beforUpdate() { },
  501. //生命周期-更新之后
  502. updated() { },
  503. //生命周期-销毁之前
  504. beforeDestory() { },
  505. //生命周期-销毁完成
  506. destoryed() { },
  507. //如果页面有keep-alive缓存功能,这个函数会触发
  508. activated() { }
  509. }
  510. </script>
  511. <style lang="scss" scoped>
  512. /* @import url(); 引入css类 */
  513. </style>
  514. <style lang="scss">
  515. .organize-manage{
  516. .el-cascader{
  517. width: 160px;
  518. height: 32px;
  519. line-height: 32px;
  520. .el-input{
  521. width: 100%;
  522. height: 32px;
  523. }
  524. }
  525. }
  526. </style>