index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div style="height: 100%">
  3. <Toptitle :title="title">
  4. <slot name="titleButton"></slot>
  5. </Toptitle>
  6. <div class="page-edit">
  7. <div class="nav">
  8. <Topsearch v-if="showTopSearch"
  9. :showbtn="showbtn"
  10. @changeSelected="changeSelected"
  11. :list="list"
  12. @init="init"
  13. @searchData="searchData" />
  14. <div style="padding-bottom: 15px">
  15. <slot name="navButton"></slot>
  16. </div>
  17. </div>
  18. <div v-if="logList"
  19. slot="text-list"
  20. class="log-list">
  21. <div class="log-item"
  22. v-for="(item, index) of logList"
  23. :key="index">
  24. <span>{{ item.key }}:</span>
  25. <span :style="item.color ? 'color:' + item.color : ''">{{
  26. item.value
  27. }}</span>
  28. </div>
  29. </div>
  30. <div>
  31. <slot name="text-list"></slot>
  32. </div>
  33. <Table ref="table"
  34. v-if="showTable"
  35. :width="tableWidth"
  36. :loading="loading"
  37. :disabled-hover="disabledHover"
  38. @on-selection-change="selectTable"
  39. @on-select='select'
  40. @on-select-cancel='selectTableCancel'
  41. @on-select-all-cancel='selectTableAllCancel'
  42. :stripe="stripe"
  43. border
  44. :size="size"
  45. :columns="tableColums"
  46. :data="tableData">
  47. <template slot-scope="{ row }"
  48. slot="set">
  49. <slot name="set"
  50. :row="row"></slot>
  51. </template>
  52. <template slot-scope="{ row }"
  53. slot="basicTypeSet">
  54. <slot name="basicTypeSet"
  55. :row="row"></slot>
  56. </template>
  57. <template slot-scope="{ row,index }"
  58. slot="urlSet">
  59. <slot name="urlSet"
  60. :row="row"
  61. :index='index'></slot>
  62. </template>
  63. <template slot-scope="{ row,index }"
  64. slot="fashion">
  65. <slot name="fashion"
  66. :row="row"
  67. :index='index'></slot>
  68. </template>
  69. </Table>
  70. <slot></slot>
  71. </div>
  72. <slot name="pageSlot"></slot>
  73. <Footer v-if="showPage"
  74. :pageIndex="pageIndex"
  75. :total="total"
  76. :pageSize="pageSize"
  77. @changeSize="changeSize"
  78. @change="changePage" />
  79. </div>
  80. </template>
  81. <script>
  82. import { mapActions } from 'vuex'
  83. export default {
  84. props: {
  85. list: {
  86. // type:Array,
  87. // default:null,
  88. },
  89. tableColums: {
  90. type: Array,
  91. },
  92. tableData: {
  93. type: Array,
  94. },
  95. pageIndex: {
  96. type: Number,
  97. default: 1,
  98. },
  99. pageSize: {
  100. type: Number,
  101. default: 10,
  102. },
  103. total: {
  104. type: Number,
  105. default: 0,
  106. },
  107. title: {
  108. type: String,
  109. default: '',
  110. },
  111. showTopSearch: {
  112. type: Boolean,
  113. default: true,
  114. },
  115. loading: {
  116. type: Boolean,
  117. default: false,
  118. },
  119. stripe: {
  120. type: Boolean,
  121. default: true,
  122. },
  123. disabledHover: {
  124. type: Boolean,
  125. default: false,
  126. },
  127. size: {
  128. type: String,
  129. default: 'default'
  130. },
  131. logList: {
  132. type: Array,
  133. default: null,
  134. },
  135. showPage: {
  136. type: Boolean,
  137. default: true,
  138. },
  139. showbtn: {
  140. type: Boolean,
  141. default: true,
  142. },
  143. showTable: {
  144. type: Boolean,
  145. default: true,
  146. },
  147. },
  148. data () {
  149. return {
  150. tableWidth: null,
  151. tableHeight: null,
  152. }
  153. },
  154. created () { },
  155. mounted () {
  156. this.$nextTick(() => {
  157. if (this.showTable) {
  158. this.tableWidth = window.innerWidth - 350
  159. this.tableHeight =
  160. window.innerHeight - this.$refs.table.$el.offsetTop - 300
  161. window.addEventListener('resize', (e) => {
  162. this.tableWidth = e.target.innerWidth - 350
  163. // this.tableHeight = e.target.innerHeight - this.$refs.table.$el.offsetTop - 320;
  164. this.$forceUpdate()
  165. })
  166. }
  167. })
  168. //2021年07月23日17:24:05
  169. let id = JSON.parse(sessionStorage.getItem('crumbs')).parantData.id
  170. if (this.$route.query.permisssions_id || id) {
  171. this.axios('/api/get_permission', {
  172. params: {
  173. menu_id: this.$route.query.permisssions_id || id,
  174. },
  175. }).then((res) => {
  176. if (res.code == 200) {
  177. const result = Object.values(res.data)
  178. if (result.length > 0) {
  179. const obj = {}
  180. result.forEach((element) => (obj[element.remark] = element.status))
  181. this.updata_permission(obj)
  182. } else {
  183. this.updata_permission({ all: 1 })
  184. }
  185. }
  186. })
  187. }
  188. },
  189. destroyed () {
  190. window.removeEventListener('resize', (e) => {
  191. this.tableWidth = e.target.innerWidth - 350
  192. })
  193. },
  194. methods: {
  195. ...mapActions(['updata_permission']),
  196. init (row) {
  197. this.$emit('init', row)
  198. },
  199. searchData (row) {
  200. this.$emit('searchData', row)
  201. },
  202. changePage (e) {
  203. this.$emit('changePage', e)
  204. },
  205. selectTable (e) {
  206. this.$emit('selectTable', e)
  207. },
  208. changeSize (e) {
  209. this.$emit('changeSize', e)
  210. },
  211. changeSelected (e) {
  212. this.$emit('changeSelected', e)
  213. },
  214. selectTableCancel(e,row){
  215. this.$emit('selectTableCancel',e,row)
  216. },
  217. select(e,row){
  218. this.$emit('select',e,row)
  219. },
  220. selectTableAllCancel(e){
  221. this.$emit('selectTableAllCancel',e)
  222. }
  223. },
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .nav {
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: flex-end;
  231. }
  232. .page-edit {
  233. // overflow: hidden;
  234. overflow-y: auto;
  235. position: relative;
  236. top: 0px;
  237. height: 80%;
  238. }
  239. </style>