index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <el-dialog :visible.sync="crud.tempShow.dmSystem" title="选择子系统" width="60%">
  3. <!--用户数据-->
  4. <el-row>
  5. <el-col :xs="15" :sm="18" :md="19" :lg="20" :xl="20">
  6. <!--工具栏-->
  7. <div class="head-container">
  8. <!-- 搜索 -->
  9. <el-input
  10. v-model="code"
  11. type="text"
  12. size="small"
  13. placeholder="输入子系统名称搜索"
  14. style="width: 200px;"
  15. class="filter-item"
  16. />
  17. <span>
  18. <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="getDmSystem()">搜索</el-button>
  19. <el-button class="filter-item" size="mini" type="warning" icon="el-icon-refresh-left" @click="crud.resetQuery()">重置</el-button>
  20. </span>
  21. </div>
  22. </el-col>
  23. </el-row>
  24. <el-row>
  25. <el-col :span="17">
  26. <el-table
  27. ref="multipleTable"
  28. v-loading="crud.loading"
  29. :data="dmSystems"
  30. tooltip-effect="dark"
  31. @selection-change="handleSelectionChange"
  32. >
  33. <el-table-column
  34. type="selection"
  35. width="55"
  36. />
  37. <el-table-column :show-overflow-tooltip="true" prop="systemName" label="用户名" />
  38. <el-table-column :show-overflow-tooltip="true" prop="createTime" width="135" label="创建日期" />
  39. </el-table>
  40. <!--分页组件-->
  41. <el-pagination
  42. :page-size.sync="size"
  43. :total="total"
  44. :current-page.sync="page"
  45. style="margin-top: 8px;"
  46. layout="total, prev, pager, next, sizes"
  47. @size-change="getDmSystem()"
  48. @current-change="getDmSystem()"
  49. />
  50. </el-col>
  51. <el-col :span="6" :push="1">
  52. <el-card style="height: 100%;">
  53. <div>您已选择:</div>
  54. <div>{{ checkInfo }}</div>
  55. </el-card>
  56. </el-col>
  57. </el-row>
  58. <div slot="footer">
  59. <el-row>
  60. <el-col :xs="10" :sm="10" :md="10" :lg="15" :xl="15">
  61. <el-button style="" class="filter-item" @click="toggleSelection()">取消选择</el-button>
  62. <el-button class="filter-item" style="margin-left:20% ;" @click="selected()">选择</el-button>
  63. </el-col>
  64. </el-row>
  65. </div>
  66. </el-dialog>
  67. </template>
  68. <script>
  69. import crudDmSystem from '@/api/dm/system/dmSystem'
  70. import { mapGetters } from 'vuex'
  71. import CRUD, { crud } from '@crud/crud'
  72. export default {
  73. mixins: [crud()],
  74. cruds() {
  75. return CRUD({ title: '子系统', url: 'api/dmSystem', tempBtnShow: {
  76. dmSystem: true
  77. }, crudMethod: { ...crudDmSystem }})
  78. },
  79. props: {
  80. visible: {
  81. type: Boolean,
  82. default: false
  83. }
  84. },
  85. data() {
  86. return {
  87. dmSystems: [],
  88. multipleSelection: crud.selectData || [],
  89. checkInfo: '',
  90. code: '',
  91. size: 0,
  92. page: 0,
  93. total: 0
  94. }
  95. },
  96. computed: {
  97. ...mapGetters([
  98. 'dmSystem'
  99. ])
  100. },
  101. watch: {
  102. 'crud.selectData': {
  103. handler: function(datainfo) {
  104. this.$nextTick(function() {
  105. this.toggleSelection()
  106. this.dmSystems.forEach((item, i) => {
  107. datainfo.forEach(row => {
  108. if (this.dmSystems[i].id === row * 1) {
  109. this.$refs.multipleTable.toggleRowSelection(this.dmSystems[i])
  110. this.setCheckInfo()
  111. }
  112. })
  113. })
  114. })
  115. },
  116. deep: true
  117. },
  118. multipleSelection: {
  119. handler: function() {
  120. this.setCheckInfo()
  121. }
  122. }
  123. },
  124. created() {
  125. crudDmSystem.getDmSystem().then(res => {
  126. this.total = res.totalElements
  127. this.dmSystems = res.content.map(function(obj) {
  128. return obj
  129. })
  130. })
  131. },
  132. methods: {
  133. getDmSystem() {
  134. crudDmSystem.getDmSystem({ blurry: this.code, page: this.page, size: this.size }).then(res => {
  135. this.total = res.totalElements
  136. this.dmSystems = res.content.map(function(obj) {
  137. return obj
  138. })
  139. })
  140. },
  141. toggleSelection(rows) {
  142. if (rows) {
  143. rows.forEach(row => {
  144. this.$refs.multipleTable.toggleRowSelection(row)
  145. })
  146. } else {
  147. this.$refs.multipleTable.clearSelection()
  148. }
  149. this.crud.doCloseDmSystem()
  150. },
  151. handleSelectionChange(val) {
  152. var selectOne = this.crud.selectOne
  153. if (selectOne === false) { // 不限制选项
  154. this.multipleSelection = val
  155. }
  156. if (selectOne === true) {
  157. this.multipleSelection = val
  158. this.multipleSelection = val[0]
  159. if (val.length > 1) {
  160. this.$refs.multipleTable.clearSelection()
  161. this.$refs.multipleTable.toggleRowSelection(val.pop())
  162. }
  163. }
  164. },
  165. selected() {
  166. this.$emit('on-change', this.$refs.multipleTable.selection, this.crud.openId)
  167. this.$refs.multipleTable.clearSelection()
  168. this.crud.doCloseDmSystem()
  169. },
  170. setCheckInfo() {
  171. var checkedDmSystems = this.$refs.multipleTable.selection
  172. var info = ''
  173. checkedDmSystems.forEach(row => {
  174. info += row.systemName + ','
  175. })
  176. this.checkInfo = info.substring(0, info.length - 1)
  177. }
  178. }
  179. }
  180. </script>