sys-dict-item-list.html 6.9 KB

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