contactsInfo.vue 5.2 KB

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