758e532faf932ac4ec27c18cde269daa245db3fc.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div v-loading="loading" class="container" style="position:relactive">
  3. <div v-show="editBtn" style="position:absolute;top:170px;right:100px;z-index:1">
  4. <!-- <el-button class="miniSuccess" @click="control_edit()">编辑</el-button> -->
  5. <el-button v-if="isRoleEdit" class="successBorder" :loading="control_btn_l" @click="control_edit()">
  6. {{ control_btn }}
  7. </el-button>
  8. </div>
  9. <el-card v-show="false" body-style="padding: 0px;" class="dashboard-list" shadow="never">
  10. <!-- <div slot="header">
  11. <span>看板</span>
  12. <i class="el-icon-plus" @click="addDashboard" />
  13. </div> -->
  14. <ul>
  15. <draggable v-model="dashboardList" :group="{name: 'dashboard',pull: true}" class="draggable-wrapper" @change="handleOrderChange">
  16. <li v-for="item in dashboardList" :key="item.dashboard_id" :class="{'dashboard-list-item': true, 'high-light-dashboard': currentDashboard.dashboard_id === item.dashboard_id}">
  17. <span @click="switchDb(item)">
  18. <i class="el-icon-document" />
  19. <span>{{ item.name }}</span>
  20. </span>
  21. <el-dropdown szie="mini" trigger="click" @command="handleCommand">
  22. <span class="el-dropdown-link">
  23. <i class="el-icon-more" />
  24. </span>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item
  27. :command="{
  28. type: 'edit',
  29. target: item
  30. }"
  31. >
  32. {{ $t('common.edit') }}
  33. </el-dropdown-item>
  34. <el-dropdown-item
  35. :command="{
  36. type: 'delete',
  37. target: item
  38. }"
  39. >
  40. {{ $t('common.delete') }}
  41. </el-dropdown-item>
  42. </el-dropdown-menu>
  43. </el-dropdown>
  44. </li>
  45. </draggable>
  46. </ul>
  47. </el-card>
  48. <dashboardItem :dashboard="currentDashboard" :mode="isEdit" :title="isTitle" @fatherMethod="getList" />
  49. <el-dialog :title="$t('dashboard.addOrEditDashboard')" width="750px" :visible.sync="editDialogVisible">
  50. <el-form label-width="160px">
  51. <el-form-item :label="$t('dashboard.dashboardName')">
  52. <el-input v-model="dbObj.name" size="small" style="width: 450px;" :placeholder="$t('dashboard.dashboardNamePlaceholder')" />
  53. </el-form-item>
  54. <el-form-item :label="$t('dashboard.dashboardDesc')">
  55. <el-input v-model="dbObj.desc" type="textarea" :rows="5" size="small" style="width: 450px;" :placeholder="$t('dashboard.dashboardDescPlaceholder')" />
  56. </el-form-item>
  57. </el-form>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button type="primary" size="small" @click="editDialogVisible = false"> {{ $t('common.cancel') }}</el-button>
  60. <el-button type="primary" size="small" @click="handleSubmit"> {{ $t('common.confirm') }}</el-button>
  61. </span>
  62. </el-dialog>
  63. </div>
  64. </template>
  65. <script>
  66. import draggable from 'vuedraggable'
  67. import dashboardItem from './dashboardItem'
  68. import { GetDataByName, ExeSqlJiade, PostDataByName, dashboardListJiade, checkButtons } from '@/api/common'
  69. import Cookies from 'js-cookie'
  70. // import { addDashboard, updateDashboard, dashboardList, deleteDashboard, dbOrder } from '@/api/dashboard'
  71. import { addDashboard, updateDashboard, deleteDashboard, dbOrder } from '@/api/dashboard'
  72. export default {
  73. name: 'Addboard',
  74. components: { dashboardItem, draggable },
  75. data() {
  76. return {
  77. isRoleEdit: [],
  78. isEdit: 'view',
  79. dashboardList: [],
  80. currentDashboard: undefined,
  81. editDialogVisible: false,
  82. dbObj: {},
  83. loading: false,
  84. isCollapse: false,
  85. did: undefined,
  86. isTitle: '2',
  87. editBtn: false,
  88. control_btn: '编辑',
  89. control_btn_l: false,
  90. get_role_data: {
  91. name: 'getChartRole',
  92. page: 1,
  93. offset: 1,
  94. pagecount: 10,
  95. returntype: 'Map',
  96. parammaps: {
  97. pastureid: Cookies.get('pastureid'),
  98. empid: Cookies.get('employeid'),
  99. type: '1',
  100. id: localStorage.getItem('AddboardIsEditId')
  101. }
  102. }
  103. }
  104. },
  105. created() {
  106. // console.log('this.$route.params.id', this.$route.params.id)
  107. // const isEdit = this.$route.params.isEdit
  108. // this.isEdit = isEdit
  109. const Edit = 'BoardEchartManagement'
  110. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  111. this.isRoleEdit = isRoleEdit
  112. // this.isRoleEdit = this.$route.params.isRoleEdit
  113. this.did = window.location.href.split('~')[1]
  114. this.haha = window.location.href.split('~')[2]
  115. console.log('this.did', this.did)
  116. console.log('this.haha', this.haha)
  117. console.log('this.isRoleEdit', this.isRoleEdit)
  118. if (this.haha == 3) {
  119. console.log('this.haha333333333')
  120. this.isTitle = '3'
  121. this.editBtn = false
  122. } else {
  123. this.isTitle = '2'
  124. this.get_Role()
  125. }
  126. this.getList()
  127. },
  128. methods: {
  129. get_Role() {
  130. GetDataByName(this.get_role_data).then(res => {
  131. console.log('权限数据', res.data)
  132. if (res.data.list[0].statue == 'editOk') {
  133. this.editBtn = true
  134. } else {
  135. this.editBtn = false
  136. }
  137. console.log('this.editBtn', this.editBtn)
  138. })
  139. },
  140. control_edit() {
  141. this.isEdit = 'edit'
  142. if (this.control_btn == '编辑') {
  143. this.control_btn = '正在编辑'
  144. this.control_btn_l = true
  145. } else {
  146. this.control_btn = '编辑'
  147. this.control_btn_l = false
  148. }
  149. },
  150. // getList() {
  151. // this.loading = true
  152. // dashboardList().then(resp => {
  153. // this.loading = false
  154. // this.dashboardList = []
  155. // resp.data.order.forEach((id, index) => {
  156. // const itemIndex = resp.data.dashboards.findIndex(item => item.dashboard_id === id)
  157. // if (itemIndex >= 0) {
  158. // this.dashboardList.push(resp.data.dashboards[itemIndex])
  159. // resp.data.dashboards.splice(itemIndex, 1)
  160. // } else {
  161. // console.log(id, index)
  162. // }
  163. // })
  164. // this.dashboardList = this.dashboardList.concat(resp.data.dashboards)
  165. // const dashboard = this.dashboardList.find(item => item.dashboard_id === this.$route.query.id)
  166. // if (dashboard) {
  167. // this.currentDashboard = dashboard
  168. // } else {
  169. // this.currentDashboard = this.dashboardList[0]
  170. // }
  171. // if (this.currentDashboard) {
  172. // this.$router.push(`/dashboard?id=${this.currentDashboard.dashboard_id}`).catch(_ => { })
  173. // }
  174. // })
  175. // },
  176. getList() {
  177. this.loading = true
  178. // if (this.$route.params.id) {
  179. // this.did = this.$route.params.id
  180. // } else {
  181. // this.did = this.did
  182. // }
  183. if (this.did) {
  184. this.did = this.did
  185. } else {
  186. this.did = localStorage.getItem('AddboardIsEditId')
  187. }
  188. var send_data = {
  189. name: 'getdashboardsV2',
  190. parammaps: {
  191. pastureid: Cookies.get('pastureid'),
  192. empid: Cookies.get('employeid'),
  193. did: this.did
  194. }
  195. }
  196. console.log('进入大页面=================')
  197. dashboardListJiade(send_data).then(resp => {
  198. this.loading = false
  199. this.dashboardList = []
  200. console.log('看板列表数据:', resp)
  201. console.log('看板列表优化数据list:', resp.data.list)
  202. console.log('看板列表优化数据dashboards:', resp.data.dashboards)
  203. // resp.data.order.forEach((id, index) => {
  204. // const itemIndex = resp.data.dashboards.findIndex(item => item.dashboard_id === id)
  205. // if (itemIndex >= 0) {
  206. // this.dashboardList.push(resp.data.dashboards[itemIndex])
  207. // resp.data.dashboards.splice(itemIndex, 1)
  208. // } else {
  209. // console.log(id, index)
  210. // }
  211. // })
  212. this.dashboardList = this.dashboardList.concat(resp.data.dashboards)
  213. // const dashboard = this.dashboardList.find(item => item.dashboard_id === this.$route.params.id)
  214. const dashboard = this.dashboardList.find(item => item.dashboard_id === localStorage.getItem('AddboardIsEditId'))
  215. if (dashboard) {
  216. this.currentDashboard = dashboard
  217. } else {
  218. this.currentDashboard = this.dashboardList[0]
  219. }
  220. console.log('this.currentDashboard', this.currentDashboard)
  221. console.log('this.dashboardList', this.dashboardList)
  222. if (this.currentDashboard) {
  223. // this.$router.push({ path: '/customboard/addboard', query: { id: this.currentDashboard.dashboard_id }}).catch(_ => { })
  224. }
  225. })
  226. },
  227. switchDb(db) {
  228. if (db.dashboard_id === this.currentDashboard.dashboard_id) {
  229. this.getList()
  230. return
  231. }
  232. this.currentDashboard = db
  233. this.$router.push(`/dashboard?id=${this.currentDashboard.dashboard_id}`)
  234. },
  235. addDashboard() {
  236. this.dbObj = {}
  237. this.editDialogVisible = true
  238. },
  239. editDashboard(db) {
  240. this.dbObj = Object.assign({}, db)
  241. this.editDialogVisible = true
  242. },
  243. handleCommand(cmd) {
  244. if (cmd.type === 'edit') {
  245. this.editDashboard(cmd.target)
  246. } else {
  247. this.deleteDashboard(cmd.target)
  248. }
  249. },
  250. // handleSubmit() {
  251. // if (this.dbObj.dashboard_id) {
  252. // updateDashboard(this.dbObj).then(resp => {
  253. // this.getList()
  254. // this.editDialogVisible = false
  255. // })
  256. // } else {
  257. // addDashboard(this.dbObj).then(resp => {
  258. // this.getList()
  259. // this.editDialogVisible = false
  260. // })
  261. // }
  262. // },
  263. handleSubmit() {
  264. if (this.dbObj.dashboard_id) {
  265. updateDashboard(this.dbObj).then(resp => {
  266. this.getList()
  267. this.editDialogVisible = false
  268. })
  269. } else {
  270. console.log('this.dbObj', this.dbObj)
  271. var data = {
  272. name: 'insertDashboard',
  273. parammaps: {
  274. dname: this.dbObj.name,
  275. display: this.dbObj.desc,
  276. pastureid: Cookies.get('pastureid'),
  277. empid: Cookies.get('employeid'),
  278. emp: Cookies.get('employename')
  279. }
  280. }
  281. PostDataByName(data).then(response => {
  282. console.log('新增保存发送参数', data)
  283. this.$message({
  284. type: 'success',
  285. message: this.$t('common.saveSuccess')
  286. })
  287. this.getList()
  288. this.editDialogVisible = false
  289. })
  290. // addDashboard(this.dbObj).then(resp => {
  291. // this.getList()
  292. // this.editDialogVisible = false
  293. // })
  294. }
  295. },
  296. handleOrderChange(evt) {
  297. const data = {
  298. order: this.dashboardList.map(item => item.dashboard_id)
  299. }
  300. dbOrder(data)
  301. },
  302. deleteDashboard(db) {
  303. this.$confirm(this.$t('dashboard.deleteConfirm', db.name), this.$t('common.confirm')).then(() => {
  304. deleteDashboard({ dashboard_id: db.dashboard_id }).then(() => {
  305. this.getList()
  306. this.$message({
  307. type: 'success',
  308. message: this.$t('common.deleteSuccess')
  309. })
  310. })
  311. })
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss" scoped>
  317. .container {
  318. display: flex;
  319. min-height: calc(100vh - 62px);
  320. // align-items: stretch;
  321. .dashboard-list {
  322. width: 250px;
  323. min-height: 100%;
  324. padding: 20px 10px;
  325. /deep/ .el-card__header {
  326. div {
  327. display: flex;
  328. justify-content: space-between;
  329. font-size: 14px;
  330. color: #606266;
  331. i {
  332. cursor: pointer;
  333. }
  334. }
  335. padding: 5px 0px;
  336. }
  337. .dashboard-list-item {
  338. display: flex;
  339. justify-content: space-between;
  340. line-height: 35px;
  341. font-size: 14px;
  342. cursor: pointer;
  343. color: #606266;
  344. i {
  345. margin-right: 10px;
  346. line-height: 35px;
  347. }
  348. }
  349. .high-light-dashboard {
  350. color: #205cd8;
  351. }
  352. }
  353. .dashboard-wrapper {
  354. width: 100%;
  355. }
  356. }
  357. </style>