tb-department-list.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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="../../static/kj/element-ui/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="../../static/kj/vue.min.js"></script>
  12. <script src="../../static/kj/element-ui/index.js"></script>
  13. <script src="../../static/kj/httpVueLoader.js"></script>
  14. <script src="../../static/kj/jquery.min.js"></script>
  15. <script src="../../static/kj/layer/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. <div class="c-title">检索参数</div>
  23. <el-form ref="form" :model='p' @submit.native.prevent>
  24. <sa-item type="text" name="名称" v-model="p.name"></sa-item>
  25. <el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
  26. <el-button type="primary" icon="el-icon-plus" @click="add" v-if="sa.isAuth('tb-department-add')">新增
  27. </el-button>
  28. <el-button type="info" icon="el-icon-refresh" @click="f5()">重置</el-button>
  29. </el-form>
  30. <!-- ------------- 数据列表 ------------- -->
  31. <el-table class="data-table" ref="data-table" :data="dataList">
  32. <sa-td type="index" name="序号"></sa-td>
  33. <sa-td name="单位名称" prop="name"></sa-td>
  34. <el-table-column label="是否锁定" title="锁定的单位为系统维持正常运行的重要单位,不可删除">
  35. <template slot-scope="s">
  36. <el-tag v-if="s.row.status == 1">已锁定</el-tag>
  37. <el-tag v-else type="success">未锁定</el-tag>
  38. </template>
  39. </el-table-column>
  40. <sa-td name="创建时间" prop="createTime" width="140"></sa-td>
  41. <sa-td name="更新时间" prop="updateTime" width="140"></sa-td>
  42. <el-table-column label="操作" fixed="right" width="280px">
  43. <template slot-scope="s">
  44. <el-button v-if="sa.isAuth('tb-department-edit')" class="c-btn" type="primary" icon="el-icon-edit" @click="update(s.row)">修改
  45. </el-button>
  46. <el-button v-if="sa.isAuth('tb-department-del')" class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除
  47. </el-button>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <!-- ------------- 分页 ------------- -->
  52. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
  53. </sa-item>
  54. </div>
  55. </div>
  56. <script>
  57. var app = new Vue({
  58. components: {
  59. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  60. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  61. },
  62. el: '.vue-box',
  63. data: {
  64. p: { // 查询参数
  65. name: '', // 名称
  66. phone: '', // 联系号码
  67. dutyPeople: '', // 负责人
  68. pageNo: 1, // 当前页
  69. pageSize: 10, // 页大小
  70. sortType: 0 // 排序方式
  71. },
  72. dataCount: 0,
  73. dataList: [], // 数据集合
  74. },
  75. methods: {
  76. // 刷新
  77. f5: function() {
  78. sa.ajax('/TbDepartment/getList', sa.removeNull(this.p), function(res) {
  79. this.dataList = res.data; // 数据
  80. this.dataCount = res.dataCount; // 数据总数
  81. sa.f5TableHeight(); // 刷新表格高度
  82. }.bind(this));
  83. },
  84. adminFn(data){
  85. sa.showIframe('管理员', 'admin-list.html?customerId=' + data.id, '1080px', '80%');
  86. },
  87. // 查看
  88. get: function(data) {
  89. sa.showIframe('数据详情', 'tb-department-info.html?id=' + data.id, '550px', '60%');
  90. },
  91. // 查看 - 根据选中的
  92. getBySelect: function(data) {
  93. var selection = this.$refs['data-table'].selection;
  94. if (selection.length == 0) {
  95. return sa.msg('请选择一条数据')
  96. }
  97. this.get(selection[0]);
  98. },
  99. // 修改
  100. update: function(data) {
  101. sa.showIframe('修改数据', 'tb-department-add.html?id=' + data.id, '450px', '40%');
  102. },
  103. // 新增
  104. add: function(data) {
  105. sa.showIframe('新增数据', 'tb-department-add.html?id=-1', '450px', '40%');
  106. },
  107. // 删除
  108. del: function(data) {
  109. if(data.status == 1){
  110. return layer.alert('锁定的单位为系统维持正常运行的重要单位,不可删除');
  111. };
  112. sa.confirm('是否删除,此操作不可撤销', function() {
  113. sa.ajax('/TbDepartment/delete?id=' + data.id, function(res) {
  114. sa.arrayDelete(this.dataList, data);
  115. sa.ok('删除成功');
  116. sa.f5TableHeight(); // 刷新表格高度
  117. }.bind(this))
  118. }.bind(this));
  119. },
  120. // 批量删除
  121. deleteByIds: function() {
  122. // 获取选中元素的id列表
  123. let selection = this.$refs['data-table'].selection;
  124. let ids = sa.getArrayField(selection, 'id');
  125. if (selection.length == 0) {
  126. return sa.msg('请至少选择一条数据')
  127. }
  128. // 提交删除
  129. sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
  130. sa.ajax('/TbDepartment/deleteByIds', {
  131. ids: ids.join(',')
  132. }, function(res) {
  133. sa.arrayDelete(this.dataList, selection);
  134. sa.ok('删除成功');
  135. sa.f5TableHeight(); // 刷新表格高度
  136. }.bind(this))
  137. }.bind(this));
  138. },
  139. // 改 - 状态(0=否,1=是)
  140. updateStatus: function(data) {
  141. // 声明变量记录是否成功
  142. var isOk = false;
  143. var oldValue = data.status;
  144. var ajax = sa.ajax('/TbDepartment/updateStatus', {
  145. id: data.id,
  146. value: data.status
  147. }, function(res) {
  148. isOk = true;
  149. sa.msg('修改成功');
  150. }.bind(this));
  151. // 如果未能修改成功, 则回滚
  152. $.when(ajax).done(function() {
  153. if (isOk == false) {
  154. data.status = oldValue;
  155. }
  156. })
  157. },
  158. },
  159. created: function() {
  160. this.f5();
  161. sa.onInputEnter();
  162. }
  163. })
  164. </script>
  165. </body>
  166. </html>