editChart.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. <template>
  2. <div class="editchart-container" id="box">
  3. <span
  4. class="slide-icon slide-right"
  5. @click="isSlideLeft = !isSlideLeft"
  6. v-show="isSlideLeft"
  7. >
  8. <i class="el-icon-d-arrow-right"></i>
  9. </span>
  10. <div class="left-cont" v-show="!isSlideLeft" id="left">
  11. <div class="left-top">
  12. <el-button
  13. type="primary"
  14. @click="saveHandle"
  15. :disabled="chartInfo.ChartType === 5 && tableData.length !== 2"
  16. >保存</el-button>
  17. <el-button v-permission="permissionBtn.chartLibPermission.chartLib_otherSave"
  18. type="primary" @click="saveChartOtherHandle">另存为</el-button>
  19. <el-button type="primary" plain @click="$router.replace({
  20. path: '/chartsetting',
  21. query: {
  22. code: chartInfo.UniqueCode,
  23. id: chartInfo.ChartInfoId
  24. }
  25. })">取消</el-button>
  26. </div>
  27. <div class="left-min">
  28. <el-form
  29. ref="diaForm"
  30. label-position="top"
  31. label-width="80px"
  32. :model="chartInfo"
  33. :rules="chartRules"
  34. >
  35. <el-form-item label="图表生成样式" prop="ChartType">
  36. <el-select
  37. v-model="chartInfo.ChartType"
  38. placeholder="请选择生成样式"
  39. style="width: 90%"
  40. @change="needWatch=true;"
  41. >
  42. <el-option
  43. v-for="item in styleArr"
  44. :key="item.key"
  45. :label="item.label"
  46. :value="item.key"
  47. >
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="图表名称" prop="ChartName">
  52. <el-input
  53. v-model="chartInfo.ChartName"
  54. style="width: 90%"
  55. placeholder="必填项"
  56. clearable
  57. />
  58. </el-form-item>
  59. <el-form-item label="图表分类" prop="classify">
  60. <el-cascader
  61. v-model="chartInfo.classify"
  62. :options="classifyOptions"
  63. :props="levelProps"
  64. style="width: 90%"
  65. placeholder="请选择所属分类"
  66. />
  67. </el-form-item>
  68. <el-form-item label="图表单位" prop="Unit" v-if="chartInfo.ChartType===7">
  69. <el-input
  70. v-model="chartInfo.Unit"
  71. style="width: 90%"
  72. placeholder="请输入图表单位"
  73. clearable
  74. @change="changeUnit"
  75. />
  76. </el-form-item>
  77. </el-form>
  78. <div class="search-cont" v-if="chartInfo.ChartType!==10">
  79. <div>
  80. <label>选择指标:</label>
  81. <el-radio-group v-model="edbFromType">
  82. <el-radio :label="0" style="margin-right: 15px">ETA指标</el-radio>
  83. <el-radio :label="1">ETA预测指标</el-radio>
  84. </el-radio-group>
  85. </div>
  86. <el-select
  87. v-model="search_txt"
  88. v-loadMore="searchLoad"
  89. ref="searchRef"
  90. :filterable="!search_txt"
  91. remote
  92. clearable
  93. placeholder="指标ID/指标名称"
  94. style="width:90%;margin-top: 10px;display: block;"
  95. :remote-method="searchHandle"
  96. @click.native="inputFocusHandle"
  97. @change="selectTarget($event && searchOptions.find(_ => _.EdbInfoId === $event))"
  98. >
  99. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  100. <el-option
  101. v-for="item in searchOptions"
  102. :key="item.EdbInfoId"
  103. :label="chart_lang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  104. :value="item.EdbInfoId"
  105. >
  106. <edbDetailPopover :info="item">
  107. <div slot="reference">{{chart_lang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName }}</div>
  108. </edbDetailPopover>
  109. </el-option>
  110. </el-select>
  111. </div>
  112. <div class="xaxis-range-cont" v-if="chartInfo.ChartType===2">
  113. <!-- 仅用于季节性图配置 -->
  114. <div style="margin-bottom: 12px;" class="xaxis-range-tip">
  115. 横坐标显示范围
  116. <el-tooltip>
  117. <div slot="content">
  118. <p class="hint-message">配置横坐标显示的时间刻度</p>
  119. <p class="hint-message">1、若开始日期小于结束日期,则默认不跨年,允许勾选跨年</p>
  120. <p class="hint-message">2、若开始日期大于等于结束日期,则跨年,不允许取消勾选</p>
  121. </div>
  122. <img src="~@/assets/img/icons/question_mark_black.png" style="height: 16px;cursor: pointer;margin-left: 6px;" />
  123. </el-tooltip>
  124. </div>
  125. <el-date-picker
  126. style="width: 45%;"
  127. v-model="SeasonExtraConfig.XStartDate"
  128. value-format="MM-dd"
  129. popper-class="x-range-picker-date"
  130. format="MM-dd"
  131. placeholder="开始日期"
  132. @change="xAxisChange"
  133. :clearable="false"
  134. ></el-date-picker>
  135. <el-date-picker
  136. style="width: 45%;"
  137. v-model="SeasonExtraConfig.XEndDate"
  138. value-format="MM-dd"
  139. popper-class="x-range-picker-date"
  140. format="MM-dd"
  141. placeholder="结束日期"
  142. @change="xAxisChange"
  143. :clearable="false"
  144. ></el-date-picker>
  145. <!-- <el-date-picker
  146. style="width: 90%;"
  147. v-model="xAxisRange"
  148. type="daterange"
  149. value-format="MM-dd"
  150. popper-class="x-range-picker-date"
  151. format="MM-dd"
  152. start-placeholder="开始日期"
  153. end-placeholder="结束日期"
  154. @change="xAxisRangeChange"
  155. :clearable="false"
  156. ></el-date-picker> -->
  157. <el-checkbox label="跨年" v-model="isSpanYear" :disabled="isSpanYearDisable"
  158. style="margin-top: 12px;" @change="changeIsSpanYear"></el-checkbox>
  159. <div class="legend-set-text" @click="openLegendEditDia">
  160. <span>图例名称设置</span>
  161. <img src="~@/assets/img/icons/edit-blue.png" />
  162. </div>
  163. </div>
  164. <div class="targetset-cont">
  165. <!-- 仅用于散点图配置提出 -->
  166. <div class="scatter-setting" v-if="chartInfo.ChartType === 5 && tableData.length">
  167. <div style="display: flex;margin-right: 15px;">
  168. <span style="margin-right: 3px">线条颜色:</span>
  169. <el-color-picker
  170. v-model="tableData[0].ChartColor"
  171. size="mini"
  172. show-alpha
  173. :predefine="predefineColors"
  174. ></el-color-picker>
  175. </div>
  176. <el-checkbox v-model="tableData[0].IsOrder">逆序</el-checkbox>
  177. </div>
  178. <el-collapse v-model="activeNames" class="target-list" v-if="tableData.length&&![7,10].includes(chartInfo.ChartType)">
  179. <el-collapse-item v-for="(item,index) in tableData" :key="item.EdbInfoId" :disabled="[2,5].includes(chartInfo.ChartType)">
  180. <template slot="title">
  181. <span class="text_oneLine">{{item.EdbName}}</span>
  182. <i class="el-icon-delete del-icon" @click.stop="delTarget(item)"></i>
  183. </template>
  184. <ul class="setting-cont">
  185. <!-- 堆叠图 或组合图中的堆叠类型 非第一项隐藏配置 -->
  186. <template v-if="showYOptionsHandle(item,index)">
  187. <li>
  188. <el-checkbox v-model="item.IsOrder">逆序</el-checkbox>
  189. </li>
  190. <li>
  191. <el-radio-group v-model="item.IsAxis" size="mini">
  192. <el-radio-button :label="1">左轴</el-radio-button>
  193. <el-radio-button :label="0">右轴</el-radio-button>
  194. <!-- 指标有右轴时才可以选右2轴 不然没有右2这个概念的意义 -->
  195. <el-radio-button
  196. v-if="[1,6].includes(chartInfo.ChartType)"
  197. :label="2"
  198. :disabled="(tableData.findIndex(_ => _.IsAxis===0) === -1)
  199. || (tableData.findIndex(_ => _.IsAxis===0) === index
  200. && tableData.filter(_ => _.IsAxis===0).length === 1)"
  201. >右2轴</el-radio-button>
  202. </el-radio-group>
  203. </li>
  204. </template>
  205. <li style="min-width: 250px">
  206. <el-radio
  207. v-model="item.EdbInfoType"
  208. :label="1"
  209. @change="getPreviewSplineInfo"
  210. >标准指标</el-radio
  211. >
  212. <div style="margin-top: 15px">
  213. <el-radio
  214. v-model="item.EdbInfoType"
  215. :label="0"
  216. style="margin-right: 10px"
  217. @change="getPreviewSplineInfo"
  218. >领先指标</el-radio
  219. >
  220. <template v-if="item.EdbInfoType === 0">
  221. 领先
  222. <el-input
  223. style="width: 60px"
  224. size="mini"
  225. type="number"
  226. min="0"
  227. v-model="item.LeadValue"
  228. @change="getPreviewSplineInfo"
  229. @keyup.native="filterCode(item)"
  230. ></el-input>
  231. <el-select
  232. v-model="item.LeadUnit"
  233. placeholder=""
  234. style="width: 60px"
  235. size="mini"
  236. @change="getPreviewSplineInfo"
  237. >
  238. <el-option
  239. v-for="item in fre_options"
  240. :key="item"
  241. :label="item"
  242. :value="item"
  243. >
  244. </el-option>
  245. </el-select>
  246. </template>
  247. </div>
  248. </li>
  249. <li>
  250. <div style="display: flex">
  251. <span style="margin-right: 3px">线条颜色:</span>
  252. <el-color-picker
  253. v-model="item.ChartColor"
  254. size="mini"
  255. show-alpha
  256. :predefine="predefineColors"
  257. ></el-color-picker>
  258. </div>
  259. <div
  260. style="margin-top: 12px"
  261. v-if="chartInfo.ChartType === 1
  262. || (chartInfo.ChartType === 6 &&item.ChartStyle==='spline')"
  263. >
  264. 线条粗细:
  265. <el-input
  266. style="width: 60px"
  267. size="mini"
  268. type="number"
  269. :min="1"
  270. v-model="item.ChartWidth"
  271. />
  272. </div>
  273. </li>
  274. <li v-if="chartInfo.ChartType === 6">
  275. <div style="display: flex">
  276. <span style="margin-right: 3px">生成样式:</span>
  277. <el-select
  278. v-model="item.ChartStyle"
  279. placeholder="请选择生成样式"
  280. style="width: 50%"
  281. class="edb-item-style"
  282. >
  283. <el-option
  284. v-for="item in chartItemStyleArr"
  285. :key="item.key"
  286. :label="item.label"
  287. :value="item.value"
  288. >
  289. </el-option>
  290. </el-select>
  291. </div>
  292. </li>
  293. </ul>
  294. </el-collapse-item>
  295. </el-collapse>
  296. <!-- 奇怪柱状图配置 -->
  297. <bar-option
  298. v-if="chartInfo.ChartType===7"
  299. ref="BarOptRef"
  300. :edblist="tableData"
  301. :datedata="barDateList"
  302. :initData="initBarOptions"
  303. @getData="getBarPreviewData"
  304. />
  305. <!-- 截面散点图 -->
  306. <sectional-scatter-option
  307. v-if="chartInfo.ChartType===10"
  308. ref="SectionScatterOptRef"
  309. :initData="chartInfo.ExtraConfig?JSON.parse(chartInfo.ExtraConfig):null"
  310. @getData="getSectionScatterData"
  311. />
  312. </div>
  313. </div>
  314. <span
  315. class="move-btn resize"
  316. v-drag
  317. id="resize"
  318. ></span>
  319. <span class="slide-icon slide-left" @click="isSlideLeft = !isSlideLeft">
  320. <i class="el-icon-d-arrow-left"></i>
  321. </span>
  322. </div>
  323. <div class="right-cont" id="right" :style="isSlideLeft ? 'width:100%' : `width:80%`">
  324. <div class="chart-min-cont" v-if="tableData.length">
  325. <div class="cont-top">
  326. <div class="top-left">
  327. <!-- 默认曲线图 -->
  328. <template v-if="sameOptionType.includes(chartInfo.ChartType)">
  329. <el-button
  330. type="primary"
  331. v-for="item in yearSelector"
  332. :key="item.value"
  333. size="medium"
  334. :plain="item.value !== year_select"
  335. class="year-btn"
  336. @click.native="changeYear(item)"
  337. >{{ item.name }}</el-button
  338. >
  339. <el-button type="text" class="btn-sty" @click="openDateDia">{{
  340. dateTip
  341. }}</el-button>
  342. </template>
  343. <!-- 季节性图选择年份区间 -->
  344. <!-- <date-picker
  345. v-else-if="chartInfo.ChartType === 2"
  346. v-model="season_year"
  347. type="month"
  348. value-type="format"
  349. range
  350. placeholder="年份日期选择"
  351. @change="seasonYearChange"
  352. /> -->
  353. <div v-else-if="chartInfo.ChartType === 2" style="padding: 10px 20px;border: 1px solid #eee;border-radius: 8px;cursor: pointer;"
  354. @click="openDateDia">
  355. {{ season_year && season_year.length>0 ? season_year[0]+'~'+season_year[1]:"年份日期选择" }}
  356. </div>
  357. </div>
  358. </div>
  359. <div class="cont-bottom">
  360. <div class="chart-show-cont" v-if="!chartInfo.WarnMsg&&options.series">
  361. <div class="chartWrapper" id="chartWrapper">
  362. <h2 class="chart-title" v-show="chartInfo.ChartName">{{ chartInfo.ChartName }}</h2>
  363. <Chart :options="options" ref="chartRef" />
  364. <div class="range-cont left" v-if="leftIndex != -1">
  365. <el-input
  366. style="width: 60px; display: block"
  367. size="mini"
  368. type="number"
  369. placeholder="上限"
  370. v-model="tableData[leftIndex].MaxData"
  371. />
  372. <el-input
  373. class="min-data-input"
  374. size="mini"
  375. type="number"
  376. placeholder="下限"
  377. v-model="tableData[leftIndex].MinData"
  378. />
  379. </div>
  380. <div class="range-cont right" v-if="rightIndex != -1">
  381. <el-input
  382. style="width: 60px; display: block"
  383. size="mini"
  384. type="number"
  385. placeholder="上限"
  386. v-model="tableData[rightIndex].MaxData"
  387. />
  388. <el-input
  389. class="min-data-input"
  390. size="mini"
  391. type="number"
  392. placeholder="下限"
  393. v-model="tableData[rightIndex].MinData"
  394. />
  395. </div>
  396. <!-- 右2上下限设置 -->
  397. <div class="range-cont rightTwo" v-if="rightTwoIndex != -1">
  398. <el-input
  399. style="width: 60px; display: block"
  400. size="mini"
  401. type="number"
  402. placeholder="上限"
  403. v-model="tableData[rightTwoIndex].MaxData"
  404. />
  405. <el-input
  406. class="min-data-input"
  407. size="mini"
  408. type="number"
  409. placeholder="下限"
  410. v-model="tableData[rightTwoIndex].MinData"
  411. />
  412. </div>
  413. <!-- 后续新图专用上下限 和其他数据依赖不公用 柱形图 截面散点-->
  414. <template v-if="[7,10].includes(chartInfo.ChartType)">
  415. <div class="range-cont left">
  416. <el-input
  417. style="width: 60px; display: block"
  418. size="mini"
  419. type="number"
  420. placeholder="上限"
  421. v-model="chartLimit.max"
  422. @change="changeLimit"
  423. />
  424. <el-input
  425. class="min-data-input"
  426. size="mini"
  427. type="number"
  428. placeholder="下限"
  429. v-model="chartLimit.min"
  430. @change="changeLimit"
  431. />
  432. </div>
  433. <!-- x轴上下限 -->
  434. <div class="range-cont bottom" v-if="chartLimit.x_min||chartLimit.x_max">
  435. <el-input
  436. class="left"
  437. size="mini"
  438. type="number"
  439. placeholder="下限"
  440. v-model="chartLimit.x_min"
  441. @change="changeLimit"
  442. />
  443. <el-input
  444. class="left"
  445. size="mini"
  446. type="number"
  447. placeholder="上限"
  448. v-model="chartLimit.x_max"
  449. @change="changeLimit"
  450. />
  451. </div>
  452. </template>
  453. </div>
  454. <span class="chart-author"
  455. >作者:{{ chartInfo.SysUserRealName }}</span
  456. >
  457. <!-- 公历农历切换 只用于季节性图 -->
  458. <el-radio-group
  459. v-model="calendar_type"
  460. class="calendar-cont"
  461. v-if="chartInfo.ChartType === 2"
  462. @change="getPreviewSplineInfo"
  463. >
  464. <el-radio-button label="公历" />
  465. <el-radio-button label="农历" />
  466. </el-radio-group>
  467. </div>
  468. <!-- 异常显示 -->
  469. <p class="error-tip" style="min-height: 400px" v-if="chartInfo.WarnMsg">{{chartInfo.WarnMsg}}</p>
  470. <el-table
  471. :data="tableData"
  472. ref="tableRef"
  473. highlight-current-row
  474. border
  475. >
  476. <el-table-column
  477. v-for="item in tableColums"
  478. :key="item.label"
  479. :label="item.label"
  480. :width="item.widthsty"
  481. :min-width="item.minwidthsty"
  482. align="center"
  483. >
  484. <template slot-scope="scope">
  485. <div v-if="item.key === 'EdbName' && chartInfo.ChartType === 7">
  486. <!-- 奇怪柱状图用别名 -->
  487. <el-input
  488. v-model="scope.row.EdbAliasName"
  489. placeholder="指标别名"
  490. class="target-other-name"
  491. v-if="chartInfo.ChartType === 7"
  492. clearable
  493. />
  494. </div>
  495. <span v-else>{{ scope.row[item.key] }}</span>
  496. </template>
  497. </el-table-column>
  498. <el-table-column
  499. label="操作"
  500. key="Copy"
  501. align="center"
  502. width="140"
  503. >
  504. <template slot-scope="scope">
  505. <span @click="delTarget(scope.row)" class="deletesty">删除&nbsp;</span>
  506. <span v-permission="permissionBtn.chartLibPermission.chartLib_copyData"
  507. class="editsty" @click="copyCode(scope.row)">
  508. <i class="el-icon-document-copy" />&nbsp;复制数据</span
  509. ><br>
  510. <span v-permission="permissionBtn.chartLibPermission.chartLib_viewData"
  511. class="editsty"
  512. @click="viewTarget(scope.row)"
  513. >查看数据</span>
  514. </template>
  515. </el-table-column>
  516. <div slot="empty">
  517. <tableNoData text="暂无指标" size="mini"/>
  518. </div>
  519. </el-table>
  520. </div>
  521. </div>
  522. <div class="nodata" v-else>
  523. <tableNoData text="暂无信息"/>
  524. </div>
  525. </div>
  526. <!-- 日期端选择弹窗 -->
  527. <DateChooseDia
  528. :isDateDia="isDateDia"
  529. :dateForm="dateForm"
  530. :earliestDate="earliestDate"
  531. @cancel="isDateDia = false"
  532. @dateBack="dataChangeBack"
  533. />
  534. <!-- 季节性 图例设置 -->
  535. <LegendEditDia
  536. :isEditLegend="legendEditDiaShow"
  537. :legendList="SeasonExtraConfig.ChartLegend"
  538. @cancel="legendEditDiaShow = false"
  539. @saveLegend="saveLegend"
  540. />
  541. <!-- 图表另存 -->
  542. <SaveChartOther
  543. :show.sync="isShowSaveOther"
  544. :data="chartInfo"
  545. />
  546. </div>
  547. </template>
  548. <script>
  549. import { dataBaseInterface } from '@/api/api.js';
  550. import { chartSetMixin } from './mixins/chartPublic';
  551. import addOrEditMixn from './mixins/addOreditMixin';
  552. import Chart from './components/chart';
  553. import DateChooseDia from './components/DateChooseDia';
  554. import SaveChartOther from './components/SaveChartOther';
  555. import barOption from './components/barOptionSection.vue';
  556. import sectionalScatterOption from './components/sectionalScatterOption.vue';
  557. import LegendEditDia from './components/LegendEditDia.vue';
  558. export default {
  559. components: { Chart,DateChooseDia,SaveChartOther,barOption,sectionalScatterOption,LegendEditDia },
  560. directives: {
  561. drag(el, bindings) {
  562. el.onmousedown = function (e) {
  563. var init = e.clientX;
  564. // console.log(init);
  565. var box = $('#box')[0];
  566. // console.log(box.clientWidth)
  567. let total_wid = box.offsetWidth;
  568. var left = $('#left')[0];
  569. var right = $('#right')[0];
  570. var initWidth = left.offsetWidth;
  571. document.onmousemove = function (e) {
  572. var end = e.clientX;
  573. var newWidth = end - init + initWidth;
  574. left.style.width = newWidth + 'px';
  575. right.style.width = newWidth > 300 ? total_wid - newWidth + 'px' : total_wid - 320 + 'px';
  576. };
  577. document.onmouseup = function () {
  578. document.onmousemove = document.onmouseup = null;
  579. e.releaseCapture && e.releaseCapture();
  580. };
  581. e.setCapture && e.setCapture();
  582. return false;
  583. };
  584. },
  585. },
  586. watch: {
  587. tableData: {
  588. handler(newval, oldval) {
  589. if(newval) {
  590. if([7,10].includes(this.chartInfo.ChartType)) {
  591. // 奇怪柱形图
  592. this.chartInfo.ChartType === 7 && this.barDateList.length && this.$refs.BarOptRef && this.$refs.BarOptRef.getBarData();
  593. }else {
  594. this.setAddChartDefault();
  595. newval.length && !this.chartInfo.WarnMsg && this.setChartOptionHandle(newval);
  596. }
  597. // 设置起始日期和最新日期
  598. this.setExtremumDate()
  599. }
  600. },
  601. deep: true,
  602. },
  603. },
  604. mixins: [chartSetMixin,addOrEditMixn],
  605. data() {
  606. return {
  607. isSlideLeft: false,
  608. search_txt: '',
  609. activeNames: '',
  610. /* right */
  611. calendar_type: '公历',//默认公历
  612. season_year:'',//季节图时间段
  613. initBarOptions: null,//编辑时回显的barOptions数据
  614. needWatch: false,
  615. };
  616. },
  617. methods: {
  618. /* 获取图表详情 */
  619. getChartInfo() {
  620. dataBaseInterface
  621. .getChartByCode({
  622. UniqueCode: this.$route.query.code,
  623. })
  624. .then((res) => {
  625. if (res.Ret !== 200) return;
  626. const { ChartInfo,EdbInfoList,BarChartInfo } = res.Data;
  627. this.chartInfo = {
  628. ...ChartInfo,
  629. classify: [ChartInfo.ChartClassify[0].ParentId,...ChartInfo.ChartClassify.map(item => item.ChartClassifyId)],
  630. Unit: BarChartInfo ? BarChartInfo.Unit : ''
  631. };
  632. this.tableData = EdbInfoList;
  633. this.calendar_type = this.chartInfo.Calendar; //日历类型
  634. this.setDefaultPreviewOption() // 设置配置项
  635. this.$nextTick(()=>{
  636. this.setDefaultDateSelect(); //设置默认的日期选中
  637. })
  638. if(this.chartInfo.ChartType === 7) {
  639. //特殊柱形图数据
  640. this.initBarData(res.Data)
  641. this.initBarOptions = BarChartInfo;
  642. }
  643. //截面散点图
  644. this.chartInfo.ChartType === 10 && this.initSectionScatterData(res.Data);
  645. });
  646. },
  647. /* 设置默认时间选中项 */
  648. setDefaultDateSelect() {
  649. this.year_select = this.chartInfo.DateType;
  650. this.select_date = [this.chartInfo.StartDate, this.chartInfo.EndDate];
  651. this.count_year = this.chartInfo.StartYear;
  652. // this.calendar_type = this.chartInfo.Calendar; //日历类型
  653. if(this.chartInfo.ChartType==2){
  654. if(this.year_select==20){
  655. let latestYear = parseInt(this.tableData[0].LatestDate.substring(0,4))
  656. this.season_year=[`${latestYear-this.count_year+1}-01-01`,`${latestYear}-12-31`]
  657. }else if(this.year_select==6){
  658. this.season_year = [this.chartInfo.SeasonStartDate,this.tableData[0].LatestDate];
  659. }else{
  660. this.season_year = [this.chartInfo.SeasonStartDate,this.chartInfo.SeasonEndDate]
  661. }
  662. }
  663. this.dateTip =
  664. this.chartInfo.DateType === 5
  665. ? `${this.chartInfo.StartDate}~${this.chartInfo.EndDate}`
  666. : this.chartInfo.DateType === 6
  667. ? `${this.chartInfo.StartDate}~至今`
  668. : this.chartInfo.DateType === 20
  669. ?`最近${this.chartInfo.StartYear}年`
  670. :'请选择时间段';
  671. },
  672. // 设置配置项
  673. setDefaultPreviewOption(){
  674. if(this.chartInfo.ChartType==2){
  675. this.count_year = this.chartInfo.StartYear
  676. // if(!(this.chartInfo.SeasonEndDate && this.chartInfo.SeasonStartDate)){
  677. // // 获取最近日期的年
  678. // let latestYear = parseInt(this.latestDate.substring(0,4))
  679. // this.season_year=[`${latestYear-this.count_year+1}-01-01`,`${latestYear}-12-31`]
  680. // }
  681. if(this.chartInfo.SeasonExtraConfig){
  682. this.SeasonExtraConfig = JSON.parse(this.chartInfo.SeasonExtraConfig)
  683. // console.log(this.SeasonExtraConfig);
  684. this.isSpanYear=!!this.SeasonExtraConfig.JumpYear
  685. this.isSpanYearDisable=
  686. !!(new Date(`2023-${this.SeasonExtraConfig.XStartDate}`) > new Date(`2023-${this.SeasonExtraConfig.XEndDate}`) ||
  687. new Date(`2023-${this.SeasonExtraConfig.XStartDate}`) == new Date(`2023-${this.SeasonExtraConfig.XEndDate}`))
  688. }
  689. // 图例名称 需要在DataList中取,SeasonExtraConfig里面的可能是旧的
  690. this.SeasonExtraConfig.ChartLegend=[]
  691. const chartDataHandle = this.calendar_type === "农历"?
  692. this.tableData[0].DataList.filter((item, index) => index > 0):
  693. this.tableData[0].DataList
  694. chartDataHandle.map(item =>{
  695. this.SeasonExtraConfig.ChartLegend.push({Name:item.Years,Value:item.ChartLegend})
  696. })
  697. }
  698. },
  699. /* 保存 */
  700. saveHandle() {
  701. if(!this.tableData.length) return this.$message.warning('暂未选择指标');
  702. this.$refs.diaForm.validate((valid) => {
  703. if(valid) {
  704. // 季节图只允许添加一个指标
  705. if(this.chartInfo.ChartType === 2 && this.tableData.length > 1) return this.$message.warning('您选择的图表样式为季节性图表,只支持单指标画图');
  706. if(this.chartInfo.ChartType === 7 && !this.$refs.BarOptRef.dateList.length) return this.$message.warning('请添加日期');
  707. if(this.chartInfo.ChartType === 10 && !this.$refs.SectionScatterOptRef.seriesArr[0].edbs) return this.$message.warning('请添加系列指标');
  708. if(this.chartInfo.ChartType === 2){
  709. if(!(this.SeasonExtraConfig.XStartDate && this.SeasonExtraConfig.XEndDate)){
  710. return this.$message.warning('横坐标显示范围不能为空');
  711. }
  712. }
  713. let db_arr = this.tableData.map(item => ({
  714. ChartColor: item.ChartColor,
  715. PredictChartColor: item.PredictChartColor,
  716. ChartStyle: item.ChartStyle,
  717. ChartWidth: Number(item.ChartWidth),
  718. EdbInfoId: item.EdbInfoId,
  719. EdbInfoType: item.EdbInfoType,
  720. IsAxis: item.IsAxis,
  721. IsOrder: item.IsOrder,
  722. LeadUnit: item.EdbInfoType ? '' : item.LeadUnit,
  723. LeadValue: item.EdbInfoType ? 0 : Number(item.LeadValue),
  724. MaxData: Number(item.MaxData),
  725. MinData: Number(item.MinData)
  726. })
  727. )
  728. let public_param = {
  729. ChartClassifyId: this.chartInfo.classify.length ? this.chartInfo.classify[this.chartInfo.classify.length - 1] : 0,
  730. ChartName: this.chartInfo.ChartName,
  731. ChartType: this.chartInfo.ChartType,
  732. ChartInfoId: this.chartInfo.ChartInfoId,
  733. ChartEdbInfoList: db_arr,
  734. }
  735. //提交参数
  736. const typePrams = this.getSaveParamsByChartType(public_param);
  737. let params = this.sameOptionType.includes(this.chartInfo.ChartType)
  738. ? {
  739. ...public_param,
  740. DateType: this.year_select,
  741. StartYear: this.count_year || 0,
  742. StartDate:
  743. [5,6].includes(this.year_select)
  744. ? this.select_date[0]
  745. : '',
  746. EndDate: this.year_select === 5 ? this.select_date[1] : '',
  747. }
  748. : typePrams
  749. dataBaseInterface.chartEdit(params).then(res => {
  750. if(res.Ret !== 200) return;
  751. this.$message.success('编辑成功');
  752. if(this.$route.query.from === 'mychart') {
  753. window.close();
  754. }else {
  755. this.$router.replace({
  756. path: '/chartsetting',
  757. query: {
  758. code: res.Data.UniqueCode,
  759. id: res.Data.ChartInfoId
  760. }
  761. })
  762. }
  763. })
  764. }
  765. })
  766. },
  767. },
  768. mounted() {
  769. this.getMenu();
  770. this.getChartInfo();
  771. this.reloadRightWid();
  772. window.addEventListener('resize', this.reloadRightWid);
  773. },
  774. destroyed() {
  775. window.removeEventListener('resize', this.reloadRightWid);
  776. }
  777. };
  778. </script>
  779. <style lang="scss">
  780. .editchart-container {
  781. $font-small: 12px; $font-normal: 14px;
  782. display: flex;
  783. *{ box-sizing: border-box; }
  784. .el-form--label-top .el-form-item__label {
  785. padding: 0;
  786. }
  787. .el-form-item {
  788. margin-bottom: 8px;
  789. }
  790. .el-input-number .el-input__inner {
  791. padding: 0 34px 0 4px;
  792. }
  793. .target-other-name .el-input__inner {
  794. padding: 0 30px 0 5px !important;
  795. height: 40px !important;
  796. line-height: 40px !important;
  797. }
  798. .el-color-picker--mini .el-color-picker__trigger {
  799. width: 60px;
  800. height: 25px;
  801. padding: 0;
  802. }
  803. .el-color-picker--mini .el-color-picker__mask {
  804. width: 60px;
  805. height: 25px;
  806. }
  807. .slide-icon {
  808. padding: 20px 0;
  809. /* display: block; */
  810. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.3);
  811. border-radius: 5px;
  812. cursor: pointer;
  813. position: absolute;
  814. top: 50%;
  815. transform: translateY(-50%);
  816. z-index: 99;
  817. &:hover {
  818. background-color: rgba(0, 0, 0, 0.05);
  819. }
  820. &.slide-left {
  821. right: 0;
  822. }
  823. &.slide-right {
  824. left: 0;
  825. }
  826. }
  827. .left-cont {
  828. width: 400px;
  829. min-width: 300px;
  830. background: #fff;
  831. margin-right: 20px;
  832. border: 1px solid #ececec;
  833. border-radius: 4px;
  834. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
  835. height: calc(100vh - 113px);
  836. overflow: hidden;
  837. position: relative;
  838. box-sizing: border-box;
  839. .left-top {
  840. padding: 15px 20px;
  841. border: 1px solid #ececec;
  842. box-shadow: 0px 3px 6px rgba(167, 167, 167, 0.09);
  843. }
  844. .left-min {
  845. padding: 30px 20px;
  846. max-height: calc(100vh - 194px);
  847. overflow-y: auto;
  848. .search-cont {
  849. color: #606266;
  850. margin-top: 10px;
  851. }
  852. .xaxis-range-cont{
  853. color: #606266;
  854. margin-top: 20px;
  855. .xaxis-range-tip{
  856. display: flex;
  857. align-items: center;
  858. justify-content: flex-start;
  859. .hint-message{
  860. font-size: 15px;
  861. line-height: 22px;
  862. }
  863. }
  864. .legend-set-text{
  865. font-size: 15px;
  866. color: #1B7BDE;
  867. display: flex;
  868. align-items: center;
  869. justify-content: flex-start;
  870. margin-top: 20px;
  871. cursor: pointer;
  872. img{
  873. height: 16px;
  874. margin-left: 5px;
  875. }
  876. }
  877. }
  878. .targetset-cont {
  879. padding: 30px 0 20px;
  880. .el-input__inner {
  881. height: 27px;
  882. line-height: 27px;
  883. padding: 0 4px;
  884. }
  885. .el-collapse-item.is-disabled .el-collapse-item__header {
  886. color: #333;
  887. }
  888. .target-list {
  889. border: 1px solid #DCDFE6;
  890. .del-icon {
  891. position: absolute;
  892. right: 10px;
  893. font-size: 16px;
  894. color: #f00;
  895. cursor: pointer;
  896. }
  897. .setting-cont {
  898. padding: 20px 20px 0;
  899. li {
  900. padding-bottom: 20px;
  901. margin-bottom: 20px;
  902. border-bottom: 1px solid #DCDFE6;
  903. &:last-child {
  904. padding-bottom: 0;
  905. margin-bottom: 0;
  906. border-bottom: none;
  907. }
  908. }
  909. }
  910. }
  911. .el-collapse-item__header {
  912. background-color: #F0F2F5;
  913. margin-bottom: 0;
  914. border-bottom: 1px solid #DCDFE6;
  915. padding: 0 30px;
  916. .el-collapse-item__arrow {
  917. position: absolute;
  918. left: 8px;
  919. }
  920. }
  921. .scatter-setting {
  922. display: flex;
  923. margin-bottom: 20px;
  924. }
  925. }
  926. }
  927. .move-btn {
  928. height: 100%;
  929. width: 4px;
  930. position: absolute;
  931. right: 0px;
  932. top: 0;
  933. &:hover {
  934. cursor: col-resize;
  935. }
  936. }
  937. }
  938. .right-cont {
  939. width: 80%;
  940. .mx-datepicker {
  941. width: 220px !important;
  942. }
  943. /* =================== */
  944. .chart-min-cont {
  945. background: #fff;
  946. border: 1px solid #ececec;
  947. height: calc(100vh - 118px);
  948. overflow: auto;
  949. /* overflow: hidden; */
  950. border-radius: 4px;
  951. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
  952. .cont-top {
  953. padding: 12px 30px;
  954. border-bottom: 1px solid #ececec;
  955. display: flex;
  956. justify-content: space-between;
  957. align-items: center;
  958. box-shadow: 0px 3px 6px rgba(167, 167, 167, 0.09);
  959. .top-left {
  960. .year-btn {
  961. margin-right: 5px;
  962. margin-bottom: 5px;
  963. }
  964. .btn-sty {
  965. border: 1px solid #409eff;
  966. }
  967. .date-setting{
  968. border: 1px solid #DCDFE6;
  969. border-radius: 4px;
  970. cursor: pointer;
  971. color: #333333;
  972. line-height: 16px;
  973. }
  974. }
  975. .top-right {
  976. font-size: 16px;
  977. .join_txt {
  978. color: #409eff;
  979. cursor: pointer;
  980. &:hover {
  981. text-decoration: underline;
  982. }
  983. }
  984. .collected {
  985. color: #f00;
  986. cursor: pointer;
  987. &:hover {
  988. text-decoration: underline;
  989. }
  990. }
  991. .span-item {
  992. color: #409eff;
  993. cursor: pointer;
  994. &:hover {
  995. text-decoration: underline;
  996. }
  997. .el-icon-collection,
  998. .el-icon-document-copy {
  999. color: #409eff;
  1000. }
  1001. }
  1002. }
  1003. }
  1004. .cont-bottom {
  1005. padding: 20px 30px;
  1006. .error-tip{ color: #D03F28; font-size: 16px; margin-bottom: 25px; }
  1007. /* height: calc(100vh - 250px);
  1008. overflow: auto; */
  1009. .el-input__inner {
  1010. height: 27px;
  1011. line-height: 27px;
  1012. padding: 0 4px;
  1013. }
  1014. .el-input-number .el-input__inner {
  1015. padding: 0 34px 0 4px;
  1016. }
  1017. .highcharts-range-selector-group {
  1018. display: none;
  1019. .highcharts-input-group {
  1020. display: none;
  1021. }
  1022. }
  1023. .highcharts-axis-title {
  1024. display: block;
  1025. }
  1026. .calendar-cont {
  1027. display: block;
  1028. margin: 10px auto 0;
  1029. text-align: center;
  1030. }
  1031. /* =================== */
  1032. .chart-show-cont {
  1033. padding: 0 150px 20px 120px;
  1034. position: relative;
  1035. .chart-title {
  1036. font-size: 16px;
  1037. font-weight: normal;
  1038. text-align: center;
  1039. margin-bottom: 10px;
  1040. }
  1041. .chart-author {
  1042. font-size: 14px;
  1043. color: #333;
  1044. position: absolute;
  1045. bottom: 20px;
  1046. right: 50px;
  1047. }
  1048. .chartWrapper {
  1049. position: relative;
  1050. .range-cont {
  1051. position: absolute;
  1052. top: 15%;
  1053. .min-data-input {
  1054. width: 60px;
  1055. display: block;
  1056. }
  1057. &.left {
  1058. left: -80px;
  1059. }
  1060. &.right {
  1061. right: -65px;
  1062. }
  1063. &.rightTwo {
  1064. right: -130px;
  1065. }
  1066. &.bottom {
  1067. width: 100%;
  1068. display: flex;
  1069. justify-content: space-between;
  1070. top: auto;
  1071. right: 0;
  1072. bottom: -3%;
  1073. .left {
  1074. width: 60px;
  1075. display: block;
  1076. flex-shrink: 0;
  1077. }
  1078. }
  1079. }
  1080. }
  1081. }
  1082. .options-cont {
  1083. display: flex;
  1084. flex-wrap: wrap;
  1085. justify-content: space-between;
  1086. }
  1087. }
  1088. }
  1089. .nodata {
  1090. height: calc(100vh - 120px);
  1091. background-color: #fff;
  1092. text-align: center;
  1093. font-size: 16px;
  1094. color: #666;
  1095. padding: 100px 0;
  1096. }
  1097. @media screen and (min-width: 1711px){
  1098. .min-data-input {
  1099. margin-top: 310px;
  1100. }
  1101. .btn-sty {
  1102. padding: 10px;
  1103. }
  1104. .year-btn,.btn-sty {
  1105. font-size: $font-normal;
  1106. }
  1107. .date-setting{
  1108. width: 210px;
  1109. height: 40px;
  1110. padding: 12px;
  1111. font-size: $font-normal;
  1112. }
  1113. }
  1114. @media screen and (max-width: 1710px){
  1115. .min-data-input {
  1116. margin-top: 230px;
  1117. }
  1118. .year-btn {
  1119. font-size: $font-small;
  1120. margin-left: 5px;
  1121. margin-right: 5px;
  1122. margin-bottom: 5px;
  1123. padding: 6px 12px;
  1124. }
  1125. .btn-sty {
  1126. font-size: $font-small;
  1127. margin-left: 5px;
  1128. padding: 6px;
  1129. border: 1px solid #409eff;
  1130. }
  1131. .date-setting{
  1132. width: 180px;
  1133. height: 36px;
  1134. padding: 10px;
  1135. font-size: $font-small;
  1136. }
  1137. }
  1138. }
  1139. }
  1140. </style>
  1141. <style lang="scss">
  1142. .edb-item-style .el-input__icon {
  1143. line-height: 27px;
  1144. }
  1145. /*他不要下拉选择框 QAQ */
  1146. .x-range-picker-date {
  1147. display: none;
  1148. }
  1149. </style>