orderSettlementManage.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <!-- 普通菜单 -->
  3. <div class="jsmind_layout">111111
  4. <js-mind :values="mind" :options="options" ref="jsMind" height="1000px"></js-mind>
  5. </div>
  6. </template>
  7. <script>
  8. import Vue from 'vue'
  9. import jm from 'vue-jsmind'
  10. // require('jsmind/js/jsmind.draggable.js')
  11. // require('jsmind/js/jsmind.screenshot.js')
  12. export default {
  13. props: {
  14. showBar: { // 是否显示工具栏,显示启用编辑
  15. type: Boolean,
  16. default: true
  17. },
  18. theme: { // 主题
  19. type: String,
  20. default: 'info'
  21. },
  22. lineColor: { // 线条颜色
  23. type: String,
  24. default: 'skyblue'
  25. }
  26. },
  27. data() {
  28. return {
  29. mind: {},
  30. jm: null,
  31. isZoomIn: false,
  32. isZoomOut: false,
  33. level: 0,
  34. nodeOptions: [
  35. { value: 1, label: '展开到一级节点' },
  36. { value: 2, label: '展开到二级节点' },
  37. { value: 3, label: '展开到三级节点' },
  38. { value: 0, label: '展开全部节点' },
  39. { value: -1, label: '隐藏全部节点' }
  40. ],
  41. themeOptions: [
  42. { value: 'default', label: 'default' },
  43. { value: 'primary', label: 'primary' },
  44. { value: 'warning', label: 'warning' },
  45. { value: 'danger', label: 'danger' },
  46. { value: 'success', label: 'success' },
  47. { value: 'info', label: 'info' },
  48. { value: 'greensea', label: 'greensea' },
  49. { value: 'nephrite', label: 'nephrite' },
  50. { value: 'belizehole', label: 'belizehole' },
  51. { value: 'wisteria', label: 'wisteria' },
  52. { value: 'asphalt', label: 'asphalt' },
  53. { value: 'orange', label: 'orange' },
  54. { value: 'pumpkin', label: 'pumpkin' },
  55. { value: 'pomegranate', label: 'pomegranate' },
  56. { value: 'clouds', label: 'clouds' },
  57. { value: 'asbestos', label: 'asbestos' }
  58. ],
  59. localTheme: this.theme,
  60. dialogVisible: false,
  61. nodeOption: {
  62. content: '',
  63. bgColor: '',
  64. fontColor: '',
  65. fontSize: '',
  66. fontWeight: '',
  67. fontStyle: ''
  68. }
  69. }
  70. },
  71. created() {
  72. },
  73. mounted() {
  74. this.getData()
  75. this.mouseWheel()
  76. },
  77. methods: {
  78. beforeUpload (file) { // 上传文件之前钩子
  79. if (file) {
  80. jsMind.util.file.read(file, (jsmindData) => {
  81. const mind = jsMind.util.json.string2json(jsmindData)
  82. if (mind) {
  83. this.jm.show(mind)
  84. this.$message({ type: 'success', message: '打开成功' })
  85. } else {
  86. this.prompt_info('不能打开mindmap文件')
  87. }
  88. })
  89. } else {
  90. this.prompt_info('请先选择文件')
  91. return false
  92. }
  93. },
  94. upload() {},
  95. getData() {
  96. this.$API({
  97. name: 'getMind'
  98. }).then(res => {
  99. this.mind = res.data
  100. this.open_empty()
  101. }).catch(error => {
  102. this.$message.error(error)
  103. })
  104. },
  105. open_empty() {
  106. const options = {
  107. container: 'jsmind_container', // 必选,容器ID
  108. editable: this.showBar, // 可选,是否启用编辑
  109. theme: this.localTheme, // 可选,主题
  110. view: {
  111. line_width: 2, // 思维导图线条的粗细
  112. line_color: this.lineColor // 思维导图线条的颜色
  113. },
  114. shortcut: {
  115. enable: true // 禁用快捷键
  116. },
  117. layout: {
  118. hspace: 50, // 节点之间的水平间距
  119. vspace: 20, // 节点之间的垂直间距
  120. pspace: 13 // 节点与连接线之间的水平间距(用于容纳节点收缩/展开控制器)
  121. },
  122. mode: 'side' // 显示模式,子节点只分布在根节点右侧
  123. }
  124. this.jm = jsMind.show(options, this.mind)
  125. // 改变窗口大小重置画布
  126. window.onresize = () => {
  127. this.jm.resize()
  128. }
  129. },
  130. save_nodearray_file() {
  131. const mindData = this.jm.get_data('node_array')
  132. const mindName = mindData.meta.name
  133. const mindStr = jsMind.util.json.json2string(mindData)
  134. jsMind.util.file.save(mindStr, 'text/jsmind', mindName + '.jm')
  135. },
  136. screen_shot() {
  137. this.jm.screenshot.shootDownload()
  138. },
  139. expand_all() {
  140. this.jm.expand_all()
  141. },
  142. collapse_all() {
  143. this.jm.collapse_all()
  144. },
  145. expand_to_level(num) {
  146. switch (num) {
  147. case -1:
  148. this.collapse_all()
  149. break
  150. case 0:
  151. this.expand_all()
  152. break
  153. default:
  154. this.jm.expand_to_depth(num)
  155. break
  156. }
  157. },
  158. zoomIn() {
  159. if (this.jm.view.zoomIn()) {
  160. this.isZoomOut = false
  161. } else {
  162. this.isZoomIn = true
  163. }
  164. },
  165. zoomOut() {
  166. if (this.jm.view.zoomOut()) {
  167. this.isZoomIn = false
  168. } else {
  169. this.isZoomOut = true
  170. }
  171. },
  172. prompt_info(msg) {
  173. this.$message({ type: 'warning', message: msg})
  174. },
  175. get_nodearray_data() {
  176. const mindData = this.jm.get_data('node_array')
  177. const mindString = jsMind.util.json.json2string(mindData)
  178. this.$message({ type: 'info', message: mindString})
  179. },
  180. set_theme(themeName) {
  181. this.jm.set_theme(themeName)
  182. },
  183. scrollFunc(e) {
  184. e = e || window.event
  185. if (e.wheelDelta) {
  186. if (e.wheelDelta > 0) {
  187. this.zoomIn()
  188. } else {
  189. this.zoomOut()
  190. }
  191. } else if (e.detail) {
  192. if (e.detail > 0) {
  193. this.zoomIn()
  194. } else {
  195. this.zoomOut()
  196. }
  197. }
  198. this.jm.resize()
  199. },
  200. // 鼠标滚轮放大缩小
  201. mouseWheel() {
  202. if (document.addEventListener) {
  203. document.addEventListener('domMouseScroll', this.scrollFunc, false)
  204. }
  205. this.$refs.container.onmousewheel = this.scrollFunc
  206. },
  207. // 新增节点
  208. addNode() {
  209. let selectedNode = this.jm.get_selected_node()
  210. if (!selectedNode) {
  211. this.$message({ type: 'warning', message: '请先选择一个节点!'})
  212. return
  213. }
  214. let nodeid = jsMind.util.uuid.newid()
  215. let topic = 'new Node'
  216. let newNode = this.jm.add_node(selectedNode, nodeid, topic)
  217. if (newNode) {
  218. this.jm.select_node(nodeid)
  219. this.jm.begin_edit(nodeid)
  220. }
  221. },
  222. // 新增兄弟节点
  223. addBrotherNode() {
  224. let selectedNode = this.jm.get_selected_node()
  225. if (!selectedNode) {
  226. this.$message({ type: 'warning', message: '请先选择一个节点!'})
  227. return
  228. } else if (selectedNode.isroot) {
  229. this.$message({ type: 'warning', message: '不能在根节点添加,请重新选择节点!'})
  230. return
  231. }
  232. let nodeid = jsMind.util.uuid.newid()
  233. let topic = 'new Node'
  234. let newNode = this.jm.insert_node_after(selectedNode, nodeid, topic)
  235. if (newNode) {
  236. this.jm.select_node(nodeid)
  237. this.jm.begin_edit(nodeid)
  238. }
  239. },
  240. // 获取选中标签的 ID
  241. get_selected_nodeid () {
  242. let selectedNode = this.jm.get_selected_node()
  243. if (selectedNode) {
  244. return selectedNode.id
  245. } else {
  246. return null
  247. }
  248. },
  249. // 删除节点
  250. removeNode() {
  251. let selectedId = this.get_selected_nodeid()
  252. if (!selectedId) {
  253. this.$message({
  254. type: 'warning',
  255. message: '请先选择一个节点!'
  256. })
  257. return
  258. }
  259. this.jm.remove_node(selectedId)
  260. },
  261. // 编辑节点
  262. editNode () {
  263. let selectedId = this.get_selected_nodeid()
  264. if (!selectedId) {
  265. this.$message({ type: 'warning', message: '请先选择一个节点!'})
  266. return
  267. }
  268. let nodeObj = this.jm.get_node(selectedId)
  269. this.nodeOption.content = nodeObj.topic
  270. this.nodeOption.bgColor = nodeObj.data['background-color']
  271. this.nodeOption.fontColor = nodeObj.data['foreground-color']
  272. this.nodeOption.fontSize = nodeObj.data['font-size']
  273. this.nodeOption.fontWeight = nodeObj.data['font-weight']
  274. this.nodeOption.fontStyle = nodeObj.data['font-style']
  275. this.dialogVisible = true
  276. },
  277. sureEditNode () {
  278. let selectedId = this.get_selected_nodeid()
  279. this.jm.update_node(selectedId, this.nodeOption.content)
  280. this.jm.set_node_font_style(selectedId, this.nodeOption.fontSize, this.nodeOption.fontWeight, this.nodeOption.fontStyle)
  281. this.jm.set_node_color(selectedId, this.nodeOption.bgColor, this.nodeOption.fontColor)
  282. this.nodeOption = {
  283. content: '',
  284. bgColor: '',
  285. fontColor: '',
  286. fontSize: '',
  287. fontWeight: '',
  288. fontStyle: ''
  289. }
  290. this.dialogVisible = false
  291. }
  292. },
  293. beforeDestroy() {
  294. document.removeEventListener('domMouseScroll', this.scrollFunc, false)
  295. }
  296. }
  297. </script>
  298. <style lang="less">
  299. .jsmind_layout {
  300. position: relative;
  301. display: flex;
  302. flex-direction: column;
  303. width: 100%;
  304. height: calc(100% - 40px);
  305. overflow: hidden;
  306. /deep/ .el-button--medium, /deep/ .el-input--medium {
  307. margin-top: 10px;
  308. }
  309. }
  310. jmnode.selected {
  311. background-color: #b9b9b9 !important;
  312. box-shadow: 2px 2px 8px #777 !important;
  313. }
  314. jmnode:hover {
  315. box-shadow: 2px 2px 8px #777 !important;
  316. }
  317. .jsmind_toolbar {
  318. width: 100%;
  319. padding: 10px;
  320. height: auto;
  321. flex-shrink: 0;
  322. display: flex;
  323. align-items: center;
  324. flex-wrap: wrap;
  325. background-color: #f8f9fa;
  326. box-shadow: 0 0 4px #b8b8b8;
  327. }
  328. #jsmind_container {
  329. flex: 1 1 auto;
  330. position: relative;
  331. }
  332. .jsmind-inner {
  333. overflow: hidden auto !important;
  334. }
  335. .el-upload-list {
  336. display: none !important;
  337. }
  338. .zoom_in_out {
  339. position: absolute;
  340. bottom: 20px;
  341. right: 20px;
  342. height: auto;
  343. display: flex;
  344. align-items: center;
  345. flex-direction: column;
  346. padding: 5px;
  347. background-color: #fff;
  348. border-radius: 4px;
  349. box-shadow: 2px 2px 4px #e0e0e0;
  350. border: 1px solid #f5f5f5;
  351. z-index: 999;
  352. }
  353. .zoom-icon {
  354. cursor: pointer;
  355. font-size: 20px;
  356. padding: 6px 5px;
  357. }
  358. .disabled {
  359. color: #bdbcbc;
  360. cursor: not-allowed;
  361. }
  362. .el-icon-plus {
  363. border-bottom: 1px solid #9f9f9f;
  364. }
  365. /* 隐藏滚动条 */
  366. .jsmind-inner::-webkit-scrollbar {
  367. display: none;
  368. }
  369. .pad {
  370. margin-right: 10px;
  371. }
  372. .pad-left {
  373. margin-left: 10px;
  374. }
  375. </style>