department.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="mod-role">
  3. <!-- <el-container> -->
  4. <!-- form表单 -->
  5. <!-- <el-header>
  6. <div class="rect rect-form">
  7. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()" size="mini">
  8. <el-form-item>
  9. <el-input v-model="dataForm.keyword" placeholder="角色名称" clearable></el-input>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button @click="getDataList()" icon="el-icon-search">查询</el-button>
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. </el-header> -->
  17. <!-- role表格 -->
  18. <!-- <el-main> -->
  19. <div class="rect rect-table">
  20. <!-- 新增 删除按钮 -->
  21. <el-form inline size="mini">
  22. <el-form-item>
  23. <el-button
  24. icon="el-icon-plus"
  25. v-if="isAuth('sys:role:save')"
  26. @click="addOrUpdateHandle()">
  27. 新 增
  28. </el-button>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button
  32. icon="el-icon-delete"
  33. v-if="isAuth('sys:role:delete')"
  34. type="danger"
  35. @click="deleteHandle()"
  36. :disabled="dataListSelections.length <= 0">
  37. 删 除
  38. </el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-table
  42. :data="dataList"
  43. border
  44. stripe
  45. v-loading="dataListLoading"
  46. @selection-change="selectionChangeHandle"
  47. style="width: 100%;"
  48. size="mini"
  49. height="620"
  50. :header-cell-style="{background:'rgb(245,245,245)',color:'#000',height: '45px',fontSize: '13px',fontWeight: 'normal',borderBottom: '1px solid #ccc'}"
  51. :cell-style="{color: '#888',fontSize: '13px'}">
  52. <el-table-column
  53. type="selection"
  54. header-align="center"
  55. align="center"
  56. width="50">
  57. </el-table-column>
  58. <el-table-column
  59. prop="departmentName"
  60. header-align="center"
  61. align="center"
  62. label="部门名称">
  63. </el-table-column>
  64. <el-table-column
  65. prop="departmentCode"
  66. header-align="center"
  67. align="center"
  68. label="部门代码">
  69. </el-table-column>
  70. <el-table-column
  71. prop="leader"
  72. header-align="center"
  73. align="center"
  74. label="部门负责人">
  75. </el-table-column>
  76. <el-table-column
  77. header-align="center"
  78. align="center"
  79. width="150"
  80. label="操作">
  81. <template slot-scope="scope">
  82. <el-button v-if="isAuth('sys:role:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
  83. <el-button v-if="isAuth('sys:role:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <el-pagination
  88. @size-change="sizeChangeHandle"
  89. @current-change="currentChangeHandle"
  90. :current-page="pageIndex"
  91. :page-sizes="[10, 20, 50, 100]"
  92. :page-size="pageSize"
  93. :total="totalPage"
  94. layout="total, sizes, prev, pager, next, jumper">
  95. </el-pagination>
  96. <!-- 弹窗, 新增 / 修改 -->
  97. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  98. </div>
  99. <!-- </el-main>
  100. </el-container> -->
  101. </div>
  102. </template>
  103. <script>
  104. import AddOrUpdate from './department-add-or-update'
  105. export default {
  106. data () {
  107. return {
  108. dataForm: {
  109. keyword: ''
  110. },
  111. dataList: [],
  112. pageIndex: 1,
  113. pageSize: 10,
  114. totalPage: 0,
  115. dataListLoading: false,
  116. dataListSelections: [],
  117. addOrUpdateVisible: false,
  118. farmId: undefined
  119. }
  120. },
  121. components: {
  122. AddOrUpdate
  123. },
  124. activated () {
  125. this.getDataList()
  126. },
  127. methods: {
  128. // 左侧树状图对users的限制
  129. getUsers (val) {
  130. this.farmId = undefined
  131. if (val.order === 1) {
  132. this.farmId = val.id
  133. }
  134. this.getDataList()
  135. },
  136. // 获取数据列表
  137. getDataList () {
  138. this.dataListLoading = true
  139. this.$http({
  140. url: this.$http.adornUrl('/sys/department/list'),
  141. method: 'get',
  142. params: this.$http.adornParams({
  143. 'page': this.pageIndex,
  144. 'limit': this.pageSize,
  145. 'keyword': this.dataForm.keyword
  146. })
  147. }).then(({data}) => {
  148. console.log(data);
  149. if (data && data.code === 0) {
  150. this.dataList = data.page.list
  151. this.totalPage = data.page.totalCount
  152. } else {
  153. this.$message.error(data.msg)
  154. this.dataList = []
  155. this.totalPage = 0
  156. }
  157. this.dataListLoading = false
  158. })
  159. },
  160. // 每页数
  161. sizeChangeHandle (val) {
  162. this.pageSize = val
  163. this.pageIndex = 1
  164. this.getDataList()
  165. },
  166. // 当前页
  167. currentChangeHandle (val) {
  168. this.pageIndex = val
  169. this.getDataList()
  170. },
  171. // 多选
  172. selectionChangeHandle (val) {
  173. this.dataListSelections = val
  174. },
  175. // 新增 / 修改
  176. addOrUpdateHandle (id) {
  177. this.addOrUpdateVisible = true
  178. this.$nextTick(() => {
  179. this.$refs.addOrUpdate.init(id)
  180. })
  181. },
  182. // 删除
  183. deleteHandle (id) {
  184. var ids = id ? [id] : this.dataListSelections.map(item => {
  185. return item.id
  186. })
  187. this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
  188. confirmButtonText: '确定',
  189. cancelButtonText: '取消',
  190. type: 'warning'
  191. }).then(() => {
  192. this.$http({
  193. url: this.$http.adornUrl('/sys/department/delete'),
  194. method: 'post',
  195. data: this.$http.adornData(ids, false)
  196. }).then(({data}) => {
  197. if (data && data.code === 0) {
  198. this.$message({
  199. message: '操作成功',
  200. type: 'success',
  201. duration: 1500,
  202. onClose: () => {
  203. this.getDataList()
  204. }
  205. })
  206. } else {
  207. this.$message.error(data.msg)
  208. }
  209. })
  210. }).catch(() => {})
  211. }
  212. }
  213. }
  214. </script>
  215. <style scoped>
  216. .rect {
  217. background-color: #fff;
  218. padding: 30px 15px;
  219. border-radius: 5px;
  220. border: 1px solid #e8e8e8;
  221. }
  222. .rect-form {
  223. padding-bottom: 10px;
  224. }
  225. /* .rect-table {
  226. margin-top: 20px;
  227. } */
  228. .demo-table-expand {
  229. font-size: 0;
  230. margin-left: 40px;
  231. }
  232. .demo-table-expand label {
  233. width: 90px;
  234. color: #99a9bf;
  235. }
  236. .demo-table-expand .el-form-item {
  237. margin-right: 0;
  238. margin-bottom: 0;
  239. width: 80%;
  240. }
  241. .el-table .height {
  242. background: rgba(254, 254, 254, 0.5);
  243. }
  244. /deep/ .el-table--mini td, .el-table--mini th {
  245. padding: 3px 0 !important;
  246. height: 20px !important;
  247. }
  248. /deep/ .el-checkbox__input.is-checked+.el-checkbox__label {
  249. color: rgb(24,144,255);
  250. background-color: rgb(24,144,255);
  251. border-color: rgb(24,144,255);
  252. }
  253. /deep/.el-table .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  254. background-color: rgb(24,144,255);
  255. border-color: rgb(24,144,255);
  256. }
  257. /deep/.el-table .el-checkbox__inner:hover {
  258. border-color: rgb(24,144,255);
  259. }
  260. /deep/.el-table .el-checkbox__input.is-focus .el-checkbox__inner {
  261. border-color: rgb(24,144,255);
  262. }
  263. /deep/.el-table #select .cell .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  264. background-color: rgb(24,144,255);
  265. border-color: rgb(24,144,255);
  266. }
  267. </style>