normalBook.vue 13 KB

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