index.vue 16 KB

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