4581cb5bc2eeeb7ebc95beeb4771b9a75cd0dfe6.svn-base 12 KB

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