8d1d36cbbcb59e6d246c3a2c52451a7eb6bc685d.svn-base 12 KB

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