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