index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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="activeApp" style="font-size:26px;font-weight:300">{{customTitle ? customTitle : activeApp.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. <div v-if="oldFormPath || formPath">
  17. <cpAdd v-if="tool.checkAuth($route.name,'insert')" :formPath="formPath" :oldFormPath="oldFormPath" @onAddSuccess="listData(param.content.pageNumber = 1)"></cpAdd>
  18. </div>
  19. <slot name="titleLight"></slot>
  20. <!-- <el-button-group v-if="tool.checkAuth($route.name,'delete')" class="inline-16">
  21. <el-button :type="selection.length === 0?'':'primary'" :disabled="selection.length === 0" size="small" @click="deleteData">删 除</el-button>
  22. </el-button-group> -->
  23. <!-- <el-button class="inline-16" size="small" type="primary" plain>导 入</el-button> -->
  24. <excel :tablecols="layout" :param="param" :total="total" :specialKey="specialKey" :excelTitle="routerName"></excel>
  25. </div>
  26. <slot name="titleRight"></slot>
  27. </div>
  28. <div class="normal-margin">
  29. <setColumn :layout="layout" @changeColumn="changeColumn"></setColumn>
  30. <setFixed :data="tableLayout" @onFixedClick="onFixedClick"></setFixed>
  31. <i class="el-icon-refresh" @click="listData(param.content.pageNumber = 1,param.content.where.condition = '')"></i>
  32. </div>
  33. </div>
  34. <div class="flex-align-stretch" style="min-width:800px">
  35. <slot name="custom"></slot>
  36. <el-input v-if="!hideSearch" style="width:200px;" placeholder="搜索" :suffix-icon="param.content.where.condition?param.content.where.condition.length > 0?'':'':'el-icon-search'" v-model="param.content.where.condition" @keyup.native.enter="listData(param.content.pageNumber = 1)" @clear="clearSearchValue" size="small" class="input-with-select inline-16 layout_search__panel" clearable>
  37. </el-input>
  38. <slot name="custom-right"></slot>
  39. </div>
  40. </div>
  41. <div class="normal-panel flex-align-center" style="padding:0 16px">
  42. <slot name="tableLeft"></slot>
  43. <div style="flex:0 1 auto;width: 100%;" v-if="listType === 'table' && refreshTable">
  44. <tableTemp ref="table" :layout="tableLayout" :tableName="tableName" :custom="true" :data="list" :fixRightData="fixRightData" :fixLeftData="fixLeftData" @headerSearch="onHeaderSearch" @checkboxCallBack="checkboxCallBack">
  45. <template v-slot:temp="scope">
  46. <slot name="tempChild" :data="scope.data"></slot>
  47. </template>
  48. <template v-slot:customcol="scope">
  49. <slot :data="scope" name="tbList"></slot>
  50. </template>
  51. <template v-slot:opreation="scope">
  52. <drawerTemp class="inline-16" v-if="detailPath && checkRowStatus(scope.data.status)" :data="scope.data" :detailPath="detailPath" :idName="idName" @onSuccess="listData"></drawerTemp>
  53. <!--systemappid != 163 排除报表应用-->
  54. <reportCenter class="inline-16" :data="reportCenterLsit" v-if="reportCenterLsit.length > 0 && systemappid != 163">
  55. <template v-slot:print="scope2">
  56. <el-button @click="printBtn(scope.data,scope2.data)" type="text" size="mini">打 印</el-button>
  57. </template>
  58. </reportCenter>
  59. <slot :data="scope" name="tbOpreation"></slot>
  60. </template>
  61. </tableTemp>
  62. <div style="display:flex;align-items:center;flex-direction:row-reverse;justify-content:space-between">
  63. <div v-if="!hidePagination" class="container normal-panel" style="text-align:right">
  64. <el-pagination
  65. background
  66. @size-change="handleSizeChange"
  67. @current-change="handleCurrentChange"
  68. :current-page="currentPage"
  69. :page-sizes="[20, 50, 100, 200]"
  70. layout="total,sizes, prev, pager, next, jumper"
  71. :total="total">
  72. </el-pagination>
  73. </div>
  74. <slot name="footerLeft"></slot>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <drawer :drawerWidth="drawerWidth" @onSuccess="listData"></drawer>
  80. </div>
  81. </template>
  82. <script>
  83. import {mapGetters} from 'vuex'
  84. export default {
  85. componentName:'normalTable',
  86. props:['tableName','idName','tableData','apiId','formPath','oldFormPath','options','autoQuery','detailPath','customTitle','hidePagination','hideSearch','statusHideDetailBtn','specialKey','drawerWidth'],
  87. components:{
  88. tableTemp: () => import('./modules/table.vue'),
  89. setColumn: () => import('./modules/setColumn.vue'),
  90. cpAdd: () => import('./modules/cpAdd'),
  91. cpEdit: () => import('./modules/cpEdit'),
  92. setFixed: () => import('./modules/setFixed'),
  93. drawerTemp:() => import('./drawerDetail/index'),
  94. excel:() => import('@/components/export_excel/index.vue'),
  95. cardTemp:() => import('./modules/cardList.vue'),
  96. drawer:() => import('./drawerDetail/drawer'),
  97. reportCenter:() => import('./reportCenter/index'),
  98. },
  99. computed:{
  100. ...mapGetters({
  101. activeApp:'activeApp',
  102. searchValue:'searchValue',
  103. menuApp:'menuApp',
  104. })
  105. },
  106. data () {
  107. return {
  108. listType:'table',
  109. routerName:'',
  110. select:'',
  111. param:{
  112. content:{
  113. "isExport":0,
  114. "pageNumber": 1,
  115. "pageSize": 20,
  116. "where": {
  117. "condition": "",
  118. "tablefilter":{}
  119. }
  120. }
  121. },
  122. layout:[],
  123. fixRightData:['operation'],
  124. fixLeftData:[],
  125. tableLayout:[],
  126. selection:[],
  127. list:[],
  128. total:0,
  129. currentPage:0,
  130. refreshTable:true,
  131. title:'',
  132. name:'',
  133. systemappid:JSON.parse(sessionStorage.getItem('activeApp')).systemappid,
  134. reportCenterLsit:[]
  135. }
  136. },
  137. methods:{
  138. clearSearch () {
  139. this.$store.state.searchValue = ''
  140. this.listData(this.param.content.pageNumber = 1)
  141. },
  142. async listData () {
  143. this.searchValue?this.param.content.where.condition = this.searchValue:''
  144. this.param.id = this.apiId.query
  145. const res = await this.$api.requested(this.param)
  146. this.list = res.data
  147. this.total = res.total
  148. this.currentPage = res.pageNumber
  149. /* 请求的数据暴露出去 二次处理 */
  150. this.$emit('listData',this.list)
  151. // 保存一下列表数据用于翻页
  152. this.$store.dispatch('saveListData',this.list)
  153. },
  154. selectChange () {
  155. this.param.content.pageNumber = 1
  156. this.param.content.where.status = this.select
  157. this.listData()
  158. },
  159. handleSizeChange(val) {
  160. // console.log(`每页 ${val} 条`);
  161. this.param.content.pageSize = val
  162. this.listData()
  163. },
  164. handleCurrentChange(val) {
  165. // console.log(`当前页: ${val}`);
  166. this.param.content.pageNumber = val
  167. this.listData()
  168. },
  169. checkboxCallBack (val) {
  170. this.selection = val
  171. this.$emit('checkboxCallBack',val)
  172. },
  173. deleteData () {
  174. this.$confirm('确定删除这些数据吗?', '提示', {
  175. confirmButtonText: '确定',
  176. cancelButtonText: '取消',
  177. type: 'warning'
  178. }).then(async () => {
  179. let param = {
  180. "id": this.apiId.del,
  181. "content":{}
  182. }
  183. if (this.idName instanceof Array) { //判断传入的类型是多个还是单个idname
  184. let obj = {}
  185. this.idName.forEach(e=>{
  186. obj[e] = ''
  187. })
  188. param.content[`${this.idName[0]}s`] = this.selection.map(e=>{
  189. Object.keys(obj).map((key,item)=>{
  190. obj[key] = e[key]
  191. })
  192. return obj
  193. })
  194. } else {
  195. param.content[`${this.idName}s`] = this.selection.map(e=>{
  196. return e[this.idName]
  197. })
  198. }
  199. const res = await this.$api.requested(param)
  200. this.tool.showMessage(res,()=>{
  201. this.listData()
  202. })
  203. }).catch((err) => {
  204. console.log(err)
  205. this.$message({
  206. type: 'info',
  207. message: '已取消删除'
  208. });
  209. });
  210. },
  211. onFixedClick (right,left) {
  212. this.fixRightData = right
  213. this.fixLeftData = left
  214. this.$refs['table'].checkFixed()
  215. },
  216. // 筛选列
  217. changeColumn (arr) {
  218. this.tableLayout = arr
  219. this.refreshTable= false
  220. setTimeout(() => {
  221. this.refreshTable= true
  222. }, 0);
  223. },
  224. // 创建快捷应用
  225. async addToAsideBar () {
  226. const res = await this.$api.requested({
  227. "classname": "sysmanage.develop.userauthforweb.userauth",
  228. "method": "create_usershortcuts",
  229. "content": {
  230. "systemappid":this.activeApp.systemappid
  231. }
  232. })
  233. this.$store.dispatch('setAppMenu')
  234. },
  235. showAppCollection () {
  236. let _isSame = this.menuApp.some(m=>this.activeApp.name === m.systemapp)
  237. return _isSame
  238. },
  239. checkRowStatus (status) {
  240. if (this.statusHideDetailBtn) {
  241. let _isSame = this.statusHideDetailBtn.some(m=>status === m)
  242. return !_isSame
  243. } else {
  244. return true
  245. }
  246. },
  247. onHeaderSearch (key,val) {
  248. this.param.content.pageNumber = 1
  249. this.param.content.where.tablefilter[key] = val
  250. this.listData()
  251. },
  252. /* 获取是否有报表数据 */
  253. async getSystemAppid () {
  254. let res = await this.$api.requested({
  255. "id":20221213094401,
  256. "content": {
  257. "systemappid":this.systemappid,
  258. }
  259. })
  260. this.reportCenterLsit = res.data
  261. console.log(res,'报表数据');
  262. },
  263. async printBtn (data,data2) {
  264. let res = await this.$api.requested({
  265. "id":20221213094501,
  266. "content": {
  267. sys_reportid:data2.sys_reportid,
  268. dataid:data[this.idName]
  269. }
  270. })
  271. this.tool.showMessage(res,() => {
  272. window.open(this.tool.getBaseUrl() + res.data + `&${this.idName}=${data[this.idName]}`)
  273. })
  274. },
  275. clearSearchValue () {
  276. this.$store.dispatch('clearSearchValue')
  277. this.listData(this.param.content.pageNumber = 1)
  278. }
  279. },
  280. watch:{
  281. },
  282. mounted () {
  283. this.autoQuery === false?'':this.listData()
  284. console.log(process.env)
  285. },
  286. created () {
  287. this.$emit('listCreate',this.param)
  288. try {
  289. this.routerName = this.$route.meta.title
  290. this.layout = this.tool.tabelCol(this.$route.name)[this.tableName].tablecols
  291. this.tableLayout = this.layout
  292. this.getSystemAppid()
  293. } catch (error) {
  294. console.log(error)
  295. }
  296. }
  297. }
  298. </script>
  299. <style>
  300. .layout_search__panel{
  301. align-items: center;
  302. }
  303. .layout-header-panel .el-input-group__append, .el-input-group__prepend{
  304. background-color: #fff !important;
  305. color: #999 !important;
  306. border: 1px solid #dcdfe6 !important;
  307. cursor: pointer;
  308. }
  309. .layout-header-panel .el-input--small .el-input__icon{
  310. height: 32px !important;
  311. }
  312. </style>
  313. <style scoped>
  314. /* .basic__layout__panel{
  315. padding: 16px 0;
  316. } */
  317. .card__list{
  318. display: flex;
  319. }
  320. .collection{
  321. color: orange !important;
  322. flex-direction: row-reverse;
  323. }
  324. </style>