EditStrategyReport.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <script setup>
  2. import moment from "moment"
  3. import { reactive,ref } from "vue"
  4. import apiReportEn from '@/api/reportEn'
  5. import {reportFrequencyOpts} from '@/views/report/utils/config'
  6. import { showToast } from "vant"
  7. const props=defineProps({
  8. defaultData:null
  9. })
  10. const emits=defineEmits(['close','confirm'])
  11. const baseInfo=reactive({
  12. author:props.defaultData?[props.defaultData.Author]:['Horizon Insights FICC Team'],
  13. frequency: props.defaultData?[props.defaultData.Frequency]:['日度'],
  14. createtime:props.defaultData?moment(props.defaultData.CreateTime).format('YYYY-MM-DD'):moment().format('YYYY-MM-DD'),
  15. title:props.defaultData?props.defaultData.Title:'',
  16. abstract:props.defaultData?props.defaultData.Abstract:''
  17. })
  18. // 研报作者
  19. const showAuthorPop=ref(false)
  20. const authorOpts=ref([])
  21. const temAuthorVal=ref([])
  22. function handleShowSelectAuthor(){
  23. temAuthorVal.value=baseInfo.author
  24. showAuthorPop.value=true
  25. }
  26. function handleConfirmAuthor(){
  27. baseInfo.author=temAuthorVal.value
  28. showAuthorPop.value=false
  29. }
  30. function getAuthorOpts(){
  31. apiReportEn.reportAuthorList({}).then(res=>{
  32. if(res.Ret===200){
  33. authorOpts.value=res.Data?.List??[]
  34. }
  35. })
  36. }
  37. getAuthorOpts()
  38. // 报告频度
  39. const showFrequencyPop=ref(false)
  40. const temFrequencyVal=ref(['日度'])
  41. function handleShowFrequency(){
  42. temFrequencyVal.value=baseInfo.frequency
  43. showFrequencyPop.value=true
  44. }
  45. function handleConfirmFrequency(){
  46. baseInfo.frequency=temFrequencyVal.value
  47. showFrequencyPop.value=false
  48. }
  49. // 创建日期
  50. const minDate=new Date(2015, 0, 1)
  51. const defaultDate=ref(new Date())
  52. const showCreateTimePop=ref(false)
  53. function handleShowCreatetime(){
  54. defaultDate.value=new Date(baseInfo.createtime.replace(/-/g,'/'))
  55. showCreateTimePop.value=true
  56. }
  57. function handleConfirmCreatime(e){
  58. baseInfo.createtime=moment(e).format('YYYY-MM-DD')
  59. showCreateTimePop.value=false
  60. }
  61. // 报告标题
  62. const showReportTitlePop=ref(false)
  63. const temReportTitleVal=ref('')
  64. function handleShowReportTitle(){
  65. temReportTitleVal.value=baseInfo.title
  66. showReportTitlePop.value=true
  67. }
  68. function handleConfirmReportTitle(){
  69. baseInfo.title=temReportTitleVal.value
  70. showReportTitlePop.value=false
  71. }
  72. // 摘要
  73. const showReportAbsPop=ref(false)
  74. const temReportAbsVal=ref('')
  75. function handleShowReportAbs(){
  76. temReportAbsVal.value=baseInfo.abstract
  77. showReportAbsPop.value=true
  78. }
  79. function handleConfirmReportAbs(){
  80. baseInfo.abstract=temReportAbsVal.value
  81. showReportAbsPop.value=false
  82. }
  83. function close(){
  84. emits('close')
  85. }
  86. async function handleSave(){
  87. const res=await apiReportEn.strategyReportEdit({
  88. ReportId:props.defaultData.Id,
  89. Title:baseInfo.title,
  90. Abstract:baseInfo.abstract,
  91. Author:baseInfo.author.join(','),
  92. Frequency:baseInfo.frequency[0],
  93. CreateTime:baseInfo.createtime
  94. })
  95. if(res.Ret===200){
  96. showToast('编辑成功')
  97. emits('confirm')
  98. }
  99. }
  100. </script>
  101. <template>
  102. <div class="edit-strategy-report-wrap">
  103. <van-cell-group>
  104. <van-cell value-class="cell-con" required title="分类" :value="defaultData.ClassifyNameFirst+'/'+defaultData.ClassifyNameSecond" />
  105. <van-cell value-class="cell-con" title="作者" :value="baseInfo.author.join(',')" is-link @click="handleShowSelectAuthor"/>
  106. <van-cell value-class="cell-con" title="频度" :value="baseInfo.frequency.join('')" is-link @click="handleShowFrequency"/>
  107. <van-cell value-class="cell-con" title="创建时间" :value="baseInfo.createtime" is-link @click="handleShowCreatetime"/>
  108. </van-cell-group>
  109. <van-cell-group style="margin:10px 0">
  110. <van-cell required title="标题" :label="baseInfo.title" is-link @click="handleShowReportTitle"/>
  111. </van-cell-group>
  112. <van-cell-group>
  113. <van-cell required title="摘要" :label="baseInfo.abstract" is-link @click="handleShowReportAbs"/>
  114. </van-cell-group>
  115. <div class="bot-btns">
  116. <van-button class="bot-btn" type="default" @click="close">取消</van-button>
  117. <van-button class="bot-btn" type="primary" @click="handleSave">保存</van-button>
  118. </div>
  119. </div>
  120. <!-- 作者 -->
  121. <van-popup
  122. v-model:show="showAuthorPop"
  123. position="bottom"
  124. :style="{ height: '100%' }"
  125. >
  126. <div class="select-author-pop">
  127. <van-checkbox-group v-model="temAuthorVal">
  128. <van-checkbox
  129. v-for="item in authorOpts"
  130. :key="item.Id"
  131. :name="item.ReportAuthor"
  132. >{{item.ReportAuthor}}</van-checkbox>
  133. </van-checkbox-group>
  134. <div class="bot-btns">
  135. <van-button class="bot-btn" type="default" @click="showAuthorPop=false">取消</van-button>
  136. <van-button class="bot-btn" type="primary" @click="handleConfirmAuthor">确定</van-button>
  137. </div>
  138. </div>
  139. </van-popup>
  140. <!-- 报告频度 -->
  141. <van-popup
  142. v-model:show="showFrequencyPop"
  143. position="bottom"
  144. round
  145. >
  146. <van-picker
  147. v-model="temFrequencyVal"
  148. title="选择频度"
  149. :columns="reportFrequencyOpts"
  150. @confirm="handleConfirmFrequency"
  151. @cancel="showFrequencyPop=false"
  152. />
  153. </van-popup>
  154. <!-- 创建日期 -->
  155. <van-calendar
  156. :min-date="minDate"
  157. :default-date="defaultDate"
  158. v-model:show="showCreateTimePop"
  159. title="选择创建日期"
  160. @confirm="handleConfirmCreatime"
  161. />
  162. <!-- 标题 -->
  163. <van-popup
  164. v-model:show="showReportTitlePop"
  165. position="bottom"
  166. :style="{ height: '100%' }"
  167. >
  168. <div class="input-report-title-pop">
  169. <van-field v-model="temReportTitleVal" placeholder="请输入报告标题" />
  170. <div class="bot-btns">
  171. <van-button class="bot-btn" type="default" @click="showReportTitlePop=false">取消</van-button>
  172. <van-button class="bot-btn" type="primary" :disabled="!temReportTitleVal" @click="handleConfirmReportTitle">确定</van-button>
  173. </div>
  174. </div>
  175. </van-popup>
  176. <!-- 摘要 -->
  177. <van-popup
  178. v-model:show="showReportAbsPop"
  179. position="bottom"
  180. :style="{ height: '100%' }"
  181. >
  182. <div class="input-report-title-pop">
  183. <van-field type="textarea" autosize v-model="temReportAbsVal" placeholder="请输入报告摘要" />
  184. <div class="bot-btns">
  185. <van-button class="bot-btn" type="default" @click="showReportAbsPop=false">取消</van-button>
  186. <van-button class="bot-btn" type="primary" :disabled="!temReportAbsVal" @click="handleConfirmReportAbs">确定</van-button>
  187. </div>
  188. </div>
  189. </van-popup>
  190. </template>
  191. <style lang="scss" scoped>
  192. .edit-strategy-report-wrap{
  193. height: 100%;
  194. position: relative;
  195. background: $page-bg-grey;
  196. :deep(.cell-con){
  197. flex: 2;
  198. }
  199. .bot-btns{
  200. position: absolute;
  201. bottom: 48px;
  202. left: 0;
  203. width: 100%;
  204. text-align: center;
  205. }
  206. }
  207. .bot-btn{
  208. width: 315px;
  209. margin: 0 10px;
  210. }
  211. .select-author-pop{
  212. height: 100%;
  213. display: flex;
  214. flex-direction: column;
  215. .van-checkbox-group{
  216. padding: $page-padding;
  217. flex: 1;
  218. overflow-y: auto;
  219. .van-checkbox{
  220. :deep(.van-checkbox__label){
  221. padding: 32px 0;
  222. flex: 1;
  223. border-bottom: 1px solid $border-color;
  224. }
  225. }
  226. }
  227. .bot-btns{
  228. flex-shrink: 0;
  229. padding: 20px 0;
  230. text-align: center;
  231. }
  232. }
  233. .input-report-title-pop{
  234. height: 100%;
  235. display: flex;
  236. flex-direction: column;
  237. justify-content: space-between;
  238. background-color: $page-bg-grey;
  239. .bot-btns{
  240. flex-shrink: 0;
  241. padding: 20px 0;
  242. text-align: center;
  243. }
  244. }
  245. </style>