MenuNode.vue 7.5 KB

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