38295abbc7484cd8b07a76a7d89473a9c8680f6c.svn-base 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <template>
  2. <div>
  3. <el-card body-style="padding:0;" style="margin-bottom: 20px;" class="panel-header">
  4. <div slot="header" style="display: flex; justify-content:space-between;">
  5. <span>
  6. <span class="back-button" @click="$router.push({ name: 'BoardEchartManagement', params: { tab: 'second' } })">
  7. <i class="el-icon-back" />
  8. <span>返回</span>
  9. </span>
  10. <span v-if="this.$route.params.id == 'create'">新增图表</span>
  11. <span v-if="this.$route.params.isEdit == 'view'">查看图表</span>
  12. <span v-if="this.$route.params.isEdit == 'edit'">编辑图表</span>
  13. </span>
  14. <span>
  15. <el-button v-if="false" size="mini" type="primary" style="float: right;margin:0 10px 0 0;" icon="el-icon-download" @click="handleDownload" />
  16. <el-button v-if="this.$route.params.isEdit == 'edit'" size="mini" type="primary" style="float: right;margin:0 10px 0 0;" @click="handleLinkDB">添加到看板</el-button>
  17. <el-button v-if="this.$route.params.isEdit == 'edit'" size="mini" type="primary" style="float: right;margin:0 10px 0 0;" icon="el-icon-save" @click="handleSave">保存</el-button>
  18. <el-button v-if="false" size="mini" type="primary" style="float: right;margin:0 10px 0 0;" @click="$router.replace(`/chartpanel/create`)">创建新的图表</el-button>
  19. </span>
  20. </div>
  21. </el-card>
  22. <div class="app-container" style="display: flex;">
  23. <el-card id="dataPanel" style="width:300px;margin-right: 20px;text-align:center;">
  24. <data-panel ref="dataPanel" :result-loading="loading" :data-src="dataSrc" :isEdit="this.$route.params.isEdit" @change="handleDataSrcChange" />
  25. </el-card>
  26. <!-- 图表部分 -->
  27. <el-card style="width: 100%;" body-style="padding: 10px 20px;">
  28. <div class="form-wrapper">
  29. <el-form id="formPanel" size="mini" class="analysis-form">
  30. <el-form-item id="dimensionInput" label="维度">
  31. <draggable v-model="sharedState.dimensions" :group="{name: 'col',pull: true, put: true}" class="draggable-wrapper" @change="handleDimensionChange">
  32. <el-tag v-for="col in sharedState.dimensions" :key="col.Column" class="draggable-item" size="small" closable @close="handleCloseDimensionTag(col)">
  33. {{ col.Comment }}
  34. </el-tag>
  35. </draggable>
  36. </el-form-item>
  37. <el-form-item id="fieldInput" label="数值">
  38. <draggable v-model="sharedState.caculCols" :group="{name: 'col',pull: true, put: true}" class="draggable-wrapper" @change="handleColChange">
  39. <el-tag v-for="col in sharedState.caculCols" :key="col.Column" size="small" closable class="selected-field" @close="handleCloseColTag(col)">
  40. <el-select v-model="col.calculFunc" class="draggable-item" size="mini" closable style="background: rgba(0,0,0,0);">
  41. <!-- <el-option v-for="(item, optIndex) in col.availableFunc" :key="optIndex" :label="`${col.Column}(${item.name})`" :value="item.func" /> -->
  42. <el-option v-for="(item, optIndex) in col.availableFunc" :key="optIndex" :label="`${col.Comment}(${item.name})`" :value="item.func" />
  43. </el-select>
  44. </el-tag>
  45. </draggable>
  46. </el-form-item>
  47. <orderPanel v-model="orderByStrs" />
  48. <filterPanel :filters.sync="currentFilters" :disabled="!allSelected || allSelected.length===0" @change="handleAddFilter" />
  49. <el-form-item>
  50. <div class="limit-input">
  51. <span v-show="!editLimit">
  52. {{ $t('chart.limit', [limit]) }}
  53. <el-button type="text" @click="editLimit=true">{{ $t('common.edit') }}</el-button>
  54. </span>
  55. <span v-show="editLimit">
  56. <el-input-number v-model="limit" :disabled="loading" size="mini" style="width:100px;" @blur="editLimit=false" :max="60000" />
  57. <el-button size="mini" @click="editLimit=false">确认</el-button>
  58. </span>
  59. </div>
  60. </el-form-item>
  61. </el-form>
  62. <el-form class="chart-form" size="mini" label-position="top">
  63. <el-form-item label="图表名称:">
  64. <el-input v-model="chartName" size="mini" :placeholder="$t('chart.namePlaceholder')" />
  65. </el-form-item>
  66. <el-form-item label="图表描述:">
  67. <el-input v-model="chartDesc" size="mini" :placeholder="$t('chart.descPlaceholder')" />
  68. </el-form-item>
  69. </el-form>
  70. </div>
  71. <visualize-panel id="vizPanel" v-loading="loading" :data="result" :chart-type.sync="chartType" :schema="allSelected" />
  72. </el-card>
  73. </div>
  74. <el-dialog :title="$t('chart.myChart')" :visible.sync="showMyCharts">
  75. <el-table :data="myChartList">
  76. <el-table-column :label="$t('chart.chartName')" width="200" prop="chart_name" />
  77. <el-table-column :label="$t('chart.chartDesc')" prop="desc" />
  78. <el-table-column :label="$t('common.operation')" width="200" align="center">
  79. <template slot-scope="scope">
  80. <el-button size="mini" type="primary" icon="el-icon-edit" @click="switchChart(scope.row)">
  81. {{ $t('common.edit') }}
  82. </el-button>
  83. <el-button size="mini" type="danger" icon="el-icon-delete" @click="deleteChart(scope.row)">
  84. {{ $t('common.delete') }}
  85. </el-button>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <span slot="footer" class="dialog-footer">
  90. <el-button type="primary" size="mini" @click="showMyCharts = false">{{ $t('common.close') }}</el-button>
  91. </span>
  92. </el-dialog>
  93. <el-dialog title="仪表盘列表" :visible.sync="showDashboards" width="25%">
  94. <p style=" ">请选择仪表盘</p>
  95. <div style="margin-bottom:20px;">
  96. <el-select v-model="selectedDb" size="small">
  97. <el-option v-for="item in dashboardList" :key="item.objectId" :label="item.name" :value="item.dashboard_id" />
  98. </el-select>
  99. </div>
  100. <span slot="footer" class="dialog-footer">
  101. <el-button type="primary" size="small" @click="showDashboards = false">取消</el-button>
  102. <el-button type="primary" size="small" @click="linkDb">添加到仪表盘</el-button>
  103. </span>
  104. </el-dialog>
  105. <!-- <el-tooltip content="帮助中心" placement="top"> -->
  106. <el-dropdown v-if="false" class="help-center-wrapper" placement="top" size="mini" @command="handleHelp">
  107. <div class="help-center">
  108. <i class="el-icon-question" />
  109. </div>
  110. <el-dropdown-menu slot="dropdown" size="mini">
  111. <el-dropdown-item command="guide">
  112. {{ this.$t('common.openGuide') }}
  113. </el-dropdown-item>
  114. </el-dropdown-menu>
  115. </el-dropdown>
  116. <!-- </el-tooltip 1> -->
  117. </div>
  118. </template>
  119. <script>
  120. import draggable from 'vuedraggable'
  121. import Driver from 'driver.js' // import driver.js
  122. import 'driver.js/dist/driver.min.css' // import driver.js css
  123. import { GetDataByName, ExeSqlJiade, PostDataByName, dashboardListJiade } from '@/api/common'
  124. import filterPanel from './components/filterPanel'
  125. import orderPanel from './components/orderPanel'
  126. import visualizePanel from './components/visualizePanel'
  127. import dataPanel from './components/dataPanel'
  128. import Cookies from 'js-cookie'
  129. import { createChart, updateChart, getChartById, chartList, deleteChart } from '@/api/chart'
  130. import { dashboardList, addChartToDB, dbByChart } from '@/api/dashboard'
  131. import exeSql from '@/api/exeSql'
  132. import { parseTime } from '@/utils'
  133. import { buildSqlSentence } from '@/utils/buildSentence'
  134. import steps from './guideSteps'
  135. import store from './store'
  136. const driver = new Driver()
  137. export default {
  138. name: 'ChartPanel',
  139. components: { visualizePanel, dataPanel, draggable, filterPanel, orderPanel },
  140. data() {
  141. return {
  142. loading: false,
  143. result: [],
  144. dataSrc: {},
  145. limit: 200,
  146. orderByStrs: [],
  147. filterStr: undefined,
  148. editLimit: false,
  149. currentFilters: [],
  150. sharedState: store.state,
  151. chartType: 'table',
  152. chartName: undefined,
  153. chartDesc: undefined,
  154. showMyCharts: false,
  155. myChartList: [],
  156. showDashboards: false,
  157. dashboardList: [],
  158. selectedDb: undefined,
  159. linkedDbIds: [],
  160. execInstance: null,
  161. LastInsertId: ""
  162. }
  163. },
  164. computed: {
  165. allSelected() {
  166. return store.state.dimensions.concat(store.state.caculCols)
  167. },
  168. sqlSentence() {
  169. return buildSqlSentence({
  170. dataSrc: this.dataSrc.table,
  171. selectedCalcul: this.sharedState.caculCols,
  172. selectedDimension: this.sharedState.dimensions,
  173. orderByStrs: this.orderByStrs,
  174. filterStr: this.filterStr,
  175. limit: this.limit
  176. })
  177. }
  178. },
  179. watch: {
  180. sqlSentence(value) {
  181. if (value) {
  182. this.fetchData(value)
  183. } else {
  184. this.result = []
  185. }
  186. },
  187. '$route.params.id': {
  188. immediate: true,
  189. handler() {
  190. if (this.$route.params.id !== 'create') {
  191. console.log('我是编辑图表哦~~~')
  192. console.log('this.$route.params.id', this.$route.params.id)
  193. console.log('localStorage==========', localStorage.getItem('ChartPanelIsEditId'))
  194. var send_data = {
  195. name: 'getChartDetail',
  196. parammaps: {
  197. pastureid: Cookies.get('pastureid'),
  198. // id: this.$route.params.id
  199. id: localStorage.getItem('ChartPanelIsEditId')
  200. }
  201. }
  202. GetDataByName(send_data).then(response => {
  203. console.log('图表数据', response.data.list)
  204. const chart = response.data.list[0]
  205. this.chartName = chart.chart_name
  206. this.chartDesc = chart.desc
  207. const content = JSON.parse(chart.content) || {}
  208. this.dataSrc.table = content.dataSrc
  209. this.dataSrc.source_id = chart.source_id
  210. this.chartType = content.chartType
  211. this.limit = content.limit || 200
  212. this.currentFilters = content.filters
  213. this.orderByStrs = content.orderByStrs
  214. store.setCaculColsAction(content.selectedCalcul)
  215. store.setDimensionsAction(content.selectedDimension)
  216. this.$refs.dataPanel.initWithDataSrc(this.dataSrc)
  217. })
  218. } else {
  219. console.log('我是新增图标哦~~~')
  220. this.chartName = undefined
  221. this.chartDesc = undefined
  222. store.setCaculColsAction([])
  223. store.setDimensionsAction([])
  224. this.$nextTick(() => {
  225. this.$refs.dataPanel.initWithDataSrc()
  226. })
  227. }
  228. }
  229. }
  230. },
  231. created() {
  232. },
  233. methods: {
  234. // fetchData(sqlSentence) {
  235. // if (this.loading) {
  236. // this.execInstance && this.execInstance.cancel()
  237. // }
  238. // this.loading = true
  239. // this.execInstance = exeSql()
  240. // this.execInstance.fetch({ source_id: this.dataSrc.source_id, sql: sqlSentence }).then(resp => {
  241. // this.loading = false
  242. // this.result = resp.data
  243. // })
  244. // },
  245. fetchData(sqlSentence) {
  246. if (this.loading) {
  247. this.execInstance && this.execInstance.cancel()
  248. }
  249. this.loading = true
  250. this.execInstance = exeSql()
  251. const obj = {
  252. dataSrc: this.dataSrc.table,
  253. source_id: this.dataSrc.source_id,
  254. orderByStrs: this.orderByStrs,
  255. limit: this.limit,
  256. selectedCalcul: this.sharedState.caculCols,
  257. selectedDimension: this.sharedState.dimensions,
  258. chartType: this.chartType,
  259. filters: this.currentFilters
  260. }
  261. var send_data = { source_id: this.dataSrc.source_id, content: obj, pastureid: Cookies.get('pastureid') }
  262. ExeSqlJiade(send_data).then(response => {
  263. console.log('图的数据', response.data.list)
  264. if (response.data !== null) {
  265. this.loading = false
  266. this.result = response.data
  267. } else {
  268. this.loading = false
  269. this.result = []
  270. }
  271. })
  272. },
  273. handleDataSrcChange(value) {
  274. console.log('dataSrc', value)
  275. this.dataSrc = value
  276. store.setCaculColsAction([])
  277. store.setDimensionsAction([])
  278. this.filterStr = undefined
  279. this.orderByStrs = []
  280. },
  281. handleColChange(evt) {
  282. if (evt.added) {
  283. store.addCaculColAction(evt.added.element)
  284. }
  285. },
  286. handleDimensionChange(evt) {
  287. console.log('handleDimensionChange的evt', evt)
  288. if (evt.added) {
  289. store.addDimensionAction(evt.added.element)
  290. }
  291. },
  292. handleCloseColTag(col) {
  293. store.deleteCaculColAction(col)
  294. },
  295. handleCloseDimensionTag(col) {
  296. store.deleteDimensionAction(col)
  297. },
  298. handleAddFilter(value) {
  299. this.filterStr = value
  300. },
  301. // 保存
  302. // handleSave() {
  303. // if (!this.chartName) {
  304. // this.$message({
  305. // type: 'warning',
  306. // message: this.$t('chart.chartNameWarning')
  307. // })
  308. // return
  309. // }
  310. // const chartId = this.$route.params.id === 'create' ? undefined : this.$route.params.id
  311. // const obj = {
  312. // dataSrc: this.dataSrc.table,
  313. // source_id: this.dataSrc.source_id,
  314. // orderByStrs: this.orderByStrs,
  315. // limit: this.limit,
  316. // selectedCalcul: this.sharedState.caculCols,
  317. // selectedDimension: this.sharedState.dimensions,
  318. // chartType: this.chartType,
  319. // filters: this.currentFilters
  320. // }
  321. // const data = {
  322. // id: chartId,
  323. // chart_name: this.chartName,
  324. // source_id: this.dataSrc.source_id,
  325. // desc: this.chartDesc,
  326. // content: obj
  327. // }
  328. // if (chartId) {
  329. // updateChart(data).then(resp => {
  330. // this.$message({
  331. // type: 'success',
  332. // message: this.$t('common.saveSuccess')
  333. // })
  334. // })
  335. // } else {
  336. // createChart(data).then(resp => {
  337. // // console.log(resp)
  338. // this.$router.replace(`/chartpanel/${resp.data.id}`)
  339. // this.$message({
  340. // type: 'success',
  341. // message: this.$t('common.saveSuccess')
  342. // })
  343. // })
  344. // }
  345. // },
  346. handleSave() {
  347. if (!this.chartName) {
  348. this.$message({
  349. type: 'warning',
  350. message: this.$t('chart.chartNameWarning')
  351. })
  352. return
  353. }
  354. // const chartId = this.$route.params.id === 'create' ? undefined : this.$route.params.id
  355. const chartId = localStorage.getItem('ChartPanelIsEditId') === 'create' ? undefined : localStorage.getItem('ChartPanelIsEditId')
  356. const obj = {
  357. dataSrc: this.dataSrc.table,
  358. source_id: this.dataSrc.source_id,
  359. orderByStrs: this.orderByStrs,
  360. limit: this.limit,
  361. selectedCalcul: this.sharedState.caculCols,
  362. selectedDimension: this.sharedState.dimensions,
  363. chartType: this.chartType,
  364. filters: this.currentFilters
  365. }
  366. const data = {
  367. name: 'insertChart',
  368. parammaps: {
  369. id: chartId,
  370. cname: this.chartName,
  371. source_id: this.dataSrc.source_id,
  372. desc: this.chartDesc,
  373. display: this.chartDesc,
  374. pastureid: Cookies.get('pastureid'),
  375. empid: Cookies.get('employeid'),
  376. emp: Cookies.get('employename'),
  377. content: obj
  378. }
  379. }
  380. var send_data2 = {
  381. name: 'updateChartV2',
  382. parammaps: {
  383. id: chartId,
  384. cname: this.chartName,
  385. source_id: this.dataSrc.source_id,
  386. desc: this.chartDesc,
  387. display: this.chartDesc,
  388. pastureid: Cookies.get('pastureid'),
  389. empid: Cookies.get('employeid'),
  390. emp: Cookies.get('employename'),
  391. content: obj
  392. }
  393. }
  394. if (chartId) {
  395. PostDataByName(send_data2).then(res => {
  396. console.log('编辑保存发送参数', data)
  397. this.$message({
  398. type: 'success',
  399. message: this.$t('common.saveSuccess')
  400. })
  401. })
  402. } else {
  403. PostDataByName(data).then(res => {
  404. console.log('新增保存发送参数', data)
  405. this.$message({
  406. type: 'success',
  407. message: this.$t('common.saveSuccess')
  408. })
  409. this.LastInsertId = res.data.LastInsertId
  410. })
  411. // createChart(data).then(resp => {
  412. // // console.log(resp)
  413. // this.$router.replace(`/chartpanel/${resp.data.id}`)
  414. // this.$message({
  415. // type: 'success',
  416. // message: this.$t('common.saveSuccess')
  417. // })
  418. // })
  419. }
  420. },
  421. handleLinkDB() {
  422. this.showDashboards = true
  423. var send_data = {
  424. name: 'getdashboards',
  425. parammaps: {
  426. pastureid: Cookies.get('pastureid'),
  427. empid: Cookies.get('employeid'),
  428. emp: Cookies.get('employename')
  429. }
  430. }
  431. dashboardListJiade(send_data).then(resp => {
  432. console.log('看板列表数据:', resp)
  433. this.dashboardList = resp.data.list
  434. })
  435. },
  436. getDbByChart(id) {
  437. dbByChart(id).then(resp => {
  438. this.linkedDbIds = resp.data || []
  439. })
  440. },
  441. isDbDisbaled(db) {
  442. return !!this.linkedDbIds.find(id => id === db.objectId)
  443. },
  444. linkDb() {
  445. this.showDashboards = false
  446. console.log(this.$route.params.id)
  447. console.log('仪表盘列表ID:', this.selectedDb)
  448. var chartid1 = this.$route.params.id
  449. if (chartid1 == "create") {
  450. chartid1 = this.LastInsertId
  451. } else {
  452. chartid1 = localStorage.getItem('ChartPanelIsEditId')
  453. }
  454. // var chartid1 = localStorage.getItem('ChartPanelIsEditId')
  455. // if (chartid1 == "create") {
  456. // chartid1 = this.LastInsertId
  457. // } else {
  458. // chartid1 = localStorage.getItem('ChartPanelIsEditId')
  459. // }
  460. const data = {
  461. name: 'insertdashboard_chart',
  462. parammaps: {
  463. did: this.selectedDb,
  464. cid: chartid1,
  465. pastureid: Cookies.get('pastureid')
  466. }
  467. }
  468. PostDataByName(data).then(response => {
  469. console.log('看板保存发送参数', data)
  470. this.$message({
  471. type: 'success',
  472. message: this.$t('common.saveSuccess')
  473. })
  474. })
  475. },
  476. viewAllChart() {
  477. this.showMyCharts = true
  478. // chartList().then(resp => {
  479. // this.myChartList = resp.data
  480. // })
  481. this.myChartList = [{ 'name': 'kook', 'desc': '', 'content': '{"layout": [{"id": "035573f4-bf71-4472-814a-f1747b6bd8e0", "x": 0, "y": 7, "w": 5, "h": 6, "i": "035573f4-bf71-4472-814a-f1747b6bd8e0", "moved": false, "yOffSet": 13, "xOffSet": 5, "bottomLine": [[0, 13], [5, 13]], "topLine": [[0, 7], [5, 7]]}, {"id": "02c012be-db57-431b-b9aa-40d1640a2592", "x": 2, "y": 29, "w": 7, "h": 6, "i": "02c012be-db57-431b-b9aa-40d1640a2592", "yOffSet": 35, "xOffSet": 9, "bottomLine": [[2, 35], [9, 35]], "topLine": [[2, 29], [9, 29]], "moved": false}, {"id": "087df61d-b02e-49a5-a954-b2d9124df685", "x": 6, "y": 0, "w": 7, "h": 7, "i": "087df61d-b02e-49a5-a954-b2d9124df685", "moved": false, "yOffSet": 7, "xOffSet": 13, "bottomLine": [[6, 7], [13, 7]], "topLine": [[6, 0], [13, 0]]}, {"id": "045ad6b0-8f7e-47db-92a7-8c4a31b7683d", "x": 5, "y": 16, "w": 10, "h": 6, "i": "045ad6b0-8f7e-47db-92a7-8c4a31b7683d", "moved": false, "yOffSet": 22, "xOffSet": 15, "bottomLine": [[5, 22], [15, 22]], "topLine": [[5, 16], [15, 16]]}, {"id": "182d02ef-ced5-4ded-a648-630c94f4a790", "x": 9, "y": 22, "w": 9, "h": 9, "i": "182d02ef-ced5-4ded-a648-630c94f4a790", "moved": false, "yOffSet": 31, "xOffSet": 18, "bottomLine": [[9, 31], [18, 31]], "topLine": [[9, 22], [18, 22]]}, {"id": "0755ae6e-6869-4e09-8630-62dd3118a2fc", "x": 0, "y": 0, "w": 6, "h": 7, "i": "0755ae6e-6869-4e09-8630-62dd3118a2fc", "moved": false, "yOffSet": 7, "xOffSet": 6, "bottomLine": [[0, 7], [6, 7]], "topLine": [[0, 0], [6, 0]]}, {"id": "3e4408f1-67c2-45c7-8315-136a6eec6980", "x": 5, "y": 22, "w": 4, "h": 7, "i": "3e4408f1-67c2-45c7-8315-136a6eec6980", "moved": false, "yOffSet": 29, "xOffSet": 9, "bottomLine": [[5, 29], [9, 29]], "topLine": [[5, 22], [9, 22]]}, {"id": "00af7fdb-b486-4855-ac7c-85014d283f2c", "x": 5, "y": 7, "w": 5, "h": 9, "i": "00af7fdb-b486-4855-ac7c-85014d283f2c", "moved": false, "yOffSet": 16, "xOffSet": 10, "bottomLine": [[5, 16], [10, 16]], "topLine": [[5, 7], [10, 7]]}, {"id": "3e39e265-684b-4d62-be3c-4613fd8730cd", "x": 14, "y": 7, "w": 8, "h": 9, "i": "3e39e265-684b-4d62-be3c-4613fd8730cd", "moved": false}]}', 'is_private': true, 'status': 1, 'creator': 1, 'created_at': '2020-05-13T06:08:39.438Z', 'updated_at': '2020-09-14T07:48:58.477Z', 'dashboard_id': 'dd02cfe9-8ee9-48fa-83b3-98b604d87b57' }]
  482. },
  483. switchChart(chart) {
  484. this.$confirm(this.$t('chart.beforeLeaveConfirm'), this.$t('common.confirm')).then(() => {
  485. this.$router.replace(`/chartpanel/${chart.chart_id}`)
  486. this.showMyCharts = false
  487. })
  488. },
  489. deleteChart(chart) {
  490. this.$confirm(this.$t('chart.deleteConfirm', chart.chart_name), this.$t('common.confirm')).then(() => {
  491. deleteChart({ chart_id: chart.chart_id }).then(() => {
  492. // if (this.$route.params.id === chart.chart_id) {
  493. // this.$router.push('/chartpanel/create')
  494. // this.showMyCharts = false
  495. // } else {
  496. // this.viewAllChart()
  497. // }
  498. if (localStorage.getItem('ChartPanelIsEditId') === chart.chart_id) {
  499. this.$router.push('/chartpanel/create')
  500. this.showMyCharts = false
  501. } else {
  502. this.viewAllChart()
  503. }
  504. this.$message({
  505. type: 'success',
  506. message: this.$t('common.deleteSuccess')
  507. })
  508. })
  509. })
  510. },
  511. handleHelp(command) {
  512. if (command === 'guide') {
  513. driver.defineSteps(steps)
  514. driver.start()
  515. }
  516. },
  517. handleDownload() {
  518. import('@/vendor/Export2Excel').then(excel => {
  519. const tHeader = this.allSelected.map(item => item.Column)
  520. const filterVal = tHeader
  521. const data = this.formatJson(filterVal, this.result)
  522. excel.export_json_to_excel({ header: tHeader, data, filename: 'DataExport' + parseTime(Date.now(), '{m}{d}{h}{i}{s}'), autoWidth: true })
  523. })
  524. },
  525. formatJson(filterVal, jsonData) {
  526. return jsonData.map(v =>
  527. filterVal.map(j => {
  528. const tempArr = j.split('.')
  529. if (tempArr.length <= 1) {
  530. return v[j]
  531. } else {
  532. return tempArr.reduce(
  533. (pre, cur) => (pre[cur] ? pre[cur] : '--'),
  534. v
  535. )
  536. }
  537. })
  538. )
  539. }
  540. }
  541. }
  542. </script>
  543. <style lang="scss" scoped>
  544. .back-button {
  545. display: inline-block;
  546. padding-right: 10px;
  547. margin-right: 10px;
  548. border-right: 1px solid #909090;
  549. cursor: pointer;
  550. span {
  551. padding: 5px;
  552. font-size: 14px;
  553. }
  554. }
  555. .analysis-form {
  556. width: 100%;
  557. padding-right: 20px;
  558. /deep/ .el-form-item--mini.el-form-item {
  559. margin-bottom: 10px;
  560. }
  561. /deep/ .el-form-item--mini .el-form-item__label,
  562. .limit-input {
  563. color: #909399;
  564. font-size: 14px;
  565. }
  566. }
  567. .form-wrapper {
  568. display: flex;
  569. }
  570. .chart-form {
  571. width: 250px;
  572. /deep/ .el-form-item--mini.el-form-item {
  573. margin-bottom: 10px;
  574. }
  575. }
  576. .draggable-wrapper {
  577. font-size: 14px;
  578. min-height: 30px;
  579. border-bottom: 1px solid #e4e7ed;
  580. .draggable-item {
  581. margin-right: 10px;
  582. }
  583. /deep/ .el-select--mini {
  584. margin: 0;
  585. }
  586. }
  587. .selected-field {
  588. /deep/ .el-input__inner {
  589. height: 20px;
  590. line-height: 20px;
  591. border: none;
  592. background-color: rgba($color: #fff, $alpha: 0);
  593. padding: 0;
  594. }
  595. /deep/ .el-input__suffix {
  596. right: 0px;
  597. .el-input__suffix-inner {
  598. display: inline-block;
  599. height: 20px;
  600. line-height: 20px;
  601. .el-input__icon {
  602. font-size: 12px;
  603. line-height: 20px;
  604. }
  605. }
  606. }
  607. }
  608. .help-center-wrapper {
  609. cursor: pointer;
  610. position: fixed;
  611. bottom: 25px;
  612. right: 25px;
  613. .help-center {
  614. width: 45px;
  615. height: 45px;
  616. background: #fff;
  617. border-radius: 50%;
  618. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  619. line-height: 45px;
  620. font-size: 20px;
  621. color: #205cd8;
  622. text-align: center;
  623. /deep/ .el-dropdown {
  624. font-size: 20px;
  625. color: #205cd8;
  626. }
  627. }
  628. }
  629. .el-dialog__body {
  630. padding: 20px 20px 50px 20px;
  631. color: #606266;
  632. font-size: 14px;
  633. word-break: break-all;
  634. }
  635. </style>