index.vue 6.1 KB

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