write-report.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div id="submit-report-layout-target1" 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="conclusion-name-box ml-2">
  10. <span class="text-cut conclusion-alias text-xl">编写结论、提交报告</span>
  11. <div class="text-cut conclusion-name text-xs">{{ 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 :loading="cancelLoading" @click="cancleSubmit">撤回提交</el-button>
  18. <el-button v-if="isShowSubmit && state !== 2" type="danger" round :loading="subLoading" @click="submissionClick">确认提交</el-button>
  19. <el-button color="#7729F5" round :loading="saveDraftLaod" :disabled="state === 2" @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. v-model="isSubmitReportDrawer" to-id="submit-report-layout-target1"
  36. is-close @close="onSubmitReportDrawerClose"
  37. >
  38. <template #header>
  39. <div class="hc-select-view w-52">
  40. <el-select v-model="pdfDateId" placeholder="选择日期" @change="changePdfDate">
  41. <el-option v-for="item in timeData " :key="item.id" :label="item.approveDate" :value="item.id" />
  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. } else {
  97. window.$message?.error(msg || '操作失败')
  98. }
  99. }
  100. //确认提交
  101. const submissionClick = () => {
  102. SMSAuthShow.value = true
  103. }
  104. const isShowSubmit = ref(false)
  105. const getIsSubmit = async ()=>{
  106. const { error, code, data } = await writeApi.checkSubmit({
  107. projectId: projectId.value,
  108. })
  109. if (!error && code === 200) {
  110. isShowSubmit.value = data
  111. getConclusion()
  112. } else {
  113. isShowSubmit.value = false
  114. }
  115. }
  116. //短信验证
  117. const SMSAuthLoading = ref(false)
  118. const SMSAuthShow = ref(false)
  119. const subLoading = ref(false)
  120. const SMSAuthConfirm = async () => {
  121. SMSAuthShow.value = false
  122. //确认提交调接口
  123. subLoading.value = true
  124. const { error, code, msg } = await writeApi.submitTable({
  125. ...consolusionData.value,
  126. status:2,
  127. })
  128. subLoading.value = false
  129. if (!error && code === 200) {
  130. window.$message.success(msg)
  131. // state.value = 2
  132. getConclusion()
  133. } else {
  134. window.$message?.error(msg || '操作失败')
  135. }
  136. }
  137. const SMSAuthCancel = () => {
  138. SMSAuthShow.value = false
  139. }
  140. //上一步
  141. const previousStep = () => {
  142. router.back()
  143. }
  144. //返回主页
  145. const toBackClick = () => {
  146. router.push({
  147. name: 'transfer-initial-expert',
  148. })
  149. }
  150. //历史报告
  151. const isSubmitReportDrawer = ref(false)
  152. const reportData = ref([])
  153. const timeData = ref([])
  154. const onSubmitReportClick = async () => {
  155. const { data } = await initialgApi.getHistoryTable({
  156. projectId: projectId.value,
  157. })
  158. const res = getArrValue(data)
  159. reportData.value = res
  160. if (res.length >= 0) {
  161. pdfDateId.value = res[0].id
  162. curPdf.value = res[0].tableUrl
  163. tableTitle.value = res[0].tableTitle
  164. isSubmitReportDrawer.value = true
  165. } else {
  166. window.$message?.warning('暂无历史报告')
  167. }
  168. }
  169. const pdfDateId = ref(null)
  170. const curPdf = ref('')
  171. const tableTitle = ref('')
  172. //历史报告
  173. const onSubmitReportDrawerClose = () => {
  174. isSubmitReportDrawer.value = false
  175. curPdf.value = ''
  176. }
  177. const changePdfDate = (val) => {
  178. reportData.value.forEach((ele)=>{
  179. if (ele.id === val) {
  180. curPdf.value = ele.tableUrl
  181. tableTitle.value = ele.tableTitle
  182. }
  183. })
  184. }
  185. const consolusionData = ref({
  186. foreword:'',
  187. generalSituation:'',
  188. questionSuggest:'',
  189. adminCondition :'',
  190. })
  191. const changConsoluData = (val)=>{
  192. consolusionData.value = val
  193. }
  194. //获取结论
  195. const getConclusion = async ()=>{
  196. const { error, code, data } = await initialgApi.getTable({
  197. projectId: projectId.value,
  198. })
  199. if (!error && code === 200) {
  200. consolusionData.value = getObjValue(data)
  201. state.value = data['status']
  202. } else {
  203. consolusionData.value = {
  204. foreword:'',
  205. generalSituation:'',
  206. questionSuggest:'',
  207. adminCondition :'',
  208. }
  209. }
  210. }
  211. //撤回提交
  212. const cancelLoading = ref(false)
  213. const cancleSubmit = async ()=>{
  214. cancelLoading.value = true
  215. const { error, code, data, msg } = await writeApi.repealTable({
  216. id: consolusionData.value.id,
  217. })
  218. cancelLoading.value = false
  219. if (!error && code === 200) {
  220. window.$message.success(msg)
  221. getConclusion()
  222. } else {
  223. window.$message?.error(msg || '操作失败')
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. @import '~style/transfer/scoped/submit-report.scss';
  229. .hc-conclusion-header-box {
  230. position: relative;
  231. display: flex;
  232. align-items: flex-start;
  233. .hc-conclusion-icon-box {
  234. font-size: 28px;
  235. color: var(--el-color-primary);
  236. }
  237. .conclusion-name-box {
  238. flex: auto;
  239. position: relative;
  240. overflow: hidden;
  241. .conclusion-alias {
  242. color: var(--el-color-primary);
  243. }
  244. .conclusion-name {
  245. margin-top: 4px;
  246. color: #838791;
  247. }
  248. }
  249. }
  250. </style>
  251. <style lang="scss">
  252. @import '~style/transfer/submit-report.scss';
  253. </style>