information.vue 10 KB

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