7e1815086f24c60a87893c30ee0faeec30e8b15e.svn-base 23 KB

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