index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div v-if="refreshPage" style="min-width:1200px">
  3. <div style="margin:10px 10px 0 10px;border-radius:5px;position:relative" class="container normal-panel sticky" @click="closeTags">
  4. <div class="flex-align-start flex-between normal-margin" style="flex-wrap:nowrap">
  5. <div>
  6. <p class="main_title mt-10">{{titleText?titleText:'##'}}</p>
  7. <tagTemp v-if="activeApp.isdatatag" ref="tag" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)" @onSuccess="onSuccess" @sysTag="sysTag"></tagTemp>
  8. </div>
  9. <div class="flex-align-center" style="flex: 1 0 auto; justify-content: flex-end;">
  10. <cpEdit v-if="tool.checkAuth($route.name,'update')" :formPath="formPath" :oldFormPath="oldFormPath" :data="editData" btnType="default" @onAddSuccess="onSuccess"></cpEdit>
  11. <!-- 打印 -->
  12. <reportCenter size="mini" position="detail" class="inline-16" :data="reportCenterLsit.filter(item => item.type == 'printinfo')" v-if="reportCenterLsit.filter(item => item.type == 'printinfo').length > 0 && systemappid != 163">
  13. <template v-slot:print="scope2">
  14. <el-button @click="printBtn($route.query.id,scope2.data)" type="text" size="mini">打 印</el-button>
  15. </template>
  16. </reportCenter>
  17. <div>
  18. <slot name="customOperation"></slot>
  19. </div>
  20. <el-button v-if="tool.checkAuth($route.name,'delete') && delApiId" :type="checkDisabled()?'':'primary'" class="inline-16" size="mini" :disabled="checkDisabled()" @click="deleteData">删 除</el-button>
  21. <div v-if="!pageChange">
  22. <el-button size="mini" icon="el-icon-arrow-left" @click="previous()"></el-button>
  23. <el-button size="mini" @click="next()"><i class="el-icon-arrow-right"></i></el-button>
  24. </div>
  25. </div>
  26. </div>
  27. <div>
  28. <slot name="d_head"></slot>
  29. </div>
  30. <div v-show="isTop">
  31. <el-descriptions :column="5" size="mini">
  32. <el-descriptions-item label-class-name="my-label-layout" content-class-name="my-content" v-for="item in mainAData" :key="item.index" :label="item.label">
  33. <span v-if="item.label === '关联应用数据'" @click="onGoto(item,item.index)" :style="item.style?item.style():''">{{item.value !== ''?item.value:'--'}}</span>
  34. <span v-else :style="item.style?item.style():''">{{item.value !== ''?item.value:'--'}}</span>
  35. </el-descriptions-item>
  36. </el-descriptions>
  37. <el-descriptions :column="1" size="mini">
  38. <el-descriptions-item label-class-name="my-label-layout" content-class-name="my-content" v-for="item in mainAData2" :key="item.index" :label="item.label">
  39. <span :style="item.style?item.style():''">{{item.value !== ''?item.value:'--'}}</span>
  40. </el-descriptions-item>
  41. </el-descriptions>
  42. <slot name="headerBottom"></slot>
  43. </div>
  44. <span @click="isTop=!isTop" style="color:#3874f6;position:absolute;right:10px;bottom:10px;cursor: pointer;">
  45. <i :class="isTop ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
  46. {{ isTop ? '收起' : '展开' }}
  47. </span>
  48. </div>
  49. <div style="box-sizing: border-box;padding:10px">
  50. <el-row class="flex-align-stretch no-wrap" :gutter="activeApp.isdatateam?10:activeApp.isdatafollowup?10:0">
  51. <el-col style="flex:1 0 auto;" :span="activeApp.isdatateam?18:activeApp.isdatafollowup?18:24">
  52. <slot name="customBefore"></slot>
  53. <tabTemp :status="status" :tabs="tabs" :editData="editData" :idname="idname" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)" @onTabClick="onTabClick">
  54. <div :slot="'slot' + index" v-for="(tab,index) in tabs" :key="tab.index">
  55. <slot :name="'slot' + index"></slot>
  56. </div>
  57. </tabTemp>
  58. <slot name="custom"></slot>
  59. </el-col>
  60. <el-col v-if="collapse" style="width:400px;" :span="6">
  61. <taskTemp v-if="activeApp.istask" :status="status" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)">
  62. <el-button slot="collapse" type="text" icon="el-icon-s-unfold" class="inline-16" @click="onCollapse"></el-button>
  63. </taskTemp>
  64. <group v-if="activeApp.isdatateam" :status="status" ref="group" style="margin-bottom:10px" :justsaler="justsaler" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)" @onSuccess="onSuccess" @teamList="teamList">
  65. <el-button slot="collapse" type="text" icon="el-icon-s-unfold" class="inline-16" @click="onCollapse"></el-button>
  66. </group>
  67. <follow-up v-if="activeApp.isdatafollowup" :status="status" ref="follow" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)">
  68. <el-button slot="collapse" type="text" icon="el-icon-s-unfold" class="inline-16" @click="onCollapse"></el-button>
  69. </follow-up>
  70. </el-col>
  71. <div v-else style="text-align-center" class="container normal-panel">
  72. <el-button slot="collapse" type="text" icon="el-icon-s-fold" @click="onCollapse"></el-button>
  73. </div>
  74. </el-row>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import cpEdit from '../modules/cpEdit.vue'
  80. import followUp from './modules/followUp/followUp.vue'
  81. import tagTemp from './modules/tags/tag.vue'
  82. import tabTemp from './modules/tabs/tab.vue'
  83. import group from './modules/group/group.vue'
  84. import taskTemp from './modules/task/index.vue'
  85. import reportCenter from '../reportCenter/index'
  86. import {mapGetters} from 'vuex'
  87. export default {
  88. props:['titleText','mainAreaData','turnPageId','delApiId','idname','ownertable','formPath','oldFormPath','editData','tags','tabs','statusCheck','pageChange','justsaler','mainData','status'],
  89. data () {
  90. return {
  91. isTop:true,
  92. routerName:'',
  93. rowindex:0,
  94. total:0,
  95. param:{
  96. "id": '',
  97. "content": {
  98. "isExport":false,
  99. "pageNumber": 1,
  100. "pageSize": 1,
  101. "nocache": true,
  102. "where": {
  103. "condition": ""
  104. }
  105. }
  106. },
  107. collapse:true,
  108. refreshPage:true,
  109. reportCenterLsit:[],
  110. systemappid:JSON.parse(sessionStorage.getItem('activeApp')).systemappid,
  111. }
  112. },
  113. computed:{
  114. mainAData () {
  115. try {
  116. let data = this.mainAreaData.filter(e=>{
  117. if(e.label !== '备注') {
  118. return e
  119. }
  120. })
  121. return data
  122. } catch (error) {
  123. }
  124. },
  125. mainAData2 () {
  126. try {
  127. let data = this.mainAreaData.filter(e=>{
  128. if(e.label == '备注') {
  129. return e
  130. }
  131. })
  132. return data
  133. } catch (error) {
  134. }
  135. },
  136. ...mapGetters({
  137. activeApp:"activeApp",
  138. svlistData:'svlistData'
  139. })
  140. },
  141. components:{
  142. cpEdit,
  143. followUp,
  144. group,
  145. tagTemp,
  146. tabTemp,
  147. taskTemp,
  148. reportCenter
  149. },
  150. methods:{
  151. // async queryData (pageNumber) {
  152. // this.$emit('updateParam',this.param)
  153. // this.param.id = this.turnPageId
  154. // this.param.content.pageNumber = pageNumber
  155. // const res = await this.$api.requested(this.param)
  156. // this.total = res.total
  157. // this.$refs['tag']?this.$refs['tag'].queryTag():''
  158. // this.refresh()
  159. // },
  160. async nextData(param,fn) {
  161. console.log('执行')
  162. this.rowStatus = null
  163. const res = await this.$api.requested(param)
  164. this.$store.dispatch('saveListData',{listData:res.data,param:param,pageTotal:res.pageTotal})
  165. fn?fn():''
  166. },
  167. /* 获取是否有报表数据 */
  168. async getSystemAppid () {
  169. let res = await this.$api.requested({
  170. "id":20221213094401,
  171. "content": {
  172. "systemappid":this.systemappid,
  173. }
  174. })
  175. this.reportCenterLsit = res.data || []
  176. console.log('报表',this.reportCenterLsit);
  177. },
  178. async printBtn (data,data2) {
  179. let res = await this.$api.requested({
  180. "id":20221213094501,
  181. "content": {
  182. sys_reportid:data2.sys_reportid,
  183. dataid:data[this.idName]
  184. }
  185. })
  186. this.tool.showMessage(res,() => {
  187. window.open(this.tool.getBaseUrl() + res.data + `&${this.idname}=${data}`)
  188. })
  189. },
  190. async next () {
  191. const rs = await this.checkPaginationData()
  192. if (rs == 0 && this.svlistData.listData.length == 1) return false
  193. if (rs == 1 && this.svlistData.param.content.pageNumber == this.svlistData.pageTotal) return false
  194. let fun = (rs) =>{
  195. let nowId = this.$route.query.id
  196. let changeId = ''
  197. if (rs == 1) {
  198. changeId = this.svlistData.listData[0][this.idname]
  199. } else {
  200. this.svlistData.listData.forEach((e,index)=>{
  201. if (e[this.idname] == nowId) {
  202. changeId = this.svlistData.listData[index + 1][this.idname]
  203. }
  204. })
  205. }
  206. this.$emit('pageChange',changeId,this.idx)
  207. this.refresh()
  208. }
  209. if (rs == 1) {
  210. this.svlistData.param.content.pageNumber ++
  211. this.nextData(this.svlistData.param,(rs)=>{
  212. fun(1)
  213. })
  214. } else {
  215. fun()
  216. }
  217. },
  218. async previous () {
  219. const res = await this.checkPaginationData()
  220. if (res == 0 && this.svlistData.param.content.pageNumber == 1) return false
  221. const fun = (rs)=>{
  222. let nowId = this.$route.query.id
  223. let changeId = ''
  224. if (rs == 0) {
  225. changeId = this.svlistData.listData[this.svlistData.listData.length - 1][this.idname]
  226. } else {
  227. this.svlistData.listData.forEach((e,index)=>{
  228. if (e[this.idname] == nowId) {
  229. changeId = this.svlistData.listData[index - 1][this.idname]
  230. }
  231. })
  232. }
  233. this.$emit('pageChange',changeId,this.idx)
  234. this.refresh()
  235. }
  236. if (res == 0) {
  237. this.svlistData.param.content.pageNumber --
  238. this.nextData(this.svlistData.param,()=>{
  239. fun(0)
  240. })
  241. } else {
  242. fun()
  243. }
  244. },
  245. onSuccess () {
  246. this.$emit('onEditSuccess')
  247. },
  248. deleteData () {
  249. this.$confirm('确定删除当前数据吗?', '提示', {
  250. confirmButtonText: '确定',
  251. cancelButtonText: '取消',
  252. type: 'warning'
  253. }).then(async () => {
  254. let param = {
  255. "id": this.delApiId,
  256. "content":{}
  257. }
  258. if (this.idname instanceof Array) { //判断传入的类型是多个还是单个idname
  259. let obj = {}
  260. this.idname.forEach(e=>{
  261. obj[e] = ''
  262. })
  263. param.content[`${this.idname[0]}s`] = [Object.keys(obj).map((key,item)=>{
  264. obj[key] = this.editData[key]
  265. })]
  266. } else {
  267. param.content[`${this.idname}s`] = [this.editData[this.idname]]
  268. }
  269. const res = await this.$api.requested(param)
  270. this.tool.showMessage(res,()=>{
  271. this.$store.dispatch('changeDetailDrawer',false)
  272. })
  273. }).catch((err) => {
  274. console.log(err)
  275. this.$message({
  276. type: 'info',
  277. message: '已取消删除'
  278. });
  279. });
  280. },
  281. checkDisabled () {
  282. if (this.statusCheck) {
  283. let _isSame = this.statusCheck.some(item=>item.value === this.editData[item.key])
  284. return _isSame
  285. } else {
  286. return false
  287. }
  288. },
  289. onTabClick () {
  290. this.$emit('onTabClick')
  291. },
  292. onCollapse () {
  293. this.collapse?this.collapse = false:this.collapse = true
  294. },
  295. refresh () {
  296. this.refreshPage = false
  297. setTimeout(() => {
  298. this.refreshPage = true
  299. }, 10);
  300. },
  301. refreshTag () {
  302. this.$refs.tag.queryTag()
  303. },
  304. closeTags() {
  305. this.$refs.tag?this.$refs.tag.closeTag():''
  306. },
  307. checkPaginationData () {
  308. return new Promise((reslove,reject)=>{
  309. let id = this.$route.query.id
  310. let n = 0
  311. this.svlistData.listData.filter((e,index)=>{
  312. if (e[this.idname] == id){
  313. n = index
  314. }
  315. })
  316. if (n == 0) {
  317. reslove(0)
  318. } else if (n == this.svlistData.listData.length - 1) {
  319. reslove(1)
  320. } else {
  321. reslove(-1)
  322. }
  323. })
  324. },
  325. sysTag(val){
  326. this.$emit('sysTag',val)
  327. },
  328. /*任务页面跳转*/
  329. onGoto(row,index){
  330. let path = this.mainData.systemapp[0].apppath_index
  331. let route = this.$route
  332. if (route.path !== path.slice(1)){
  333. this.oldRoute = {path:route.path,query:route.query}
  334. this.$store.dispatch('setHistoryRouter',this.oldRoute)
  335. }
  336. this.$router.push({
  337. path:path,
  338. query:{
  339. id:this.mainData.ownerid,
  340. rowindex:this.mainData.rowindex
  341. }
  342. })
  343. },
  344. /*任务协助人*/
  345. teamList(val){
  346. this.$emit('teamList',val)
  347. }
  348. },
  349. mounted () {
  350. // this.checkPaginationData()
  351. this.idx = this.$route.query.rowindex
  352. },
  353. created () {
  354. this.$emit('detailCreate',this.param)
  355. this.routerName = this.$route.meta.title
  356. this.rowindex = Number(this.$route.query.rowindex)
  357. this.getSystemAppid()
  358. },
  359. watch:{
  360. mainAreaData () {
  361. // console.log(this.mainAData,'mainAData')
  362. // this.checkPaginationData()
  363. }
  364. }
  365. }
  366. </script>
  367. <style>
  368. .detail__head__label{
  369. display: inline-block;
  370. width: 70px;
  371. }
  372. .my-label-layout{
  373. font-size: 14px;
  374. color: #999;
  375. }
  376. </style>
  377. <style scoped>
  378. .appname{
  379. display: inline;
  380. background: #FA8C19;
  381. color:#fff;
  382. border-radius: 4px;
  383. padding: 2px 10px;
  384. font-size: 12px;
  385. }
  386. .my-tabs{
  387. background:#eeeeee
  388. }
  389. .sticky{
  390. position: sticky;
  391. top:0;
  392. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  393. }
  394. .no-wrap{
  395. flex-wrap:nowrap !important;
  396. }
  397. .main_title{
  398. font-size:30px;
  399. font-weight:300;
  400. margin-right:16px;
  401. line-height: 32px;
  402. }
  403. </style>