businessInfo.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div class="flex flex-col h-full">
  3. <div class="bg-white info flex-1 overflow-y-auto cellnormall">
  4. <van-cell title="商机名称" :value="info.name" />
  5. <van-cell title="客户名称" :value="info.customerName" />
  6. <van-cell title="联系人姓名" :value="info.contactsName" />
  7. <van-cell title="商机金额">
  8. <template #default>
  9. <span class="text-[#FF8B32]" v-if="info.amountOfMoney">¥ {{ info.amountOfMoney }}</span>
  10. </template>
  11. </van-cell>
  12. <van-cell title="预计成交" :value="info.expectedTransactionDate" />
  13. <van-cell title="商机阶段" :value="info.stageValue" />
  14. <van-cell title="负责人">
  15. <template #default>
  16. <TranslationComponent :openId="info.inchargerName" />
  17. </template>
  18. </van-cell>
  19. <van-cell title="备注" :value="info.remark" />
  20. </div>
  21. <div class="bottomButton">
  22. <van-button type="primary" class="w-full block" v-if="!info.contactsName"
  23. @click="shoContactDialag()">关联联系人</van-button>
  24. <van-button type="warning" class="w-full block" v-if="info.inchargerName"
  25. @click="showDialogCli()">转移商机</van-button>
  26. <van-button type="primary" class="w-full block" v-if="!info.inchargerName"
  27. @click="claimAndClaim()">认领商机</van-button>
  28. </div>
  29. <!-- 转移弹窗 -->
  30. <van-dialog v-model:show="showDialog" :title="`转移商机`" show-cancel-button @confirm="confirmTransfer"
  31. :before-close="dialogCloseBefo">
  32. <van-cell title="转移至" is-link @click="showSelect = true">
  33. <template #value>
  34. {{ dialogSelection.label }}
  35. </template>
  36. </van-cell>
  37. <div class="themeTextColor text-size-small pl-4 pt-2 pb-2">转移后,将看不到此商机了</div>
  38. </van-dialog>
  39. <van-dialog v-model:show="showContactDialog" :title="`关联联系人`" show-cancel-button @confirm="relatedContacts"
  40. :before-close="dialogCloseBefo">
  41. <van-cell title="联系人" is-link @click="showContactSelect = true">
  42. <template #value>
  43. {{ dialogSelection.label }}
  44. </template>
  45. </van-cell>
  46. </van-dialog>
  47. <!-- select 选择器 -->
  48. <van-popup v-model:show="showSelect" destroy-on-close position="bottom" :style="{ height: '80%' }">
  49. <PullDownSelector @change="selectChange" />
  50. </van-popup>
  51. <van-popup v-model:show="showContactSelect" destroy-on-close position="bottom" :style="{ height: '80%' }">
  52. <PullDownSelector :options="allContactsList" :doYouNeedTranslation="false" @change="selectChange" />
  53. </van-popup>
  54. </div>
  55. </template>
  56. <script setup>
  57. import { ref } from 'vue';
  58. import { useLifecycle } from '@hooks/useCommon.js';
  59. import { BUSINESS_OPPORTUNITY_TRANSFER, GET_CONTACTS_WITH_MORE_I_DS, CONTACT_PERSON_ASSOCIATED_WITH_BUSINESS_OPPORTUNITY } from '@hooks/useApi'
  60. import requests from "@common/requests";
  61. import useShowToast from '@hooks/useToast'
  62. import useInfoStore from '@store/useInfoStore'
  63. const userInfo = useInfoStore()
  64. const { toastSuccess, toastFail, toastText } = useShowToast()
  65. const props = defineProps({
  66. info: {
  67. type: Object,
  68. required: true,
  69. default: () => ({})
  70. }
  71. })
  72. const showDialog = ref(false);
  73. const showSelect = ref(false);
  74. const showContactSelect = ref(false);
  75. const showContactDialog = ref(false)
  76. const dialogSelection = ref({});
  77. const allContactsList = ref([]);
  78. function shoContactDialag() {
  79. dialogSelection.value = {}
  80. showContactDialog.value = true
  81. }
  82. function relatedContacts() {
  83. if (!dialogSelection.value.label) {
  84. return toastText('请选择要关联的联系人')
  85. }
  86. requests.post(CONTACT_PERSON_ASSOCIATED_WITH_BUSINESS_OPPORTUNITY, {
  87. id: props.info.id,
  88. contactsId: dialogSelection.value.value
  89. }).then((res) => {
  90. props.info.contactsName = dialogSelection.value.label
  91. showContactDialog.value = false
  92. toastSuccess('关联成功')
  93. })
  94. }
  95. function confirmTransfer() {
  96. if (!dialogSelection.value.label) {
  97. return toastText('请选择要转移的人员')
  98. }
  99. requests.post(BUSINESS_OPPORTUNITY_TRANSFER, { ids: props.info.id, inchargerId: dialogSelection.value.value }).then((res) => {
  100. toastSuccess('转移成功')
  101. showDialog.value = false
  102. setTimeout(() => {
  103. history.back()
  104. }, 2000)
  105. })
  106. }
  107. function claimAndClaim() {
  108. showConfirmDialog({
  109. title: '认领商机',
  110. message: `确定认领【${props.info.name}】商机吗?`,
  111. }).then(() => {
  112. requests.post(BUSINESS_OPPORTUNITY_TRANSFER, { ids: props.info.id, inchargerId: userInfo.userInfo.id }).then((res) => {
  113. toastSuccess('认领成功')
  114. props.info.inchargerName = userInfo.userInfo.name
  115. showDialog.value = false
  116. })
  117. })
  118. }
  119. function selectChange(value, label) {
  120. dialogSelection.value = {
  121. value, label
  122. }
  123. showSelect.value = false
  124. showContactSelect.value = false
  125. }
  126. function showDialogCli() {
  127. dialogSelection.value = {}
  128. showDialog.value = true
  129. }
  130. function dialogCloseBefo(val) {
  131. if (val == 'confirm' && showDialog.value) {
  132. return false
  133. }
  134. return true
  135. }
  136. function getAllContactsList() {
  137. requests.get(`${GET_CONTACTS_WITH_MORE_I_DS}?customerId=${props.info.customerId}`).then(({ data = [] }) => {
  138. let list = data.map(item => {
  139. return {
  140. label: item.name,
  141. value: item.id,
  142. }
  143. })
  144. if (!list.length) {
  145. list = [{}]
  146. }
  147. allContactsList.value = list
  148. })
  149. }
  150. useLifecycle({
  151. load: () => {
  152. getAllContactsList()
  153. },
  154. init: () => {
  155. getAllContactsList()
  156. }
  157. });
  158. </script>
  159. <style lang='scss' scoped>
  160. .bottomButton {
  161. margin: 0 14px;
  162. padding-bottom: 30px;
  163. :deep(.van-button) {
  164. margin-bottom: 20px;
  165. }
  166. }
  167. .info {
  168. margin: 8px 14px 30px 14px;
  169. padding: 14px;
  170. }
  171. </style>