index.vue 9.1 KB

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