information.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. <TextTranslation translationTypes="userName" :translationValue="information.inchargerName"></TextTranslation>
  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. <TextTranslation translationTypes="userName" :translationValue="information.creatorName"></TextTranslation>
  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. <personnel-search v-model="transferValue" :size="''" placeholder="请选择"></personnel-search>
  116. </div>
  117. <div class="pl-3 text-[#e94a4a]">转移后,将看不到此客户</div>
  118. </div>
  119. </el-dialog>
  120. <el-dialog v-model="allVisible.editCustomerVisible" width="1000" :show-close="false" top="10vh">
  121. <template #header="{ close, titleId, titleClass }">
  122. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  123. <h4 :id="titleId">{{ '编辑客户' }}</h4>
  124. <div>
  125. <el-button type="primary" @click="saveCustomer()" :loading="allLoading.saveLading"
  126. >保存</el-button
  127. >
  128. <el-button @click="closeVisible('editCustomerVisible')">取消</el-button>
  129. </div>
  130. </div>
  131. </template>
  132. <div
  133. class="h-[60vh] overflow-y-auto scroll-bar pt-3"
  134. v-loading="allLoading.generateFormDataLoading"
  135. >
  136. <GenerateForm
  137. ref="generateForm"
  138. :data="generateFormData"
  139. :value="generateFormValue"
  140. :key="generateFormKey"
  141. />
  142. </div>
  143. </el-dialog>
  144. </div>
  145. </template>
  146. <script lang="ts" setup>
  147. import { confirmAction } from '@/utils/tools';
  148. import { ref, reactive, onMounted, onUnmounted, inject, watchEffect } from 'vue';
  149. import { GenerateForm } from '@zmjs/form-design';
  150. import { useStore } from '@/store/index';
  151. import { get, post } from '@/utils/request';
  152. import { GETPERSONNEL, URL_CLAIM, URL_EDITSAVE, URL_TEMPLALE } from '../api';
  153. import { formatDate } from '@/utils/times';
  154. import personnelSearch from '@/components/translationComponent/personnelSearch/personnelSearch.vue';
  155. const emits = defineEmits(['refreshData']);
  156. const { userInfo } = useStore();
  157. const props = defineProps<{
  158. data: any;
  159. }>();
  160. const generateFormData = ref({
  161. config: {},
  162. list: []
  163. }); // 自定义表单数据
  164. const isExistBusiness = sessionStorage.getItem("isExistBusiness");
  165. const businessLabel = isExistBusiness === "1" ? "商机" : "项目";
  166. const generateFormValue = ref({});
  167. const generateForm = ref<typeof GenerateForm>();
  168. const generateFormKey = ref(1);
  169. const globalPopup = inject<GlobalPopup>('globalPopup');
  170. const information = ref<any>({});
  171. const transferValue = ref('');
  172. const transferOptions = ref<personnelInterface[]>([]);
  173. const allLoading = reactive({
  174. editBusinessLoading: false,
  175. saveLading: false,
  176. transferCustomerLoading: false,
  177. saveContactLoading: false,
  178. generateFormDataLoading: false
  179. });
  180. const allVisible = reactive({
  181. transferCustomerVisible: false,
  182. editCustomerVisible: false
  183. });
  184. function saveCustomer() {
  185. generateForm.value
  186. ?.getData()
  187. .then((res: any) => {
  188. allLoading.saveLading = true;
  189. let formVal = { ...generateFormValue.value, ...res };
  190. delete formVal.createTime;
  191. post(URL_EDITSAVE, { ...formVal })
  192. .then((_res) => {
  193. globalPopup?.showSuccess('操作成功');
  194. closeVisible('editCustomerVisible');
  195. emits('refreshData');
  196. })
  197. .finally(() => {
  198. allLoading.saveLading = false;
  199. });
  200. })
  201. .catch((_err: any) => {
  202. console.log(_err);
  203. globalPopup?.showError('请填写完整');
  204. });
  205. }
  206. function transferCli() {
  207. transferValue.value;
  208. showVisible('transferCustomerVisible');
  209. }
  210. function transferCustomer() {
  211. const ids = information.value?.id;
  212. const inchargerId = information.value?.inchargerName ? transferValue.value : userInfo.id;
  213. if (!inchargerId) {
  214. globalPopup?.showWarning('请选择转移的人员');
  215. return;
  216. }
  217. allLoading.transferCustomerLoading = true;
  218. post(URL_CLAIM, { ids, inchargerId })
  219. .then((res) => {
  220. if (res.code == 'ok') {
  221. globalPopup?.showSuccess('操作成功');
  222. allVisible.transferCustomerVisible = false;
  223. emits('refreshData');
  224. }
  225. })
  226. .finally(() => {
  227. allLoading.transferCustomerLoading = false;
  228. });
  229. }
  230. function claimCustomer() {
  231. confirmAction(`确定认领【${information.value.customName}】${businessLabel}吗?`).then(() => {
  232. transferCustomer();
  233. });
  234. }
  235. function editCustomer() {
  236. const {
  237. id,
  238. contactsName,
  239. companyPhone,
  240. customName,
  241. inchargerId,
  242. createTime,
  243. customSourceId,
  244. customerIndustryId,
  245. customerLevelId,
  246. email,
  247. telPhone,
  248. customDesc,
  249. address
  250. } = information.value;
  251. const formVal = {
  252. id,
  253. customName,
  254. inchargerId,
  255. customerIndustryId,
  256. customerLevelId,
  257. contactsName,
  258. email,
  259. customSourceId,
  260. createTime: formatDate(new Date(createTime)),
  261. telPhone,
  262. companyPhone,
  263. customDesc,
  264. address
  265. };
  266. generateFormValue.value = formVal;
  267. allLoading.generateFormDataLoading = true;
  268. showVisible('editCustomerVisible');
  269. setTimeout(() => {
  270. generateForm.value && generateForm.value?.reset();
  271. generateFormKey.value++;
  272. allLoading.generateFormDataLoading = false;
  273. }, 500);
  274. }
  275. function showVisible(type: keyof typeof allVisible) {
  276. allVisible[type] = true;
  277. }
  278. function closeVisible(type: keyof typeof allVisible) {
  279. allVisible[type] = false;
  280. }
  281. async function getSystemField() {
  282. const { data } = await post(GETPERSONNEL, {});
  283. transferOptions.value = data.map((item: any) => {
  284. const { id, name, phone, jobNumber } = item;
  285. return {
  286. id,
  287. name,
  288. phone,
  289. jobNumber
  290. };
  291. });
  292. const res = await get(URL_TEMPLALE);
  293. generateFormData.value = JSON.parse(res.data[0].config);
  294. }
  295. watchEffect(() => {
  296. const { data } = props;
  297. information.value = data;
  298. });
  299. // 生命周期钩子
  300. onMounted(() => {
  301. getSystemField();
  302. });
  303. </script>
  304. <style scoped lang="scss">
  305. .information {
  306. .title {
  307. font-size: 18px;
  308. color: #606266;
  309. }
  310. .form {
  311. .formItem {
  312. width: 48%;
  313. }
  314. .text {
  315. display: -webkit-box;
  316. /* Safari */
  317. -webkit-line-clamp: 2;
  318. /* number of lines to show */
  319. -webkit-box-orient: vertical;
  320. overflow: hidden;
  321. line-height: 1.5;
  322. }
  323. }
  324. }
  325. </style>