computedDialog.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. <template>
  2. <el-dialog
  3. :visible.sync="isOpenComputed"
  4. :close-on-click-modal="false"
  5. :modal-append-to-body="false"
  6. @close="cancelHandle"
  7. custom-class="computed-dialog fit-screen-dialog"
  8. center
  9. top="6vh"
  10. v-dialogDrag
  11. >
  12. <div slot="title" style="display: flex; align-items: center">
  13. <img
  14. :src="$icons.computed"
  15. style="color: #fff; width: 16px; height: 16px; margin-right: 5px"
  16. />
  17. <span style="font-size: 16px">{{ title }}</span>
  18. </div>
  19. <div class="dialog-main">
  20. <ul class="add-cont">
  21. <li class="add-li" v-for="(list, index) in addList" :key="index">
  22. <span class="li-tag">{{ list.tag }}</span>
  23. <el-select
  24. v-model="list.target"
  25. v-loadMore="searchLoad"
  26. :filterable="!list.target"
  27. clearable
  28. placeholder="请输入指标名称"
  29. style="width: 400px"
  30. @change="chooseTarget"
  31. @clear="clearHandle(index)"
  32. :disabled="calulateForm.view"
  33. remote
  34. :remote-method="searchTarget"
  35. @click.native="inputFocusHandle"
  36. >
  37. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  38. <el-option
  39. v-for="item in searchOptions"
  40. :key="item.EdbInfoId"
  41. :label="$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  42. :value="item.EdbInfoId"
  43. >
  44. <edbDetailPopover :info="item">
  45. <div slot="reference">{{$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}</div>
  46. </edbDetailPopover>
  47. </el-option>
  48. </el-select>
  49. <i class="el-icon-tickets" style="color:#409EFF;font-size:18px" @click="$emit('lookHistory',list.target)" v-if="list.target"/>
  50. <i
  51. class="el-icon-error del-tag"
  52. v-if="index > 3 && !calulateForm.view"
  53. @click="delTarget(index)"
  54. />
  55. <span :class="{
  56. 'target-date': true,
  57. 'newest': list.end_date===newestDate
  58. }" v-if="list.start_date">{{
  59. `${list.start_date}至${list.end_date}`
  60. }}</span>
  61. </li>
  62. </ul>
  63. <span class="add-icon" @click="addTargetHandle" v-if="!calulateForm.view">
  64. <i
  65. class="el-icon-circle-plus-outline"
  66. style="color: #5882ef; font-size: 16px"
  67. />
  68. 添加更多参数
  69. </span>
  70. <div class="computed-min">
  71. <div class="computed-section" v-if="edbSource !== 'predict'">
  72. <div>
  73. <label class="label">生成指标时间序列</label>
  74. <div style="width:200px;display: inline-block;">
  75. <el-cascader
  76. v-model="selectTimeSeriesVal"
  77. style="width:100%"
  78. :options="timeSeriesOpt"
  79. :props="{emitPath:false}"
  80. :show-all-levels="false"
  81. placeholder="请选择"
  82. :disabled="calulateForm.view"
  83. ></el-cascader>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="computed-section">
  88. <div>
  89. <label class="label">空值处理
  90. <el-tooltip placement="top">
  91. <div slot="content" v-html="formTips['null-val']" style="width:300px;line-height:20px;"/>
  92. <i class="el-icon-question"/>
  93. </el-tooltip>
  94. </label>
  95. <el-select
  96. v-model="nullValueForm.nullValueWay"
  97. placeholder="请选择"
  98. :disabled="calulateForm.view"
  99. >
  100. <el-option
  101. v-for="item in nullWayOptions"
  102. :key="item.value"
  103. :label="item.label"
  104. :value="item.value"
  105. >
  106. </el-option>
  107. </el-select>
  108. </div>
  109. <div style="margin-left: 120px" v-if="showMaxNullDeal">
  110. <label class="label">MAX、MIN空值处理
  111. <el-tooltip placement="top">
  112. <div slot="content" v-html="formTips['max-null-val']" style="width:300px;line-height:20px;"/>
  113. <i class="el-icon-question"/>
  114. </el-tooltip>
  115. </label>
  116. <el-select
  117. v-model="nullValueForm.maxNullWay"
  118. placeholder="请选择"
  119. :disabled="calulateForm.view"
  120. >
  121. <el-option label="等于0" :value="1" />
  122. <el-option label="跳过空值" :value="2" />
  123. </el-select>
  124. </div>
  125. </div>
  126. <div class="computed-section">
  127. <label class="label">计算公式
  128. <el-tooltip placement="top">
  129. <div slot="content" v-html="formTips['formula']" style="width:300px;line-height:20px;"/>
  130. <i class="el-icon-question"/>
  131. </el-tooltip>
  132. </label>
  133. <!-- <el-input placeholder="请输入公式" v-model="formula" clearable :disabled="calulateForm.view">
  134. </el-input> -->
  135. <ul class="formula-list">
  136. <li style="margin-bottom: 15px;">
  137. <el-input placeholder="请输入公式" v-model="formulaList[0].formula" clearable :disabled="calulateForm.view" style="width: 600px"/>
  138. <span v-if="formulaDateArr.length" class="date-section-text">{{formulaDateArr[formulaDateArr.length-1]}}(含)之后</span>
  139. <span class="example-txt">公式示例:A*0.5+B*C*1.2+120-MAX(A,B,C) &nbsp;函数支持:MAX(),MIN(),ln(A),log(a,A),abs(),exp(),pow(),round()</span>
  140. </li>
  141. <li class="formula-item" v-for="(item,index) in formulaList.slice(1)" :key="index+1">
  142. <el-input
  143. placeholder="请输入公式"
  144. v-model="item.formula"
  145. clearable
  146. :disabled="calulateForm.view"
  147. style="width: 220px"
  148. />
  149. <el-date-picker
  150. v-model="item.date"
  151. type="date"
  152. value-format="yyyy-MM-dd"
  153. style="margin: 0 10px;width: 220px"
  154. placeholder="选择日期"
  155. :disabled="calulateForm.view"
  156. @change="selectFormulaDate($event,item)"
  157. />
  158. <i class="el-icon-circle-close" style="font-size:20px;" v-if="!calulateForm.view" @click="removeFormulaItem(index+1)"/>
  159. <template v-if="formulaDateArr.length&&item.date">
  160. <span v-if="item.date===formulaDateArr[0]" class="date-section-text">{{formulaDateArr[0]}}之前</span>
  161. <span v-else class="date-section-text">{{formulaDateArr[formulaDateArr.findIndex(_ =>_ ===item.date)-1]}}(含)——{{item.date}}</span>
  162. </template>
  163. </li>
  164. </ul>
  165. </div>
  166. <el-button
  167. v-if="!calulateForm.view"
  168. icon="el-icon-plus"
  169. style="margin-left:70px;"
  170. @click="addFormulaHandle"
  171. >新增分段</el-button>
  172. </div>
  173. <el-form
  174. ref="diaForm"
  175. label-position="right"
  176. inline
  177. label-width="80px"
  178. :model="formData"
  179. :rules="formRules"
  180. :disabled="calulateForm.view"
  181. >
  182. <el-form-item label="指标名称" prop="targetName">
  183. <el-input
  184. v-model="formData.targetName"
  185. style="width: 340px"
  186. placeholder="请输入指标名称"
  187. />
  188. </el-form-item>
  189. <el-form-item label="单位" prop="unit">
  190. <selectUnit v-model="formData.unit" style="width: 340px" />
  191. </el-form-item>
  192. <el-form-item label="指标目录" prop="menu">
  193. <el-cascader
  194. v-model="formData.menu"
  195. :options="options"
  196. :props="levelProps"
  197. clearable
  198. placeholder="请选择指标目录"
  199. />
  200. </el-form-item>
  201. <el-form-item label="频度" prop="frequency">
  202. <el-select
  203. v-model="formData.frequency"
  204. placeholder="请选择频率"
  205. style="width: 340px"
  206. clearable
  207. >
  208. <el-option
  209. v-for="item in frequencyArr"
  210. :key="item"
  211. :label="item"
  212. :value="item"
  213. >
  214. </el-option>
  215. </el-select>
  216. </el-form-item>
  217. </el-form>
  218. </div>
  219. <div class="dia-bot" v-if="!calulateForm.view">
  220. <el-button
  221. type="primary"
  222. style="margin-right: 20px"
  223. @click="saveHandle"
  224. :loading="dataloading"
  225. v-if="title==='计算指标'"
  226. >生成计算指标</el-button
  227. >
  228. <el-button
  229. type="primary"
  230. style="margin-right: 20px"
  231. @click="saveHandle"
  232. v-else
  233. >保存</el-button
  234. >
  235. <el-button type="primary" plain @click="cancelHandle('cancel')">取消</el-button>
  236. </div>
  237. <el-popover
  238. placement="top-start"
  239. width="360"
  240. trigger="click">
  241. <p style="padding:30px;line-height:25px;" v-html="$parent.tips.get(type)"/>
  242. <span slot="reference" class="tip-label">公式说明</span>
  243. </el-popover>
  244. </el-dialog>
  245. </template>
  246. <script>
  247. import { dataBaseInterface } from '@/api/api.js';
  248. import * as preDictEdbInterface from '@/api/modules/predictEdbApi.js';
  249. import { formRules } from '../databaseComponents/util';
  250. import { unitArr } from '@/utils/defaultOptions';
  251. import {generateSeriesArray} from './util'
  252. const MAXEDBNUM=50//最大可添加的指标数量
  253. const tag_arr = generateSeriesArray();
  254. // for(let i=0;i<26;i++) tag_arr.push(String.fromCharCode(65+i));
  255. export default {
  256. name: '',
  257. props: {
  258. isOpenComputed: {
  259. type: Boolean,
  260. },
  261. title: {
  262. type: String,
  263. default: '计算指标',
  264. },
  265. calulateForm: {
  266. type: Object,
  267. },
  268. calulateList: {
  269. type: Array,
  270. },
  271. edbSource: { // ''||'predict'
  272. type: String,
  273. default: ''
  274. }
  275. },
  276. computed: {
  277. type() {
  278. return this.edbSource ? 31 : 4;
  279. },
  280. /* max空值处理显示 当输入的公式包含MAX、MIN且空值处理为0时,输入公式失焦后出现右侧选项; */
  281. showMaxNullDeal() {
  282. let haveMaxOrMin = this.formulaList.some(_ => _.formula.toUpperCase().includes('MAX') || _.formula.toUpperCase().includes('MIN'))
  283. return haveMaxOrMin && this.nullValueForm.nullValueWay===4
  284. },
  285. formulaDateArr() {
  286. return this.formulaList.map(_ => _.date).filter(_ => _).sort((a,b) => new Date(a)-new Date(b))
  287. },
  288. timeSeriesOpt(){
  289. const arr=[
  290. {
  291. label:'指定指标时间序列',
  292. value:'0',
  293. children:[]
  294. },
  295. {
  296. label:'所有指标时间序列并集',
  297. value:'all',
  298. }
  299. ]
  300. arr[0].children=this.addList.filter(item=>item.target).map(item=>{
  301. return {
  302. label:`指标${item.tag}`,
  303. value:item.tag
  304. }
  305. })
  306. return arr
  307. }
  308. },
  309. watch: {
  310. isOpenComputed(newval) {
  311. newval && this.getMenu();
  312. // newval && this.searchTarget('');
  313. /* 回显 */
  314. if (this.calulateList.length && newval) {
  315. this.addList = _.cloneDeep(this.calulateList);
  316. this.formulaList = JSON.parse(this.calulateForm.formula).map(_ => ({
  317. formula: _.f,
  318. date: _.d||''
  319. }));
  320. this.formData = {
  321. targetName: this.calulateForm.targetName,
  322. unit: this.calulateForm.unit,
  323. menu: this.calulateForm.menu,
  324. frequency: this.calulateForm.frequency,
  325. };
  326. this.nullValueForm = {
  327. nullValueWay: this.calulateForm.emptyType,
  328. maxNullWay: this.calulateForm.maxEmptyType,
  329. }
  330. this.searchOptions = this.calulateList.map(item => ({
  331. EdbInfoId: item.target,
  332. EdbName: item.edb_name,
  333. }))
  334. if(this.calulateForm.Extra){
  335. const ExtraObj=JSON.parse(this.calulateForm.Extra)
  336. this.selectTimeSeriesVal=ExtraObj.DateTag
  337. }
  338. this.getNewestDate();
  339. }
  340. },
  341. 'addList':{
  342. handler(n){
  343. if(this.selectTimeSeriesVal=='all') return
  344. const arr=this.addList.filter(item=>item.target).map(item=>{
  345. return {
  346. label:`指标${item.tag}`,
  347. value:item.tag
  348. }
  349. })
  350. if(!arr.length) return
  351. if(!this.selectTimeSeriesVal){
  352. this.selectTimeSeriesVal=arr[0].value
  353. }else{//已经有选择的值了
  354. let flag=false
  355. arr.forEach(item=>{
  356. if(item.value==this.selectTimeSeriesVal){
  357. flag=true
  358. }
  359. })
  360. if(!flag){
  361. this.selectTimeSeriesVal=arr[0].value
  362. }
  363. }
  364. },
  365. deep:true
  366. }
  367. },
  368. data() {
  369. return {
  370. options: [],
  371. levelProps: {
  372. label: 'ClassifyName',
  373. value: 'ClassifyId',
  374. children: 'Children',
  375. checkStrictly: true
  376. },
  377. frequencyArr: ['日度', '周度','旬度','月度', '季度', '年度'],
  378. formRules,
  379. unitArr,
  380. addList: [
  381. {
  382. tag: tag_arr[0],
  383. target: '',
  384. start_date: '',
  385. end_date: '',
  386. },
  387. {
  388. tag: tag_arr[1],
  389. target: '',
  390. start_date: '',
  391. end_date: '',
  392. },
  393. {
  394. tag: tag_arr[2],
  395. target: '',
  396. start_date: '',
  397. end_date: '',
  398. },
  399. {
  400. tag: tag_arr[3],
  401. target: '',
  402. start_date: '',
  403. end_date: '',
  404. },
  405. ],
  406. searchOptions: [],
  407. formula: '', //计算公式
  408. formulaList: [ //公式数组
  409. { formula: '', }
  410. ],
  411. dataloading: false,
  412. formData: {
  413. targetName: '',
  414. unit: '',
  415. menu: '',
  416. frequency: '',
  417. },
  418. search_have_more: false,
  419. search_page: 1,
  420. current_search:'',
  421. newestDate: '',
  422. nullValueForm: {
  423. nullValueWay: 0,
  424. maxNullWay: 1
  425. },//空值处理
  426. nullWayOptions: [
  427. { label: '查找前后35天最近值',value: 0 },
  428. { label: '不计算',value: 1 },
  429. { label: '前值填充',value: 2 },
  430. { label: '后值填充',value: 3 },
  431. { label: '等于0',value: 4 },
  432. ],
  433. selectTimeSeriesVal:'',
  434. formTips: {
  435. 'null-val': `1、查找前后35天最近值:在参与计算的日期序列上某指标无值时,该指标往前/往后找距离最近的值作为当天的值进行计算,遍历允许跨年,往前最多35天,往后最多35天<br>
  436. 2、不计算:只要有一个指标在某个日期没有值(即空值),则计算指标在该日期没有值 <br>
  437. 3、前值填充:空值优先以最近的前值填充,没有前值时,用后值填充 <br>
  438. 4、后值填充:空值优先以最近的后值填充,没有前值时,用后值填充 <br>
  439. 5、等于0:空值以0值参与计算 <br>
  440. 注意:此处缺失值的处理,作用于数据全部时间段`,
  441. 'max-null-val': `MAX、MIN公式中指标存在空值时按如下规则处理:<br>
  442. 1、等于0,空值用0参与计算;<br>
  443. 2、跳过空值,去除空值指标,剩余指标进行计算,若该日期所有指标均为空值,则该日期无值;`,
  444. 'formula':`1、支持新增分段,实现不同分段使用不同的计算公式,若未新增分段,则所有日期序列用统一公式计算<br>
  445. 2、新增分段需配置新公式和时间节点,在时间节点之前(不含)使用新公式,在时间节点之后(含)使用已配置公式,每个分段公式支持修改<br>
  446. 3、分段时间节点不允许重复,不允许超出第一个指标的日期区间`
  447. }
  448. };
  449. },
  450. methods: {
  451. /* 获取目录结构 */
  452. async getMenu() {
  453. const res = this.edbSource === 'predict'
  454. ? await preDictEdbInterface.classifyListV2()
  455. : await dataBaseInterface.menuListV3()
  456. if (res.Ret !== 200) return
  457. this.filterNodes(res.Data.AllNodes||[]);
  458. this.options = res.Data.AllNodes || [];
  459. },
  460. // 递归改变第三级目录结构
  461. filterNodes(arr) {
  462. arr.length &&
  463. arr.forEach((item) => {
  464. item.Children.length && this.filterNodes(item.Children);
  465. if (!item.Children.length) {
  466. delete item.Children;
  467. }
  468. });
  469. },
  470. /* 添加额外的指标列 */
  471. addTargetHandle() {
  472. const MAXNUM=this.edbSource === 'predict'?26:MAXEDBNUM
  473. if(this.addList.length >=MAXNUM) return this.$message.warning('添加指标个数已达上限')
  474. let tag = this.addList[this.addList.length-1].tag;
  475. let index = tag_arr.findIndex(item => item === tag);
  476. const item = {
  477. tag: tag_arr[index+1],
  478. target: '',
  479. start_date: '',
  480. end_date: ''
  481. };
  482. this.addList.push(item);
  483. },
  484. /* 搜索指标 */
  485. searchTarget(query) {
  486. this.search_page = 1;
  487. this.current_search = query;
  488. this.searchApi(this.current_search);
  489. },
  490. /* 聚焦获取当前检索 */
  491. inputFocusHandle(e) {
  492. this.search_page = 1;
  493. this.current_search = e.target.value;
  494. this.searchApi(this.current_search);
  495. },
  496. async searchApi(query,page=1) {
  497. const res = this.edbSource === 'predict'
  498. ? await preDictEdbInterface.edbSearch({
  499. Keyword: query,
  500. CurrentIndex: page,
  501. FilterSource: this.type === 45 ? 3 : this.type === 66 ? 6 : 1,
  502. Frequency: this.type===64?'季度': ''
  503. })
  504. : await dataBaseInterface.targetSearchByPage({
  505. KeyWord:query,
  506. CurrentIndex: page,
  507. FilterSource: this.type === 14 ? 3 : this.type === 63 ? 6 : 1,
  508. Frequency: this.type===61?'季度': ''
  509. })
  510. if(res.Ret !== 200) return
  511. const { List,Paging } = res.Data;
  512. this.search_have_more = page < Paging.Pages;
  513. this.searchOptions = page === 1 ? List : this.searchOptions.concat(List);
  514. },
  515. searchLoad() {
  516. if(!this.search_have_more) return;
  517. this.searchApi(this.current_search,++this.search_page)
  518. },
  519. /* 选中指标 显示开始日期结束日期 */
  520. chooseTarget(val) {
  521. if (val) {
  522. const choose_obj = this.searchOptions.find(
  523. (item) => item.EdbInfoId === val
  524. );
  525. this.addList.forEach((list) => {
  526. if (list.target === val) {
  527. list.start_date = choose_obj.StartDate;
  528. list.end_date = choose_obj.EndDate;
  529. this.getNewestDate();
  530. }
  531. });
  532. }
  533. },
  534. /* 获取所选日期最早日期 */
  535. getNewestDate() {
  536. let dateArr = this.addList.filter(_ => _.end_date).map(_ => new Date(_.end_date).getTime())
  537. let earliestDate = Math.min(...dateArr);
  538. let sameDateArr = dateArr.filter(_ => _===earliestDate)
  539. if(dateArr.length === 1 || sameDateArr.length===dateArr.length) {
  540. this.newestDate = '';
  541. return
  542. }
  543. this.newestDate = this.$moment(Math.min(...dateArr)).format('YYYY-MM-DD');
  544. },
  545. /* 清空指标和关联日期 */
  546. clearHandle(index) {
  547. this.addList[index].start_date = '';
  548. this.addList[index].end_date = '';
  549. this.getNewestDate();
  550. },
  551. // 删除指标
  552. delTarget(index) {
  553. this.addList.splice(index, 1);
  554. this.getNewestDate();
  555. },
  556. async saveHandle() {
  557. if (!this.formulaList[0].formula) return this.$message.warning('计算公式不能为空');
  558. await this.$refs.diaForm.validate();
  559. // 指标id数组
  560. let EdbInfoIdArr = this.addList.filter((item) => item.target).map((item) => ({
  561. EdbInfoId: item.target,
  562. FromTag: item.tag,
  563. }));
  564. let formulaArr = this.formulaList
  565. .filter((_,index) => index===0||(index>0&&_.formula&&_.date))
  566. .map(_ => ({f: _.formula,d: _.date}))
  567. const { nullValueWay,maxNullWay } = this.nullValueForm;
  568. let params = {
  569. CalculateFormula: JSON.stringify(formulaArr),
  570. ClassifyId: this.formData.menu[this.formData.menu.length - 1] || 0,
  571. EdbName: this.formData.targetName,
  572. Frequency: this.formData.frequency,
  573. Unit: this.formData.unit,
  574. EdbInfoIdArr,
  575. EmptyType: nullValueWay,
  576. MaxEmptyType: maxNullWay,
  577. Extra:JSON.stringify({
  578. DateTag:this.selectTimeSeriesVal
  579. })
  580. };
  581. this.dataloading = true;
  582. let res;
  583. if(this.edbSource === 'predict') {
  584. res = await preDictEdbInterface.calculateEdbSave(this.calulateForm.edb_id ? {...params,EdbInfoId:this.calulateForm.edb_id } : params)
  585. }else {
  586. res = this.calulateForm.edb_id
  587. ? await dataBaseInterface.calculateEdit({...params,EdbInfoId: this.calulateForm.edb_id})
  588. : await dataBaseInterface.calculateAdd(params)
  589. }
  590. this.dataloading = false;
  591. if (res.Ret !== 200) return
  592. this.$message.success(res.Msg);
  593. this.calulateForm.edb_id
  594. ? this.$emit('addCallBack','edit')
  595. : this.$emit('addCallBack','add',{ code:res.Data.UniqueCode,id:res.Data.EdbInfoId,classifyId:params.ClassifyId });
  596. this.init();
  597. },
  598. /* 新增公式分段 */
  599. addFormulaHandle() {
  600. let addItem = {
  601. formula: this.formulaList[this.formulaList.length-1].formula,
  602. date: ''
  603. }
  604. this.formulaList.push(addItem)
  605. },
  606. /* 移除公式 */
  607. removeFormulaItem(index) {
  608. this.formulaList.splice(index,1)
  609. },
  610. /* 选择日期 检验排 */
  611. selectFormulaDate(val,item) {
  612. console.log(val,item)
  613. const { start_date,end_date } = this.addList[0];
  614. if(!start_date) return
  615. let dateStamp = new Date(val).getTime(),
  616. startStamp = new Date(start_date).getTime(),
  617. endStamp = new Date(end_date).getTime();
  618. if (dateStamp > endStamp || dateStamp < startStamp) {
  619. item.date = '';
  620. return this.$message.warning('分段日期必须在第一个指标日期区间')
  621. }
  622. else if(this.formulaList.filter(_ => _.date===val).length>1) {
  623. item.date = '';
  624. return this.$message.warning('分段日期不可重复')
  625. }
  626. },
  627. init() {
  628. this.$refs.diaForm.resetFields();
  629. this.addList = [
  630. {
  631. tag: tag_arr[0],
  632. target: '',
  633. start_date: '',
  634. end_date: '',
  635. },
  636. {
  637. tag: tag_arr[1],
  638. target: '',
  639. start_date: '',
  640. end_date: '',
  641. },
  642. {
  643. tag: tag_arr[2],
  644. target: '',
  645. start_date: '',
  646. end_date: '',
  647. },
  648. {
  649. tag: tag_arr[3],
  650. target: '',
  651. start_date: '',
  652. end_date: '',
  653. },
  654. ];
  655. this.searchOptions = [];
  656. this.formula = '';
  657. this.formData = {
  658. targetName: '',
  659. unit: '',
  660. menu: '',
  661. frequency: '',
  662. };
  663. this.formulaList = [
  664. { formula: '' }
  665. ]
  666. this.nullValueForm = {
  667. nullValueWay: 0,
  668. maxNullWay: 1
  669. }
  670. },
  671. cancelHandle(type) {
  672. this.init();
  673. this.$emit('cancel');
  674. type==='cancel' && !this.calulateForm.edb_id && this.$emit('openPrev');
  675. },
  676. },
  677. mounted() {},
  678. };
  679. </script>
  680. <style lang="scss">
  681. .computed-dialog {
  682. max-width: 1200px !important;
  683. width:85vw;
  684. overflow: hidden;
  685. div::-webkit-scrollbar {
  686. width: 6px !important;
  687. }
  688. .el-dialog__body {
  689. max-height: 840px;
  690. overflow: auto;
  691. }
  692. .dialog-main {
  693. padding: 25px 42px 25px 25px;
  694. @media screen and (max-height:850px){
  695. box-sizing: border-box;
  696. height: 65vh;
  697. overflow-y: auto;
  698. }
  699. .el-cascader .el-input {
  700. width: 340px;
  701. }
  702. .add-cont {
  703. display: flex;
  704. flex-wrap: wrap;
  705. justify-content: space-between;
  706. .add-li {
  707. position: relative;
  708. margin-bottom: 48px;
  709. .li-tag {
  710. font-size: 16px;
  711. margin-right: 8px;
  712. }
  713. .del-tag {
  714. position: absolute;
  715. right: -30px;
  716. top: 12px;
  717. font-size: 16px;
  718. cursor: pointer;
  719. }
  720. .target-date {
  721. color: #5882ef;
  722. position: absolute;
  723. bottom: -25px;
  724. left: 24px;
  725. &.newest {
  726. color: #f00;
  727. }
  728. }
  729. }
  730. }
  731. .add-icon {
  732. font-size: 16px;
  733. color: #5882ef;
  734. cursor: pointer;
  735. }
  736. .computed-min {
  737. margin: 50px 0;
  738. padding-bottom: 40px;
  739. border-bottom: 1px dashed #aab4cc;
  740. .computed-section {
  741. display: flex;
  742. margin-top: 20px;
  743. .el-cascader .el-input {
  744. width: 100%;
  745. }
  746. }
  747. .label {
  748. padding:10px 10px 10px 0;
  749. }
  750. .example-txt {
  751. display: block;
  752. margin-top: 10px;
  753. }
  754. .formula-item {
  755. display: flex;
  756. align-items: center;
  757. margin-bottom: 15px;
  758. }
  759. .date-section-text {
  760. margin-left: 15px;
  761. }
  762. }
  763. }
  764. .dia-bot {
  765. padding-bottom: 40px;
  766. display: flex;
  767. justify-content: center;
  768. }
  769. .tip-label {
  770. position: absolute;
  771. bottom: 30px;
  772. right: 30px;
  773. color: #409EFF;
  774. cursor: pointer;
  775. }
  776. }
  777. </style>