addChart.vue 31 KB

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