index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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" :exportName="exportName" :exportValue="exportValue" :exporAdd="exporAdd"></excel>
  25. <exportFile :columns="columns" :param="param" :fileName="fileName" v-if="isNewExport" class="inline-16" ></exportFile>
  26. <reportCenter class="inline-16" :btnName="$t('报 表')" 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="getComputedDetailPath(scope.data)" :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,500,1000]"
  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','exportValue','exportName','exporAdd','is_cache'],
  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: (() => { try { return JSON.parse(sessionStorage.getItem('activeApp')).systemappid } catch(e) { return '' } })(),
  143. reportCenterLsit:[]
  144. }
  145. },
  146. methods:{
  147. getComputedDetailPath(data) {
  148. // 如果detailPath是函数,则调用它并传入数据
  149. if (typeof this.detailPath === 'function') {
  150. return this.detailPath(data);
  151. }
  152. // 否则直接返回detailPath对象
  153. return this.detailPath;
  154. },
  155. clearSearch () {
  156. this.$store.state.searchValue = ''
  157. this.listData(this.param.content.pageNumber = 1)
  158. },
  159. async listData () {
  160. this.searchValue?this.param.content.where.condition = this.searchValue:''
  161. if (this.is_cache){
  162. this.param.content.nocache = true
  163. }
  164. this.param.id = this.apiId.query
  165. const res = await this.$api.requested(this.param)
  166. this.list = res.data
  167. this.total = res.total
  168. this.currentPage = res.pageNumber
  169. /* 请求的数据暴露出去 二次处理 */
  170. this.$emit('listData',this.list)
  171. console.log(this.list,'表格数据1*****11111')
  172. // if (!this.list){
  173. // this.listData()
  174. // }
  175. // 保存一下列表数据用于翻页
  176. let isGo = sessionStorage.getItem('isGo')
  177. sessionStorage.setItem('total',res.total)
  178. if (isGo == 1){
  179. }else {
  180. sessionStorage.setItem('listqueryid',res.listqueryid)
  181. this.$store.dispatch('saveListData',{listData:this.list,param:this.param,pageTotal:res.pageTotal})
  182. }
  183. },
  184. selectChange () {
  185. this.param.content.pageNumber = 1
  186. this.param.content.where.status = this.select
  187. this.listData()
  188. },
  189. handleSizeChange(val) {
  190. // console.log(`每页 ${val} 条`);
  191. this.param.content.pageSize = val
  192. this.listData()
  193. },
  194. handleCurrentChange(val) {
  195. // console.log(`当前页: ${val}`);
  196. this.param.content.pageNumber = val
  197. this.listData()
  198. },
  199. checkboxCallBack (val) {
  200. this.selection = val
  201. this.$emit('checkboxCallBack',val)
  202. },
  203. deleteData () {
  204. this.$confirm(this.$t('确定删除这些数据吗') + '?', this.$t('提示'), {
  205. confirmButtonText: this.$t('确定'),
  206. cancelButtonText: this.$t('取消'),
  207. type: 'warning'
  208. }).then(async () => {
  209. let param = {
  210. "id": this.apiId.del,
  211. "content":{}
  212. }
  213. if (this.idName instanceof Array) { //判断传入的类型是多个还是单个idname
  214. let obj = {}
  215. this.idName.forEach(e=>{
  216. obj[e] = ''
  217. })
  218. param.content[`${this.idName[0]}s`] = this.selection.map(e=>{
  219. Object.keys(obj).map((key,item)=>{
  220. obj[key] = e[key]
  221. })
  222. return obj
  223. })
  224. } else {
  225. param.content[`${this.idName}s`] = this.selection.map(e=>{
  226. return e[this.idName]
  227. })
  228. }
  229. const res = await this.$api.requested(param)
  230. this.tool.showMessage(res,()=>{
  231. this.listData()
  232. })
  233. }).catch((err) => {
  234. console.log(err)
  235. this.$message({
  236. type: 'info',
  237. message: this.$t('已取消删除')
  238. });
  239. });
  240. },
  241. onFixedClick (right,left) {
  242. this.fixRightData = right
  243. this.fixLeftData = left
  244. this.$refs['table'].checkFixed()
  245. },
  246. // 筛选列
  247. changeColumn (arr) {
  248. this.tableLayout = arr
  249. this.refreshTable= false
  250. setTimeout(() => {
  251. this.refreshTable= true
  252. }, 0);
  253. },
  254. // 创建快捷应用
  255. async addToAsideBar () {
  256. const res = await this.$api.requested({
  257. "classname": "sysmanage.develop.userauthforweb.userauth",
  258. "method": "create_usershortcuts",
  259. "content": {
  260. "systemappid":this.activeApp.systemappid
  261. }
  262. })
  263. this.$store.dispatch('setAppMenu')
  264. },
  265. showAppCollection () {
  266. let _isSame = this.menuApp.some(m=>this.activeApp.name === m.systemapp)
  267. return _isSame
  268. },
  269. checkRowStatus (status) {
  270. if (this.statusHideDetailBtn) {
  271. let _isSame = this.statusHideDetailBtn.some(m=>status === m)
  272. return !_isSame
  273. } else {
  274. return true
  275. }
  276. },
  277. onHeaderSearch (key,val) {
  278. this.param.content.pageNumber = 1
  279. this.param.content.where.tablefilter[key] = val
  280. this.listData()
  281. },
  282. /* 获取是否有报表数据 */
  283. async getSystemAppid () {
  284. let res = await this.$api.requested({
  285. "id":20221213094401,
  286. "content": {
  287. "systemappid":this.systemappid,
  288. }
  289. })
  290. this.reportCenterLsit = res.data
  291. console.log(res,'报表数据');
  292. },
  293. async printBtn (data,data2) {
  294. /* 报表类型 type = datainfo */
  295. if (!Object.keys(data).length) data[this.idName] = 0
  296. let res = await this.$api.requested({
  297. "id":20221213094501,
  298. "content": {
  299. sys_reportid:data2.sys_reportid,
  300. dataid:data[this.idName]
  301. }
  302. })
  303. this.tool.showMessage(res,() => {
  304. window.open(this.tool.getBaseUrl() + res.data + `&${this.idName}=${data[this.idName]}`)
  305. })
  306. },
  307. clearSearchValue () {
  308. this.$store.dispatch('clearSearchValue')
  309. this.listData(this.param.content.pageNumber = 1)
  310. }
  311. },
  312. watch:{
  313. },
  314. mounted () {
  315. this.autoQuery === false?'':this.listData()
  316. this.isExport !== false ? this.exports = true : this.exports = false
  317. console.log(process.env)
  318. },
  319. created () {
  320. this.$emit('listCreate',this.param)
  321. try {
  322. this.routerName = this.excelTitle?this.excelTitle:this.$route.meta.title
  323. this.layout = this.tool.tabelCol(this.$route.name)[this.tableName].tablecols
  324. this.tableLayout = this.layout
  325. this.getSystemAppid()
  326. } catch (error) {
  327. console.log(error)
  328. }
  329. }
  330. }
  331. </script>
  332. <style>
  333. .layout_search__panel{
  334. align-items: center;
  335. }
  336. .layout-header-panel .el-input-group__append, .el-input-group__prepend{
  337. background-color: #fff !important;
  338. color: #999 !important;
  339. border: 1px solid #dcdfe6 !important;
  340. cursor: pointer;
  341. }
  342. .layout-header-panel .el-input--small .el-input__icon{
  343. height: 32px !important;
  344. }
  345. </style>
  346. <style scoped>
  347. /* .basic__layout__panel{
  348. padding: 16px 0;
  349. } */
  350. .card__list{
  351. display: flex;
  352. }
  353. .collection{
  354. color: orange !important;
  355. flex-direction: row-reverse;
  356. }
  357. .flex-wrap {
  358. flex-wrap: wrap;
  359. }
  360. </style>