visitorDetails.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <Page title="访客计划详情">
  3. <template v-slot:headerRight>
  4. <div class="themeTextColor" v-if="detailedData.finishState == 0" @click="visitorEditor">编辑</div>
  5. </template>
  6. <template v-slot:body>
  7. <!-- 头部 -->
  8. <div class="planDetailsHead">
  9. <div class="w-full flex items-center justify-between">
  10. <div class="text-size-in font-bold text-[#474A56]">{{ detailedData.planName }}</div>
  11. <div :class="`labelTag ${detailedData.finishState == 0 ? 'toBeCompleted' : 'completed'}`">{{ ['未完成',
  12. '已完成'][detailedData.finishState] }}</div>
  13. </div>
  14. <div class="w-full mt-4">拜访目的:{{ detailedData.visitGoalName }}</div>
  15. <div class="w-full mt-4">拜访时间: {{ detailedData.visitTime }}</div>
  16. <div class="line"></div>
  17. <div class="w-full flex items-center">
  18. <van-icon name="user-circle-o" class="text-size-in mr-2" />
  19. 客户:
  20. <div class="ml-2 themeTextColor decoration-auto underline" @click="jumpToCustomerDetails()">{{
  21. detailedData.customName }}</div>
  22. </div>
  23. </div>
  24. <!-- 主体 -->
  25. <van-cell-group>
  26. <van-cell title="计划名称" :value="detailedData.planName" />
  27. <van-cell title="客户姓名" :value="detailedData.customName" />
  28. <van-cell title="负责人" :value="detailedData.inchargerName" />
  29. <van-cell title="拜访目的" :value="detailedData.visitGoalName" />
  30. <van-cell title="拜访时间" :value="detailedData.visitTime" />
  31. <van-cell title="提醒" :value="detailedData.remindTypeName" />
  32. <van-cell title="提醒时间" :value="detailedData.remindTime" v-if="detailedData.remindType == -1" />
  33. <van-cell title="备注" :value="detailedData.remark" />
  34. </van-cell-group>
  35. <div class="h-10"></div>
  36. <!-- 弹窗 -->
  37. <van-popup v-model:show="showContacts" closeable position="bottom" round>
  38. <div class="newModuleAdded relative">
  39. <div class="text-size-large text-[#474A56] absolute topTitle">联系人号码</div>
  40. <div class="flex flex-col overflow-y-auto boxLxr">
  41. <template v-for="item in contactList">
  42. <a :href="`tel:+${item.phone}`">
  43. <div class="bg-[#F8F8FA] flex justify-between items-center px-6 py-4 mb-3 rounded">
  44. <div class="w-3/12">{{ item.name }}</div>
  45. <div class="flex-1">{{ item.phone }}</div>
  46. <van-icon name="phone" color="#075985" size="1.4rem" />
  47. </div>
  48. </a>
  49. </template>
  50. </div>
  51. </div>
  52. </van-popup>
  53. <van-popup v-model:show="showDelay" closeable position="bottom" round>
  54. <div class="newModuleAdded relative">
  55. <div class="text-size-large text-[#474A56] absolute topTitle">{{ delayRestartText }}时间</div>
  56. <div class="flex flex-col overflow-y-auto h-52">
  57. <div class="flex-1">
  58. <div class="px-6 py-4 bg-[#F8F8FA] flex justify-between items-center mt-2" @click="showDatePicker = true">
  59. <div>选择时间</div>
  60. <div class="flex items-center">
  61. {{ showDelayData }}
  62. <van-icon name="arrow" size="1.2rem" class="ml-2" />
  63. </div>
  64. </div>
  65. </div>
  66. <van-button type="primary" :disabled="!showDelayData" @click="delayTimeEvent()">保存</van-button>
  67. </div>
  68. </div>
  69. </van-popup>
  70. <van-popup v-model:show="showDatePicker" destroy-on-close position="bottom" :style="{ height: '50%' }">
  71. <van-date-picker v-model="showDatePickerVal" @confirm="showPickerConfirm" @cancel="showDatePicker = false" />
  72. </van-popup>
  73. <van-popup v-model:show="timeShowPicker" destroy-on-close position="bottom" :style="{ height: '50%' }">
  74. <van-time-picker v-model="currentTime" title="选择时间" @confirm="timeConfirm" />
  75. </van-popup>
  76. </template>
  77. <template v-slot:footer v-if="detailedData.finishState == 0">
  78. <div class="w-full flex justify-between layout">
  79. <div class="footerBtnLeft layouts" @click="showContactsCli()">
  80. <div class="imgClss">
  81. <img src="/src/assets/image/lianxir.png" alt="">
  82. </div>
  83. 联系人
  84. </div>
  85. <div class="footerBtnRight layouts" @click="delayRestart('DELAY')">
  86. <div class="imgClss">
  87. <img src="/src/assets/image/yanqi.png" alt="">
  88. </div>
  89. 延期
  90. </div>
  91. <div class="coverWithWhite"></div>
  92. <div class="bigCircle" @click="completeThePlan()">
  93. <div class="imgClss">
  94. <img src="/src/assets/image/wanc.png" alt="">
  95. </div>
  96. 完成
  97. </div>
  98. </div>
  99. </template>
  100. <template v-slot:footer v-if="detailedData.finishState != 0">
  101. <div class="w-full flex justify-between layout">
  102. <div class="footerBtnTwoLeft layoutsTwo" @click="showContactsCli()">
  103. <div class="imgClss">
  104. <img src="/src/assets/image/lianxir.png" alt="">
  105. </div>
  106. 联系人
  107. </div>
  108. <div class="footerBtnTwoLeft layoutsTwo" @click="delayRestart('RESTART')">
  109. <div class="imgClss">
  110. <img src="/src/assets/image/chongqi.png" alt="">
  111. </div>
  112. 重启
  113. </div>
  114. </div>
  115. </template>
  116. </Page>
  117. </template>
  118. <script setup>
  119. import { ref } from "vue";
  120. import { showConfirmDialog } from 'vant';
  121. import { useLifecycle } from "@hooks/useCommon.js";
  122. import { OBTAIN_DETAILS_OF_THE_VISIT_PLAN, POSTPONE_THE_VISIT_PLAN, COMPLETE_THE_VISIT_PLAN, OBTAIN_CUSTOMER_DETAILS } from "@hooks/useApi"
  123. import useToast from "@hooks/useToast"
  124. import requests from "@common/requests";
  125. import useRouterStore from "@store/useRouterStore.js";
  126. import dayjs from "dayjs";
  127. import { routingInfos } from "@utility/generalVariables.js";
  128. import useFixedData from "@store/useFixedData.js";
  129. import PullDownSelector from "@components/common/pullDownSelector.vue";
  130. const router = useRouterStore();
  131. const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
  132. const detailedData = ref({});
  133. const showContacts = ref(false);
  134. const showDelay = ref(false)
  135. const showDatePicker = ref(false)
  136. const timeShowPicker = ref(false)
  137. const showDatePickerVal = ref(dayjs().format("YYYY-MM-DD").split('-'))
  138. const showDelayData = ref('')
  139. const currentTime = ref('')
  140. const contactList = ref([]);
  141. const delayRestartText = ref('')
  142. function delayRestart(type = 'DELAY') {
  143. const textType = { 'DELAY': '延期', 'RESTART': '重启' }
  144. delayRestartText.value = textType[type]
  145. showDelay.value = true
  146. showDelayData.value = ''
  147. }
  148. function visitorEditor() {
  149. router.navigateTo({
  150. pathName: 'addEditorVisitor',
  151. success: () => {
  152. router.emit('addEditorVisitorParameter', {
  153. row: JSON.stringify(detailedData.value || {}),
  154. date: JSON.stringify(detailedData.value.visitTime || {})
  155. })
  156. }
  157. })
  158. }
  159. function jumpToCustomerDetails() {
  160. const routerInfo = routingInfos['customer']
  161. requests.post(OBTAIN_CUSTOMER_DETAILS, { id: detailedData.value.customId }).then(res => {
  162. router.navigateTo({
  163. pathName: 'details',
  164. success: () => {
  165. router.emit('detailParameter', {
  166. routerInfo: JSON.stringify(routerInfo || {}),
  167. parameter: JSON.stringify(res.data || {})
  168. })
  169. }
  170. })
  171. })
  172. }
  173. function showContactsCli() {
  174. if (!((contactList.value || []).length)) {
  175. toastText('该联系人无号码')
  176. return
  177. }
  178. showContacts.value = true
  179. }
  180. function completeThePlan() {
  181. showConfirmDialog({
  182. title: `完成访客计划`,
  183. message: `确定完成【${detailedData.value.planName}】访客计划吗?`,
  184. }).then(() => {
  185. requests.post(COMPLETE_THE_VISIT_PLAN, { planId: detailedData.value.id, }).then((res) => {
  186. toastSuccess('操作成功')
  187. getDetailData(detailedData.value)
  188. })
  189. })
  190. }
  191. function delayTimeEvent() {
  192. requests.post(POSTPONE_THE_VISIT_PLAN, { planId: detailedData.value.id, visitTime: showDelayData.value }).then(() => {
  193. toastSuccess(`操作成功`)
  194. getDetailData(detailedData.value)
  195. showDelay.value = false
  196. })
  197. }
  198. function getDetailData(row) {
  199. requests.post(OBTAIN_DETAILS_OF_THE_VISIT_PLAN, { planId: row.id }).then(({ data = [] }) => {
  200. detailedData.value = data
  201. contactList.value = data.contacts || []
  202. })
  203. }
  204. function showPickerConfirm({ selectedValues }) {
  205. const dates = selectedValues.join('-')
  206. const times = dayjs().format("hh:mm")
  207. showDelayData.value = `${dates} ${times}`
  208. currentTime.value = times.split(':')
  209. showDatePicker.value = false
  210. timeShowPicker.value = true
  211. }
  212. function timeConfirm({ selectedValues }) {
  213. const dates = dayjs(new Date(showDatePickerVal.value)).format("YYYY-MM-DD")
  214. showDelayData.value = `${dates} ${selectedValues.join(':')}`
  215. timeShowPicker.value = false
  216. }
  217. function processingDataSource(data) {
  218. const row = JSON.parse(data.row);
  219. detailedData.value = row || {}
  220. getDetailData(row)
  221. }
  222. useLifecycle({
  223. load: () => {
  224. console.log('开始执行')
  225. router.on("visitorDetailsParameter", (data) => {
  226. processingDataSource(data);
  227. });
  228. },
  229. });
  230. </script>
  231. <style lang="scss" scoped>
  232. .planDetailsHead {
  233. background: #ffa35919;
  234. padding: 14px 18px;
  235. margin: 10px;
  236. .toBeCompleted {
  237. background: rgba($color: #f38b3c, $alpha: 0.1);
  238. border-color: #f38b3c;
  239. color: #f38b3c;
  240. }
  241. .completed {
  242. background: rgba($color: #07c160, $alpha: 0.1);
  243. border-color: #07c160;
  244. color: #07c160;
  245. }
  246. .labelTag {
  247. font-size: 10px;
  248. padding: 3px 8px;
  249. border-radius: 4px;
  250. border: 1px solid;
  251. }
  252. .line {
  253. width: 100%;
  254. height: 1px;
  255. background-color: #E6D3C7;
  256. margin: 14px 0;
  257. }
  258. }
  259. .layout {
  260. height: 90px;
  261. position: relative;
  262. .layouts {
  263. width: 40%;
  264. height: 100%;
  265. background: #fff;
  266. box-shadow: 0px -2px 30px 0px #00000014;
  267. display: flex;
  268. flex-direction: column;
  269. align-items: center;
  270. justify-content: center;
  271. }
  272. .layoutsTwo {
  273. width: 40%;
  274. height: 100%;
  275. background: #fff;
  276. display: flex;
  277. flex-direction: column;
  278. align-items: center;
  279. justify-content: center;
  280. }
  281. .footerBtnLeft {
  282. border-top-right-radius: 25px;
  283. .imgClss {
  284. width: 30px;
  285. height: 30px;
  286. margin-bottom: 6px;
  287. }
  288. }
  289. .footerBtnTwoLeft {
  290. width: 50%;
  291. .imgClss {
  292. width: 30px;
  293. height: 30px;
  294. margin-bottom: 6px;
  295. }
  296. }
  297. .footerBtnRight {
  298. border-top-left-radius: 25px;
  299. .imgClss {
  300. width: 26px;
  301. height: 24px;
  302. margin-bottom: 9px;
  303. }
  304. }
  305. .coverWithWhite {
  306. width: 20%;
  307. background: #fff;
  308. position: absolute;
  309. bottom: 0;
  310. left: 50%;
  311. transform: translateX(-50%);
  312. height: 70px;
  313. z-index: 1;
  314. }
  315. .bigCircle {
  316. width: 80px;
  317. height: 80px;
  318. ;
  319. border-radius: 50%;
  320. background: $themeColor;
  321. box-shadow: 0px -2px 30px 0px #00000014;
  322. position: absolute;
  323. bottom: 27px;
  324. left: 50%;
  325. transform: translateX(-50%);
  326. z-index: 2;
  327. color: #fff;
  328. display: flex;
  329. align-items: center;
  330. justify-content: center;
  331. flex-direction: column;
  332. .imgClss {
  333. width: 25.5px;
  334. height: 25.5px;
  335. margin-bottom: 4px;
  336. }
  337. }
  338. }
  339. .newModuleAdded {
  340. padding: 45px 25px 45px 25px;
  341. }
  342. .topTitle {
  343. top: 14px;
  344. }
  345. .boxLxr {
  346. max-height: 180px;
  347. }
  348. </style>