DisclaimerInformation.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. const loading = this.$loading({
  142. lock: true,
  143. text: 'Loading',
  144. spinner: 'el-icon-loading',
  145. background: 'rgba(0, 0, 0, 0.7)'
  146. });
  147. api.discInformation(param).then((res) => {
  148. loading.close()
  149. if (res.data.code == '0') {
  150. const data = res.data.data;
  151. this.list = data.records;
  152. this.cacheData[param.current] = data.records;
  153. this.total = data.total;
  154. }
  155. }).catch((error) => {
  156. console.log(error);
  157. });
  158. },
  159. getDetail(item) {
  160. this.$router.push({name:'DiscInfoDetail', params:{info: item}})
  161. },
  162. getFilterItems(isTurnPage) {
  163. //翻页时筛选条件没点确定则清空
  164. if(isTurnPage&&!this.searched){
  165. this.filter.title='';
  166. };
  167. const param = {
  168. title: this.filter.title.trim(),
  169. current: this.currentPage,
  170. size: this.pageSize
  171. };
  172. return param;
  173. },
  174. indexMethod(index) {
  175. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  176. },
  177. currentChange(next) {
  178. this.currentPage = next;
  179. /*if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  180. this.list = this.cacheData[next];
  181. } else {*/
  182. this.getDataList(true);
  183. //}
  184. },
  185. warning(msg,type){
  186. this.$message({
  187. showClose: true,
  188. message:msg,
  189. type:type||'warning'
  190. })
  191. },
  192. showConfirmDialog(msg,resolve){
  193. this.$alert(msg, '提示', {
  194. confirmButtonText: '确定',
  195. type: 'warning'
  196. }).then(() => {
  197. resolve();
  198. }).catch(() => {});
  199. },
  200. showDelDialog(item){
  201. // 启用状态下不能删除
  202. if(item.status==1){return}
  203. this.showConfirmDialog('是否删除该免责声明?',()=>{
  204. api.delDiscInformation({id:item.id}).then((res)=>{
  205. if(res.data.code=='0'){
  206. if(!this.searched){
  207. //未点确认时清空搜索条件
  208. this.filter={
  209. title: ''
  210. };
  211. }
  212. this.warning(res.data.msg||'操作成功','success');
  213. this.getDataList();
  214. }else{
  215. this.warning(res.data.msg);
  216. }
  217. }).catch((error)=>{
  218. this.warning(error);
  219. })
  220. });
  221. },
  222. toOpen(item){
  223. // status=0停用,status=1启用
  224. if(item.status==0){
  225. this.showConfirmDialog('是否启用该免责声明?',()=>{
  226. api.openInformation({id:item.id}).then((res)=>{
  227. if(res.data.code==0){
  228. //恢复成功后跳转到筛选条件的首页
  229. this.currentPage = 1;
  230. this.$message({
  231. type:'success',
  232. message:res.data.msg ||"启用成功"
  233. })
  234. this.getDataList();
  235. }
  236. }).catch((error)=>{
  237. this.warning(error);
  238. })
  239. });
  240. }
  241. },
  242. toClose(item){
  243. if(item.status==1){
  244. this.showConfirmDialog('是否停用该免责声明?',()=>{
  245. api.closeInformation({id:item.id}).then((res)=>{
  246. if(res.data.code==0){
  247. this.$message({
  248. type:'success',
  249. message:res.data.msg ||"停用成功"
  250. })
  251. this.getDataList();
  252. }
  253. }).catch((error)=>{
  254. this.warning(error);
  255. })
  256. });
  257. }
  258. }
  259. }
  260. }
  261. </script>
  262. <style lang="less" scoped>
  263. @import "../../less/admin.less";
  264. .delete{
  265. color: red !important;
  266. }
  267. .forbid{
  268. color: #BFBFBF !important;
  269. }
  270. </style>