index.vue 13 KB

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