businessInfo.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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="infoData.name" />
  5. <van-cell title="客户名称" :value="infoData.customerName" />
  6. <van-cell title="联系人姓名" :value="infoData.contactsName" />
  7. <van-cell title="商机金额">
  8. <template #default>
  9. <span class="text-[#FF8B32]" v-if="infoData.amountOfMoney">¥ {{ infoData.amountOfMoney }}</span>
  10. </template>
  11. </van-cell>
  12. <van-cell title="预计成交" :value="infoData.expectedTransactionDate" />
  13. <van-cell title="商机阶段" :value="infoData.stageValue" />
  14. <van-cell title="负责人">
  15. <template #default>
  16. <TranslationComponent :openId="infoData.inchargerName" />
  17. </template>
  18. </van-cell>
  19. <van-cell title="备注" :value="infoData.remark" />
  20. </div>
  21. <div class="bottomButton">
  22. <van-button type="primary" class="w-full block" v-if="!infoData.contactsName"
  23. @click="shoContactDialag()">关联联系人</van-button>
  24. <van-button type="warning" class="w-full block" v-if="infoData.inchargerName"
  25. @click="showDialogCli()">转移商机</van-button>
  26. <van-button type="primary" class="w-full block" v-if="!infoData.inchargerName"
  27. @click="claimAndClaim()">认领商机</van-button>
  28. <van-button type="default" class="w-full block" v-permission="[routingInformation.jurisdiction.edit]" @click="jumpEdit()">编辑商机</van-button>
  29. <van-button type="danger" class="w-full block" v-permission="[routingInformation.jurisdiction.delete]" @click="deleteBusinessOpportunity()">删除商机</van-button>
  30. </div>
  31. <!-- 转移弹窗 -->
  32. <van-dialog v-model:show="showDialog" :title="`转移商机`" show-cancel-button @confirm="confirmTransfer"
  33. :before-close="dialogCloseBefo">
  34. <van-cell title="转移至" is-link @click="showSelect = true">
  35. <template #value>
  36. {{ dialogSelection.label }}
  37. </template>
  38. </van-cell>
  39. <div class="themeTextColor text-size-small pl-4 pt-2 pb-2">转移后,将看不到此商机了</div>
  40. </van-dialog>
  41. <van-dialog v-model:show="showContactDialog" :title="`关联联系人`" show-cancel-button @confirm="relatedContacts"
  42. :before-close="dialogCloseBefo">
  43. <van-cell title="联系人" is-link @click="showContactSelect = true">
  44. <template #value>
  45. {{ dialogSelection.label }}
  46. </template>
  47. </van-cell>
  48. </van-dialog>
  49. <!-- select 选择器 -->
  50. <van-popup v-model:show="showSelect" destroy-on-close position="bottom" :style="{ height: '80%' }">
  51. <PullDownSelector :showElement="showSelect" @change="selectChange" />
  52. </van-popup>
  53. <van-popup v-model:show="showContactSelect" destroy-on-close position="bottom" :style="{ height: '80%' }">
  54. <PullDownSelector :showElement="showContactSelect" :options="allContactsList" :doYouNeedTranslation="false" @change="selectChange" />
  55. </van-popup>
  56. </div>
  57. </template>
  58. <script setup>
  59. import { ref, watch } from 'vue';
  60. import { showConfirmDialog } from 'vant';
  61. import { useLifecycle } from '@hooks/useCommon.js';
  62. import { BUSINESS_OPPORTUNITY_TRANSFER, GET_CONTACTS_WITH_MORE_I_DS, CONTACT_PERSON_ASSOCIATED_WITH_BUSINESS_OPPORTUNITY } from '@hooks/useApi'
  63. import { resetListData, getListFieldKey } from '@components/common/formForm/formCorrespondenceProcessing'
  64. import requests from "@common/requests";
  65. import useShowToast from '@hooks/useToast'
  66. import useInfoStore from '@store/useInfoStore'
  67. import useFixedData from "@store/useFixedData.js"
  68. import useRouterStore from "@store/useRouterStore.js";
  69. import { routingInfos } from "@utility/generalVariables"
  70. const router = useRouterStore()
  71. const fixedData = useFixedData()
  72. const userInfo = useInfoStore()
  73. const { toastSuccess, toastLoading, toastFail, toastText, clearToast } = useShowToast()
  74. const props = defineProps({
  75. info: {
  76. type: Object,
  77. required: true,
  78. default: () => ({})
  79. }
  80. })
  81. const infoData = ref(props.info)
  82. const routingInformation = routingInfos['business']
  83. watch(() => props.info, (newValue) => {
  84. infoData.value = newValue
  85. getAllContactsList()
  86. })
  87. const showDialog = ref(false);
  88. const showSelect = ref(false);
  89. const showContactSelect = ref(false);
  90. const showContactDialog = ref(false)
  91. const dialogSelection = ref({});
  92. const allContactsList = ref([]);
  93. function deleteBusinessOpportunity() {
  94. const { name = '', searchFiled = {}, deteleFiled = '' } = routingInformation
  95. const row = infoData.value
  96. const foemVal = { [routingInformation.key == 'tasks' ? 'taskIds' : 'ids']: row.id }
  97. showConfirmDialog({
  98. title: `删除${name}`,
  99. message: `确定删除【${row[searchFiled?.search]}】${name}吗?`,
  100. }).then(() => {
  101. requests.post(deteleFiled, { ...foemVal }).then((res) => {
  102. toastSuccess('删除成功')
  103. router.navigateBack({
  104. success: () => {
  105. router.emit('moduleListDetailParameter', {
  106. row: JSON.stringify(routingInformation)
  107. })
  108. }
  109. })
  110. }).catch((err) => {
  111. toastFail(err.msg ? err.msg : '删除失败')
  112. })
  113. })
  114. }
  115. function jumpEdit() {
  116. const formJson = fixedData.formJson[routingInformation.key] || []
  117. const formList = resetListData(formJson?.list)
  118. const filedObj = getListFieldKey(formList, infoData.value)
  119. const formVal = { ...filedObj, id: infoData.value.id }
  120. router.navigateTo({
  121. pathName: 'addEditor',
  122. success: () => {
  123. router.emit('addEditorParameter', {
  124. routerInfo: JSON.stringify(routingInformation),
  125. filedValue: JSON.stringify(formVal)
  126. })
  127. }
  128. })
  129. }
  130. function shoContactDialag() {
  131. dialogSelection.value = {}
  132. showContactDialog.value = true
  133. }
  134. function relatedContacts() {
  135. if (!dialogSelection.value.label) {
  136. return toastText('请选择要关联的联系人')
  137. }
  138. requests.post(CONTACT_PERSON_ASSOCIATED_WITH_BUSINESS_OPPORTUNITY, {
  139. id: props.info.id,
  140. contactsId: dialogSelection.value.value
  141. }).then((res) => {
  142. props.info.contactsName = dialogSelection.value.label
  143. showContactDialog.value = false
  144. toastSuccess('关联成功')
  145. listReloadData()
  146. })
  147. }
  148. function confirmTransfer() {
  149. if (!dialogSelection.value.label) {
  150. return toastText('请选择要转移的人员')
  151. }
  152. requests.post(BUSINESS_OPPORTUNITY_TRANSFER, { ids: props.info.id, inchargerId: dialogSelection.value.value }).then((res) => {
  153. toastSuccess('转移成功')
  154. showDialog.value = false
  155. setTimeout(() => {
  156. listReloadData()
  157. }, 2000)
  158. })
  159. }
  160. function claimAndClaim() {
  161. showConfirmDialog({
  162. title: '认领商机',
  163. message: `确定认领【${props.info.name}】商机吗?`,
  164. }).then(() => {
  165. requests.post(BUSINESS_OPPORTUNITY_TRANSFER, { ids: props.info.id, inchargerId: userInfo.userInfo.id }).then((res) => {
  166. toastSuccess('认领成功')
  167. listReloadData()
  168. props.info.inchargerName = userInfo.userInfo.name
  169. showDialog.value = false
  170. })
  171. })
  172. }
  173. function listReloadData() {
  174. router.navigateBack({
  175. success: () => {
  176. router.eventEmit('moduleListRefreshData', {})
  177. }
  178. })
  179. }
  180. function selectChange(value, label) {
  181. dialogSelection.value = {
  182. value, label
  183. }
  184. showSelect.value = false
  185. showContactSelect.value = false
  186. }
  187. function showDialogCli() {
  188. dialogSelection.value = {}
  189. showDialog.value = true
  190. }
  191. function dialogCloseBefo(val) {
  192. if (val == 'confirm' && showDialog.value) {
  193. return false
  194. }
  195. return true
  196. }
  197. function getAllContactsList() {
  198. requests.get(`${GET_CONTACTS_WITH_MORE_I_DS}?customerId=${props.info.customerId}`).then(({ data = [] }) => {
  199. let list = data.map(item => {
  200. return {
  201. label: item.name,
  202. value: item.id,
  203. }
  204. })
  205. if (!list.length) {
  206. list = [{}]
  207. }
  208. allContactsList.value = list
  209. })
  210. }
  211. useLifecycle({
  212. load: () => {
  213. },
  214. init: () => {
  215. getAllContactsList()
  216. }
  217. });
  218. </script>
  219. <style lang='scss' scoped>
  220. .bottomButton {
  221. margin: 0 14px;
  222. padding-bottom: 30px;
  223. :deep(.van-button) {
  224. margin-bottom: 20px;
  225. }
  226. }
  227. .info {
  228. margin: 8px 14px 30px 14px;
  229. padding: 14px;
  230. }
  231. </style>