f5ec79ccede31cf0c1bfc1130e2a5da02a319206.svn-base 23 KB

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