index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. selectChange () {
  153. this.param.content.pageNumber = 1
  154. this.param.content.where.status = this.select
  155. this.listData()
  156. },
  157. handleSizeChange(val) {
  158. // console.log(`每页 ${val} 条`);
  159. this.param.content.pageSize = val
  160. this.listData()
  161. },
  162. handleCurrentChange(val) {
  163. // console.log(`当前页: ${val}`);
  164. this.param.content.pageNumber = val
  165. this.listData()
  166. },
  167. checkboxCallBack (val) {
  168. this.selection = val
  169. this.$emit('checkboxCallBack',val)
  170. },
  171. deleteData () {
  172. this.$confirm('确定删除这些数据吗?', '提示', {
  173. confirmButtonText: '确定',
  174. cancelButtonText: '取消',
  175. type: 'warning'
  176. }).then(async () => {
  177. let param = {
  178. "id": this.apiId.del,
  179. "content":{}
  180. }
  181. if (this.idName instanceof Array) { //判断传入的类型是多个还是单个idname
  182. let obj = {}
  183. this.idName.forEach(e=>{
  184. obj[e] = ''
  185. })
  186. param.content[`${this.idName[0]}s`] = this.selection.map(e=>{
  187. Object.keys(obj).map((key,item)=>{
  188. obj[key] = e[key]
  189. })
  190. return obj
  191. })
  192. } else {
  193. param.content[`${this.idName}s`] = this.selection.map(e=>{
  194. return e[this.idName]
  195. })
  196. }
  197. const res = await this.$api.requested(param)
  198. this.tool.showMessage(res,()=>{
  199. this.listData()
  200. })
  201. }).catch((err) => {
  202. console.log(err)
  203. this.$message({
  204. type: 'info',
  205. message: '已取消删除'
  206. });
  207. });
  208. },
  209. onFixedClick (right,left) {
  210. this.fixRightData = right
  211. this.fixLeftData = left
  212. this.$refs['table'].checkFixed()
  213. },
  214. // 筛选列
  215. changeColumn (arr) {
  216. this.tableLayout = arr
  217. this.refreshTable= false
  218. setTimeout(() => {
  219. this.refreshTable= true
  220. }, 0);
  221. },
  222. // 创建快捷应用
  223. async addToAsideBar () {
  224. const res = await this.$api.requested({
  225. "classname": "sysmanage.develop.userauthforweb.userauth",
  226. "method": "create_usershortcuts",
  227. "content": {
  228. "systemappid":this.activeApp.systemappid
  229. }
  230. })
  231. this.$store.dispatch('setAppMenu')
  232. },
  233. showAppCollection () {
  234. let _isSame = this.menuApp.some(m=>this.activeApp.name === m.systemapp)
  235. return _isSame
  236. },
  237. checkRowStatus (status) {
  238. if (this.statusHideDetailBtn) {
  239. let _isSame = this.statusHideDetailBtn.some(m=>status === m)
  240. return !_isSame
  241. } else {
  242. return true
  243. }
  244. },
  245. onHeaderSearch (key,val) {
  246. this.param.content.pageNumber = 1
  247. this.param.content.where.tablefilter[key] = val
  248. this.listData()
  249. },
  250. /* 获取是否有报表数据 */
  251. async getSystemAppid () {
  252. let res = await this.$api.requested({
  253. "id":20221213094401,
  254. "content": {
  255. "systemappid":this.systemappid,
  256. }
  257. })
  258. this.reportCenterLsit = res.data
  259. console.log(res,'报表数据');
  260. },
  261. async printBtn (data,data2) {
  262. let res = await this.$api.requested({
  263. "id":20221213094501,
  264. "content": {
  265. sys_reportid:data2.sys_reportid,
  266. dataid:data[this.idName]
  267. }
  268. })
  269. this.tool.showMessage(res,() => {
  270. window.open(this.tool.getBaseUrl() + res.data + `&${this.idName}=${data[this.idName]}`)
  271. })
  272. },
  273. clearSearchValue () {
  274. this.$store.dispatch('clearSearchValue')
  275. this.listData(this.param.content.pageNumber = 1)
  276. }
  277. },
  278. watch:{
  279. },
  280. mounted () {
  281. this.autoQuery === false?'':this.listData()
  282. console.log(process.env)
  283. },
  284. created () {
  285. this.$emit('listCreate',this.param)
  286. try {
  287. this.routerName = this.$route.meta.title
  288. this.layout = this.tool.tabelCol(this.$route.name)[this.tableName].tablecols
  289. this.tableLayout = this.layout
  290. this.getSystemAppid()
  291. } catch (error) {
  292. console.log(error)
  293. }
  294. }
  295. }
  296. </script>
  297. <style>
  298. .layout_search__panel{
  299. align-items: center;
  300. }
  301. .layout-header-panel .el-input-group__append, .el-input-group__prepend{
  302. background-color: #fff !important;
  303. color: #999 !important;
  304. border: 1px solid #dcdfe6 !important;
  305. cursor: pointer;
  306. }
  307. .layout-header-panel .el-input--small .el-input__icon{
  308. height: 32px !important;
  309. }
  310. </style>
  311. <style scoped>
  312. /* .basic__layout__panel{
  313. padding: 16px 0;
  314. } */
  315. .card__list{
  316. display: flex;
  317. }
  318. .collection{
  319. color: orange !important;
  320. flex-direction: row-reverse;
  321. }
  322. </style>