6397c7e7cd9d51e2607f056c629d880d3460fd68.svn-base 12 KB

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