crmAction.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="crm-action">
  3. <!-- 收录 -->
  4. <div class="action-content" v-for="(item, i) in getList" :key="i">
  5. <div @click="setActionEvent(item)" class="action-list" :class="'action-' + item.class">
  6. <i class="iconfont" :class="[ 'icon-' + item['icon-' + item.active] , {'checked': !!item.active }]">
  7. <div class="msg" v-if="item.msg">{{ item.msg }}</div>
  8. </i>
  9. <span> {{ item.active ? '已' : '' }}{{ item.title }}</span>
  10. </div>
  11. </div>
  12. <iframe-dialog :iframe-src="iframeSrc" @getEmployInfo="getEmployEvent" @setDialogStatus="setDialogStatus" :showDialog="setShowDialog"></iframe-dialog>
  13. </div>
  14. </template>
  15. <script>
  16. import '@/assets/style/iconfont.css'
  17. import iframeDialog from '@/components/crm-info/IframeDialog.vue'
  18. import { ajaxIgnoreOperate, ajaxEmployOperate, ajaxEmployInfo } from '@/api/modules/'
  19. export default {
  20. name: 'crm-action',
  21. props: {
  22. params: {
  23. type: Object,
  24. default () {
  25. return {
  26. employType: 3,
  27. idArr: ''
  28. }
  29. }
  30. },
  31. ename: {
  32. type: Object,
  33. default () {
  34. return ''
  35. }
  36. }
  37. },
  38. components: {
  39. iframeDialog
  40. },
  41. data () {
  42. return {
  43. list: [
  44. { title: '收录', 'icon-0': 'a-Property1shoulu', 'icon-1': 'a-Property1yishoulu', class: 'employ', active: 0 },
  45. { title: '忽略', 'icon-0': 'a-Property1hulve', 'icon-1': 'a-Property1yihulve', class: 'ignore', active: 0 },
  46. { title: '创建客户', 'icon-0': 'chuangjiankehu', 'icon-1': 'chuangjiankehu', class: 'custom', active: 0, msg: 0 }
  47. ],
  48. employInfo: {},
  49. setShowDialog: false,
  50. iframeSrc: ''
  51. }
  52. },
  53. computed: {
  54. getList () {
  55. if (this.list[0].active === 0) {
  56. return this.list.slice(0, 1)
  57. } else {
  58. return this.list
  59. }
  60. }
  61. },
  62. created () {
  63. this.getEmployEvent()
  64. },
  65. methods: {
  66. setDialogStatus (data) {
  67. this.setShowDialog = data
  68. },
  69. // 收录情况
  70. async getEmployEvent () {
  71. const { data, error_code: code } = await ajaxEmployInfo(this.params)
  72. if (code === 0 && Array.from(data) && data.length > 0) {
  73. this.employInfo = data
  74. // 收录情况
  75. this.list[0].active = data[0].isEmploy ? 1 : 0
  76. // 忽略情况
  77. this.list[1].active = data[0].isIgnore ? 1 : 0
  78. }
  79. },
  80. setActionEvent (data) {
  81. switch (data.class) {
  82. case 'employ':
  83. this.setEmployEvent(data)
  84. break
  85. case 'ignore':
  86. this.setIgnoreEvent(data)
  87. break
  88. case 'custom':
  89. this.setShowDialog = true
  90. this.iframeSrc = location.origin + '/succbi/crm_system/app/crm.app/%E9%80%9A%E7%94%A8%E5%88%9B%E5%BB%BA/create_customer.spg?E_customer_name=' + this.ename
  91. break
  92. default:
  93. break
  94. }
  95. },
  96. // 收录操作
  97. async setEmployEvent (item) {
  98. const info = this.employInfo[0]
  99. const params = {
  100. idArr: this.params.idArr,
  101. isEmploy: !info.isEmploy,
  102. employType: this.params.employType
  103. }
  104. const { data, error_code: code } = await ajaxEmployOperate(params)
  105. if (code === 0) {
  106. if (data.status) {
  107. item.active = item.active === 0 ? 1 : 0
  108. }
  109. }
  110. },
  111. // 忽略操作
  112. async setIgnoreEvent (item) {
  113. const info = this.employInfo[0]
  114. const params = {
  115. idArr: this.params.idArr,
  116. isIgnore: !info.isIgnore,
  117. employType: this.params.employType
  118. }
  119. const { data, error_code: code } = await ajaxIgnoreOperate(params)
  120. if (code === 0) {
  121. if (data.status) {
  122. item.active = item.active === 0 ? 1 : 0
  123. }
  124. }
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss">
  130. .crm-action{
  131. display: flex;
  132. align-items: center;
  133. .action-list{
  134. margin-left: 16px;
  135. cursor: pointer;
  136. }
  137. .iconfont{
  138. position: relative;
  139. margin-right: 4px;
  140. font-size: 20px;
  141. color: #AAA;
  142. &.checked{
  143. color: #2ABED1;
  144. }
  145. &.icon-chuangjiankehu{
  146. color: #2ABED1;
  147. }
  148. &.icon-a-Property1yihulve {
  149. color: #FF9F40;
  150. }
  151. .msg {
  152. position: absolute;
  153. top: -8px;
  154. right: -6px;
  155. display: flex;
  156. align-items: center;
  157. justify-content: center;
  158. width: 16px;
  159. height: 16px;
  160. background: #FF3A20;
  161. border-radius: 50%;
  162. color: #fff;
  163. font-size: 12px;
  164. }
  165. }
  166. }
  167. </style>