insertDateDia.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <el-dialog
  3. :visible.sync="isShow"
  4. :close-on-click-modal="false"
  5. :modal-append-to-body='false'
  6. :title="$t('ETableChildren.impord_date_title')"
  7. @close="cancelHandle"
  8. custom-class="dialog"
  9. center
  10. width="650px"
  11. v-dialogDrag>
  12. <div class="dialog-main">
  13. <ul>
  14. <li class="form-item">
  15. <el-radio
  16. v-model="dateChangeSelect"
  17. style="margin-right:12px"
  18. :label="2"
  19. >{{$t('ETableChildren.indicator_date_radio')}}</el-radio>
  20. <selectTarget
  21. :defaultId="search_edb"
  22. :defaultOpt="searchOptions"
  23. ref="selectRef"
  24. @select="e => { selectEdbInfo = e ||{} }"
  25. :filter="false"
  26. width="240px"
  27. />
  28. <span v-show="selectEdbInfo.Frequency" style="margin: 0 10px">{{$t('ETableChildren.frequency_lable')}}: {{ selectEdbInfo.Frequency }}</span>
  29. <span v-show="selectEdbInfo.LatestDate">{{$t('OnlineExcelPage.lastest_date_lab')}}: {{ selectEdbInfo.LatestDate }}</span>
  30. </li>
  31. <li class="form-item" style="padding-left:10px">
  32. <label class="el-form-item__label">{{$t('ETableChildren.lagging_period_label')}}</label>
  33. <el-input
  34. v-model="formData.MoveForward"
  35. type="number"
  36. :min="0"
  37. style="margin-right:10px;width:80px"
  38. @change="e => {formData.MoveForward=Number(e)}"
  39. />{{$t('ETableChildren.term_ipt')}}
  40. </li>
  41. <li class="form-item">
  42. <el-radio
  43. v-model="dateChangeSelect"
  44. :label="1"
  45. style="margin-right:12px"
  46. >{{$t('ETableChildren.system_date_rai')}}</el-radio>
  47. <span>{{ $moment().format('YYYY-MM-DD') }}</span>
  48. </li>
  49. <li class="form-item">
  50. <dateMoveWaySec ref="dateMoveWayRef"/>
  51. </li>
  52. </ul>
  53. </div>
  54. <el-popover
  55. placement="top-start"
  56. width="500"
  57. trigger="click">
  58. <p style="padding:20px;line-height:25px;" v-html="tips"/>
  59. <el-button slot="reference" class="tip-label" type="text">{{$t('ETableChildren.formula_explanation_btn')}}</el-button>
  60. </el-popover>
  61. <div class="dia-bot">
  62. <el-button type="primary" style="margin-right:20px" @click="saveInsertHandle">{{$t('Dialog.confirm_btn')}}</el-button>
  63. <el-button type="primary" plain @click="cancelHandle">{{$t('ETable.Btn.cancel_btn')}}</el-button>
  64. </div>
  65. </el-dialog>
  66. </template>
  67. <script>
  68. import * as sheetInterface from "@/api/modules/sheetApi.js";
  69. import { dataBaseInterface } from '@/api/api.js';
  70. import selectTarget from '@/views/chartRelevance_manage/components/selectTarget.vue'
  71. import dateMoveWaySec from './dateMoveWaySection.vue'
  72. export default {
  73. props: {
  74. isShow: {
  75. type: Boolean
  76. },
  77. info: {
  78. type: Object
  79. }
  80. },
  81. components: { selectTarget,dateMoveWaySec },
  82. watch: {
  83. isShow : {
  84. async handler(nval) {
  85. if(nval && this.info.Value) { //处理日期编辑回显
  86. const valueObj = JSON.parse(this.info.Value);
  87. // this.formData = {
  88. // ...this.formData,
  89. // ...valueObj
  90. // }
  91. this.formData = {
  92. MoveForward: valueObj.MoveForward
  93. }
  94. this.dateChangeSelect = this.info.DataTimeType;
  95. if(this.info.DataTimeType===2) { //指标日期时获取指标详情
  96. const { Data } = await dataBaseInterface.targetDetail({EdbInfoId: valueObj.EdbInfoId})
  97. const { EdbName,LatestDate,Frequency,EdbInfoId } = Data;
  98. this.selectEdbInfo = { EdbName,LatestDate,Frequency,EdbInfoId }
  99. this.search_edb = valueObj.EdbInfoId;
  100. this.searchOptions = [this.selectEdbInfo];
  101. }
  102. this.$nextTick(() => {
  103. this.$refs.dateMoveWayRef&&this.$refs.dateMoveWayRef.initData(valueObj.DateChange)
  104. })
  105. }
  106. }
  107. }
  108. },
  109. computed:{
  110. tips(){
  111. return this.$t('ETableChildren.tips_text')
  112. }
  113. },
  114. data() {
  115. return {
  116. formData: {
  117. // Source: 1,
  118. // Frequency: '本周',
  119. // Day: '周一',
  120. // CalculateNum: 0,
  121. // CalculateFrequency: '日'
  122. MoveForward: 0,
  123. },
  124. selectEdbInfo: {},
  125. dateChangeSelect: 2,//日期方式选择 1系统日期 2指标日期
  126. }
  127. },
  128. methods:{
  129. // 保存插入信息
  130. async saveInsertHandle() {
  131. if(this.dateChangeSelect===2 && !this.selectEdbInfo.EdbInfoId) return this.$message.warning('请选择指标')
  132. let backData = {}
  133. //插入系统日期
  134. // if(this.info.key==='insert-sys-date') {
  135. let valueParam = {
  136. EdbInfoId: this.selectEdbInfo.EdbInfoId||0,
  137. MoveForward: this.formData.MoveForward,
  138. DateChange: this.$refs.dateMoveWayRef.dateChangeArr
  139. }
  140. let { Data } = await sheetInterface.getSystemDate({
  141. DataTimeType: this.dateChangeSelect,
  142. Value: JSON.stringify(valueParam)
  143. })
  144. backData = {
  145. insertValue: Data.Date,
  146. dataTimeType: this.dateChangeSelect,
  147. str: JSON.stringify(valueParam)
  148. }
  149. // }else { //指标日期
  150. // backData = {
  151. // insertValue: this.selectEdbInfo.LatestDate,
  152. // dataTimeType: 2,
  153. // str: JSON.stringify({EdbInfoId: this.selectEdbInfo.EdbInfoId})
  154. // }
  155. // }
  156. this.$emit('insert',backData)
  157. this.cancelHandle()
  158. },
  159. init() {
  160. this.formData = {
  161. MoveForward: 0,
  162. }
  163. this.search_edb = '';
  164. this.searchOptions = [];
  165. if(this.$refs.selectRef) this.$refs.selectRef.search_txt='';
  166. this.selectEdbInfo = {}
  167. this.dateChangeSelect = 2;
  168. this.$refs.dateMoveWayRef.initData();
  169. },
  170. cancelHandle() {
  171. this.init()
  172. this.$emit('update:isShow',false)
  173. }
  174. },
  175. }
  176. </script>
  177. <style scoped lang='scss'>
  178. .dialog-main {
  179. padding: 0 20px;
  180. .form-item {
  181. margin: 20px 0;
  182. display: flex;
  183. align-items: center;
  184. label { width: 90px;flex-shrink: 0;text-align: right;}
  185. }
  186. }
  187. .dia-bot {
  188. margin: 30px 0;
  189. display: flex;
  190. justify-content: center;
  191. }
  192. .tip-label {
  193. position: absolute;
  194. bottom: 20px;
  195. right: 20px;
  196. cursor: pointer;
  197. }
  198. </style>