org.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="mod-menu">
  3. <el-form :inline="true" :model="dataForm">
  4. <el-form-item>
  5. <el-button v-if="isAuth('sys:menu:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
  6. </el-form-item>
  7. </el-form>
  8. <el-table
  9. :data="dataList"
  10. row-key="orgId"
  11. border
  12. :indent='20'
  13. style="width: 100%; ">
  14. <!-- <el-table-column type="selection" width="40">
  15. <template slot-scope="scope">
  16. <el-radio :label="scope.row.orgId" v-model="orgId"> &nbsp; </el-radio>
  17. </template>
  18. </el-table-column> -->
  19. <el-table-column
  20. prop="name"
  21. header-align="center"
  22. min-width="100"
  23. label="机构名称" >
  24. </el-table-column>
  25. <!-- <el-table-column
  26. prop="orgType"
  27. header-align="center"
  28. align="center"
  29. width="120"
  30. label="机构类型">
  31. <template slot-scope="scope">
  32. <span>{{ orgType[Number(scope.row.orgType || 0)] }}</span>
  33. </template>
  34. </el-table-column> -->
  35. <el-table-column
  36. prop="parentName"
  37. header-align="center"
  38. align="center"
  39. label="上级机构">
  40. </el-table-column>
  41. <!-- <el-table-column
  42. prop="orgId"
  43. header-align="center"
  44. align="center"
  45. min-width="100"
  46. :show-overflow-tooltip="true"
  47. label="机构ID">
  48. </el-table-column> -->
  49. <el-table-column
  50. fixed="right"
  51. header-align="center"
  52. align="center"
  53. width="150"
  54. label="操作">
  55. <template slot-scope="scope">
  56. <el-button v-if="isAuth('sys:menu:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.orgId)">修改</el-button>
  57. <el-button v-if="isAuth('sys:menu:delete')" type="text" size="small" @click="deleteHandle(scope.row.orgId)">删除</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <!-- 弹窗, 新增 / 修改 -->
  62. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  63. </div>
  64. </template>
  65. <script>
  66. import AddOrUpdate from './org-add-or-update'
  67. export default {
  68. data () {
  69. return {
  70. dataForm: {},
  71. dataList: [],
  72. dataListLoading: false,
  73. addOrUpdateVisible: false,
  74. orgId: ''
  75. }
  76. },
  77. components: {
  78. AddOrUpdate
  79. },
  80. activated () {
  81. this.getDataList()
  82. },
  83. methods: {
  84. // 获取数据列表
  85. getDataList () {
  86. this.dataListLoading = true
  87. this.$http({
  88. url: this.$http.adornUrl('/user-service/org/queryTree'),
  89. method: 'get',
  90. params: this.$http.adornParams()
  91. }).then(({data}) => {
  92. if (data.code === '200') {
  93. this.dataList = JSON.parse(JSON.stringify(data.data).replace(/"children":null/g, '"children":[]'))
  94. }
  95. this.dataListLoading = false
  96. })
  97. },
  98. // 新增 / 修改
  99. addOrUpdateHandle (id) {
  100. this.addOrUpdateVisible = true
  101. this.$nextTick(() => {
  102. this.$refs.addOrUpdate.init(id)
  103. })
  104. },
  105. // 删除
  106. deleteHandle (id) {
  107. this.$confirm(`确定对[orgId=${id}]进行[删除]操作?`, '提示', {
  108. confirmButtonText: '确定',
  109. cancelButtonText: '取消',
  110. type: 'warning'
  111. }).then(() => {
  112. this.$http({
  113. url: this.$http.adornUrl(`/user-service/org/delete/${id}`),
  114. method: 'DELETE',
  115. data: this.$http.adornData()
  116. }).then(({data}) => {
  117. if (data && data.code === '200') {
  118. this.$message({
  119. message: '操作成功',
  120. type: 'success',
  121. duration: 1500,
  122. onClose: () => {
  123. this.getDataList()
  124. }
  125. })
  126. } else {
  127. this.$message.error(data.msg)
  128. }
  129. })
  130. }).catch(() => {})
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. ::v-deep .el-table__header-wrapper .el-checkbox{
  137. display: none;
  138. }
  139. </style>