CommonUse.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <WorkspaceCard class="work-common" title="常用功能">
  3. <span slot="header-right" class="header-right-set" @click="changeDialogState(true)"><i class="icon-set-img"></i> 设置</span>
  4. <div class="common-lists">
  5. <div class="list-item" v-for="item in commonList" :key="item.id" @click="openLink(item)">
  6. <div class="icon-box-container" v-if="item.icon && item.icon.indexOf('icon-') === 0">
  7. <JyIcon :name="item.icon" classPrefix=""></JyIcon>
  8. </div>
  9. <div v-else class="icon-box-container">
  10. <el-image :src="item.icon" alt="常用功能">
  11. <img slot="error" src="https://www.jianyu360.cn/common-module/public/image/auto.png" />
  12. </el-image>
  13. </div>
  14. <span v-html="item.name" class="item-name"></span>
  15. </div>
  16. <div v-if="commonList && commonList.length < maxCount" class="list-add" @click="changeDialogState(true)">
  17. <span class="icon-add-img"></span>
  18. <span class="add-text">添加常用功能</span>
  19. </div>
  20. </div>
  21. <!-- 设置常用功能dialog -->
  22. <el-dialog
  23. custom-class="fn-dialog"
  24. :visible.sync="dialogShow"
  25. :close-on-click-modal="false"
  26. :show-close="false"
  27. v-if="dialogShow"
  28. center
  29. width="696px">
  30. <SelectorCard @onCancel="changeDialogState(false)" @onConfirm="confirmSaveFn" confirmText="确定">
  31. <div slot="header">常用功能设置</div>
  32. <div class="transfer-content">
  33. <Transfer :maxCount="maxCount" submitKey="id" :left="allFunctions" :right="transferCommonList" @onSave="onTransferSave"></Transfer>
  34. </div>
  35. <p class="more-tips">最多可选择 <em style="color:#2CB7CA;">{{ maxCount }}</em> 个常用功能</p>
  36. </SelectorCard>
  37. </el-dialog>
  38. </WorkspaceCard>
  39. </template>
  40. <script>
  41. import { JyIcon } from '@jianyu/icon'
  42. import { mapState, mapMutations, mapActions } from 'vuex'
  43. import { Dialog, Image } from 'element-ui'
  44. import WorkspaceCard from '../ui/WorkspaceCard'
  45. import SelectorCard from '@/components/selector/SelectorCard'
  46. import Transfer from '@/components/work-desktop/Transfer'
  47. import { mixinNoPowerMessageTip } from '@/utils/mixins/no-power-message-box'
  48. import { tryCallHooks } from '@jianyu/easy-inject-qiankun'
  49. export default {
  50. name: 'CommonUse',
  51. mixins: [mixinNoPowerMessageTip],
  52. components: {
  53. [Dialog.name]: Dialog,
  54. [Image.name]: Image,
  55. WorkspaceCard,
  56. SelectorCard,
  57. JyIcon,
  58. Transfer
  59. },
  60. computed: {
  61. ...mapState({
  62. maxCount: state => state.workspace.commonUse.maxCount,
  63. dialogShow: state => state.workspace.commonUse.dialogShow,
  64. allFunctions: state => state.workspace.commonUse.allFunctions, // 所有功能
  65. transferCommonList: state => state.workspace.commonUse.transferCommonList,
  66. commonList: state => state.workspace.commonUse.commonList // 常用功能
  67. })
  68. },
  69. async created () {
  70. await this.getCanUseFunctions()
  71. await this.getAllFunctions({ vm: this })
  72. },
  73. methods: {
  74. ...mapMutations('workspace/commonUse', [
  75. 'changeDialogState',
  76. 'transferSave'
  77. ]),
  78. ...mapActions('workspace/commonUse', [
  79. 'getAllFunctions',
  80. 'getCanUseFunctions',
  81. 'confirmSave'
  82. ]),
  83. // 穿梭框子组件传来的组件
  84. onTransferSave (data) {
  85. this.transferSave(data)
  86. },
  87. openLink (item) {
  88. const { url } = item
  89. if (item.usable) {
  90. tryCallHooks({
  91. fn: () => {
  92. this.$BRACE.methods.open({
  93. route: {
  94. ...item,
  95. link: url
  96. }
  97. })
  98. },
  99. spareFn: () => {
  100. window.open(url)
  101. }
  102. })
  103. } else {
  104. this.showNoPowerMessageTip()
  105. }
  106. },
  107. confirmSaveFn () {
  108. try {
  109. this.confirmSave()
  110. } catch (error) {
  111. this.$toast(error)
  112. }
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. $main: #2cb7ca;
  119. ::v-deep{
  120. .fn-dialog{
  121. .el-dialog__header,.el-dialog__body{
  122. padding: 0;
  123. }
  124. }
  125. .transfer-content{
  126. display: flex;
  127. align-items: center;
  128. justify-content: center;
  129. }
  130. .selector-card-header{
  131. margin: 0 0 28px!important;
  132. }
  133. .selector-card.s-card{
  134. width: 100%;
  135. }
  136. .selector-card-content{
  137. display: block!important;
  138. padding: 0 30px;
  139. }
  140. .more-tips{
  141. margin-top: 20px;
  142. font-size: 14px;
  143. line-height: 22px;
  144. text-align: center;
  145. color: #686868;
  146. }
  147. }
  148. .icon-box-container {
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. width: 44px;
  153. height: 44px;
  154. ::before{
  155. content: ''
  156. }
  157. ::v-deep {
  158. .el-image {
  159. width: 100%;
  160. height: 100%;
  161. img {
  162. width: 100%;
  163. height: 100%;
  164. }
  165. }
  166. }
  167. }
  168. .icon-set-img{
  169. display: inline-block;
  170. width: 18px;
  171. height: 18px;
  172. margin-right: 6px;
  173. background: url('~@/assets/images/icon/icon-set.png') no-repeat center center;
  174. background-size: contain;
  175. }
  176. .icon-add-img{
  177. display: inline-block;
  178. width: 44px;
  179. height: 44px;
  180. background: url('~@/assets/images/icon/icon-add.png') no-repeat center center;
  181. background-size: contain;
  182. }
  183. .header-right-set {
  184. display: flex;
  185. align-items: center;
  186. color: $main;
  187. font-size: 14px;
  188. cursor: pointer;
  189. }
  190. .common-lists{
  191. padding: 0 20px;
  192. display: flex;
  193. .list-item,
  194. .list-add{
  195. width: 120px;
  196. padding: 18px 0 24px;
  197. display: flex;
  198. flex-direction: column;
  199. align-items: center;
  200. text-align: center;
  201. cursor: pointer;
  202. }
  203. .list-item{
  204. // flex: 1;
  205. &:hover{
  206. span{
  207. color: $main;
  208. }
  209. }
  210. }
  211. .item-name,.add-text{
  212. margin-top: 10px;
  213. font-size: 14px;
  214. line-height: 20px;
  215. color: #1D1D1D;
  216. }
  217. .item-img{
  218. width: 44px;
  219. height: 44px;
  220. }
  221. .add-text{
  222. white-space: nowrap;
  223. color: #686868;
  224. }
  225. }
  226. </style>