index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <!-- -->
  2. <template>
  3. <div>
  4. <el-dropdown @command="handleCommand">
  5. <el-button type="primary" size="mini" @click="createClick">
  6. 开始汇报
  7. </el-button>
  8. <el-dropdown-menu slot="dropdown">
  9. <el-dropdown-item :command="{name:item.reportname,id:item.sys_workreportmodelid}" v-for="(item,index) in modelList" :key="index">{{ item.reportname }}</el-dropdown-item>
  10. </el-dropdown-menu>
  11. </el-dropdown>
  12. <el-drawer
  13. title="创建汇报"
  14. :visible.sync="drawer"
  15. direction="rtl"
  16. :show-close="false"
  17. append-to-body
  18. size="800px">
  19. <div class="drawer__panel" v-if="drawer">
  20. <template v-for="item in detail">
  21. <!-- <div :style="{'display':item.editable ? 'block' : 'none','margin-bottom':'40px'}"> -->
  22. <div :style="{'margin-bottom':'40px'}">
  23. <p class="normal-title" style="margin-bottom:20px">{{ item.title }}</p>
  24. <p ref="content" :contenteditable="item.editable ? true : false" class="content" :style="!item.editable ? 'background:#FAFAFA' : ''">
  25. <template v-for="item2 in item.content">
  26. {{ item2.content }}<br/>
  27. </template>
  28. </p>
  29. </div>
  30. </template>
  31. <upload
  32. ref="upload"
  33. :folderid="folderid"
  34. @onSuccess="onSuccess"
  35. :bindData="bindData"
  36. type="button">
  37. </upload>
  38. </div>
  39. <div class="fixed__btn__panel">
  40. <el-button class="normal-btn-width" :loading="loading" type="primary" size="small" @click="submitForm">创 建</el-button>
  41. <!-- <el-button class="normal-btn-width" size="small" @click="resetForm">重 置</el-button> -->
  42. </div>
  43. </el-drawer>
  44. </div>
  45. </template>
  46. <script>
  47. import upload from '@/SManagement/orderclue/components/upload'
  48. export default {
  49. components:{upload},
  50. data () {
  51. return {
  52. modelList:[],
  53. loading:false,
  54. drawer:false,
  55. detail:'',
  56. currentModel:{},
  57. bindData:{},
  58. folderid:JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
  59. uploadIndex:0,
  60. }
  61. },
  62. methods: {
  63. async getModelList () {
  64. let res = await this.$api.requested({
  65. "id": "20230524091902",
  66. "content": {
  67. },
  68. })
  69. this.modelList = res.data
  70. },
  71. async handleCommand (data) {
  72. this.currentModel = data
  73. console.log(this.currentModel);
  74. this.drawer = true
  75. let res = await this.$api.requested({
  76. "id": "20230523131702",
  77. "content": {
  78. "sys_workreportmodelid": data.id
  79. },
  80. })
  81. this.detail = res.data
  82. this.detail.forEach(item => {
  83. item.content.forEach(item2 => {
  84. if (item.title == '数据统计') return
  85. item2.content = `${item2.rowindex}、${item2.content}`
  86. })
  87. })
  88. console.log(this.detail);
  89. },
  90. createClick () {
  91. if (!this.modelList.length) {
  92. this.$message('暂无汇报模板',{
  93. type:'warning'
  94. })
  95. }
  96. },
  97. async submitForm () {
  98. let result = this.$refs.content.map((item,index) => {
  99. return {
  100. rowindex:index+1,
  101. content:item.innerText
  102. }
  103. })
  104. let copyDetail = JSON.parse(JSON.stringify(this.detail))
  105. copyDetail.forEach((item,index) => {
  106. item.content = [result[index]]
  107. })
  108. let res = await this.$api.requested({
  109. "id": "20230523094702",
  110. "content": {
  111. "sys_workreportmodelid": this.currentModel.id,
  112. "reportname": this.currentModel.reportname, //可以不传,不传时为模板名称
  113. "items": copyDetail
  114. },
  115. })
  116. this.tool.showMessage(res,() => {
  117. this.bindData = {
  118. "ownertable": 'sys_workreport',
  119. "ownerid": res.data.sys_workreportid,
  120. "usetype": 'default',
  121. }
  122. if (!this.$refs.upload.fileList.length) {
  123. this.drawer = false
  124. res.data.name = res.data.createby
  125. this.$emit('onSuccess',res.data)
  126. } else {
  127. this.loading = true
  128. let index = 0
  129. this.$refs['upload'].toUpload(() => {
  130. if (!index) this.uploadIndex = this.$refs.upload.fileList.length
  131. index++
  132. if (this.uploadIndex == index) {
  133. this.loading = false
  134. this.drawer = false
  135. res.data.name = res.data.createby
  136. this.$emit('onSuccess',res.data)
  137. }
  138. })
  139. }
  140. })
  141. console.log(res);
  142. },
  143. onSuccess () {
  144. }
  145. },
  146. created () {
  147. this.getModelList()
  148. },
  149. }
  150. </script>
  151. <style scoped>
  152. /deep/.el-textarea__inner {
  153. border: none !important;
  154. font-size: 12px !important;
  155. }
  156. .normal-title {
  157. font-size: 14px;
  158. font-weight: normal;
  159. }
  160. .content {
  161. font-size:12px;
  162. border: 1px solid #dcdfe6;
  163. border-radius:4px;
  164. padding: 15px 10px;
  165. }
  166. </style>