ReleaseReport.vue 13 KB

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