customerInfo.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.customName" />
  5. <van-cell title="客户来源" :value="info.customSourceValue" />
  6. <van-cell title="电话号码" :value="info.companyPhone" />
  7. <van-cell title="邮箱" :value="info.email" />
  8. <van-cell title="客户行业" :value="info.customerIndustryValue" />
  9. <van-cell title="客户级别" :value="info.customerLevelValue" />
  10. <van-cell title="客户地址" :value="info.address" />
  11. <van-cell title="负责人">
  12. <template #default>
  13. <TranslationComponent :openId="info.inchargerName" />
  14. </template>
  15. </van-cell>
  16. <van-cell title="备注" :value="info.customDesc" />
  17. </div>
  18. <div class="bottomButton">
  19. <van-button type="warning" class="w-full block" v-if="info.inchargerName"
  20. @click="showDialogCli()">转移客户</van-button>
  21. <van-button type="primary" class="w-full block" v-if="!info.inchargerName"
  22. @click="claimAndClaim()">认领客户</van-button>
  23. <van-button type="default" class="w-full block" v-permission="[routingInformation.jurisdiction.edit]" @click="jumpEdit()">编辑客户</van-button>
  24. <van-button type="danger" class="w-full block" v-permission="[routingInformation.jurisdiction.delete]" @click="deleteRow()">删除客户</van-button>
  25. </div>
  26. <!-- 转移弹窗 -->
  27. <van-dialog v-model:show="showDialog" :title="`转移线索`" show-cancel-button @confirm="confirmTransfer"
  28. :before-close="dialogCloseBefo">
  29. <van-cell title="转移至" is-link @click="showSelect = true">
  30. <template #value>
  31. {{ dialogSelection.label }}
  32. </template>
  33. </van-cell>
  34. <div class="themeTextColor text-size-small pl-4 pt-2 pb-2">转移后,将看不到此线索了</div>
  35. </van-dialog>
  36. <!-- select 选择器 -->
  37. <van-popup v-model:show="showSelect" destroy-on-close position="bottom" :style="{ height: '80%' }">
  38. <PullDownSelector @change="selectChange" />
  39. </van-popup>
  40. </div>
  41. </template>
  42. <script setup>
  43. import { ref } from 'vue';
  44. import { useLifecycle } from '@hooks/useCommon.js';
  45. import { TRANSFER_CUSTOMERS } from '@hooks/useApi'
  46. import { showConfirmDialog } from 'vant';
  47. import requests from "@common/requests";
  48. import useShowToast from '@hooks/useToast'
  49. import useInfoStore from '@store/useInfoStore'
  50. import useRouterStore from "@store/useRouterStore.js";
  51. import { routingInfos } from "@utility/generalVariables"
  52. import { resetListData, getListFieldKey } from '@components/common/formForm/formCorrespondenceProcessing'
  53. import useFixedData from "@store/useFixedData.js"
  54. const fixedData = useFixedData()
  55. const router = useRouterStore()
  56. const userInfo = useInfoStore()
  57. const { toastSuccess, toastFail, toastText } = useShowToast()
  58. const props = defineProps({
  59. info: {
  60. type: Object,
  61. required: true,
  62. default: () => ({})
  63. }
  64. })
  65. const showDialog = ref(false);
  66. const showSelect = ref(false);
  67. const dialogSelection = ref({});
  68. const routingInformation = routingInfos['customer']
  69. function deleteRow() {
  70. const { name = '', searchFiled = {}, deteleFiled = '' } = routingInformation
  71. const row = props.info
  72. const foemVal = { [routingInformation.key == 'tasks' ? 'taskIds' : 'ids']: row.id }
  73. showConfirmDialog({
  74. title: `删除${name}`,
  75. message: `确定删除【${row[searchFiled?.search]}】${name}吗?`,
  76. }).then(() => {
  77. requests.post(deteleFiled, { ...foemVal }).then((res) => {
  78. toastSuccess('删除成功')
  79. router.navigateBack({
  80. success: () => {
  81. router.emit('moduleListDetailParameter', {
  82. row: JSON.stringify(routingInformation)
  83. })
  84. }
  85. })
  86. }).catch((err) => {
  87. toastFail(err.msg ? err.msg : '删除失败')
  88. })
  89. })
  90. }
  91. function jumpEdit() {
  92. const formJson = fixedData.formJson[routingInformation.key] || []
  93. const formList = resetListData(formJson?.list)
  94. const filedObj = getListFieldKey(formList, props.info)
  95. const formVal = { ...filedObj, id: props.info.id }
  96. router.navigateTo({
  97. pathName: 'addEditor',
  98. success: () => {
  99. router.emit('addEditorParameter', {
  100. routerInfo: JSON.stringify(routingInformation),
  101. filedValue: JSON.stringify(formVal)
  102. })
  103. }
  104. })
  105. }
  106. function confirmTransfer() {
  107. if (!dialogSelection.value.label) {
  108. return toastText('请选择要转移的人员')
  109. }
  110. requests.post(TRANSFER_CUSTOMERS, { ids: props.info.id, inchargerId: dialogSelection.value.value }).then((res) => {
  111. toastSuccess('转移成功')
  112. showDialog.value = false
  113. setTimeout(() => {
  114. listReloadData()
  115. }, 2000)
  116. })
  117. }
  118. function claimAndClaim() {
  119. showConfirmDialog({
  120. title: '认领客户',
  121. message: `确定认领【${props.info.customName}】客户吗?`,
  122. }).then(() => {
  123. requests.post(TRANSFER_CUSTOMERS, { ids: props.info.id, inchargerId: userInfo.userInfo.id }).then((res) => {
  124. toastSuccess('认领成功')
  125. listReloadData()
  126. props.info.inchargerName = userInfo.userInfo.customName
  127. showDialog.value = false
  128. })
  129. })
  130. }
  131. function listReloadData() {
  132. router.navigateBack({
  133. success: () => {
  134. router.eventEmit('moduleListRefreshData', {})
  135. }
  136. })
  137. }
  138. function selectChange(value, label) {
  139. dialogSelection.value = {
  140. value, label
  141. }
  142. showSelect.value = false
  143. }
  144. function showDialogCli() {
  145. dialogSelection.value = {}
  146. showDialog.value = true
  147. }
  148. function dialogCloseBefo(val) {
  149. if (val == 'confirm' && showDialog.value) {
  150. return false
  151. }
  152. return true
  153. }
  154. useLifecycle({
  155. load: () => {
  156. // 添加加载逻辑
  157. }
  158. });
  159. </script>
  160. <style lang='scss' scoped>
  161. .bottomButton {
  162. margin: 0 14px;
  163. padding-bottom: 30px;
  164. :deep(.van-button) {
  165. margin-bottom: 20px;
  166. }
  167. }
  168. .info {
  169. margin: 8px 14px 30px 14px;
  170. padding: 14px;
  171. }
  172. </style>