write-report.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div id="submit-report-layout-target" class="hc-page-box write-report">
  3. <hc-new-card>
  4. <template #header>
  5. <div class="hc-conclusion-header-box">
  6. <div class="hc-conclusion-icon-box">
  7. <HcIcon name="file-ppt-2" fill />
  8. </div>
  9. <div class="ml-2 conclusion-name-box">
  10. <span class="text-xl text-cut conclusion-alias">编写结论、提交报告</span>
  11. <div class="text-xs text-cut conclusion-name">{{ projectInfo.name }}</div>
  12. </div>
  13. </div>
  14. </template>
  15. <template #extra>
  16. <el-button v-if="state === 2" type="success" round @click="onSubmitReportClick">查看验收意见</el-button>
  17. <el-button v-if="state === 2" type="danger" round>撤回提交</el-button>
  18. <el-button v-if="isShowSubmit && state !== 2" type="danger" round @click="submissionClick">确认提交</el-button>
  19. <el-button color="#7729F5" round :loading="saveDraftLaod" @click="officeDraft">暂存草稿</el-button>
  20. <el-button round plain type="danger" @click="previousStep">上一步</el-button>
  21. <el-button type="danger" round plain @click="toBackClick">返回主页</el-button>
  22. </template>
  23. <!-- <HcOnlineOffice
  24. ref="officeRef" :key1="dataKey" :src="docxUrl" title="测试的文档.docx"
  25. :url="saveUrl" :project-id="projectId" :token="token" :user-info="userInfo"
  26. @download="officeDownload"
  27. /> -->
  28. <reportDetail :consolusion-data="consolusionData" :state="state" @change="changConsoluData" />
  29. </hc-new-card>
  30. <!-- 短信认证 -->
  31. <HcSmsAuth :loading="SMSAuthLoading" :show="SMSAuthShow" @cancel="SMSAuthCancel" @confirm="SMSAuthConfirm" />
  32. <!-- 历史报告 -->
  33. <!-- 历史报告 -->
  34. <HcDrawer
  35. :show="isSubmitReportDrawer" to-id="submit-report-layout-target" uis="hc-submit-report-target"
  36. @close="onSubmitReportDrawerClose"
  37. >
  38. <template #header>
  39. <div class="hc-select-view w-52">
  40. <el-select v-model="pdfDate" placeholder="选择日期" @change="changePdfDate">
  41. <el-option v-for="item in timeData " :label="item" :value="item" />
  42. </el-select>
  43. </div>
  44. <div class="hc-title-view">{{ tableTitle }}</div>
  45. </template>
  46. <template #extra>
  47. <el-button type="danger" round plain @click="onSubmitReportDrawerClose">返回主页</el-button>
  48. </template>
  49. <HcPdf
  50. :src="curPdf"
  51. />
  52. </HcDrawer>
  53. </div>
  54. </template>
  55. <script setup>
  56. import { onMounted, ref } from 'vue'
  57. import { useAppStore } from '~src/store'
  58. import { useRouter } from 'vue-router'
  59. import initialgApi from '~api/initial/initial'
  60. import writeApi from '~api/transfer/write-conclusion'
  61. import { getToken } from '~src/api/util/auth'
  62. import reportDetail from './report-detail.vue'
  63. import { arrToKey, getArrValue, getObjValue } from 'js-fast-way'
  64. //变量
  65. const router = useRouter()
  66. const useAppState = useAppStore()
  67. const projectId = ref(useAppState.getProjectId)
  68. const contractId = ref(useAppState.getContractId)
  69. const projectInfo = ref(useAppState.getProjectInfo)
  70. const userInfo = ref(useAppState.getUserInfo)
  71. const token = ref( getToken())
  72. //渲染完成
  73. onMounted(() => {
  74. // setTimeout(() => {
  75. // geDocxUrl()
  76. // }, 1000)
  77. getIsSubmit()
  78. getConclusion()
  79. })
  80. const state = ref(1)
  81. const docxUrl = ref('')
  82. const dataKey = ref('')
  83. const datafile = ref({})
  84. //const docxUrl = ref('https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20230317/e2bdc6581e397b810b46ac7cd71b111b.docx')
  85. //暂存草稿
  86. const saveDraftLaod = ref(false)
  87. const officeDraft = async () => {
  88. saveDraftLaod.value = true
  89. const { error, code, msg } = await writeApi.saveTable({
  90. ...consolusionData.value,
  91. })
  92. saveDraftLaod.value = false
  93. if (!error && code === 200) {
  94. window.$message.success(msg)
  95. getConclusion()
  96. }
  97. }
  98. //确认提交
  99. const submissionClick = () => {
  100. SMSAuthShow.value = true
  101. }
  102. const isShowSubmit = ref(false)
  103. const getIsSubmit = async ()=>{
  104. const { error, code, data } = await writeApi.checkSubmit({
  105. projectId: projectId.value,
  106. })
  107. if (!error && code === 200) {
  108. isShowSubmit.value = data
  109. } else {
  110. isShowSubmit.value = false
  111. }
  112. }
  113. //短信验证
  114. const SMSAuthLoading = ref(false)
  115. const SMSAuthShow = ref(false)
  116. const SMSAuthConfirm = async () => {
  117. SMSAuthShow.value = false
  118. //确认提交调接口
  119. const { error, code, msg } = await writeApi.submitTable({
  120. ...consolusionData.value,
  121. })
  122. if (!error && code === 200) {
  123. window.$message.success(msg)
  124. // state.value = 2
  125. getConclusion()
  126. }
  127. }
  128. const SMSAuthCancel = () => {
  129. SMSAuthShow.value = false
  130. }
  131. //上一步
  132. const previousStep = () => {
  133. router.back()
  134. }
  135. //返回主页
  136. const toBackClick = () => {
  137. router.push({
  138. name: 'transfer-initial-expert',
  139. })
  140. }
  141. //历史报告
  142. const isSubmitReportDrawer = ref(false)
  143. const reportData = ref([])
  144. const timeData = ref([])
  145. const onSubmitReportClick = async () => {
  146. const { error, code, data } = await initialgApi.getHistoryTable({
  147. projectId: projectId.value,
  148. })
  149. if (!error && code === 200) {
  150. reportData.value = getArrValue(data)
  151. const dataString = arrToKey( reportData.value, 'approveDate', ',')
  152. timeData.value = dataString.split(',')
  153. if (timeData.value.length > 0) {
  154. pdfDate.value = timeData.value[0]
  155. curPdf.value = reportData.value[0].tableUrl
  156. tableTitle.value = reportData.value[0].tableTitle
  157. isSubmitReportDrawer.value = true
  158. }
  159. } else {
  160. reportData.value = []
  161. }
  162. }
  163. const pdfDate = ref(null)
  164. const curPdf = ref('')
  165. const tableTitle = ref('')
  166. //历史报告
  167. const onSubmitReportDrawerClose = () => {
  168. isSubmitReportDrawer.value = false
  169. curPdf.value = ''
  170. }
  171. const changePdfDate = (val)=>{
  172. reportData.value.forEach((ele)=>{
  173. if (ele.approveDate === val) {
  174. curPdf.value = ele.tableUrl
  175. tableTitle.value = ele.tableTitle
  176. }
  177. })
  178. }
  179. const consolusionData = ref({
  180. foreword:'',
  181. generalSituation:'',
  182. questionSuggest:'',
  183. adminCondition :'',
  184. })
  185. const changConsoluData = (val)=>{
  186. consolusionData.value = val
  187. }
  188. //获取结论
  189. const getConclusion = async ()=>{
  190. const { error, code, data } = await initialgApi.getTable({
  191. projectId: projectId.value,
  192. })
  193. if (!error && code === 200) {
  194. console.log(data, 'data')
  195. consolusionData.value = getObjValue(data)
  196. state.value = data['status']
  197. } else {
  198. consolusionData.value = {
  199. foreword:'',
  200. generalSituation:'',
  201. questionSuggest:'',
  202. adminCondition :'',
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. @import '~style/transfer/scoped/submit-report.scss';
  209. .hc-conclusion-header-box {
  210. position: relative;
  211. display: flex;
  212. align-items: flex-start;
  213. .hc-conclusion-icon-box {
  214. font-size: 28px;
  215. color: var(--el-color-primary);
  216. }
  217. .conclusion-name-box {
  218. flex: auto;
  219. position: relative;
  220. overflow: hidden;
  221. .conclusion-alias {
  222. color: var(--el-color-primary);
  223. }
  224. .conclusion-name {
  225. margin-top: 4px;
  226. color: #838791;
  227. }
  228. }
  229. }
  230. </style>
  231. <style lang="scss">
  232. @import '~style/transfer/submit-report.scss';
  233. </style>