index.vue 12 KB

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