editWorkbench.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <div class="workbench">
  3. <div class="ComponentSave">
  4. <div class="saveColumn">
  5. <span class="title">工作台-自拟定</span>
  6. <el-select v-model="model" @change="changeSelect" class="saveColumn-select">
  7. <el-option v-for="(item, index) in modelSelect" :key="index" :label="item.lable" :value="item.model_id"></el-option>
  8. </el-select>
  9. </div>
  10. <div class="saveColumn-buttons">
  11. <el-button @click="close">取消</el-button>
  12. <el-button type="primary" @click="saveWork">保存并使用</el-button>
  13. </div>
  14. </div>
  15. <div class="operation">
  16. <div class="leftAssembly">
  17. <el-select v-model="componentsValue" clearable @change="changeSelect" class="saveColumn-select">
  18. <el-option
  19. v-for="(item, index) in componentsSelect"
  20. :key="index"
  21. :label="item.lable"
  22. :value="item.model_id"
  23. ></el-option>
  24. </el-select>
  25. <div class="componentsBlock">
  26. <template v-for="(item, index) in componentsArrar">
  27. <div
  28. class="moveBlock"
  29. :data-id="item.data_id"
  30. @mousedown="moveBlock($event, item.data_id)"
  31. :key="index"
  32. draggable
  33. @dragstart="dragstart($event, item)"
  34. @dragend="dragend($event)"
  35. @drag="drag($event)"
  36. >
  37. <div class="moveBlock_titles">{{ item.title }}</div>
  38. <div class="moveBlock_img">
  39. <img :src="item.imgPng" :alt="item.title" />
  40. </div>
  41. <div class="moveBlock_icon">
  42. <img :src="item.imgIcon" :alt="item.title" />
  43. </div>
  44. </div>
  45. </template>
  46. </div>
  47. </div>
  48. <model-one v-if="model == 1" :ref="model + '_model'"></model-one>
  49. <model-two v-if="model == 2" :ref="model + '_model'"></model-two>
  50. <model-three v-if="model == 3" :ref="model + '_model'"></model-three>
  51. <model-four v-if="model == 4" :ref="model + '_model'"></model-four>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. import workcommonFcuntion from './template/index.js';
  57. export default {
  58. mixins: [workcommonFcuntion],
  59. data() {
  60. return {
  61. model: 1,
  62. oldValue: {},
  63. modelSelect: [
  64. {
  65. model_id: 1,
  66. lable: '模板一(默认模块)'
  67. },
  68. {
  69. model_id: 2,
  70. lable: '模板二(默认模块)'
  71. },
  72. {
  73. model_id: 3,
  74. lable: '模板三'
  75. }
  76. // {
  77. // model_id: 4,
  78. // lable: '模板四'
  79. // }
  80. ],
  81. componentsSelect: [
  82. {
  83. model_id: 0,
  84. lable: '全部'
  85. }
  86. ],
  87. componentsArrar: [
  88. {
  89. data_id: 1,
  90. title: '高德地图',
  91. imgPng: require('@assets/img/formulation/img_ditu@2x.png'),
  92. imgIcon: require('@assets/img/formulation/tag_4x@2x.png')
  93. },
  94. {
  95. data_id: 2,
  96. title: '投诉建议',
  97. imgPng: require('@assets/img/formulation/img_bingzhuangtu@2x.png'),
  98. imgIcon: require('@assets/img/formulation/tag_1x@2x.png')
  99. },
  100. {
  101. data_id: 3,
  102. title: '常用功能',
  103. imgPng: require('@assets/img/formulation/img_changyonggongneng@2x.png'),
  104. imgIcon: require('@assets/img/formulation/tag_1x@2x.png')
  105. },
  106. {
  107. data_id: 4,
  108. title: '服务满意度趋势',
  109. imgPng: require('@assets/img/formulation/img_zhuzhuangtu@2x.png'),
  110. imgIcon: require('@assets/img/formulation/tag_2x@2x.png')
  111. },
  112. {
  113. data_id: 5,
  114. title: '设备告警趋势',
  115. imgPng: require('@assets/img/formulation/img_zhexiantu@2x.png'),
  116. imgIcon: require('@assets/img/formulation/tag_2x@2x.png')
  117. },
  118. // img_bing+baifenbi@2x
  119. {
  120. data_id: 6,
  121. title: '房屋租售率',
  122. imgPng: require('@assets/img/formulation/img_bing+baifenbi@2x.png'),
  123. imgIcon: require('@assets/img/formulation/tag_1x@2x.png')
  124. },
  125. {
  126. data_id: 7,
  127. title: '收款率分析',
  128. imgPng: require('@assets/img/formulation/img_bing+baifenbi@2x.png'),
  129. imgIcon: require('@assets/img/formulation/tag_1x@2x.png')
  130. }
  131. ],
  132. componentsValue: 0,
  133. isEdit: false,
  134. dataId: null
  135. };
  136. },
  137. watch: {
  138. $route(to, from) {
  139. if (to.query.editWorkbench) {
  140. this.isEdit = true;
  141. }
  142. }
  143. },
  144. methods: {
  145. moveBlock(e, num) {
  146. this.dataId = num;
  147. },
  148. communityNameList() {
  149. this.$http.get('/sc-community/assets/community/list').then(({ data, msg, status }) => {
  150. if (status == 0) {
  151. this.$store.commit('setAreaSelect', data);
  152. }
  153. });
  154. },
  155. dragstart(e, item) {
  156. //拖拽开始时将item存入vuex
  157. this.$store.commit('setDragItem', item);
  158. },
  159. drag(e) {
  160. //拖拽中执行的事件
  161. // console.log('drag',e)s
  162. },
  163. dragend(e) {
  164. //拖拽结束执行的事件
  165. // console.log('dragend', e);
  166. },
  167. close() {
  168. let tagsList = this.$store.getters['getTagsList'];
  169. let activeRout = this.$route;
  170. if (tagsList.length > 1) {
  171. tagsList.forEach((item, index) => {
  172. if (item.title == activeRout.meta.title || item.path == activeRout.path) {
  173. tagsList.splice(index, 1);
  174. this.$router.push({
  175. path: tagsList[index - 1].path
  176. });
  177. }
  178. });
  179. } else {
  180. this.$router.push({
  181. path: '/'
  182. });
  183. }
  184. },
  185. saveWork() {
  186. let simeCom = JSON.stringify({ model: this.model, pageLoction: this.$refs[this.model + '_model'].sumit() });
  187. let installVal = {
  188. positionInfo: simeCom,
  189. urls: '',
  190. id: ''
  191. };
  192. let url = '/sc-community/workbenchConfig/add';
  193. if (!!this.oldValue.id) {
  194. url = '/sc-community/workbenchConfig/update';
  195. installVal.id = this.oldValue.id;
  196. }
  197. this.$http.post(url, installVal).then(({ data, msg, status }) => {
  198. if (status == 0) {
  199. this.close();
  200. }
  201. });
  202. },
  203. getData() {
  204. this.$http.get('/sc-community/workbenchConfig/list').then(({ data, msg, status }) => {
  205. if (status == 0) {
  206. if (!!data[0]) {
  207. let val = data[0];
  208. this.model = JSON.parse(val.positionInfo).model;
  209. this.oldValue = val;
  210. }
  211. }
  212. });
  213. }
  214. },
  215. destroyed() {
  216. this.$store.dispatch('collapse', false);
  217. },
  218. created() {
  219. this.$store.dispatch('collapse', true);
  220. this.getData();
  221. this.communityNameList();
  222. }
  223. };
  224. </script>
  225. <style lang="scss" scoped>
  226. @import '@assets/css/public-style.scss';
  227. $BackColor: #171f32;
  228. .overflowHidden {
  229. overflow: hidden;
  230. }
  231. .list_border {
  232. border: 1px solid $BackColor;
  233. border-radius: 4px;
  234. }
  235. .mr10 {
  236. margin: rem(10);
  237. }
  238. .workbench {
  239. background: #2c354a;
  240. height: 100%;
  241. min-height: rem(700);
  242. overflow: auto;
  243. color: white;
  244. &::-webkit-scrollbar {
  245. display: none;
  246. }
  247. .ComponentSave {
  248. height: rem(60);
  249. min-height: 60px;
  250. background: $BackColor;
  251. border-radius: 4px;
  252. margin-bottom: rem(20);
  253. padding: 0 rem(20);
  254. display: flex;
  255. justify-content: space-between;
  256. .saveColumn {
  257. display: flex;
  258. align-items: center;
  259. .saveColumn-select {
  260. margin-left: rem(20);
  261. /deep/ .el-input__inner {
  262. background: transparent;
  263. color: white;
  264. }
  265. }
  266. }
  267. .saveColumn-buttons {
  268. display: flex;
  269. align-items: center;
  270. /deep/ .el-button {
  271. padding: rem(8) rem(20);
  272. }
  273. /deep/ .el-button--default {
  274. background: transparent;
  275. border-color: #0eaeff;
  276. color: white;
  277. &:active {
  278. opacity: 0.8;
  279. }
  280. }
  281. }
  282. }
  283. .operation {
  284. height: rem(794);
  285. min-height: 794px;
  286. display: flex;
  287. justify-content: space-between;
  288. .leftAssembly {
  289. width: 174px;
  290. background: $BackColor;
  291. border-radius: 4px;
  292. padding: rem(20) rem(8) rem(20) rem(20);
  293. .saveColumn-select {
  294. margin-bottom: rem(30);
  295. margin-right: rem(12);
  296. /deep/ .el-input__inner {
  297. background: transparent;
  298. color: white;
  299. border-color: rgba(255, 255, 255, 0.2);
  300. }
  301. }
  302. // 块级模块
  303. .componentsBlock {
  304. height: calc(100% - #{rem(62)});
  305. overflow-y: auto;
  306. overflow-x: hidden;
  307. &::-webkit-scrollbar {
  308. z-index: 11;
  309. width: rem(4);
  310. }
  311. &::-webkit-scrollbar-track,
  312. &::-webkit-scrollbar-corner {
  313. background: transparent;
  314. }
  315. &::-webkit-scrollbar-thumb {
  316. border-radius: 5px;
  317. width: rem(4);
  318. background: rgba(250, 250, 250, 0.09);
  319. }
  320. &::-webkit-scrollbar-track-piece {
  321. background: transparent;
  322. width: rem(4);
  323. }
  324. .moveBlock {
  325. font-size: 12px;
  326. width: rem(132);
  327. height: rem(132);
  328. background: rgba(0, 0, 0, 0.1);
  329. box-sizing: border-box;
  330. border-radius: 4px;
  331. border: 1px solid rgba(255, 255, 255, 0.2);
  332. padding: rem(10);
  333. margin-bottom: rem(20);
  334. text-align: center;
  335. position: relative;
  336. cursor: move;
  337. .moveBlock_titles {
  338. overflow: hidden;
  339. white-space: nowrap;
  340. text-overflow: ellipsis;
  341. width: 100%;
  342. }
  343. .moveBlock_img {
  344. width: rem(60);
  345. margin: auto;
  346. img {
  347. width: 100%;
  348. margin-top: rem(20);
  349. }
  350. }
  351. .moveBlock_icon {
  352. position: absolute;
  353. right: 0;
  354. bottom: 0;
  355. height: rem(20);
  356. img {
  357. width: rem(28);
  358. height: rem(20);
  359. }
  360. }
  361. }
  362. }
  363. }
  364. }
  365. }
  366. </style>