88a7c07a5889de70398d437efde99bfe23346c19.svn-base 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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.go(-1)">
  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. <el-button size="mini" type="text" style="margin-left:10px;" @click="viewAllChart">
  13. {{ $t('chart.allCharts') }}
  14. </el-button>
  15. </span>
  16. <span>
  17. <el-button v-if="false" size="mini" type="primary" style="float: right;margin:0 10px 0 0;" icon="el-icon-download" @click="handleDownload" />
  18. <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>
  19. <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>
  20. <el-button v-if="false" size="mini" type="primary" style="float: right;margin:0 10px 0 0;" @click="$router.replace(`/chartpanel/create`)">创建新的图表</el-button>
  21. </span>
  22. </div>
  23. </el-card>
  24. <div class="app-container" style="display: flex;">
  25. <el-card id="dataPanel" style="width:300px;margin-right: 20px;text-align:center;">
  26. <data-panel ref="dataPanel" :result-loading="loading" :data-src="dataSrc" @change="handleDataSrcChange" />
  27. </el-card>
  28. <!-- 图表部分 -->
  29. <el-card style="width: 100%;" body-style="padding: 10px 20px;">
  30. <div class="form-wrapper">
  31. <el-form id="formPanel" size="mini" class="analysis-form">
  32. <el-form-item id="dimensionInput" :label="$t('chart.dimensions')">
  33. <draggable v-model="sharedState.dimensions" :group="{name: 'col',pull: true, put: true}" class="draggable-wrapper" @change="handleDimensionChange">
  34. <el-tag v-for="col in sharedState.dimensions" :key="col.Column" class="draggable-item" size="small" closable @close="handleCloseDimensionTag(col)">
  35. {{ col.Comment }}
  36. </el-tag>
  37. </draggable>
  38. </el-form-item>
  39. <el-form-item id="fieldInput" :label="$t('chart.values')">
  40. <draggable v-model="sharedState.caculCols" :group="{name: 'col',pull: true, put: true}" class="draggable-wrapper" @change="handleColChange">
  41. <el-tag v-for="col in sharedState.caculCols" :key="col.Column" size="small" closable class="selected-field" @close="handleCloseColTag(col)">
  42. <el-select v-model="col.calculFunc" class="draggable-item" size="mini" closable style="background: rgba(0,0,0,0);">
  43. <el-option v-for="(item, optIndex) in col.availableFunc" :key="optIndex" :label="`${col.Column}(${item.name})`" :value="item.func" />
  44. </el-select>
  45. </el-tag>
  46. </draggable>
  47. </el-form-item>
  48. <orderPanel v-model="orderByStrs" />
  49. <filterPanel :filters.sync="currentFilters" :disabled="!allSelected || allSelected.length===0" @change="handleAddFilter" />
  50. <el-form-item>
  51. <div class="limit-input">
  52. <span v-show="!editLimit">
  53. {{ $t('chart.limit', [limit]) }}
  54. <el-button type="text" @click="editLimit=true">{{ $t('common.edit') }}</el-button>
  55. </span>
  56. <span v-show="editLimit">
  57. <el-input-number v-model="limit" :disabled="loading" size="mini" style="width:100px;" @blur="editLimit=false" />
  58. <el-button size="mini" @click="editLimit=false">{{ $t('common.confirm') }}</el-button>
  59. </span>
  60. </div>
  61. </el-form-item>
  62. </el-form>
  63. <el-form class="chart-form" size="mini" label-position="top">
  64. <el-form-item :label="$t('chart.chartName')+':'">
  65. <el-input v-model="chartName" size="mini" :placeholder="$t('chart.namePlaceholder')" />
  66. </el-form-item>
  67. <el-form-item :label="$t('chart.chartDesc')+':'">
  68. <el-input v-model="chartDesc" size="mini" :placeholder="$t('chart.descPlaceholder')" />
  69. </el-form-item>
  70. </el-form>
  71. </div>
  72. <visualize-panel id="vizPanel" v-loading="loading" :data="result" :chart-type.sync="chartType" :schema="allSelected" />
  73. </el-card>
  74. </div>
  75. <el-dialog :title="$t('chart.myChart')" :visible.sync="showMyCharts">
  76. <el-table :data="myChartList">
  77. <el-table-column :label="$t('chart.chartName')" width="200" prop="chart_name" />
  78. <el-table-column :label="$t('chart.chartDesc')" prop="desc" />
  79. <el-table-column :label="$t('common.operation')" width="200" align="center">
  80. <template slot-scope="scope">
  81. <el-button size="mini" type="primary" icon="el-icon-edit" @click="switchChart(scope.row)">
  82. {{ $t('common.edit') }}
  83. </el-button>
  84. <el-button size="mini" type="danger" icon="el-icon-delete" @click="deleteChart(scope.row)">
  85. {{ $t('common.delete') }}
  86. </el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. <span slot="footer" class="dialog-footer">
  91. <el-button type="primary" size="mini" @click="showMyCharts = false">{{ $t('common.close') }}</el-button>
  92. </span>
  93. </el-dialog>
  94. <el-dialog :title="$t('dashboard.dashboardList')" :visible.sync="showDashboards">
  95. <div style="text-align:center;">
  96. <el-select v-model="selectedDb" size="small">
  97. <el-option v-for="item in dashboardList" :key="item.objectId" :label="item.name" :disabled="isDbDisbaled(item)" :value="item.objectId" />
  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. }
  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. var send_data = {
  193. name: 'getChartDetail',
  194. parammaps: {
  195. pastureid: Cookies.get('pastureid'),
  196. id: this.$route.params.id
  197. }
  198. }
  199. GetDataByName(send_data).then(response => {
  200. console.log('图表数据', response.data.list)
  201. const chart = response.data.list[0]
  202. this.chartName = chart.chart_name
  203. this.chartDesc = chart.desc
  204. const content = JSON.parse(chart.content) || {}
  205. this.dataSrc.table = content.dataSrc
  206. this.dataSrc.source_id = chart.source_id
  207. this.chartType = content.chartType
  208. this.limit = content.limit || 200
  209. this.currentFilters = content.filters
  210. this.orderByStrs = content.orderByStrs
  211. store.setCaculColsAction(content.selectedCalcul)
  212. store.setDimensionsAction(content.selectedDimension)
  213. this.$refs.dataPanel.initWithDataSrc(this.dataSrc)
  214. })
  215. } else {
  216. console.log('我是新增图标哦~~~')
  217. this.chartName = undefined
  218. this.chartDesc = undefined
  219. store.setCaculColsAction([])
  220. store.setDimensionsAction([])
  221. this.$nextTick(() => {
  222. this.$refs.dataPanel.initWithDataSrc()
  223. })
  224. }
  225. }
  226. }
  227. },
  228. created() {
  229. },
  230. methods: {
  231. // fetchData(sqlSentence) {
  232. // if (this.loading) {
  233. // this.execInstance && this.execInstance.cancel()
  234. // }
  235. // this.loading = true
  236. // this.execInstance = exeSql()
  237. // this.execInstance.fetch({ source_id: this.dataSrc.source_id, sql: sqlSentence }).then(resp => {
  238. // this.loading = false
  239. // this.result = resp.data
  240. // })
  241. // },
  242. fetchData(sqlSentence) {
  243. if (this.loading) {
  244. this.execInstance && this.execInstance.cancel()
  245. }
  246. this.loading = true
  247. this.execInstance = exeSql()
  248. const obj = {
  249. dataSrc: this.dataSrc.table,
  250. source_id: this.dataSrc.source_id,
  251. orderByStrs: this.orderByStrs,
  252. limit: this.limit,
  253. selectedCalcul: this.sharedState.caculCols,
  254. selectedDimension: this.sharedState.dimensions,
  255. chartType: this.chartType,
  256. filters: this.currentFilters
  257. }
  258. var send_data = { source_id: this.dataSrc.source_id, content: obj, pastureid: Cookies.get('pastureid') }
  259. ExeSqlJiade(send_data).then(response => {
  260. console.log('图的数据', response.data.list)
  261. if (response.data !== null) {
  262. this.loading = false
  263. this.result = response.data
  264. } else {
  265. this.loading = false
  266. this.result = []
  267. }
  268. })
  269. },
  270. handleDataSrcChange(value) {
  271. console.log('dataSrc', value)
  272. this.dataSrc = value
  273. store.setCaculColsAction([])
  274. store.setDimensionsAction([])
  275. this.filterStr = undefined
  276. this.orderByStrs = []
  277. },
  278. handleColChange(evt) {
  279. if (evt.added) {
  280. store.addCaculColAction(evt.added.element)
  281. }
  282. },
  283. handleDimensionChange(evt) {
  284. console.log('handleDimensionChange的evt', evt)
  285. if (evt.added) {
  286. store.addDimensionAction(evt.added.element)
  287. }
  288. },
  289. handleCloseColTag(col) {
  290. store.deleteCaculColAction(col)
  291. },
  292. handleCloseDimensionTag(col) {
  293. store.deleteDimensionAction(col)
  294. },
  295. handleAddFilter(value) {
  296. this.filterStr = value
  297. },
  298. // 保存
  299. // handleSave() {
  300. // if (!this.chartName) {
  301. // this.$message({
  302. // type: 'warning',
  303. // message: this.$t('chart.chartNameWarning')
  304. // })
  305. // return
  306. // }
  307. // const chartId = this.$route.params.id === 'create' ? undefined : this.$route.params.id
  308. // const obj = {
  309. // dataSrc: this.dataSrc.table,
  310. // source_id: this.dataSrc.source_id,
  311. // orderByStrs: this.orderByStrs,
  312. // limit: this.limit,
  313. // selectedCalcul: this.sharedState.caculCols,
  314. // selectedDimension: this.sharedState.dimensions,
  315. // chartType: this.chartType,
  316. // filters: this.currentFilters
  317. // }
  318. // const data = {
  319. // id: chartId,
  320. // chart_name: this.chartName,
  321. // source_id: this.dataSrc.source_id,
  322. // desc: this.chartDesc,
  323. // content: obj
  324. // }
  325. // if (chartId) {
  326. // updateChart(data).then(resp => {
  327. // this.$message({
  328. // type: 'success',
  329. // message: this.$t('common.saveSuccess')
  330. // })
  331. // })
  332. // } else {
  333. // createChart(data).then(resp => {
  334. // // console.log(resp)
  335. // this.$router.replace(`/chartpanel/${resp.data.id}`)
  336. // this.$message({
  337. // type: 'success',
  338. // message: this.$t('common.saveSuccess')
  339. // })
  340. // })
  341. // }
  342. // },
  343. handleSave() {
  344. if (!this.chartName) {
  345. this.$message({
  346. type: 'warning',
  347. message: this.$t('chart.chartNameWarning')
  348. })
  349. return
  350. }
  351. const chartId = this.$route.params.id === 'create' ? undefined : this.$route.params.id
  352. const obj = {
  353. dataSrc: this.dataSrc.table,
  354. source_id: this.dataSrc.source_id,
  355. orderByStrs: this.orderByStrs,
  356. limit: this.limit,
  357. selectedCalcul: this.sharedState.caculCols,
  358. selectedDimension: this.sharedState.dimensions,
  359. chartType: this.chartType,
  360. filters: this.currentFilters
  361. }
  362. const data = {
  363. name: 'insertChart',
  364. parammaps: {
  365. id: chartId,
  366. cname: this.chartName,
  367. source_id: this.dataSrc.source_id,
  368. desc: this.chartDesc,
  369. display: this.chartDesc,
  370. pastureid: Cookies.get('pastureid'),
  371. empid: Cookies.get('employeid'),
  372. emp: Cookies.get('employename'),
  373. content: obj
  374. }
  375. }
  376. var send_data2 = {
  377. name: 'updateChartV2',
  378. parammaps: {
  379. id: chartId,
  380. cname: this.chartName,
  381. source_id: this.dataSrc.source_id,
  382. desc: this.chartDesc,
  383. display: this.chartDesc,
  384. pastureid: Cookies.get('pastureid'),
  385. empid: Cookies.get('employeid'),
  386. emp: Cookies.get('employename'),
  387. content: obj
  388. }
  389. }
  390. if (chartId) {
  391. PostDataByName(send_data2).then(response => {
  392. console.log('编辑保存发送参数', data)
  393. this.$message({
  394. type: 'success',
  395. message: this.$t('common.saveSuccess')
  396. })
  397. })
  398. } else {
  399. PostDataByName(data).then(response => {
  400. console.log('新增保存发送参数', data)
  401. this.$message({
  402. type: 'success',
  403. message: this.$t('common.saveSuccess')
  404. })
  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. const data = {
  442. name: 'insertdashboard_chart',
  443. parammaps: {
  444. did: this.selectedDb,
  445. cid: this.$route.params.id,
  446. pastureid: Cookies.get('pastureid')
  447. }
  448. }
  449. PostDataByName(data).then(response => {
  450. console.log('看板保存发送参数', data)
  451. this.$message({
  452. type: 'success',
  453. message: this.$t('common.saveSuccess')
  454. })
  455. })
  456. },
  457. viewAllChart() {
  458. this.showMyCharts = true
  459. // chartList().then(resp => {
  460. // this.myChartList = resp.data
  461. // })
  462. 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' }]
  463. },
  464. switchChart(chart) {
  465. this.$confirm(this.$t('chart.beforeLeaveConfirm'), this.$t('common.confirm')).then(() => {
  466. this.$router.replace(`/chartpanel/${chart.chart_id}`)
  467. this.showMyCharts = false
  468. })
  469. },
  470. deleteChart(chart) {
  471. this.$confirm(this.$t('chart.deleteConfirm', chart.chart_name), this.$t('common.confirm')).then(() => {
  472. deleteChart({ chart_id: chart.chart_id }).then(() => {
  473. if (this.$route.params.id === chart.chart_id) {
  474. this.$router.push('/chartpanel/create')
  475. this.showMyCharts = false
  476. } else {
  477. this.viewAllChart()
  478. }
  479. this.$message({
  480. type: 'success',
  481. message: this.$t('common.deleteSuccess')
  482. })
  483. })
  484. })
  485. },
  486. handleHelp(command) {
  487. if (command === 'guide') {
  488. driver.defineSteps(steps)
  489. driver.start()
  490. }
  491. },
  492. handleDownload() {
  493. import('@/vendor/Export2Excel').then(excel => {
  494. const tHeader = this.allSelected.map(item => item.Column)
  495. const filterVal = tHeader
  496. const data = this.formatJson(filterVal, this.result)
  497. excel.export_json_to_excel({ header: tHeader, data, filename: 'DataExport' + parseTime(Date.now(), '{m}{d}{h}{i}{s}'), autoWidth: true })
  498. })
  499. },
  500. formatJson(filterVal, jsonData) {
  501. return jsonData.map(v =>
  502. filterVal.map(j => {
  503. const tempArr = j.split('.')
  504. if (tempArr.length <= 1) {
  505. return v[j]
  506. } else {
  507. return tempArr.reduce(
  508. (pre, cur) => (pre[cur] ? pre[cur] : '--'),
  509. v
  510. )
  511. }
  512. })
  513. )
  514. }
  515. }
  516. }
  517. </script>
  518. <style lang="scss" scoped>
  519. .back-button {
  520. display: inline-block;
  521. padding-right: 10px;
  522. margin-right: 10px;
  523. border-right: 1px solid #909090;
  524. cursor: pointer;
  525. span {
  526. padding: 5px;
  527. font-size: 14px;
  528. }
  529. }
  530. .analysis-form {
  531. width: 100%;
  532. padding-right: 20px;
  533. /deep/ .el-form-item--mini.el-form-item {
  534. margin-bottom: 10px;
  535. }
  536. /deep/ .el-form-item--mini .el-form-item__label,
  537. .limit-input {
  538. color: #909399;
  539. font-size: 14px;
  540. }
  541. }
  542. .form-wrapper {
  543. display: flex;
  544. }
  545. .chart-form {
  546. width: 250px;
  547. /deep/ .el-form-item--mini.el-form-item {
  548. margin-bottom: 10px;
  549. }
  550. }
  551. .draggable-wrapper {
  552. font-size: 14px;
  553. min-height: 30px;
  554. border-bottom: 1px solid #e4e7ed;
  555. .draggable-item {
  556. margin-right: 10px;
  557. }
  558. /deep/ .el-select--mini {
  559. margin: 0;
  560. }
  561. }
  562. .selected-field {
  563. /deep/ .el-input__inner {
  564. height: 20px;
  565. line-height: 20px;
  566. border: none;
  567. background-color: rgba($color: #fff, $alpha: 0);
  568. padding: 0;
  569. }
  570. /deep/ .el-input__suffix {
  571. right: 0px;
  572. .el-input__suffix-inner {
  573. display: inline-block;
  574. height: 20px;
  575. line-height: 20px;
  576. .el-input__icon {
  577. font-size: 12px;
  578. line-height: 20px;
  579. }
  580. }
  581. }
  582. }
  583. .help-center-wrapper {
  584. cursor: pointer;
  585. position: fixed;
  586. bottom: 25px;
  587. right: 25px;
  588. .help-center {
  589. width: 45px;
  590. height: 45px;
  591. background: #fff;
  592. border-radius: 50%;
  593. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  594. line-height: 45px;
  595. font-size: 20px;
  596. color: #205cd8;
  597. text-align: center;
  598. /deep/ .el-dropdown {
  599. font-size: 20px;
  600. color: #205cd8;
  601. }
  602. }
  603. }
  604. </style>