index.vue 17 KB

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