Disclaimer.vue 9.1 KB

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