EditReportBaseInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <script setup>
  2. import moment from "moment"
  3. import { computed, reactive,ref } from "vue"
  4. import ListClassify from './ListClassify.vue'
  5. import apiReportEn from '@/api/reportEn'
  6. import {reportFrequencyOpts} from '@/views/report/utils/config'
  7. import { showToast } from "vant"
  8. import { useRoute } from "vue-router"
  9. import { useWindowSize } from '@vueuse/core'
  10. const { width, height } = useWindowSize()
  11. const route=useRoute()
  12. const props=defineProps({
  13. defaultData:null
  14. })
  15. const emits=defineEmits(['close','confirm'])
  16. // 基本数据
  17. const reportBaseInfo=reactive({
  18. addType:props.defaultData?props.defaultData.addType:1,
  19. classifyName:props.defaultData?props.defaultData.classifyName:[],
  20. author:props.defaultData?props.defaultData.author:['Horizon Insights FICC Team'],
  21. frequency: props.defaultData?props.defaultData.frequency:['日度'],
  22. createtime:props.defaultData?props.defaultData.createtime:moment().format('YYYY-MM-DD'),
  23. title:props.defaultData?props.defaultData.title:'',
  24. abstract:props.defaultData?props.defaultData.abstract:''
  25. })
  26. // 报告新增类型
  27. const showAddTypePop=ref(false)
  28. const addTypeOpts=[
  29. {
  30. value:1,
  31. name:'新增报告'
  32. },
  33. {
  34. value:2,
  35. name:'继承报告'
  36. }
  37. ]
  38. function handleShowAddType(){
  39. // 编辑时不可操作
  40. if(route.path=='/reportEn/edit') return
  41. showAddTypePop.value=true
  42. }
  43. function getAddTypeName(value){
  44. return addTypeOpts.filter(item=>item.value===value)[0].name
  45. }
  46. function selectAddType(e){
  47. reportBaseInfo.addType=e.value
  48. }
  49. // 报告所属分类
  50. const showClassifyPop=ref(false)
  51. const setClassifyVal=computed(()=>{
  52. if(reportBaseInfo.classifyName.length===3){
  53. return `${reportBaseInfo.classifyName[0].text} / ${reportBaseInfo.classifyName[1].text} / ${reportBaseInfo.classifyName[2].text}`
  54. }
  55. return '请选择分类'
  56. })
  57. function handleShowClassify(){
  58. showClassifyPop.value=true
  59. }
  60. function handleConfirmClassify({rootClassify,firstClassify,secondClassify}){
  61. if(!rootClassify||!firstClassify.id||!secondClassify.id){
  62. showToast('请选择分类')
  63. return
  64. }
  65. reportBaseInfo.classifyName=[rootClassify,firstClassify,secondClassify]
  66. reportBaseInfo.title=secondClassify.text
  67. showClassifyPop.value=false
  68. }
  69. // 研报作者
  70. const showAuthorPop=ref(false)
  71. const authorOpts=ref([])
  72. const temAuthorVal=ref([])
  73. function handleShowSelectAuthor(){
  74. temAuthorVal.value=reportBaseInfo.author
  75. showAuthorPop.value=true
  76. }
  77. function handleConfirmAuthor(){
  78. reportBaseInfo.author=temAuthorVal.value
  79. showAuthorPop.value=false
  80. }
  81. function getAuthorOpts(){
  82. apiReportEn.reportAuthorList({}).then(res=>{
  83. if(res.Ret===200){
  84. authorOpts.value=res.Data?.List??[]
  85. }
  86. })
  87. }
  88. getAuthorOpts()
  89. // 报告频度
  90. const showFrequencyPop=ref(false)
  91. const temFrequencyVal=ref(['日度'])
  92. function handleShowFrequency(){
  93. temFrequencyVal.value=reportBaseInfo.frequency
  94. showFrequencyPop.value=true
  95. }
  96. function handleConfirmFrequency(){
  97. reportBaseInfo.frequency=temFrequencyVal.value
  98. showFrequencyPop.value=false
  99. }
  100. // 创建日期
  101. const minDate=new Date(2015, 0, 1)
  102. const defaultDate=ref(new Date())
  103. const showCreateTimePop=ref(false)
  104. function handleShowCreatetime(){
  105. defaultDate.value=new Date(reportBaseInfo.createtime.replace(/-/g,'/'))
  106. showCreateTimePop.value=true
  107. }
  108. function handleConfirmCreatime(e){
  109. reportBaseInfo.createtime=moment(e).format('YYYY-MM-DD')
  110. showCreateTimePop.value=false
  111. }
  112. // 报告标题
  113. const showReportTitlePop=ref(false)
  114. const temReportTitleVal=ref('')
  115. function handleShowReportTitle(){
  116. temReportTitleVal.value=reportBaseInfo.title
  117. showReportTitlePop.value=true
  118. }
  119. function handleConfirmReportTitle(){
  120. reportBaseInfo.title=temReportTitleVal.value
  121. showReportTitlePop.value=false
  122. }
  123. // 摘要
  124. const showReportAbsPop=ref(false)
  125. const temReportAbsVal=ref('')
  126. function handleShowReportAbs(){
  127. temReportAbsVal.value=reportBaseInfo.abstract
  128. showReportAbsPop.value=true
  129. }
  130. function handleConfirmReportAbs(){
  131. reportBaseInfo.abstract=temReportAbsVal.value
  132. showReportAbsPop.value=false
  133. }
  134. function close(){
  135. emits('close')
  136. }
  137. function handleSave(){
  138. emits('confirm',reportBaseInfo)
  139. }
  140. </script>
  141. <template>
  142. <div class="report-baseinfo-wrap">
  143. <van-cell-group>
  144. <van-cell value-class="cell-con" required title="新增方式" :value="getAddTypeName(reportBaseInfo.addType)" :is-link="route.path!='/reportEn/edit'" @click="handleShowAddType"/>
  145. <van-cell value-class="cell-con" required title="分类" :value="setClassifyVal" is-link @click="handleShowClassify"/>
  146. <van-cell value-class="cell-con" title="作者" :value="reportBaseInfo.author.join(',')" is-link @click="handleShowSelectAuthor"/>
  147. <van-cell value-class="cell-con" title="频度" :value="reportBaseInfo.frequency.join('')" is-link @click="handleShowFrequency"/>
  148. <van-cell value-class="cell-con" title="创建时间" :value="reportBaseInfo.createtime" is-link @click="handleShowCreatetime"/>
  149. </van-cell-group>
  150. <van-cell-group style="margin:10px 0">
  151. <van-cell required title="标题" :label="reportBaseInfo.title" is-link @click="handleShowReportTitle"/>
  152. </van-cell-group>
  153. <van-cell-group>
  154. <van-cell required title="摘要" :label="reportBaseInfo.abstract" is-link @click="handleShowReportAbs"/>
  155. </van-cell-group>
  156. <div class="bot-btns">
  157. <van-button class="bot-btn" type="default" @click="close">取消</van-button>
  158. <van-button class="bot-btn" type="primary" @click="handleSave">保存</van-button>
  159. </div>
  160. </div>
  161. <!-- 新增方式 -->
  162. <van-action-sheet
  163. v-model:show="showAddTypePop"
  164. cancel-text="取消"
  165. close-on-click-action
  166. :actions="addTypeOpts"
  167. @select="selectAddType"
  168. />
  169. <!-- 分类 -->
  170. <van-popup
  171. v-model:show="showClassifyPop"
  172. position="bottom"
  173. round
  174. >
  175. <ListClassify
  176. v-if="showClassifyPop"
  177. :defaultVal="reportBaseInfo.classifyName"
  178. :noReset="true"
  179. :firstClassifyDisabled="true"
  180. @close="showClassifyPop=false"
  181. @confirm="handleConfirmClassify"
  182. />
  183. </van-popup>
  184. <!-- 作者 -->
  185. <van-popup
  186. v-model:show="showAuthorPop"
  187. position="bottom"
  188. :style="{ height: '100%' }"
  189. >
  190. <div class="select-author-pop">
  191. <van-checkbox-group v-model="temAuthorVal">
  192. <van-checkbox
  193. v-for="item in authorOpts"
  194. :key="item.Id"
  195. :name="item.ReportAuthor"
  196. >{{item.ReportAuthor}}</van-checkbox>
  197. </van-checkbox-group>
  198. <div class="bot-btns">
  199. <van-button class="bot-btn" type="default" @click="showAuthorPop=false">取消</van-button>
  200. <van-button class="bot-btn" type="primary" @click="handleConfirmAuthor">确定</van-button>
  201. </div>
  202. </div>
  203. </van-popup>
  204. <!-- 报告频度 -->
  205. <van-popup
  206. v-model:show="showFrequencyPop"
  207. position="bottom"
  208. round
  209. >
  210. <van-picker
  211. v-model="temFrequencyVal"
  212. title="选择频度"
  213. :columns="reportFrequencyOpts"
  214. @confirm="handleConfirmFrequency"
  215. @cancel="showFrequencyPop=false"
  216. />
  217. </van-popup>
  218. <!-- 创建日期 -->
  219. <van-popup
  220. v-model:show="showCreateTimePop"
  221. :position="width>650?'center':'bottom'"
  222. :style="width>650?{ width: '400px'}:''"
  223. round
  224. >
  225. <van-calendar
  226. :poppable="false"
  227. :min-date="minDate"
  228. :default-date="defaultDate"
  229. title="选择创建日期"
  230. @confirm="handleConfirmCreatime"
  231. :style="{ height: '500px' }"
  232. />
  233. </van-popup>
  234. <!-- 标题 -->
  235. <van-popup
  236. v-model:show="showReportTitlePop"
  237. position="bottom"
  238. :style="{ height: '100%' }"
  239. >
  240. <div class="input-report-title-pop">
  241. <van-field v-model="temReportTitleVal" placeholder="请输入报告标题" />
  242. <div class="bot-btns">
  243. <van-button class="bot-btn" type="default" @click="showReportTitlePop=false">取消</van-button>
  244. <van-button class="bot-btn" type="primary" :disabled="!temReportTitleVal" @click="handleConfirmReportTitle">确定</van-button>
  245. </div>
  246. </div>
  247. </van-popup>
  248. <!-- 摘要 -->
  249. <van-popup
  250. v-model:show="showReportAbsPop"
  251. position="bottom"
  252. :style="{ height: '100%' }"
  253. >
  254. <div class="input-report-title-pop">
  255. <van-field type="textarea" autosize v-model="temReportAbsVal" placeholder="请输入报告摘要" />
  256. <div class="bot-btns">
  257. <van-button class="bot-btn" type="default" @click="showReportAbsPop=false">取消</van-button>
  258. <van-button class="bot-btn" type="primary" :disabled="!temReportAbsVal" @click="handleConfirmReportAbs">确定</van-button>
  259. </div>
  260. </div>
  261. </van-popup>
  262. </template>
  263. <style lang="scss" scoped>
  264. .report-baseinfo-wrap{
  265. height: 100%;
  266. position: relative;
  267. background: $page-bg-grey;
  268. :deep(.cell-con){
  269. flex: 2;
  270. }
  271. .bot-btns{
  272. position: absolute;
  273. bottom: 48px;
  274. left: 0;
  275. width: 100%;
  276. text-align: center;
  277. }
  278. }
  279. .bot-btn{
  280. width: 315px;
  281. margin: 0 10px;
  282. }
  283. .select-author-pop{
  284. height: 100%;
  285. display: flex;
  286. flex-direction: column;
  287. .van-checkbox-group{
  288. padding: $page-padding;
  289. flex: 1;
  290. overflow-y: auto;
  291. .van-checkbox{
  292. :deep(.van-checkbox__label){
  293. padding: 32px 0;
  294. flex: 1;
  295. border-bottom: 1px solid $border-color;
  296. }
  297. }
  298. }
  299. .bot-btns{
  300. flex-shrink: 0;
  301. padding: 20px 0;
  302. text-align: center;
  303. }
  304. }
  305. .input-report-title-pop{
  306. height: 100%;
  307. display: flex;
  308. flex-direction: column;
  309. justify-content: space-between;
  310. background-color: $page-bg-grey;
  311. .bot-btns{
  312. flex-shrink: 0;
  313. padding: 20px 0;
  314. text-align: center;
  315. }
  316. }
  317. @media screen and (min-width:$media-width){
  318. .report-baseinfo-wrap{
  319. .bot-btns{
  320. bottom: 24px;
  321. }
  322. }
  323. .select-author-pop{
  324. .van-checkbox-group{
  325. padding: $page-padding;
  326. .van-checkbox{
  327. :deep(.van-checkbox__label){
  328. padding: 16px 0;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. </style>