index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="basic__layout__panel">
  3. <div>
  4. <div class="layout-header-panel container normal-panel">
  5. <div class="flex-align-center flex-between">
  6. <div class="normal-margin flex-align-center">
  7. <p style="font-size:26px;font-weight:300">{{acitveApp.meta.title}}&nbsp;<i @click="addToAsideBar" style="color:#999" class="el-icon-star-off"></i></p>
  8. <el-divider direction="vertical"></el-divider>
  9. <div class="flex-align-center">
  10. <cpAdd v-if="tool.checkAuth($route.name,'insert')" :formPath="formPath" :oldFormPath="oldFormPath" @onAddSuccess="listData(param.content.pageNumber = 1)"></cpAdd>
  11. <el-button-group v-if="tool.checkAuth($route.name,'delete')" class="inline-16">
  12. <el-button type="default" :disabled="selection.length === 0" size="small" @click="deleteData">删 除</el-button>
  13. </el-button-group>
  14. <!-- <el-button class="inline-16" size="small" type="primary" plain>导 入</el-button> -->
  15. <excel :tablecols="layout" :param="param" :total="total" :excelTitle="routerName"></excel>
  16. </div>
  17. <slot name="titleRight"></slot>
  18. </div>
  19. <div class="normal-margin">
  20. <setColumn :layout="layout" @changeColumn="changeColumn"></setColumn>
  21. <setFixed :data="tableLayout" @onFixedClick="onFixedClick"></setFixed>
  22. <i class="el-icon-refresh" @click="listData(param.content.pageNumber = 1,param.content.where.condition = '')"></i>
  23. </div>
  24. </div>
  25. <div class="flex-align-center">
  26. <!-- <el-radio-group v-if="options" class="inline-16" v-model="listType" size="small">
  27. <el-radio-button label="table" ><i class="el-icon-tickets"></i></el-radio-button>
  28. <el-radio-button label="card"><i class="el-icon-menu"></i></el-radio-button>
  29. </el-radio-group> -->
  30. <slot name="custom"></slot>
  31. <el-input placeholder="请输入搜索内容" suffix-icon="el-icon-search" v-model="param.content.where.condition" @keyup.native.enter="listData(param.content.pageNumber = 1)" @clear="listData(param.content.pageNumber = 1)" style="width:200px" size="small" class="input-with-select inline-16" clearable>
  32. </el-input>
  33. </div>
  34. </div>
  35. <div class="normal-panel flex-align-center" style="padding:0 16px">
  36. <slot name="tableLeft"></slot>
  37. <div style="flex:0 1 auto;width: 100%;" v-if="listType === 'table' && refreshTable">
  38. <tableTemp ref="table" :layout="tableLayout" :tableName="tableName" :custom="true" :data="list" :fixRightData="fixRightData" :fixLeftData="fixLeftData" @checkboxCallBack="checkboxCallBack">
  39. <template v-slot:customcol="scope">
  40. <slot :data="scope" name="tbList"></slot>
  41. </template>
  42. <template v-slot:opreation="scope">
  43. <drawerTemp class="inline-16" v-if="detailPath" :data="scope.data" :detailPath="detailPath" :idName="idName" @onSuccess="listData"></drawerTemp>
  44. <slot :data="scope" name="tbOpreation"></slot>
  45. </template>
  46. </tableTemp>
  47. <div class="container normal-panel" style="text-align:right">
  48. <el-pagination
  49. background
  50. small
  51. @size-change="handleSizeChange"
  52. @current-change="handleCurrentChange"
  53. :current-page="currentPage"
  54. :page-sizes="[20, 50, 100, 200]"
  55. layout="total,sizes, prev, pager, next, jumper"
  56. :total="total">
  57. </el-pagination>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import {mapGetters} from 'vuex'
  66. export default {
  67. props:['tableName','idName','tableData','apiId','formPath','oldFormPath','options','autoQuery','detailPath'],
  68. components:{
  69. tableTemp: () => import('./modules/table.vue'),
  70. setColumn: () => import('./modules/setColumn.vue'),
  71. cpAdd: () => import('./modules/cpAdd'),
  72. cpEdit: () => import('./modules/cpEdit'),
  73. setFixed: () => import('./modules/setFixed'),
  74. drawerTemp:() => import('./drawerDetail/index'),
  75. excel:() => import('@/components/export_excel/index.vue'),
  76. cardTemp:() => import('./modules/cardList.vue')
  77. },
  78. computed:{
  79. ...mapGetters({
  80. acitveApp:'acitveApp',
  81. searchValue:'searchValue'
  82. })
  83. },
  84. data () {
  85. return {
  86. listType:'table',
  87. routerName:'',
  88. select:'',
  89. param:{
  90. content:{
  91. "isExport":0,
  92. "pageNumber": 1,
  93. "pageSize": 20,
  94. "where": {
  95. "condition": ""
  96. }
  97. }
  98. },
  99. layout:[],
  100. fixRightData:['operation'],
  101. fixLeftData:[],
  102. tableLayout:[],
  103. selection:[],
  104. list:[],
  105. total:0,
  106. currentPage:0,
  107. refreshTable:true
  108. }
  109. },
  110. methods:{
  111. async listData () {
  112. this.param.id = this.apiId.query
  113. const res = await this.$api.requested(this.param)
  114. this.list = res.data
  115. this.total = res.total
  116. this.currentPage = res.pageNumber
  117. /* 请求的数据暴露出去 二次处理 */
  118. this.$emit('listData',this.list)
  119. },
  120. selectChange () {
  121. this.param.content.pageNumber = 1
  122. this.param.content.where.status = this.select
  123. this.listData()
  124. },
  125. handleSizeChange(val) {
  126. // console.log(`每页 ${val} 条`);
  127. this.param.content.pageSize = val
  128. this.listData()
  129. },
  130. handleCurrentChange(val) {
  131. // console.log(`当前页: ${val}`);
  132. this.param.content.pageNumber = val
  133. this.listData()
  134. },
  135. checkboxCallBack (val) {
  136. this.selection = val
  137. this.$emit('checkboxCallBack',val)
  138. },
  139. deleteData () {
  140. this.$confirm('确定删除这些数据吗?', '提示', {
  141. confirmButtonText: '确定',
  142. cancelButtonText: '取消',
  143. type: 'warning'
  144. }).then(async () => {
  145. let param = {
  146. "id": this.apiId.del,
  147. "content":{}
  148. }
  149. if (this.idName instanceof Array) { //判断传入的类型是多个还是单个idname
  150. let obj = {}
  151. this.idName.forEach(e=>{
  152. obj[e] = ''
  153. })
  154. param.content[`${this.idName[0]}s`] = this.selection.map(e=>{
  155. Object.keys(obj).map((key,item)=>{
  156. obj[key] = e[key]
  157. })
  158. return obj
  159. })
  160. } else {
  161. param.content[`${this.idName}s`] = this.selection.map(e=>{
  162. return e[this.idName]
  163. })
  164. }
  165. const res = await this.$api.requested(param)
  166. this.tool.showMessage(res,()=>{
  167. this.listData()
  168. })
  169. }).catch((err) => {
  170. console.log(err)
  171. this.$message({
  172. type: 'info',
  173. message: '已取消删除'
  174. });
  175. });
  176. },
  177. onFixedClick (right,left) {
  178. this.fixRightData = right
  179. this.fixLeftData = left
  180. this.$refs['table'].checkFixed()
  181. },
  182. // 筛选列
  183. changeColumn (arr) {
  184. this.tableLayout = arr
  185. this.refreshTable= false
  186. setTimeout(() => {
  187. this.refreshTable= true
  188. }, 0);
  189. },
  190. // 创建快捷应用
  191. async addToAsideBar () {
  192. const res = await this.$api.requested({
  193. "classname": "sysmanage.develop.userauthforweb.userauth",
  194. "method": "create_usershortcuts",
  195. "content": {
  196. "systemappid":this.acitveApp.systemappid
  197. }
  198. })
  199. this.$store.dispatch('setAppMenu')
  200. },
  201. },
  202. mounted () {
  203. this.autoQuery === false?'':this.listData()
  204. },
  205. created () {
  206. this.routerName = this.$route.meta.title
  207. this.param.content.where.condition = this.searchValue
  208. this.layout = this.tool.tabelCol(this.$route.name)[this.tableName].tablecols
  209. this.tableLayout = this.layout
  210. this.$emit('listCreate',this.param)
  211. },
  212. }
  213. </script>
  214. <style>
  215. .layout-header-panel .el-input-group__append, .el-input-group__prepend{
  216. background-color: #fff !important;
  217. color: #999 !important;
  218. border: 1px solid #dcdfe6 !important;
  219. cursor: pointer;
  220. }
  221. </style>
  222. <style scoped>
  223. /* .basic__layout__panel{
  224. padding: 16px 0;
  225. } */
  226. .card__list{
  227. display: flex;
  228. }
  229. </style>