index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div v-if="refreshPage">
  3. <div style="margin:10px 10px 0 10px;border-radius:5px" class="container normal-panel sticky">
  4. <div class="flex-align-center flex-between normal-margin">
  5. <div class="flex-align-center" style="flex:1 0 auto">
  6. <p style="font-size:30px;font-weight:300;margin-right:16px">{{titleText?titleText:'##'}}</p>
  7. <tagTemp v-if="activeApp.isdatatag" style="flex:1" ref="tag" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)" @onSuccess="onSuccess"></tagTemp>
  8. </div>
  9. <div class="flex-align-center">
  10. <cpEdit v-if="tool.checkAuth($route.name,'update')" :formPath="formPath" :oldFormPath="oldFormPath" :data="editData" btnType="default" @onAddSuccess="onSuccess"></cpEdit>
  11. <el-button v-if="tool.checkAuth($route.name,'delete') && delApiId" class="inline-16" size="mini" :disabled="checkDisabled()" @click="deleteData">删 除</el-button>
  12. <div>
  13. <slot name="customOperation"></slot>
  14. </div>
  15. <div v-if="!pageChange">
  16. <el-button :disabled="rowindex === 1" size="mini" icon="el-icon-arrow-left" @click="previous()"></el-button>
  17. <el-button :disabled="rowindex === total" size="mini" @click="next()"><i class="el-icon-arrow-right"></i></el-button>
  18. </div>
  19. </div>
  20. </div>
  21. <div>
  22. <el-descriptions :column="5" size="mini">
  23. <el-descriptions-item label-class-name="my-label-layout" content-class-name="my-content" v-for="item in mainAreaData" :key="item.index" :label="item.label"><span :style="item.style?item.style():''">{{item.value?item.value:'--'}}</span></el-descriptions-item>
  24. </el-descriptions>
  25. </div>
  26. </div>
  27. <div style="box-sizing: border-box;padding:10px">
  28. <el-row class="flex-align-stretch no-wrap" :gutter="10">
  29. <el-col style="flex:1 0 auto;" :span="activeApp.isdatateam?18:activeApp.isdatafollowup?18:24">
  30. <slot name="customBefore"></slot>
  31. <tabTemp :tabs="tabs" :editData="editData" :idname="idname" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)" @onTabClick="onTabClick">
  32. <div :slot="'slot' + index" v-for="(tab,index) in tabs" :key="tab.index">
  33. <slot :name="'slot' + index"></slot>
  34. </div>
  35. </tabTemp>
  36. <slot name="custom"></slot>
  37. </el-col>
  38. <el-col v-if="collapse" style="width:400px;" :span="6">
  39. <group v-if="activeApp.isdatateam" ref="group" style="margin-bottom:10px" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)" @onSuccess="onSuccess">
  40. <el-button slot="collapse" type="text" icon="el-icon-s-unfold" class="inline-16" @click="onCollapse"></el-button>
  41. </group>
  42. <follow-up v-if="activeApp.isdatafollowup" ref="follow" :ownertable="ownertable?ownertable:idname.slice(0, this.idname.length - 2)">
  43. <el-button slot="collapse" type="text" icon="el-icon-s-unfold" class="inline-16" @click="onCollapse"></el-button>
  44. </follow-up>
  45. </el-col>
  46. <div v-else style="text-align-center" class="container normal-panel">
  47. <el-button slot="collapse" type="text" icon="el-icon-s-fold" @click="onCollapse"></el-button>
  48. </div>
  49. </el-row>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import cpEdit from '../modules/cpEdit.vue'
  55. import followUp from './modules/followUp/followUp.vue'
  56. import tagTemp from './modules/tags/tag.vue'
  57. import tabTemp from './modules/tabs/tab.vue'
  58. import group from './modules/group/group.vue'
  59. import {mapGetters} from 'vuex'
  60. export default {
  61. props:['titleText','mainAreaData','turnPageId','delApiId','idname','ownertable','formPath','oldFormPath','editData','tags','tabs','statusCheck','pageChange'],
  62. data () {
  63. return {
  64. routerName:'',
  65. rowindex:0,
  66. total:0,
  67. param:{
  68. "id": '',
  69. "content": {
  70. "isExport":false,
  71. "pageNumber": 1,
  72. "pageSize": 1,
  73. "where": {
  74. "condition": ""
  75. }
  76. }
  77. },
  78. collapse:true,
  79. refreshPage:true
  80. }
  81. },
  82. computed:{
  83. ...mapGetters({
  84. activeApp:"activeApp"
  85. })
  86. },
  87. components:{
  88. cpEdit,
  89. followUp,
  90. group,
  91. tagTemp,
  92. tabTemp
  93. },
  94. methods:{
  95. async queryData (pageNumber) {
  96. this.param.id = this.turnPageId
  97. this.param.content.pageNumber = pageNumber
  98. const res = await this.$api.requested(this.param)
  99. this.total = res.total
  100. this.$emit('pageChange',res.data[0][this.idname],res.data[0].rowindex)
  101. this.$refs['tag']?this.$refs['tag'].queryTag():''
  102. },
  103. next () {
  104. this.rowindex += 1
  105. this.queryData(this.rowindex)
  106. },
  107. previous () {
  108. this.rowindex -= 1
  109. this.queryData(this.rowindex)
  110. },
  111. onSuccess () {
  112. this.$emit('onEditSuccess')
  113. },
  114. deleteData () {
  115. this.$confirm('确定删除当前数据吗?', '提示', {
  116. confirmButtonText: '确定',
  117. cancelButtonText: '取消',
  118. type: 'warning'
  119. }).then(async () => {
  120. let param = {
  121. "id": this.delApiId,
  122. "content":{}
  123. }
  124. if (this.idname instanceof Array) { //判断传入的类型是多个还是单个idname
  125. let obj = {}
  126. this.idname.forEach(e=>{
  127. obj[e] = ''
  128. })
  129. param.content[`${this.idname[0]}s`] = [Object.keys(obj).map((key,item)=>{
  130. obj[key] = this.editData[key]
  131. })]
  132. } else {
  133. param.content[`${this.idname}s`] = [this.editData[this.idname]]
  134. }
  135. const res = await this.$api.requested(param)
  136. this.tool.showMessage(res,()=>{
  137. this.$store.dispatch('changeDetailDrawer',false)
  138. })
  139. }).catch((err) => {
  140. console.log(err)
  141. this.$message({
  142. type: 'info',
  143. message: '已取消删除'
  144. });
  145. });
  146. },
  147. checkDisabled () {
  148. if (this.statusCheck) {
  149. let _isSame = this.statusCheck.some(item=>item.value === this.editData[item.key])
  150. return _isSame
  151. } else {
  152. return false
  153. }
  154. },
  155. onTabClick () {
  156. this.$emit('onTabClick')
  157. },
  158. onCollapse () {
  159. this.collapse?this.collapse = false:this.collapse = true
  160. },
  161. refresh () {
  162. this.refreshPage = false
  163. setTimeout(() => {
  164. this.refreshPage = true
  165. }, 10);
  166. },
  167. refreshTag () {
  168. this.$refs.tag.queryTag()
  169. }
  170. },
  171. mounted () {
  172. },
  173. created () {
  174. this.$emit('detailCreate',this.param)
  175. this.routerName = this.$route.meta.title
  176. this.rowindex = Number(this.$route.query.rowindex)
  177. },
  178. watch:{
  179. mainAreaData () {
  180. this.refresh()
  181. }
  182. }
  183. }
  184. </script>
  185. <style>
  186. .detail__head__label{
  187. display: inline-block;
  188. width: 70px;
  189. }
  190. .my-label-layout{
  191. font-size: 14px;
  192. color: #999;
  193. }
  194. </style>
  195. <style scoped>
  196. .appname{
  197. display: inline;
  198. background: #FA8C19;
  199. color:#fff;
  200. border-radius: 4px;
  201. padding: 2px 10px;
  202. font-size: 12px;
  203. }
  204. .my-tabs{
  205. background:#eeeeee
  206. }
  207. .sticky{
  208. position: sticky;
  209. top:0;
  210. }
  211. .no-wrap{
  212. flex-wrap:nowrap !important;
  213. }
  214. </style>