MenuNode.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <li
  3. v-if="model.show"
  4. @click="changeUserMenuClickCount"
  5. >
  6. <a
  7. v-if="(model.menuNodeType != &quot;Branch&quot;) && (model.menuNodeType != &quot;HTML&quot;)"
  8. target="_blank"
  9. @click="clickMenuNode"
  10. >
  11. {{ Language.getMenuNameTrl($i18n.locale, model) }}
  12. </a>
  13. <span v-if="model.subMenus == undefined || model.subMenus.length == 0">
  14. <i
  15. v-if="model.favorite == true"
  16. class="fa fa-star menu-branch-leaf-icon"
  17. @click="changeInFavoriteList"
  18. />
  19. <i
  20. v-if="model.favorite == false"
  21. class="fa fa-star-o menu-branch-leaf-icon"
  22. @click="changeInFavoriteList"
  23. />
  24. </span>
  25. <a
  26. v-if="model.menuNodeType == 'HTML'"
  27. target="_blank"
  28. @click="clickMenuNode"
  29. >{{ Language.getMenuNameTrl($i18n.locale, model) }}</a>
  30. <a
  31. v-if="model.menuNodeType == &quot;Branch&quot;"
  32. class="menu-branch"
  33. :class="{'active': model.expand}"
  34. :style="{backgroundColor: menuColor}"
  35. @click="selectMenuNode(model)"
  36. >
  37. <i
  38. class="child_middle_menu"
  39. :class="model.icon"
  40. />
  41. {{ Language.getMenuNameTrl($i18n.locale, model) }}
  42. <span class="fa fa-chevron-down" />
  43. </a>
  44. <ul
  45. v-if="model.menuNodeType == &quot;Branch&quot;"
  46. class="nav menu-nav child_menu"
  47. :class="{'active': model.expand}"
  48. >
  49. <MenuNode
  50. v-for="item in model.subMenus"
  51. :key="item.uuid"
  52. :model="item"
  53. @select-node="selectNode($event, model.subMenus)"
  54. />
  55. </ul>
  56. </li>
  57. </template>
  58. <script>
  59. import Common from '../common/Common.js';
  60. import RouteUtil from '../common/RouteUtil.js';
  61. import CustomerWindowResource from '../api/dic/CustomerWindowResource.js';
  62. import HtmlWindowResource from '../api/dic/HtmlWindowResource.js';
  63. import MenuResource from '../api/dic/MenuResource.js';
  64. import UserMenuResource from '../api/system/UserMenuResource.js';
  65. import UserMenuClickCountResource from '../api/system/UserMenuClickCountResource.js';
  66. import Language from '../common/Language.js';
  67. import CurdWindowResourceV2 from '../api/dic/CurdWindowResourceV2.js';
  68. import { Notify, Uuid } from 'pc-component-v3';
  69. export default {
  70. name: 'MenuNode',
  71. components: {
  72. },
  73. props: {
  74. model: {
  75. type: Object,
  76. default: function(){
  77. return null;
  78. },
  79. },
  80. menuColor: {
  81. type: String,
  82. default: 'linear-gradient(#334556, #2c4257), #2a3f54',
  83. },
  84. selectColor: {
  85. type: String,
  86. default: '#495d70',
  87. },
  88. },
  89. emits: ['selectNode'],
  90. data: function () {
  91. this.Language = Language;
  92. return {
  93. 'expand': false, // 选择的节点
  94. };
  95. },
  96. mounted: function () {
  97. var _self = this;
  98. },
  99. methods: {
  100. /**
  101. * 点击菜单节点
  102. */
  103. clickMenuNode: function () {
  104. var _self = this;
  105. var nodeType = this.model.menuNodeType;
  106. if (nodeType == undefined || nodeType == 'NONE' || nodeType == 'Branch') {
  107. return '#';
  108. } else if (nodeType == 'Report' || nodeType == 'Process') {
  109. let url = '/desktop/process-report/' + _self.model.processReportNo;
  110. _self.$router.push({
  111. path: url,
  112. });
  113. } else if (nodeType == 'WorkFlow') {
  114. return '#';
  115. } else if (nodeType == 'Window') {
  116. let url = '/desktop/window/' + _self.model.curdWindowNo + '?uuid=' + Uuid.createUUID();
  117. CurdWindowResourceV2.uniqueByNoAccessControl(
  118. _self.model.curdWindowNo,
  119. ).then(successData => {
  120. if(successData.errorCode === 0){
  121. CurdWindowResourceV2.uniqueByNoVersionNumber(
  122. _self.model.curdWindowNo,
  123. ).then(successData => {
  124. if(successData === -1){
  125. _self.$router.push(
  126. '/desktop/window/' +
  127. _self.model.curdWindowNo +
  128. '?uuid=' + Uuid.createUUID(),
  129. );
  130. }else{
  131. _self.$router.push(
  132. '/desktop/window1/' +
  133. _self.model.curdWindowNo +
  134. '?uuid=' + Uuid.createUUID(),
  135. );
  136. }
  137. },errorData => {
  138. Common.processException(errorData);
  139. });
  140. }else{
  141. Notify.error(_self.$t('lang.Notify.errorOpeningCURDWindow'), successData.errorMessage, false);
  142. }
  143. },errorData => {
  144. Common.processException(errorData);
  145. });
  146. } else if (nodeType == 'SheetWindow') {
  147. let url = '/desktop/sheetWindow/' + _self.model.sheetCurdWindowNo + '?uuid=' + Uuid.createUUID();
  148. this.$router.push({
  149. path: url,
  150. });
  151. } else if (nodeType == 'Info') {
  152. let url = '/desktop/info/' + _self.model.infoWindowNo;
  153. this.$router.push({
  154. path: url,
  155. });
  156. } else if (nodeType == 'Customer') {
  157. CustomerWindowResource.uniqueByNo(_self.model.customerWindowNo).then(successData => {
  158. if (successData != null) {
  159. // var url = "/desktop/" + data.routeUrl;
  160. _self.$router.push({
  161. path: successData.routeUrl,
  162. });
  163. }
  164. }, errorData => {
  165. Common.processException(errorData);
  166. });
  167. } else if (nodeType == 'HTML') {
  168. HtmlWindowResource.uniqueByNo(_self.model.htmlWindowNo).then(successData => {
  169. if (successData != null) {
  170. var htmlFileName = successData.htmlFileName;
  171. if(htmlFileName == null){
  172. Notify.error(_self.$t('lang.Notify.dataDictionaryError'), _self.$t('lang.Notify.describe1'), false);
  173. return;
  174. }
  175. if (htmlFileName.indexOf('{URL}') >= 0) {
  176. htmlFileName = htmlFileName.replace('{URL}', Common.getHostPageBaseURL());
  177. }
  178. window.open(htmlFileName);
  179. }
  180. }, errorData => {
  181. Common.processException(errorData);
  182. });
  183. }else if(nodeType == 'LOWCODE'){
  184. let url = '/desktop/lowcode-example/' + _self.model.lowcodeWindowNo;
  185. this.$router.push({
  186. path: url,
  187. });
  188. }
  189. },
  190. changeUserMenuClickCount: function () {
  191. // 统计点击数
  192. var _self = this;
  193. if (_self.model.subMenus == undefined || _self.model.subMenus.length == 0) {
  194. UserMenuClickCountResource.changeUserMenuClickCount(_self.model.no).then(successData => {
  195. }, errorData => {
  196. Common.processException(errorData);
  197. });
  198. }
  199. },
  200. selectMenuNode: function (node) {
  201. this.changeUserMenuClickCount();
  202. node.expand = !node.expand;
  203. this.$emit('selectNode', node);
  204. },
  205. selectNode: function (node, subMenus) {
  206. if (node.expand) {
  207. subMenus.forEach(function (item) {
  208. if (item != node) {
  209. item.expand = false;
  210. }
  211. });
  212. }
  213. },
  214. // 收藏、取消收藏菜单
  215. changeInFavoriteList: function () {
  216. var _self = this;
  217. UserMenuResource.addToFavoriteList(_self.model.no).then(successData => {
  218. _self.model.favorite = !_self.model.favorite;
  219. }, errorData => {
  220. Common.processException(errorData);
  221. });
  222. },
  223. },
  224. };
  225. </script>
  226. <style>
  227. .menu-branch.active {
  228. text-shadow: rgba(0, 0, 0, 0.25) 0 -1px 0;
  229. /* background: linear-gradient(#334556, #2c4257), #2a3f54; */
  230. background: v-bind(menuColor);
  231. box-shadow: rgba(0, 0, 0, 0.25) 0 1px 0,
  232. inset rgba(255, 255, 255, 0.16) 0 1px 0;
  233. }
  234. </style>
  235. <style scoped>
  236. .menu-branch-leaf-icon {
  237. float: top;
  238. position: absolute;
  239. /* left: 150px; */
  240. right: 10px;
  241. top: 15px;
  242. color: #FFFFFF;
  243. }
  244. .menu-branch-leaf-text {
  245. text-decoration: none;
  246. color: white;
  247. padding: 15px 0px 15px 0px;
  248. }
  249. </style>