TestingReport.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <modal :visible="dialogDaliy" :title="reportHome" :showline="reportHome === `创建提测报告模版` || reportHome === '编辑提测报告模版'?false:true" @close="handleClose">
  3. <div v-if="reportHome === '提测报告' || reportHome === '模版管理' || reportHome === '自定义字段'" class="blueStripe" />
  4. <div v-else class="el-icon-arrow-left report-return didi-hover" @click="reportReturn" />
  5. <el-steps v-if="reportHome === '提测报告'" :active="active" align-center finish-status="success" class="report-steps">
  6. <el-step title="选择模版" />
  7. <el-step title="填写报告" />
  8. <el-step title="发送报告" />
  9. </el-steps>
  10. <modules v-if="showOne" style="min-height: 34vh;" :data="selectTemplate" :report-home="reportHome" :fromradio="fromData.radio" @getFromData="getFromData" @createModule="open_new_template" @deleModule="settingDeleteReportModule" />
  11. <div class="report-leftRight">
  12. <!-- 自定义字段组件 -->
  13. <custom v-if="reportHome === '自定义字段'" ref="custom" :custom="customList" :reporttype="'提测报告'" @content="getCustom" @close="closeCustom" />
  14. <!-- new模版 -->
  15. <newTestingTemplate
  16. v-if="reportHome === `创建提测报告模版` || reportHome === `编辑提测报告模版`"
  17. ref="newReportTemplate"
  18. class="daily"
  19. :custom="customList"
  20. :template-id="templateId"
  21. @getreportTemplate="getreportTemplate"
  22. @reportReturn="reportReturn"
  23. @setCustom="setCustom"
  24. />
  25. <!-- 提测报告 -->
  26. <newTestingTemplate v-if="newDailyTemplate" ref="dailyTemplate" class="daily" :template-id="fromData.radio" :task-ids="daily_taskIds" @SaveNextStep="SaveNextStep" />
  27. <!-- 提测预览 -->
  28. <TestingPreview v-if="dailyPreview" ref="dailyPreview" class="daily" :daily-id="dailyId" @handleClose="handleClose" @loading="loading = false" />
  29. </div>
  30. <div slot="footer" class="dialog-footer" :align="reportHome === `模版管理` || reportHome === `自定义字段` ? 'right' : 'center'">
  31. <div v-if="reportHome === `自定义字段`">
  32. <el-button size="small" @click="closeCustom">取消</el-button>
  33. <el-button size="small" type="primary" @click="$refs.custom.confirmUpload()">确定</el-button>
  34. </div>
  35. <el-button v-if="reportHome === `模版管理`" size="small" type="primary" @click="handleClose">确认</el-button>
  36. <!-- 新建模版 -->
  37. <el-button v-if="reportHome === `创建提测报告模版` || reportHome === `编辑提测报告模版`" size="small" type="primary" @click="created_out()">保存</el-button>
  38. <div v-if="reportHome === `提测报告`">
  39. <!-- 第一步 -->
  40. <el-button v-if="showOne" size="small" type="primary" @click="NextStep()">下一步</el-button>
  41. <!-- 第二步 -->
  42. <el-button v-if="newDailyTemplate" size="small" type="primary" @click="report_return">上一步</el-button>
  43. <el-button v-if="newDailyTemplate" size="small" type="primary" @click="getCreateData">保存, 下一步</el-button>
  44. <!-- 第三步 -->
  45. <el-button v-if="dailyPreview" size="small" type="primary" @click="sendReportReturn">上一步</el-button>
  46. <el-button v-if="dailyPreview" size="small" type="primary" :loading="loading" @click="sendReport">发送</el-button>
  47. </div>
  48. </div>
  49. </modal>
  50. </template>
  51. <script>
  52. import { mapGetters } from 'vuex'
  53. import custom from '@/views/reportManagement/components/Custom'
  54. import { settingQueryReportModuleList, settingDeleteReportModule, reportdelivertestGetReportById } from '@/api/reportTemplate'
  55. import newTestingTemplate from '@/views/reportManagement/Testing/newTestingTemplate.vue'
  56. import TestingPreview from '@/views/reportManagement/Testing/TestingPreview.vue'
  57. import modal from '@/components/modal'
  58. import modules from './template/index.vue'
  59. export default {
  60. components: {
  61. newTestingTemplate,
  62. TestingPreview,
  63. modal,
  64. modules,
  65. custom
  66. },
  67. data() {
  68. return {
  69. customList: [],
  70. temporary: {},
  71. reportHome: '提测报告', // 报告主页
  72. templateId: {}, // 模版id
  73. modelId: '', // 下一步选择的模版id
  74. selectTemplate: [], // 模版option
  75. loading: false,
  76. fromData: {
  77. radio: 1
  78. },
  79. tits: '',
  80. newDailyTemplate: false, // 新建日报模版
  81. dailyPreview: false, // 日报预览
  82. dailyId: '', // 当前创建报告的id
  83. updateDaily: false, // 编辑
  84. dialogDaliy: false,
  85. showOne: true,
  86. active: 1,
  87. daily_taskIds: [] // 选择的任务ID
  88. }
  89. },
  90. computed: {
  91. ...mapGetters(['bizId'])
  92. },
  93. methods: {
  94. async getreportTemplate() { // 获取模版list
  95. const res = await settingQueryReportModuleList({ bizId: this.bizId, type: 1 }) // 1 提测
  96. if (res.code === 200) {
  97. this.$nextTick(() => {
  98. this.selectTemplate = res.data
  99. this.fromData.radio = this.selectTemplate[0].id
  100. })
  101. }
  102. },
  103. init(index, newData) {
  104. this.dialogDaliy = true
  105. switch (index) {
  106. case 1: // 编辑
  107. reportdelivertestGetReportById(newData.id).then(res => {
  108. if (res.code === 200) {
  109. this.fromData.radio = res.data // 选择的模块
  110. this.daily_taskIds = null// 关联任务
  111. this.reportHome = '提测报告' // 步骤条
  112. this.active = 2 // 步骤条状态第三步
  113. this.showOne = false // 隐藏第一步
  114. this.newDailyTemplate = true // 隐藏第二步
  115. this.dailyPreview = false // 展示第三部
  116. this.updateDaily = false // 编辑
  117. }
  118. })
  119. break
  120. case 2: // 编辑
  121. reportdelivertestGetReportById(newData.id).then(res => {
  122. if (res.code === 200) {
  123. this.fromData.radio = res.data // 选择的模块
  124. this.daily_taskIds = null// 关联任务
  125. this.reportHome = '提测报告' // 步骤条
  126. this.active = 2 // 步骤条状态第三步
  127. this.showOne = false // 隐藏第一步
  128. this.newDailyTemplate = true // 隐藏第二步
  129. this.dailyPreview = false // 展示第三部
  130. this.updateDaily = true // 编辑
  131. }
  132. })
  133. break
  134. case 4: // 重新提测
  135. reportdelivertestGetReportById(newData.id).then(res => {
  136. if (res.code === 200) {
  137. this.getreportTemplate()
  138. this.daily_taskIds = res.data.taskIds // 关联任务
  139. this.fromData.radio = res.data // 选择的模块
  140. this.reportHome = '提测报告' // 步骤条
  141. this.active = 2 // 步骤条状态第三步
  142. this.showOne = false // 隐藏第一步
  143. this.newDailyTemplate = true // 隐藏第二步
  144. this.dailyPreview = false // 展示第三部
  145. this.updateDaily = false // 编辑
  146. }
  147. })
  148. break
  149. case 3: // 发送报告
  150. this.getreportTemplate()
  151. this.dailyId = newData.id
  152. this.reportHome = '提测报告' // 步骤条
  153. this.active = 3 // 步骤条状态第三步
  154. this.showOne = false // 隐藏第一步
  155. this.newDailyTemplate = false // 隐藏第二步
  156. this.dailyPreview = true // 展示第三部
  157. break
  158. case 7: // 新建
  159. this.getreportTemplate()
  160. this.fromData.radio = 1
  161. this.daily_taskIds = newData
  162. this.reportHome = '提测报告' // 步骤条
  163. this.active = 1 // 步骤条状态第三步
  164. this.showOne = true // 展示第一步
  165. this.newDailyTemplate = false // 隐藏第二步
  166. this.dailyPreview = false // 隐藏第三部
  167. break
  168. case 'module': // 模版管理
  169. this.getreportTemplate()
  170. this.reportHome = '模版管理'
  171. this.showOne = true
  172. }
  173. },
  174. closeCustom() { // 自定义取消
  175. this.reportHome = this.temporary.name
  176. },
  177. getCustom(arr) { // 自定义确认
  178. console.log(arr, this.temporary, '结果')
  179. this.templateId = { 'from': this.temporary.from, 'name': this.temporary.name === '创建提测报告模版' ? '新建模版' : '编辑模版' }
  180. this.customList = [...arr]
  181. this.reportHome = this.temporary.name
  182. },
  183. setCustom(modules, from) {
  184. this.temporary = { 'name': this.reportHome, 'from': from }
  185. this.customList = [...modules]
  186. this.reportHome = '自定义字段'
  187. },
  188. getFromData(e) {
  189. this.fromData.radio = e
  190. },
  191. created_out() { // 新建模版
  192. // if (this.tits === '模版管理') {
  193. // this.getreportTemplate()
  194. // this.reportHome = '模版管理'
  195. // this.showOne = true
  196. // this.$refs.newReportTemplate.getCreateData(this.templateId)
  197. // } else {
  198. this.$refs.newReportTemplate.getCreateData(this.templateId)
  199. // }
  200. },
  201. report_return() { // 新建模版点击返回
  202. this.reportHome = '提测报告' // 步骤条
  203. this.showOne = true // 模版选择
  204. this.newDailyTemplate = false // 隐藏第二步
  205. this.dailyPreview = false // 隐藏第三步
  206. this.customList = []
  207. this.getreportTemplate()
  208. },
  209. reportReturn() { // 新建模版点击返回
  210. this.reportHome = this.tits // 步骤条
  211. this.showOne = true // 模版选择
  212. this.newDailyTemplate = false // 隐藏第二步
  213. this.dailyPreview = false // 隐藏第三步
  214. this.customList = []
  215. this.getreportTemplate()
  216. },
  217. open_new_template(val, show) { // 点击新建模版
  218. !val ? this.templateId = { 'name': '新建模版', from: this.customList.length === 0 ? {} : this.temporary.from } : this.templateId = { 'name': '编辑模版', 'repot_up': val.id }
  219. this.tits = this.reportHome
  220. if (this.templateId.name === '新建模版') {
  221. this.reportHome = `创建提测报告模版` // 步骤条
  222. this.showOne = false // 模版选择
  223. this.customList = []
  224. } else {
  225. if (val.creator === localStorage.getItem('username') || show) {
  226. this.reportHome = `编辑提测报告模版` // 步骤条
  227. this.showOne = false // 模版选择
  228. } else {
  229. this.$message({ message: '没有权限,请联系创建人执行操作!', type: 'warning', duration: 1000, offset: 150 })
  230. }
  231. }
  232. },
  233. async settingDeleteReportModule(item, show) {
  234. if (item.creator === localStorage.getItem('username') || show) {
  235. const res = await settingDeleteReportModule({ id: item.id }, item.id)
  236. if (res.code === 200) {
  237. this.getreportTemplate()
  238. this.$message({ message: '已删除’', type: 'success', duration: 1000, offset: 150 })
  239. }
  240. } else {
  241. this.$message({ message: '没有权限,请联系创建人执行操作!', type: 'warning', duration: 1000, offset: 150 })
  242. }
  243. },
  244. getCreateData() { // 保存,下一步
  245. this.$refs.dailyTemplate.reportreleaseCreate(this.updateDaily)
  246. },
  247. NextStep() { // 第一步到第二步
  248. this.reportHome = '提测报告' // 步骤条
  249. this.active = 2 // 步骤条状态第二步
  250. this.showOne = false // 隐藏第一步
  251. this.newDailyTemplate = true // 展示第二步
  252. this.dailyPreview = false // 隐藏第三步
  253. },
  254. SaveNextStep(ele) { // 第二步到第三部
  255. this.dailyId = ele.id // 新建报告id
  256. this.reportHome = '提测报告' // 步骤条
  257. this.active = 3 // 步骤条状态第三步
  258. this.showOne = false // 隐藏第一步
  259. this.newDailyTemplate = false // 隐藏第二步
  260. this.dailyPreview = true // 展示第三部
  261. },
  262. async sendReportReturn() { // 第三步返回第二部
  263. const res = await reportdelivertestGetReportById(this.dailyId)
  264. if (res.code === 200) {
  265. this.daily_taskIds = []// 关联任务
  266. this.fromData.radio = res.data // 选择的模块
  267. }
  268. this.reportHome = '提测报告' // 步骤条
  269. this.active = 2 // 步骤条状态第三步
  270. this.showOne = false // 隐藏第一步
  271. this.newDailyTemplate = true // 隐藏第二步
  272. this.dailyPreview = false // 展示第三部
  273. this.updateDaily = true // 编辑
  274. },
  275. sendReport() { // 截图
  276. this.loading = true
  277. this.$refs.dailyPreview.sendReport()
  278. },
  279. handleClose() {
  280. this.loading = false
  281. this.dialogDaliy = false
  282. this.updateDaily = false
  283. this.showOne = false // 隐藏第一步
  284. this.newDailyTemplate = false // 隐藏第二步
  285. this.dailyPreview = false // 展示第三部
  286. this.customList = []
  287. this.$emit('getList')
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="less" scoped>
  293. .report-leftRight {
  294. margin: 0 8%;
  295. /deep/ .el-row .el-col {
  296. margin: 0;
  297. }
  298. }
  299. .titIcon {
  300. width: 4px;
  301. height: 17px;
  302. background: #409EFF;
  303. border-radius: 1px;
  304. }
  305. .el-dialog__header {
  306. padding: 0 !important;
  307. }
  308. .report-dialog {
  309. /deep/.el-dialog__header {
  310. padding: 20px 20px 10px;
  311. border-bottom: 1px solid rgba(238,238,238,1);
  312. opacity:1;
  313. }
  314. /deep/.el-dialog__footer {
  315. padding: 15px 20px;
  316. text-align: right;
  317. border-top: 1px solid rgba(238,238,238,1);
  318. opacity:1;
  319. }
  320. }
  321. .report-return {
  322. font-size: 18px;
  323. position: absolute;
  324. top: 23px;
  325. left: 11px;
  326. }
  327. .report-steps {
  328. margin-bottom: 20px;
  329. font-size:16px;
  330. font-family:PingFang SC;
  331. font-weight:500;
  332. line-height:22px;
  333. color:rgba(51,51,51,1);
  334. opacity:1;
  335. }
  336. </style>