index.vue 7.3 KB

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