businessInfo.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 { showConfirmDialog } from 'vant';
  59. import { useLifecycle } from '@hooks/useCommon.js';
  60. import { BUSINESS_OPPORTUNITY_TRANSFER, GET_CONTACTS_WITH_MORE_I_DS, CONTACT_PERSON_ASSOCIATED_WITH_BUSINESS_OPPORTUNITY } from '@hooks/useApi'
  61. import requests from "@common/requests";
  62. import useShowToast from '@hooks/useToast'
  63. import useInfoStore from '@store/useInfoStore'
  64. import useRouterStore from "@store/useRouterStore.js";
  65. const router = useRouterStore()
  66. const userInfo = useInfoStore()
  67. const { toastSuccess, toastFail, toastText } = useShowToast()
  68. const props = defineProps({
  69. info: {
  70. type: Object,
  71. required: true,
  72. default: () => ({})
  73. }
  74. })
  75. const showDialog = ref(false);
  76. const showSelect = ref(false);
  77. const showContactSelect = ref(false);
  78. const showContactDialog = ref(false)
  79. const dialogSelection = ref({});
  80. const allContactsList = ref([]);
  81. function shoContactDialag() {
  82. dialogSelection.value = {}
  83. showContactDialog.value = true
  84. }
  85. function relatedContacts() {
  86. if (!dialogSelection.value.label) {
  87. return toastText('请选择要关联的联系人')
  88. }
  89. requests.post(CONTACT_PERSON_ASSOCIATED_WITH_BUSINESS_OPPORTUNITY, {
  90. id: props.info.id,
  91. contactsId: dialogSelection.value.value
  92. }).then((res) => {
  93. props.info.contactsName = dialogSelection.value.label
  94. showContactDialog.value = false
  95. toastSuccess('关联成功')
  96. listReloadData()
  97. })
  98. }
  99. function confirmTransfer() {
  100. if (!dialogSelection.value.label) {
  101. return toastText('请选择要转移的人员')
  102. }
  103. requests.post(BUSINESS_OPPORTUNITY_TRANSFER, { ids: props.info.id, inchargerId: dialogSelection.value.value }).then((res) => {
  104. toastSuccess('转移成功')
  105. showDialog.value = false
  106. setTimeout(() => {
  107. listReloadData()
  108. }, 2000)
  109. })
  110. }
  111. function claimAndClaim() {
  112. showConfirmDialog({
  113. title: '认领商机',
  114. message: `确定认领【${props.info.name}】商机吗?`,
  115. }).then(() => {
  116. requests.post(BUSINESS_OPPORTUNITY_TRANSFER, { ids: props.info.id, inchargerId: userInfo.userInfo.id }).then((res) => {
  117. toastSuccess('认领成功')
  118. listReloadData()
  119. props.info.inchargerName = userInfo.userInfo.name
  120. showDialog.value = false
  121. })
  122. })
  123. }
  124. function listReloadData() {
  125. router.navigateBack({
  126. success: () => {
  127. router.eventEmit('moduleListRefreshData', {})
  128. }
  129. })
  130. }
  131. function selectChange(value, label) {
  132. dialogSelection.value = {
  133. value, label
  134. }
  135. showSelect.value = false
  136. showContactSelect.value = false
  137. }
  138. function showDialogCli() {
  139. dialogSelection.value = {}
  140. showDialog.value = true
  141. }
  142. function dialogCloseBefo(val) {
  143. if (val == 'confirm' && showDialog.value) {
  144. return false
  145. }
  146. return true
  147. }
  148. function getAllContactsList() {
  149. requests.get(`${GET_CONTACTS_WITH_MORE_I_DS}?customerId=${props.info.customerId}`).then(({ data = [] }) => {
  150. let list = data.map(item => {
  151. return {
  152. label: item.name,
  153. value: item.id,
  154. }
  155. })
  156. if (!list.length) {
  157. list = [{}]
  158. }
  159. allContactsList.value = list
  160. })
  161. }
  162. useLifecycle({
  163. load: () => {
  164. getAllContactsList()
  165. },
  166. init: () => {
  167. getAllContactsList()
  168. }
  169. });
  170. </script>
  171. <style lang='scss' scoped>
  172. .bottomButton {
  173. margin: 0 14px;
  174. padding-bottom: 30px;
  175. :deep(.van-button) {
  176. margin-bottom: 20px;
  177. }
  178. }
  179. .info {
  180. margin: 8px 14px 30px 14px;
  181. padding: 14px;
  182. }
  183. </style>