information.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="information pl-4 pr-4 pt-3 pb-3">
  3. <div class="flex justify-between">
  4. <div class="title">基本信息</div>
  5. <div>
  6. <el-button type="primary" @click="claimCustomer()" v-if="!information.inchargerName">认领</el-button>
  7. <el-button type="primary" @click="transferCli()">转移</el-button>
  8. <el-button type="primary" v-permission="['customerEdit']" @click="editCustomer()">编辑</el-button>
  9. </div>
  10. </div>
  11. <div class="form flex flex-wrap justify-between">
  12. <div class="formItem flex pt-2 pb-1">
  13. <div class="w-20 text-right text-gray-500">客户名称:</div>
  14. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>{{
  15. information.customName }}</div>
  16. </div>
  17. <div class="formItem flex pt-2 pb-1">
  18. <div class="w-22 text-right text-gray-500">客户来源:</div>
  19. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{
  20. information.customSourceValue }}
  21. </div>
  22. </div>
  23. <div class="formItem flex pt-2 pb-1">
  24. <div class="w-22 text-right text-gray-500">电话号码:</div>
  25. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>{{
  26. information.companyPhone }}
  27. </div>
  28. </div>
  29. <div class="formItem flex pt-2 pb-1">
  30. <div class="w-22 text-right text-gray-500">邮箱:</div>
  31. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>{{
  32. information.email }}</div>
  33. </div>
  34. <div class="formItem flex pt-2 pb-1">
  35. <div class="w-22 text-right text-gray-500">客户行业:</div>
  36. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{
  37. information.customerIndustryValue }}</div>
  38. </div>
  39. <div class="formItem flex pt-2 pb-1">
  40. <div class="w-22 text-right text-gray-500">客户级别:</div>
  41. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{
  42. information.customerLevelValue
  43. }}</div>
  44. </div>
  45. <div class="formItem flex pt-2 pb-1">
  46. <div class="w-22 text-right text-gray-500">客户地址:</div>
  47. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{ information.address }}</div>
  48. </div>
  49. <div class="formItem flex pt-2 pb-1">
  50. <div class="w-22 text-right text-gray-500">负责人:</div>
  51. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{ information.inchargerName }}
  52. </div>
  53. </div>
  54. <div class="formItem flex pt-2 pb-1">
  55. <div class="w-22 text-right text-gray-500">创建人:</div>
  56. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{ information.creatorName }}
  57. </div>
  58. </div>
  59. <div class="formItem flex pt-2 pb-1">
  60. <div class="w-22 text-right text-gray-500">创建时间:</div>
  61. <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{ information.newCreateTime }}
  62. </div>
  63. </div>
  64. <div class="formItem flex pt-2 pb-1" style="width: 100%;">
  65. <div class="w-22 text-right text-gray-500">备注:</div>
  66. <div class="flex-1 ml-1 text " v-ellipsis-tooltip>
  67. {{ information.customDesc }}
  68. </div>
  69. </div>
  70. </div>
  71. <!-- 弹窗 -->
  72. <el-dialog v-model="allVisible.transferCustomerVisible" width="600" :show-close="false" top="10vh">
  73. <template #header="{ close, titleId, titleClass }">
  74. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  75. <h4 :id="titleId">{{ '转移客户' }}</h4>
  76. <div>
  77. <el-button type="primary" :loading="allLoading.transferCustomerLoading"
  78. @click="transferCustomer()">转移</el-button>
  79. <el-button @click="allVisible.transferCustomerVisible = false">取消</el-button>
  80. </div>
  81. </div>
  82. </template>
  83. <div class="scroll-bar m-6">
  84. <div class="flex mb-4">
  85. <div class="w-20 flex items-center justify-end pr-4">转移至:</div>
  86. <el-select v-model="transferValue" placeholder="请选择" class="flex1">
  87. <el-option v-for="item in transferOptions" :key="item.id" :label="item.name" :value="item.id" />
  88. </el-select>
  89. </div>
  90. <div class="pl-3 text-[#e94a4a]">转移后,将看不到此客户</div>
  91. </div>
  92. </el-dialog>
  93. <el-dialog v-model="allVisible.editCustomerVisible" width="1000" :show-close="false" top="10vh">
  94. <template #header="{ close, titleId, titleClass }">
  95. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  96. <h4 :id="titleId">{{ '编辑客户' }}</h4>
  97. <div>
  98. <el-button type="primary" @click="saveCustomer()"
  99. :loading="allLoading.saveLading">保存</el-button>
  100. <el-button @click="closeVisible('editCustomerVisible')">取消</el-button>
  101. </div>
  102. </div>
  103. </template>
  104. <div class="h-[60vh] overflow-y-auto scroll-bar pt-3" v-loading="allLoading.generateFormDataLoading">
  105. <GenerateForm ref="generateForm" :data="generateFormData" :value="generateFormValue"
  106. :key="generateFormKey" />
  107. </div>
  108. </el-dialog>
  109. </div>
  110. </template>
  111. <script lang="ts" setup>
  112. import { confirmAction } from '@/utils/tools';
  113. import { ref, reactive, onMounted, onUnmounted, defineExpose, inject, watchEffect } from 'vue'
  114. import { GenerateForm } from '@zmjs/form-design';
  115. import { useStore } from '@/store/index'
  116. import { get, post } from '@/utils/request';
  117. import { GETPERSONNEL, URL_CLAIM, URL_EDITSAVE, URL_TEMPLALE } from '../api';
  118. import { formatDate } from '@/utils/times';
  119. const emits = defineEmits(['refreshData']);
  120. const { userInfo } = useStore()
  121. const props = defineProps<{
  122. data: any
  123. }>()
  124. const generateFormData = ref({
  125. config: {},
  126. list: []
  127. }) // 自定义表单数据
  128. const generateFormValue = ref({})
  129. const generateForm = ref<typeof GenerateForm>()
  130. const generateFormKey = ref(1)
  131. const globalPopup = inject<GlobalPopup>('globalPopup')
  132. const information = ref<any>({})
  133. const transferValue = ref('')
  134. const transferOptions = ref<personnelInterface[]>([])
  135. const allLoading = reactive({
  136. editBusinessLoading: false,
  137. saveLading: false,
  138. transferCustomerLoading: false,
  139. saveContactLoading: false,
  140. generateFormDataLoading: false
  141. })
  142. const allVisible = reactive({
  143. transferCustomerVisible: false,
  144. editCustomerVisible: false
  145. })
  146. function saveCustomer() {
  147. generateForm.value?.getData().then((res: any) => {
  148. allLoading.saveLading = true
  149. let formVal = { ...generateFormValue.value, ...res }
  150. delete formVal.createTime
  151. post(URL_EDITSAVE, { ...formVal }).then((_res) => {
  152. globalPopup?.showSuccess('操作成功')
  153. closeVisible('editCustomerVisible')
  154. emits('refreshData')
  155. }).finally(() => {
  156. allLoading.saveLading = false
  157. })
  158. }).catch((_err: any) => {
  159. console.log(_err)
  160. globalPopup?.showError('请填写完整')
  161. })
  162. }
  163. function transferCli() {
  164. transferValue.value
  165. showVisible('transferCustomerVisible')
  166. }
  167. function transferCustomer() {
  168. const ids = information.value?.id
  169. const inchargerId = information.value?.inchargerName ? transferValue.value : userInfo.id
  170. if (!inchargerId) {
  171. globalPopup?.showWarning('请选择转移的人员')
  172. return
  173. }
  174. allLoading.transferCustomerLoading = true
  175. post(URL_CLAIM, { ids, inchargerId }).then((res) => {
  176. if (res.code == 'ok') {
  177. globalPopup?.showSuccess('操作成功')
  178. allVisible.transferCustomerVisible = false
  179. emits('refreshData')
  180. }
  181. }).finally(() => {
  182. allLoading.transferCustomerLoading = false
  183. })
  184. }
  185. function claimCustomer() {
  186. confirmAction(`确定认领【${information.value.customName}】商机吗?`).then(() => {
  187. transferCustomer()
  188. })
  189. }
  190. function editCustomer() {
  191. const { id, companyPhone, customName, inchargerId, createTime, customSourceId, customerIndustryId, customerLevelId, email, telPhone, customDesc } = information.value
  192. const formVal = {
  193. id, customName, inchargerId, customerIndustryId, customerLevelId, email, customSourceId,
  194. createTime: formatDate(new Date(createTime)),
  195. telPhone, companyPhone,
  196. customDesc
  197. }
  198. generateFormValue.value = formVal
  199. allLoading.generateFormDataLoading = true
  200. showVisible('editCustomerVisible')
  201. setTimeout(() => {
  202. generateForm.value && generateForm.value?.reset()
  203. generateFormKey.value++
  204. allLoading.generateFormDataLoading = false
  205. }, 500)
  206. }
  207. function showVisible(type: keyof typeof allVisible) {
  208. allVisible[type] = true
  209. }
  210. function closeVisible(type: keyof typeof allVisible) {
  211. allVisible[type] = false
  212. }
  213. async function getSystemField() {
  214. const { data } = await post(GETPERSONNEL, {})
  215. transferOptions.value = data.map((item: any) => {
  216. const { id, name, phone, jobNumber } = item
  217. return {
  218. id, name, phone, jobNumber
  219. }
  220. })
  221. const res = await get(URL_TEMPLALE)
  222. generateFormData.value = JSON.parse(res.data[0].config)
  223. }
  224. watchEffect(() => {
  225. const { data } = props
  226. information.value = data
  227. })
  228. // 生命周期钩子
  229. onMounted(() => {
  230. getSystemField()
  231. });
  232. </script>
  233. <style scoped lang="scss">
  234. .information {
  235. .title {
  236. font-size: 18px;
  237. color: #000
  238. }
  239. .form {
  240. .formItem {
  241. width: 48%;
  242. }
  243. .text {
  244. display: -webkit-box;
  245. /* Safari */
  246. -webkit-line-clamp: 2;
  247. /* number of lines to show */
  248. -webkit-box-orient: vertical;
  249. overflow: hidden;
  250. line-height: 1.5;
  251. }
  252. }
  253. }
  254. </style>