0c7c4f1e421b85d545612d8014e6d55e1fab6eb6.svn-base 29 KB

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