index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 v-if="!pageChange">
  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. idx:0
  103. }
  104. },
  105. computed:{
  106. mainAData () {
  107. try {
  108. let data = this.mainAreaData.filter(e=>{
  109. if(e.label !== '备注') {
  110. return e
  111. }
  112. })
  113. return data
  114. } catch (error) {
  115. }
  116. },
  117. mainAData2 () {
  118. try {
  119. let data = this.mainAreaData.filter(e=>{
  120. if(e.label == '备注') {
  121. return e
  122. }
  123. })
  124. return data
  125. } catch (error) {
  126. }
  127. },
  128. ...mapGetters({
  129. activeApp:"activeApp",
  130. svlistData:'svlistData'
  131. })
  132. },
  133. components:{
  134. cpEdit,
  135. followUp,
  136. group,
  137. tagTemp,
  138. tabTemp,
  139. taskTemp,
  140. reportCenter
  141. },
  142. methods:{
  143. async queryData (pageNumber) {
  144. /* 暴露请求配置 进行修改 */
  145. this.$emit('updateParam',this.param)
  146. this.param.id = this.turnPageId
  147. this.param.content.pageNumber = pageNumber
  148. const res = await this.$api.requested(this.param)
  149. this.total = res.total
  150. // this.$emit('pageChange',res.data[0][this.idname],res.data[0].rowindex)
  151. this.$refs['tag']?this.$refs['tag'].queryTag():''
  152. this.refresh()
  153. },
  154. /* 获取是否有报表数据 */
  155. async getSystemAppid () {
  156. let res = await this.$api.requested({
  157. "id":20221213094401,
  158. "content": {
  159. "systemappid":this.systemappid,
  160. }
  161. })
  162. this.reportCenterLsit = res.data
  163. },
  164. async printBtn (data,data2) {
  165. let res = await this.$api.requested({
  166. "id":20221213094501,
  167. "content": {
  168. sys_reportid:data2.sys_reportid,
  169. dataid:data[this.idName]
  170. }
  171. })
  172. this.tool.showMessage(res,() => {
  173. window.open(this.tool.getBaseUrl() + res.data + `&${this.idname}=${data}`)
  174. })
  175. },
  176. next () {
  177. let nowId = this.$route.query.id
  178. let changeId = ''
  179. console.log( this.svlistData.listData)
  180. if ((this.idx + 1) == this.svlistData.listData.length) return this.$message({
  181. message:"已经是当前页最后一条了!",
  182. type:'warning'
  183. })
  184. this.svlistData.listData.forEach((e,index)=>{
  185. if (e[this.idname] == nowId) {
  186. changeId = this.svlistData.listData[index + 1][this.idname]
  187. this.idx = index + 1
  188. }
  189. })
  190. this.$emit('pageChange',changeId,this.idx)
  191. this.refresh()
  192. },
  193. previous () {
  194. let nowId = this.$route.query.id
  195. let changeId = ''
  196. if ((this.idx - 1) < 0) return this.$message({
  197. message:"当前是第一条",
  198. type:'warning'
  199. })
  200. this.svlistData.listData.forEach((e,index)=>{
  201. if (e[this.idname] == nowId) {
  202. changeId = this.svlistData.listData[index - 1][this.idname]
  203. this.idx = index - 1
  204. }
  205. })
  206. this.$emit('pageChange',changeId,this.idx)
  207. this.refresh()
  208. },
  209. onSuccess () {
  210. this.$emit('onEditSuccess')
  211. },
  212. deleteData () {
  213. this.$confirm('确定删除当前数据吗?', '提示', {
  214. confirmButtonText: '确定',
  215. cancelButtonText: '取消',
  216. type: 'warning'
  217. }).then(async () => {
  218. let param = {
  219. "id": this.delApiId,
  220. "content":{}
  221. }
  222. if (this.idname instanceof Array) { //判断传入的类型是多个还是单个idname
  223. let obj = {}
  224. this.idname.forEach(e=>{
  225. obj[e] = ''
  226. })
  227. param.content[`${this.idname[0]}s`] = [Object.keys(obj).map((key,item)=>{
  228. obj[key] = this.editData[key]
  229. })]
  230. } else {
  231. param.content[`${this.idname}s`] = [this.editData[this.idname]]
  232. }
  233. const res = await this.$api.requested(param)
  234. this.tool.showMessage(res,()=>{
  235. this.$store.dispatch('changeDetailDrawer',false)
  236. })
  237. }).catch((err) => {
  238. console.log(err)
  239. this.$message({
  240. type: 'info',
  241. message: '已取消删除'
  242. });
  243. });
  244. },
  245. checkDisabled () {
  246. if (this.statusCheck) {
  247. let _isSame = this.statusCheck.some(item=>item.value === this.editData[item.key])
  248. return _isSame
  249. } else {
  250. return false
  251. }
  252. },
  253. onTabClick () {
  254. this.$emit('onTabClick')
  255. },
  256. onCollapse () {
  257. this.collapse?this.collapse = false:this.collapse = true
  258. },
  259. refresh () {
  260. this.refreshPage = false
  261. setTimeout(() => {
  262. this.refreshPage = true
  263. }, 10);
  264. },
  265. refreshTag () {
  266. this.$refs.tag.queryTag()
  267. },
  268. closeTags() {
  269. this.$refs.tag?this.$refs.tag.closeTag():''
  270. }
  271. },
  272. mounted () {
  273. this.idx = this.$route.query.rowindex
  274. },
  275. created () {
  276. this.$emit('detailCreate',this.param)
  277. this.routerName = this.$route.meta.title
  278. this.rowindex = Number(this.$route.query.rowindex)
  279. this.getSystemAppid()
  280. },
  281. watch:{
  282. mainAreaData () {
  283. // console.log(this.mainAData,'mainAData')
  284. }
  285. }
  286. }
  287. </script>
  288. <style>
  289. .detail__head__label{
  290. display: inline-block;
  291. width: 70px;
  292. }
  293. .my-label-layout{
  294. font-size: 14px;
  295. color: #999;
  296. }
  297. </style>
  298. <style scoped>
  299. .appname{
  300. display: inline;
  301. background: #FA8C19;
  302. color:#fff;
  303. border-radius: 4px;
  304. padding: 2px 10px;
  305. font-size: 12px;
  306. }
  307. .my-tabs{
  308. background:#eeeeee
  309. }
  310. .sticky{
  311. position: sticky;
  312. top:0;
  313. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  314. }
  315. .no-wrap{
  316. flex-wrap:nowrap !important;
  317. }
  318. .main_title{
  319. font-size:30px;
  320. font-weight:300;
  321. margin-right:16px;
  322. line-height: 2rem;
  323. }
  324. </style>