insertDateDia.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <el-dialog
  3. :visible.sync="isShow"
  4. :close-on-click-modal="false"
  5. :modal-append-to-body='false'
  6. :title="titleMap[info.key]"
  7. @close="cancelHandle"
  8. custom-class="dialog"
  9. center
  10. width="560px"
  11. v-dialogDrag>
  12. <div class="dialog-main">
  13. <!-- 导入系统日期 -->
  14. <ul v-if="info.key==='insert-sys-date'">
  15. <li class="form-item">
  16. <label>导入方式</label>
  17. <el-select
  18. v-model="formData.Source"
  19. placeholder="请选择导入方式"
  20. @change="init('form')"
  21. >
  22. <el-option
  23. v-for="item in wayOptions"
  24. :key="item.value"
  25. :label="item.name"
  26. :value="item.value"
  27. />
  28. </el-select>
  29. <template v-if="formData.Source===3">
  30. <el-select
  31. style="max-width: 120px;margin:0 10px"
  32. v-model="formData.Frequency"
  33. :placeholder="$t('OnlineExcelPage.please_select_frequency')"
  34. @change="formData.Day=frequencyDaysOptions[0].name"
  35. >
  36. <el-option
  37. v-for="item in frequencyOptions"
  38. :key="item.value"
  39. :label="item.name"
  40. :value="item.value"
  41. />
  42. </el-select>
  43. <el-select
  44. style="max-width: 120px;"
  45. v-model="formData.Day"
  46. placeholder="请选择"
  47. >
  48. <el-option
  49. v-for="item in frequencyDaysOptions"
  50. :key="item.name"
  51. :label="item.name"
  52. :value="item.name"
  53. />
  54. </el-select>
  55. </template>
  56. <el-tooltip effect="dark" style="margin-left:10px">
  57. <div
  58. slot="content"
  59. v-html="tips[info.key]"
  60. style="line-height: 20px;"
  61. ></div>
  62. <i class="el-icon-question" style="font-size:18px;"/>
  63. </el-tooltip>
  64. </li>
  65. <template v-if="formData.Source===2">
  66. <li class="form-item">
  67. <label>{{$t('OnlineExcelPage.days_label')}}</label>
  68. <el-input
  69. v-model="formData.CalculateNum"
  70. type="number"
  71. style="margin-right:10px;width:200px"
  72. @change="e => {formData.CalculateNum=Number(e)}"
  73. />
  74. {{formData.CalculateFrequency}}
  75. </li>
  76. <li style="color:#999">{{$t('OnlineExcelPage.example_show_text')}}</li>
  77. </template>
  78. </ul>
  79. <!-- 导入指标日期 -->
  80. <ul v-else>
  81. <li class="form-item">
  82. <selectTarget
  83. :defaultId="search_edb"
  84. :defaultOpt="searchOptions"
  85. ref="selectRef"
  86. @select="e => { selectEdbInfo = e ||{} }"
  87. :filter="false"
  88. />
  89. <el-tooltip effect="dark" style="margin-left:10px">
  90. <div
  91. slot="content"
  92. v-html="tips[info.key]"
  93. style="line-height: 20px;"
  94. ></div>
  95. <i class="el-icon-question" style="font-size:18px;"/>
  96. </el-tooltip>
  97. </li>
  98. <li class="form-item" v-if="selectEdbInfo.Frequency">
  99. <label>{{$t('OnlineExcelPage.update_frequency_label')}}</label>
  100. {{ selectEdbInfo.Frequency }}
  101. </li>
  102. <li class="form-item" v-if="selectEdbInfo.LatestDate">
  103. <label>{{$t('OnlineExcelPage.lastest_date_label')}}</label>
  104. {{ selectEdbInfo.LatestDate }}
  105. </li>
  106. </ul>
  107. </div>
  108. <div class="dia-bot">
  109. <el-button type="primary" style="margin-right:20px" @click="saveInsertHandle">{{$t('ETable.Btn.save_btn')}}</el-button>
  110. <el-button type="primary" plain @click="cancelHandle">{{$t('ETable.Btn.cancel_btn')}}</el-button>
  111. </div>
  112. </el-dialog>
  113. </template>
  114. <script>
  115. import * as sheetInterface from "@/api/modules/sheetApi.js";
  116. import { dataBaseInterface } from '@/api/api.js';
  117. import selectTarget from '@/views/chartRelevance_manage/components/selectTarget.vue'
  118. export default {
  119. props: {
  120. isShow: {
  121. type: Boolean
  122. },
  123. info: {
  124. type: Object
  125. }
  126. },
  127. components: { selectTarget },
  128. watch: {
  129. isShow : {
  130. async handler(nval) {
  131. if(nval && this.info.Value) { //处理日期编辑回显
  132. const valueObj = JSON.parse(this.info.Value);
  133. this.formData = {
  134. ...this.formData,
  135. ...valueObj
  136. }
  137. if(this.info.DataTimeType===2) { //指标日期时获取指标详情
  138. const { Data } = await dataBaseInterface.targetDetail({EdbInfoId: valueObj.EdbInfoId})
  139. const { EdbName,LatestDate,Frequency,EdbInfoId } = Data;
  140. this.selectEdbInfo = { EdbName,LatestDate,Frequency,EdbInfoId }
  141. this.search_edb = valueObj.EdbInfoId;
  142. this.searchOptions = [this.selectEdbInfo];
  143. }
  144. }
  145. }
  146. }
  147. },
  148. computed: {
  149. frequencyDaysOptions() {
  150. let typeMap = {
  151. '本周': [
  152. { name: '周一' },
  153. { name: '周二' },
  154. { name: '周三' },
  155. { name: '周四' },
  156. { name: '周五' },
  157. { name: '周六' },
  158. { name: '周日' },
  159. ]
  160. }
  161. return typeMap[this.formData.Frequency]
  162. ? typeMap[this.formData.Frequency]
  163. : [{name:'第一天'},{name:'最后一天'}]
  164. },
  165. frequencyOptions(){
  166. return [
  167. { name: this.$t('ETable.Date.this_week') , value: '本周' },
  168. { name: this.$t('ETable.Date.this_ten_days') , value: '本旬' },
  169. { name: this.$t('ETable.Date.this_month') , value: '本月' },
  170. { name: this.$t('ETable.Date.this_season') , value: '本季' },
  171. { name: this.$t('ETable.Date.this_half_year') , value: '本半年' },
  172. { name: this.$t('ETable.Date.this_year') , value: '本年' },
  173. ]
  174. },
  175. },
  176. data() {
  177. return {
  178. formData: {
  179. Source: 1,
  180. Frequency: '本周',
  181. Day: '周一',
  182. CalculateNum: 0,
  183. CalculateFrequency: '日'
  184. },
  185. wayOptions: [
  186. { name: '直接导入', value: 1 },
  187. { name: '日期计算', value: 2 },
  188. { name: '指定频率', value: 3 },
  189. ],
  190. search_edb: '',
  191. searchOptions:[],
  192. titleMap: {
  193. 'insert-sys-date': '导入系统日期',
  194. 'insert-edb-date': '导入指标日期'
  195. },
  196. tips: {
  197. 'insert-sys-date': `1、直接导入:直接取系统日期,跟随系统日期更新<br>
  198. 2、日期计算:取系统日期进行公式计算,跟随系统日期更新 <br>
  199. 3、指定频率:取系统日期相关的指定日期,跟随系统日期更新`,
  200. 'insert-edb-date': '取指标的最新日期,跟随指标最新日期更新'
  201. },
  202. selectEdbInfo: {}
  203. }
  204. },
  205. methods:{
  206. // 保存插入信息
  207. async saveInsertHandle() {
  208. if(this.info.key==='insert-edb-date' && !this.selectEdbInfo.EdbInfoId) return this.$message.warning('请选择指标')
  209. let backData = {}
  210. //插入系统日期
  211. if(this.info.key==='insert-sys-date') {
  212. let { Data } = await sheetInterface.getSystemDate({
  213. DataTimeType: 1,
  214. Value: JSON.stringify(this.formData)
  215. })
  216. backData = {
  217. insertValue: Data.Date,
  218. dataTimeType: 1,
  219. str: JSON.stringify(this.formData)
  220. }
  221. }else { //指标日期
  222. backData = {
  223. insertValue: this.selectEdbInfo.LatestDate,
  224. dataTimeType: 2,
  225. str: JSON.stringify({EdbInfoId: this.selectEdbInfo.EdbInfoId})
  226. }
  227. }
  228. this.$emit('insert',backData)
  229. this.cancelHandle()
  230. },
  231. init(type='') {
  232. this.formData = {
  233. Source: this.formData.Source,
  234. Frequency: '本周',
  235. Day: '周一',
  236. CalculateNum: 0,
  237. CalculateFrequency: '日'
  238. }
  239. this.search_edb = '';
  240. this.searchOptions = [];
  241. if(this.$refs.selectRef) this.$refs.selectRef.search_txt='';
  242. if(!type) this.formData.Source = 1;
  243. this.selectEdbInfo = {}
  244. },
  245. cancelHandle() {
  246. this.init()
  247. this.$emit('update:isShow',false)
  248. }
  249. },
  250. }
  251. </script>
  252. <style scoped lang='scss'>
  253. .dialog-main {
  254. padding: 20px;
  255. .form-item {
  256. margin: 15px 0;
  257. display: flex;
  258. align-items: center;
  259. label { width: 80px;flex-shrink: 0; }
  260. }
  261. }
  262. .dia-bot {
  263. margin: 30px 0;
  264. display: flex;
  265. justify-content: center;
  266. }
  267. </style>