index.vue 5.5 KB

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