index.vue 13 KB

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