sys-dict-item-list.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>-列表</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!-- 所有的 css & js 资源 -->
  8. <link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
  11. <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
  12. <script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
  13. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
  14. <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
  15. <script src="../../static/sa.js"></script>
  16. </head>
  17. <body>
  18. <div class="vue-box" style="display: none;" :style="'display: block;'">
  19. <div class="c-panel">
  20. <!-- ------------- 检索参数 ------------- -->
  21. <!-- ------------- 快捷按钮 ------------- -->
  22. <sa-item type="fast-btn" show="add,reset"></sa-item>
  23. <!-- ------------- 数据列表 ------------- -->
  24. <el-table class="data-table" ref="data-table" :data="dataList" >
  25. <sa-td type="selection"></sa-td>
  26. <sa-td name="字典值" prop="itemValue" ></sa-td>
  27. <sa-td name="字典文本" prop="itemText" ></sa-td>
  28. <sa-td name="描述" prop="des" ></sa-td>
  29. <sa-td name="排序" prop="sort" type="num"></sa-td>
  30. <!-- <sa-td name="状态" prop="status" type="num">-->
  31. <!-- <template slot-scope="s">-->
  32. <!-- <el-switch v-model="s.row.status" :active-value="1" :inactive-value="0"-->
  33. <!-- @change="updateStatus(s.row)" inactive-color="#ff4949" style="vertical-align: top;">-->
  34. <!-- </el-switch>-->
  35. <!-- <span style="color: #999;" v-if="s.row.status == 1">启用</span>-->
  36. <!-- <span style="color: #999;" v-if="s.row.status == 0">禁用</span>-->
  37. <!-- </template>-->
  38. <!-- </sa-td>-->
  39. <sa-td name="状态" prop="status" type="switch" :jv="{0: '禁用[#ff0000]', 1: '启用[#005500]'}"
  40. @change="s => updateStatus(s.row)"></sa-td>
  41. <el-table-column label="操作" fixed="right" width="240px">
  42. <template slot-scope="s">
  43. <el-button class="c-btn" type="primary" icon="el-icon-edit" @click="update(s.row)">修改</el-button>
  44. <el-button class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除</el-button>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <!-- ------------- 分页 ------------- -->
  49. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()"></sa-item>
  50. </div>
  51. </div>
  52. <script>
  53. var app = new Vue({
  54. components: {
  55. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  56. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  57. },
  58. el: '.vue-box',
  59. data: {
  60. p: { // 查询参数
  61. dictId: sa.p('dictId', ''),
  62. pageNo: 1, // 当前页
  63. pageSize: 10, // 页大小
  64. sortType: 0 // 排序方式
  65. },
  66. dataCount: 0,
  67. dataList: [], // 数据集合
  68. },
  69. methods: {
  70. // 刷新
  71. f5: function() {
  72. sa.ajax('/SysDictItem/getList', sa.removeNull(this.p), function(res) {
  73. this.dataList = res.data; // 数据
  74. this.dataCount = res.dataCount; // 数据总数
  75. sa.f5TableHeight(); // 刷新表格高度
  76. }.bind(this));
  77. },
  78. // 查看
  79. get: function(data) {
  80. sa.showIframe('数据详情', 'sys-dict-item-info.html?id=' + data.id, '1050px', '90%');
  81. },
  82. // 查看 - 根据选中的
  83. getBySelect: function(data) {
  84. var selection = this.$refs['data-table'].selection;
  85. if(selection.length == 0) {
  86. return sa.msg('请选择一条数据')
  87. }
  88. this.get(selection[0]);
  89. },
  90. // 修改
  91. update: function(data) {
  92. sa.showIframe('修改数据', 'sys-dict-item-add.html?id=' + data.id + '&dictId=' + this.p.dictId,
  93. '450px', '60%');
  94. },
  95. // 新增
  96. add: function(data) {
  97. sa.showIframe('新增数据', 'sys-dict-item-add.html?id=-1&dictId=' + this.p.dictId, '450px', '60%');
  98. },
  99. // 删除
  100. del: function(data) {
  101. sa.confirm('是否删除,此操作不可撤销', function() {
  102. sa.ajax('/SysDictItem/delete?id=' + data.id, function(res) {
  103. sa.arrayDelete(this.dataList, data);
  104. sa.ok('删除成功');
  105. sa.f5TableHeight(); // 刷新表格高度
  106. }.bind(this))
  107. }.bind(this));
  108. },
  109. // 批量删除
  110. deleteByIds: function() {
  111. // 获取选中元素的id列表
  112. let selection = this.$refs['data-table'].selection;
  113. let ids = sa.getArrayField(selection, 'id');
  114. if(selection.length == 0) {
  115. return sa.msg('请至少选择一条数据')
  116. }
  117. // 提交删除
  118. sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
  119. sa.ajax('/SysDictItem/deleteByIds', {ids: ids.join(',')}, function(res) {
  120. sa.arrayDelete(this.dataList, selection);
  121. sa.ok('删除成功');
  122. sa.f5TableHeight(); // 刷新表格高度
  123. }.bind(this))
  124. }.bind(this));
  125. },
  126. // 改 - 是否可用(0=可用,1=不可用)
  127. updateStatus: function(data) {
  128. // 声明变量记录是否成功
  129. var isOk = false;
  130. var oldValue = data.status;
  131. var ajax = sa.ajax('/SysDictItem/updateStatus', {
  132. id: data.id,
  133. value: data.status
  134. }, function(res) {
  135. isOk = true;
  136. sa.msg('修改成功');
  137. }.bind(this));
  138. // 如果未能修改成功, 则回滚
  139. $.when(ajax).done(function() {
  140. if (isOk == false) {
  141. data.status = oldValue;
  142. }
  143. })
  144. },
  145. },
  146. created: function() {
  147. this.f5();
  148. sa.onInputEnter();
  149. }
  150. })
  151. </script>
  152. </body>
  153. </html>