historAllVisit copy 2.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. <template>
  2. <div class="bgcolor historAllVisit">
  3. <div class="navBarTOP">
  4. <!-- 顶部条-->
  5. <van-nav-bar class="navBar" title="历史拜访" left-arrow @click-left="onClickLeft" />
  6. <div class="searcTime">
  7. <van-row class="serchInput">
  8. <van-col span="12">
  9. <van-cell
  10. class="monthNow selectcell"
  11. :title="companyName"
  12. is-link
  13. arrow-direction="down"
  14. @click="regionClick" />
  15. </van-col>
  16. <van-col span="12">
  17. <van-cell
  18. class="monthNow selectcell"
  19. :title="regionName"
  20. is-link
  21. @click="SalesRegionClick"
  22. arrow-direction="down" />
  23. </van-col>
  24. <van-col span="12">
  25. <van-cell
  26. class="monthNow selectcell"
  27. :title="deptName"
  28. is-link
  29. @click="SalesDepartmentClick"
  30. arrow-direction="down" />
  31. </van-col>
  32. <van-col span="12">
  33. <van-cell
  34. class="monthNow selectcell"
  35. :title="userName"
  36. is-link
  37. @click="StaffClick"
  38. arrow-direction="down" />
  39. </van-col>
  40. <van-col span="12">
  41. <div class="monthNow" @click="startTimeshow = true">
  42. <span class="month">{{ startTime }}</span>
  43. <van-icon class="CalendarIcon" :name="timeico" />
  44. </div>
  45. </van-col>
  46. <van-col span="12">
  47. <div class="monthNow" @click="endTimeshow = true">
  48. <span class="month">{{ endTime }}</span>
  49. <van-icon class="CalendarIcon" :name="timeico" />
  50. </div>
  51. </van-col>
  52. </van-row>
  53. </div>
  54. <div class="searchDiv">
  55. <van-search v-model="storeName" show-action placeholder="搜索名称/编号/地址/拜访人">
  56. <template #action>
  57. <div @click="onSearch">搜索</div>
  58. </template>
  59. </van-search>
  60. </div>
  61. <div class="lineGrey"></div>
  62. </div>
  63. <!-- 主体内容-->
  64. <div class="container" style="margin-top: 262px">
  65. <van-list
  66. class="myList1"
  67. v-model="loading"
  68. :finished="finished"
  69. finished-text="没有更多了"
  70. @load="onLoad">
  71. <div v-if="list.length > 0">
  72. <div class="cellcontent" v-for="(item, index) in list" :key="index">
  73. <van-cell>
  74. <div class="card" style="position: relative" @click="detilsFn(item)">
  75. <span v-if="item.visitSource == 2" class="stateAbnormal">异常拜访</span>
  76. <!--<span v-if="item.visitModel==5" class="state">偏差过大</span>-->
  77. <span v-if="item.visitSource == 1" class="state">正常拜访</span>
  78. <div class="title">
  79. <span>{{ item.storeName }}</span> (<span style="color: #0057ba">{{
  80. item.storeCode
  81. }}</span
  82. >)
  83. </div>
  84. <div class="info">拜访人:{{ item.nickName }}</div>
  85. <div class="info">
  86. 拜访时间:{{ item.visitsTime }}
  87. <span class="textRight" v-if="item.status == '1' && item.taskId == null"
  88. >审批中</span
  89. >
  90. <span
  91. class="textRight"
  92. v-if="item.status == '1' && item.taskId != null"
  93. style="color: red"
  94. >退回修改</span
  95. >
  96. <span class="textRight" style="color: #07c160" v-if="item.status == 2"
  97. >审批完成</span
  98. >
  99. <span class="textRight" v-if="item.status == '3'" style="color: red">拒绝</span>
  100. </div>
  101. <div class="info" v-if="item.dwellTime">拜访时长:{{ item.dwellTime }}</div>
  102. <div class="info">地址:{{ item.addressLine }}</div>
  103. </div>
  104. <!-- 分销店 -->
  105. <template
  106. v-if="
  107. item.sfaStoreType &&
  108. item.sfaStoreType.type == 'fxd' &&
  109. item.sfaStoreChainsContactList
  110. ">
  111. <div class="info">
  112. 经销商:
  113. <div class="TCFXListItem" v-for="(item, index) in item.sfaStoreChainsContactList">
  114. <el-popover
  115. popper-class="zpover zpoverStoreztype"
  116. placement="bottom-start"
  117. trigger="click">
  118. <div>
  119. <div>{{ item.chainCode }}</div>
  120. <div>{{ item.chainName }}</div>
  121. </div>
  122. <div slot="reference" :key="index">
  123. {{ item.categoryDescribe }}
  124. </div>
  125. </el-popover>
  126. </div>
  127. </div>
  128. </template>
  129. <template v-else>
  130. <div class="info">经销商:{{ item.chainName }}</div>
  131. </template>
  132. </van-cell>
  133. <div class="lineGrey"></div>
  134. </div>
  135. </div>
  136. </van-list>
  137. <!-- <p style="text-align: center;color: #ccc;font-size: 12px;" v-if="list.length!=0">&#45;&#45;已经到底了&#45;&#45;</p>-->
  138. <!-- <van-empty description="&#45;&#45;已经到底了&#45;&#45;" v-if="list.length==0"/>-->
  139. </div>
  140. <van-popup v-model="startTimeshow" position="bottom" :style="{ height: '30%' }">
  141. <van-datetime-picker
  142. v-model="startcurrentDate"
  143. type="date"
  144. title="开始日期"
  145. :min-date="minDate"
  146. :max-date="startmaxDate"
  147. @confirm="dateeconfirm"
  148. @cancel="startTimeshow = false" />
  149. </van-popup>
  150. <van-popup v-model="endTimeshow" position="bottom" :style="{ height: '50%' }">
  151. <van-datetime-picker
  152. v-model="currentDate"
  153. type="date"
  154. title="开始日期"
  155. :min-date="endminDate"
  156. :max-date="maxDate"
  157. @confirm="endTimeconfirm"
  158. @cancel="endTimeshow = false" />
  159. </van-popup>
  160. <van-popup v-model="RegionShow" capture position="bottom">
  161. <van-picker
  162. show-toolbar
  163. :columns="companyList"
  164. value-key="deptName"
  165. @confirm="onregionConfirm"
  166. @cancel="RegionShow = false" />
  167. </van-popup>
  168. <van-popup v-model="SalesRegionShow" capture position="bottom">
  169. <van-picker
  170. show-toolbar
  171. :columns="regionList"
  172. value-key="deptName"
  173. @confirm="onSalesRegionConfirm"
  174. @cancel="SalesRegionShow = false" />
  175. </van-popup>
  176. <van-popup v-model="SalesDepartmentShow" capture position="bottom">
  177. <van-picker
  178. show-toolbar
  179. :columns="deptList"
  180. value-key="deptName"
  181. @confirm="onSalesDepartmentConfirm"
  182. @cancel="SalesDepartmentShow = false" />
  183. </van-popup>
  184. <van-popup v-model="StaffShow" capture position="bottom">
  185. <van-picker
  186. show-toolbar
  187. :columns="userList"
  188. @confirm="onStaffConfirm"
  189. value-key="nickName"
  190. @cancel="StaffShow = false" />
  191. </van-popup>
  192. </div>
  193. </template>
  194. <script>
  195. import { getVisits, getvisitDeptInfo } from '@/api/index';
  196. import timeico from '@/assets/Icon/datatims.png';
  197. export default {
  198. name: 'index.vue',
  199. data() {
  200. return {
  201. timeico: timeico,
  202. defaultDate: new Date(),
  203. searchValue: '',
  204. calendarShow: '',
  205. monthNames: [
  206. '-01',
  207. '-02',
  208. '-03',
  209. '-04',
  210. '-05',
  211. '-06',
  212. '-07',
  213. '-08',
  214. '-09',
  215. '-10',
  216. '-11',
  217. '-12',
  218. ],
  219. calendarIsshow: false,
  220. tabVal: 'insidePlan',
  221. list: [],
  222. loading: false,
  223. finished: true,
  224. listActive: null,
  225. query: '',
  226. show: false,
  227. minDate: new Date(2022, 0, 1),
  228. maxDate: new Date(),
  229. currentDate: new Date(),
  230. startcurrentDate: new Date(),
  231. endminDate: new Date(),
  232. startmaxDate: new Date(),
  233. endTime: '',
  234. startTime: '',
  235. endTimeshow: false,
  236. startTimeshow: false,
  237. storeName: '',
  238. companyName: '全部公司',
  239. deptName: '全部销售部',
  240. regionName: '全部大区',
  241. userName: '全部业务员',
  242. companyCode: '',
  243. deptCode: '',
  244. regionCode: '',
  245. userCode: '',
  246. companyList: [],
  247. deptList: [],
  248. regionList: [],
  249. userList: [],
  250. RegionShow: false,
  251. SalesRegionShow: false,
  252. SalesDepartmentShow: false,
  253. StaffShow: false,
  254. deptForm: { type: '', parentId: '' },
  255. pageNum: 1, // 当前页码 int类型
  256. pageSize: 10, // 当前每页条数 int类型
  257. deptLevel: null,
  258. };
  259. },
  260. activated() {
  261. this.info();
  262. this.getDeptInfo('dept', 'companyList', 'first');
  263. },
  264. created() {},
  265. methods: {
  266. onLoad() {
  267. // this.loading = false;
  268. this.getVisitsListFn();
  269. },
  270. info() {
  271. this.deptLevel = localStorage.getItem('deptLevel');
  272. // powerGrade:等级(1-销售员 2-销售部主管 3-大区主管 4-区域公司总经理 5-DIY公司)
  273. this.powerGrade = localStorage.getItem('powerGrade');
  274. this.userList = [];
  275. this.pageNum = 1;
  276. this.list = [];
  277. this.query = this.$route.query;
  278. this.startTime = this.getDay(-7);
  279. this.startcurrentDate = new Date(this.getDay(-7));
  280. this.endTime = this.parseTime(new Date(), '{y}-{m}-{d}');
  281. this.endminDate = new Date(this.getDay(-7));
  282. },
  283. detilsFn(val) {
  284. this.$router.push({
  285. path: '/historicalDetails',
  286. query: {
  287. visitId: val.id,
  288. storeId: val.storeId,
  289. storeCode: val.storeCode,
  290. taskId: val.taskId,
  291. userId: val.userId,
  292. storeCategory: val.storeCategory,
  293. },
  294. });
  295. },
  296. timeBefore7(date) {
  297. if (!date) {
  298. date = new Date();
  299. }
  300. var y = date.getFullYear();
  301. var m = date.getMonth() + 1;
  302. var d = date.getDate() - 6;
  303. if (d < 0) {
  304. m = date.getMonth();
  305. var d1 = new Date(y, m, 0);
  306. var d2 = d1.getDate();
  307. return y + '/' + (m < 10 ? '0' + m : m) + '/' + (d2 + d);
  308. } else {
  309. return y + '/' + (m < 10 ? '0' + m : m) + '/' + (d < 10 ? '0' + d : d);
  310. }
  311. },
  312. getDay(day) {
  313. var today = new Date();
  314. var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  315. today.setTime(targetday_milliseconds); //注意,这行是关键代码
  316. var tYear = today.getFullYear();
  317. var tMonth = today.getMonth();
  318. var tDate = today.getDate();
  319. tMonth = this.doHandleMonth(tMonth + 1);
  320. tDate = this.doHandleMonth(tDate);
  321. return tYear + '-' + tMonth + '-' + tDate;
  322. },
  323. doHandleMonth(month) {
  324. var m = month;
  325. if (month.toString().length == 1) {
  326. m = '0' + month;
  327. }
  328. return m;
  329. },
  330. dateeconfirm() {
  331. this.startTimeshow = false;
  332. this.startTime = this.parseTime(this.startcurrentDate, '{yy}-{mm}-{dd}');
  333. this.endminDate = new Date(this.startcurrentDate);
  334. this.onSearch();
  335. },
  336. endTimeconfirm() {
  337. this.endTimeshow = false;
  338. this.endTime = this.parseTime(this.currentDate, '{yy}-{mm}-{dd}');
  339. this.startmaxDate = new Date(this.currentDate);
  340. this.onSearch();
  341. },
  342. onClickLeft() {
  343. this.$router.go(-1);
  344. },
  345. onSearch() {
  346. this.pageNum = 1;
  347. this.list = [];
  348. this.getVisitsListFn();
  349. },
  350. getVisitsListFn() {
  351. let loading1 = this.$toast.loading({
  352. duration: 0,
  353. message: '数据获取中...',
  354. forbidClick: true,
  355. });
  356. if (this.refreshing) {
  357. this.list = [];
  358. this.refreshing = false;
  359. }
  360. getVisits({
  361. startTime: this.startTime + ' 00:00:00', //
  362. stopTime: this.endTime + ' 24:00:00', //
  363. storeRequest: this.storeName.trim(),
  364. pageNum: this.pageNum,
  365. pageSize: this.pageSize,
  366. companyId: this.companyCode,
  367. regionId: this.regionCode,
  368. userId: this.userCode,
  369. deptId: this.deptCode,
  370. }).then((res) => {
  371. loading1.clear();
  372. if (res.code == 200) {
  373. this.loading = false;
  374. this.list = this.list.concat(res.data);
  375. if (this.list.length >= res.total) {
  376. this.finished = true;
  377. } else {
  378. this.finished = false;
  379. }
  380. this.pageNum = this.pageNum + 1;
  381. } else {
  382. this.$toast.fail(res.msg);
  383. }
  384. });
  385. },
  386. regionClick() {
  387. // if(this.powerGrade>4){
  388. this.RegionShow = true;
  389. // }
  390. },
  391. SalesRegionClick(val) {
  392. // if(this.powerGrade>3){
  393. this.SalesRegionShow = true;
  394. // }
  395. },
  396. SalesDepartmentClick() {
  397. // if(this.powerGrade>2){
  398. this.SalesDepartmentShow = true;
  399. // }
  400. },
  401. StaffClick() {
  402. this.StaffShow = true;
  403. },
  404. StartTimeClick() {
  405. this.StartTimeShow = true;
  406. },
  407. onregionConfirm(val) {
  408. this.RegionShow = false;
  409. this.companyName = val.deptName;
  410. this.companyCode = val.deptId;
  411. if (val.deptName == '全部公司') {
  412. this.regionName = '全部大区';
  413. this.regionCode = '';
  414. this.deptName = '全部销售部';
  415. this.deptCode = '';
  416. this.userName = '全部业务员';
  417. this.userCode = '';
  418. } else {
  419. this.deptList = [];
  420. this.regionList = [];
  421. this.userList = [];
  422. }
  423. this.getDeptInfo('dept', 'regionList');
  424. },
  425. onSalesRegionConfirm(val) {
  426. this.SalesRegionShow = false;
  427. this.regionName = val.deptName;
  428. this.regionCode = val.deptId;
  429. if (val.deptId != '') {
  430. this.getDeptInfo('dept', 'deptList');
  431. }
  432. this.deptName = '全部销售部';
  433. this.deptCode = '';
  434. this.userName = '全部业务员';
  435. this.userCode = '';
  436. this.userList = [];
  437. },
  438. onSalesDepartmentConfirm(val) {
  439. this.SalesDepartmentShow = false;
  440. this.deptName = val.deptName;
  441. this.deptCode = val.deptId;
  442. if (val.deptId != '') {
  443. this.getDeptInfo('user', 'userList');
  444. }
  445. this.userName = '全部业务员';
  446. this.userCode = '';
  447. },
  448. onStaffConfirm(val) {
  449. this.StaffShow = false;
  450. this.userName = val.nickName;
  451. this.userCode = val.userId;
  452. },
  453. getDeptInfo(type, activaType, isFirstrequest = false) {
  454. this.deptForm.type = type;
  455. if (activaType == 'companyList') {
  456. // 总部/公司
  457. this.deptForm.parentId = '';
  458. } else if (activaType == 'regionList') {
  459. // 大区
  460. this.deptForm.parentId = this.companyCode;
  461. } else if (activaType == 'deptList') {
  462. // 销售部
  463. this.deptForm.parentId = this.regionCode;
  464. } else if (activaType == 'userList') {
  465. // 业务员
  466. this.deptForm.parentId = this.deptCode;
  467. }
  468. getvisitDeptInfo(this.deptForm).then((res) => {
  469. // 总部/公司 默认显示 “全部”;其他:默认显示第一个
  470. if (isFirstrequest) {
  471. if (this.powerGrade == 5) {
  472. this.companyList = [{ deptName: '全部公司', deptId: '' }].concat(res.data.company);
  473. // 初始化第一次请求 公司/总部身份 不需要请求大区、销售部、业务员数据
  474. this.onSearch();
  475. } else {
  476. this.companyList = res.data.company;
  477. this.companyName = res.data.company[0].deptName;
  478. this.companyCode = res.data.company[0].deptId;
  479. this.getDeptInfo('dept', 'regionList');
  480. }
  481. } else {
  482. if (activaType == 'regionList') {
  483. // 大区
  484. this.regionName = res.data.region[0].deptName;
  485. this.regionCode = res.data.region[0].deptId;
  486. this.regionList = res.data.region;
  487. this.getDeptInfo('dept', 'deptList');
  488. } else if (activaType == 'deptList') {
  489. // 销售部
  490. this.deptName = res.data.dept[0].deptName;
  491. this.deptCode = res.data.dept[0].deptId;
  492. this.deptList = res.data.dept;
  493. this.getDeptInfo('user', 'userList');
  494. } else if (activaType == 'userList') {
  495. // 业务员
  496. this.userList = [{ nickName: '全部业务员', userId: '' }].concat(res.data.user);
  497. }
  498. }
  499. // if (type == 'dept') {
  500. // if (grade == '1') {
  501. // if (res.data.region != null) {
  502. // this.regionList = [{ deptName: '全部大区', deptId: '' }].concat(res.data.region);
  503. // }
  504. // } else if (grade == '2') {
  505. // if (res.data.dept != null) {
  506. // this.deptList = [{ deptName: '全部销售部', deptId: '' }].concat(res.data.dept);
  507. // }
  508. // } else {
  509. // this.companyList = res.data.company;
  510. // if (this.$route.query.userCode == undefined) {
  511. // this.companyName = res.data.company[0].deptName;
  512. // this.companyCode = res.data.company[0].deptId;
  513. // }
  514. // if (res.data.dept != null) {
  515. // this.deptName = res.data.dept[0].deptName;
  516. // this.deptCode = res.data.dept[0].deptId;
  517. // this.deptList = res.data.dept;
  518. // }
  519. // if (res.data.region != null) {
  520. // this.regionName = res.data.region[0].deptName;
  521. // this.regionCode = res.data.region[0].deptId;
  522. // this.regionList = res.data.region;
  523. // }
  524. // if (res.data.user != null) {
  525. // this.userList = res.data.user;
  526. // this.userCode = '';
  527. // }
  528. // }
  529. // } else if (type == 'user') {
  530. // if (res.data.user != null) {
  531. // this.userList = [{ nickName: '全部业务员', userId: '' }].concat(res.data.user);
  532. // }
  533. // }
  534. });
  535. },
  536. },
  537. };
  538. </script>
  539. <style lang="scss">
  540. .searchDiv {
  541. .van-search {
  542. background: #fff;
  543. }
  544. .van-search__action {
  545. font-size: 14px;
  546. color: #1989fa;
  547. font-weight: bold;
  548. background: #f5f5f5;
  549. border-bottom-right-radius: 60px;
  550. border-top-right-radius: 60px;
  551. border: 1px solid #ccc;
  552. padding: 0 20px;
  553. }
  554. .van-search--show-action {
  555. padding-right: 12px;
  556. }
  557. .van-search__content {
  558. border: 1px solid #ccc;
  559. border-bottom-left-radius: 60px;
  560. border-top-left-radius: 60px;
  561. background: #f5f5f5;
  562. border-right: 0;
  563. }
  564. }
  565. .myList1 {
  566. .van-cell {
  567. padding: 10px 16px;
  568. &:after {
  569. border-bottom: none;
  570. }
  571. }
  572. }
  573. .historAllVisit {
  574. .TCFXListItem {
  575. display: inline-block;
  576. border: 1px solid #ccc;
  577. padding: 3px 5px;
  578. margin: 0 5px;
  579. border-radius: 6px;
  580. }
  581. }
  582. </style>
  583. <style lang="scss" scoped>
  584. .bgcolor {
  585. background-color: #f5f5f5;
  586. }
  587. .container {
  588. padding-bottom: 50px;
  589. }
  590. .monthNow {
  591. height: 34px;
  592. line-height: 34px;
  593. text-align: left;
  594. font-weight: bold;
  595. padding: 0 16px;
  596. box-sizing: border-box;
  597. background-color: #f1f1f1;
  598. border-radius: 20px;
  599. margin: 8px;
  600. border: 1px solid #ccc;
  601. position: relative;
  602. color: #333;
  603. font-size: 14px;
  604. .van-cell__left-icon,
  605. .van-cell__right-icon {
  606. line-height: 34px;
  607. }
  608. .CalendarIcon {
  609. float: right;
  610. font-size: 24px;
  611. color: #1989fa;
  612. margin-top: 6px;
  613. position: absolute;
  614. right: 12px;
  615. img {
  616. height: 0.8em;
  617. }
  618. }
  619. }
  620. .serchInput {
  621. padding: 0 4px;
  622. }
  623. .selectcell {
  624. width: 92%;
  625. }
  626. .card {
  627. box-sizing: border-box;
  628. .title {
  629. font-size: 16px;
  630. font-weight: bold;
  631. color: #333;
  632. line-height: 30px;
  633. width: 78%;
  634. }
  635. .info {
  636. font-size: 14px;
  637. color: #909090;
  638. line-height: 26px;
  639. }
  640. }
  641. /**/
  642. .searcTime {
  643. background-color: white;
  644. }
  645. .btnbox {
  646. padding: 0 16px;
  647. }
  648. .cellcontent .centerBtn {
  649. margin: 0 auto 10px;
  650. display: block;
  651. width: 92%;
  652. border-radius: 5px;
  653. }
  654. .statstext {
  655. background-color: #1c84c6;
  656. position: absolute;
  657. right: 0;
  658. top: 16px;
  659. padding: 2px 6px 2px 12px;
  660. border-bottom-left-radius: 60px;
  661. border-top-left-radius: 60px;
  662. color: #fff;
  663. }
  664. .stateAbnormal {
  665. position: absolute;
  666. right: 0;
  667. top: 0;
  668. color: #fff;
  669. background-color: red;
  670. border-radius: 5px;
  671. display: inline-block;
  672. padding: 0 5px;
  673. }
  674. .state {
  675. position: absolute;
  676. right: 0;
  677. top: 0;
  678. color: #fff;
  679. background-color: #1c84c6;
  680. border-radius: 5px;
  681. display: inline-block;
  682. padding: 0 5px;
  683. }
  684. .navBarTOP {
  685. position: fixed;
  686. width: 100%;
  687. z-index: 2;
  688. top: 0;
  689. }
  690. .cellcontent .textRight {
  691. float: right;
  692. color: #0057ba;
  693. }
  694. </style>