DisclaimerInformation.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div>
  3. <crumbs title="免责声明维护">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="标题:">
  6. <el-input size="mini" v-model="filter.title" placeholder="输入标题"></el-input>
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button size="mini" @click="filterDatas">确认</el-button>
  10. <el-button size="mini" type="warning" @click="addDisclInfo" style="margin:0 10px">添加</el-button>
  11. </el-form-item>
  12. </el-form>
  13. </crumbs>
  14. <div class="contents">
  15. <el-table :data="list"
  16. border
  17. style="width: 100%">
  18. <el-table-column
  19. type="index"
  20. :index="indexMethod"
  21. label="编号"
  22. width="60">
  23. </el-table-column>
  24. <el-table-column
  25. prop="gmtCreate"
  26. label="操作时间"
  27. :show-overflow-tooltip="true">
  28. </el-table-column>
  29. <el-table-column
  30. prop="modifier"
  31. label="操作人">
  32. </el-table-column>
  33. <el-table-column
  34. prop="title"
  35. label="标题"
  36. show-overflow-tooltip>
  37. </el-table-column>
  38. <el-table-column
  39. prop="disclaimerCode"
  40. label="归属">
  41. </el-table-column>
  42. <el-table-column
  43. label="状态">
  44. <template slot-scope="scope">
  45. <el-button type="text" size="small" :class="{forbid:scope.row.status==0}" @click="toOpen(scope.row)">启用</el-button>
  46. <!-- <span style="margin:0 3px;">|</span>
  47. <el-button type="text" size="small" :class="['delete',{'forbid':scope.row.status==1}]" @click="toClose(scope.row)">停用</el-button> -->
  48. </template>
  49. </el-table-column>
  50. <el-table-column
  51. label="操作">
  52. <template slot-scope="scope">
  53. <el-button type="text" size="small" @click="toEditDiscl(scope.row)">修改</el-button>
  54. <span style="margin:0 3px;">|</span>
  55. <el-button type="text" size="small" :class="['delete',{'forbid':scope.row.status==1}]" @click="showDelDialog(scope.row)">删除</el-button>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. label="详情">
  60. <template slot-scope="scope">
  61. <el-button type="text" size="small" @click="getDetail(scope.row)">详情</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <el-pagination v-if="total>pageSize"
  66. :current-page.sync="currentPage"
  67. @current-change="currentChange"
  68. background
  69. :page-size="pageSize"
  70. layout="total,prev, pager, next, jumper"
  71. :total="total">
  72. </el-pagination>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import api from '@api/icss.js';
  78. export default {
  79. name: 'DisclaimerInformation',
  80. data: function () {
  81. return {
  82. list: [],
  83. cacheData: {},
  84. currentPage: 1,
  85. pageSize: 10,
  86. total: 0,
  87. linkIn:[],
  88. pays:[],
  89. searched: false,
  90. filter: {
  91. title: ''
  92. }
  93. }
  94. },
  95. created() {
  96. const that = this;
  97. //返回时避免参数未赋值就获取列表
  98. setTimeout(function(){
  99. that.getDataList();
  100. });
  101. },
  102. watch: {
  103. 'filter': {
  104. handler: function () {
  105. this.searched = false;
  106. },
  107. deep: true
  108. }
  109. },
  110. beforeRouteEnter(to, from, next) {
  111. next(vm => {
  112. //const pm = to.param;
  113. Object.assign(vm, to.params);
  114. })
  115. },
  116. methods: {
  117. addDisclInfo(){
  118. const pam = this.searched ? {
  119. currentPage: this.currentPage,
  120. filter: this.filter
  121. } : {currentPage: this.currentPage};
  122. this.$router.push({name: 'AddDisclInfo', params: pam});
  123. },
  124. toEditDiscl(row){
  125. const pam = this.searched ? {
  126. currentPage: this.currentPage,
  127. filter: this.filter
  128. } : {currentPage: this.currentPage};
  129. this.$router.push({
  130. name:'AddDisclInfo',
  131. params: Object.assign(pam, {info:row})
  132. })
  133. },
  134. filterDatas(){
  135. this.currentPage = 1;
  136. this.getDataList();
  137. },
  138. getDataList(isTurnPage) {
  139. const param = this.getFilterItems(isTurnPage);
  140. this.searched = true;
  141. api.discInformation(param).then((res) => {
  142. if (res.data.code == '0') {
  143. const data = res.data.data;
  144. this.list = data.records;
  145. this.cacheData[param.current] = data.records;
  146. this.total = data.total;
  147. }
  148. }).catch((error) => {
  149. console.log(error);
  150. });
  151. },
  152. getDetail(item) {
  153. this.$router.push({name:'DiscInfoDetail', params:{info: item}})
  154. },
  155. getFilterItems(isTurnPage) {
  156. //翻页时筛选条件没点确定则清空
  157. if(isTurnPage&&!this.searched){
  158. this.filter.title='';
  159. };
  160. const param = {
  161. title: this.filter.title,
  162. current: this.currentPage,
  163. size: this.pageSize
  164. };
  165. return param;
  166. },
  167. indexMethod(index) {
  168. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  169. },
  170. currentChange(next) {
  171. this.currentPage = next;
  172. /*if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  173. this.list = this.cacheData[next];
  174. } else {*/
  175. this.getDataList(true);
  176. //}
  177. },
  178. warning(msg,type){
  179. this.$message({
  180. showClose: true,
  181. message:msg,
  182. type:type||'warning'
  183. })
  184. },
  185. showConfirmDialog(msg,resolve){
  186. this.$alert(msg, '提示', {
  187. confirmButtonText: '确定',
  188. type: 'warning'
  189. }).then(() => {
  190. resolve();
  191. }).catch(() => {});
  192. },
  193. showDelDialog(item){
  194. // 启用状态下不能删除
  195. if(item.status==1){return}
  196. this.showConfirmDialog('是否删除该免责声明?',()=>{
  197. api.delDiscInformation({id:item.id}).then((res)=>{
  198. if(res.data.code=='0'){
  199. if(!this.searched){
  200. //未点确认时清空搜索条件
  201. this.filter={
  202. title: ''
  203. };
  204. }
  205. this.warning(res.data.msg||'操作成功','success');
  206. this.getDataList();
  207. }else{
  208. this.warning(res.data.msg);
  209. }
  210. }).catch((error)=>{
  211. this.warning(error);
  212. })
  213. });
  214. },
  215. toOpen(item){
  216. // status=0停用,status=1启用
  217. if(item.status==0){
  218. this.showConfirmDialog('是否启用该免责声明?',()=>{
  219. api.openInformation({id:item.id}).then((res)=>{
  220. if(res.data.code==0){
  221. //恢复成功后跳转到筛选条件的首页
  222. this.currentPage = 1;
  223. this.$message({
  224. type:'success',
  225. message:res.data.msg ||"启用成功"
  226. })
  227. this.getDataList();
  228. }
  229. }).catch((error)=>{
  230. this.warning(error);
  231. })
  232. });
  233. }
  234. },
  235. toClose(item){
  236. if(item.status==1){
  237. this.showConfirmDialog('是否停用该免责声明?',()=>{
  238. api.closeInformation({id:item.id}).then((res)=>{
  239. if(res.data.code==0){
  240. this.$message({
  241. type:'success',
  242. message:res.data.msg ||"停用成功"
  243. })
  244. this.getDataList();
  245. }
  246. }).catch((error)=>{
  247. this.warning(error);
  248. })
  249. });
  250. }
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="less" scoped>
  256. @import "../../less/admin.less";
  257. .delete{
  258. color: red !important;
  259. }
  260. .forbid{
  261. color: #BFBFBF !important;
  262. }
  263. </style>