historAllVisit.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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. userDeptLevel: null,
  258. };
  259. },
  260. activated() {
  261. setTimeout(() => {
  262. this.onSearch();
  263. }, 1000);
  264. },
  265. created() {
  266. this.info();
  267. this.userList = [];
  268. this.pageNum = 1;
  269. this.list = [];
  270. // powerGrade:等级(1-销售员 2-销售部主管 3-大区主管 4-区域公司总经理 5-DIY公司)
  271. this.powerGrade = localStorage.getItem('powerGrade');
  272. // userDeptLevel用户部门等级字段,0-总部,1-公司,2-大区,3-销售部,4-业务员
  273. this.userDeptLevel = localStorage.getItem('userDeptLevel');
  274. this.getDeptInfo('dept');
  275. if (this.userDeptLevel == 0) {
  276. setTimeout(() => {
  277. if (this.$route.query.userCode == undefined) {
  278. this.companyName = this.companyList[0].deptName;
  279. this.companyCode = this.companyList[0].deptId;
  280. }
  281. this.getDeptInfo('dept', 1);
  282. }, 1000);
  283. }
  284. if (this.userDeptLevel == 1) {
  285. setTimeout(() => {
  286. this.getDeptInfo('dept', 1);
  287. }, 1000);
  288. }
  289. if (this.userDeptLevel == 2) {
  290. setTimeout(() => {
  291. this.getDeptInfo('dept', 2);
  292. }, 1000);
  293. }
  294. if (this.userDeptLevel == 3 || this.userDeptLevel == 4) {
  295. setTimeout(() => {
  296. this.getDeptInfo('user');
  297. }, 2000);
  298. }
  299. },
  300. methods: {
  301. onLoad() {
  302. // this.loading = false;
  303. this.getVisitsListFn();
  304. },
  305. info() {
  306. this.query = this.$route.query;
  307. this.startTime = this.getDay(-7);
  308. this.startcurrentDate = new Date(this.getDay(-7));
  309. this.endTime = this.parseTime(new Date(), '{y}-{m}-{d}');
  310. this.endminDate = new Date(this.getDay(-7));
  311. },
  312. detilsFn(val) {
  313. console.log(val.id);
  314. this.$router.push({
  315. path: '/historicalDetails',
  316. query: {
  317. visitId: val.id,
  318. storeId: val.storeId,
  319. storeCode: val.storeCode,
  320. taskId: val.taskId,
  321. userId: val.userId,
  322. storeCategory: val.storeCategory,
  323. },
  324. });
  325. },
  326. timeBefore7(date) {
  327. if (!date) {
  328. date = new Date();
  329. }
  330. var y = date.getFullYear();
  331. var m = date.getMonth() + 1;
  332. var d = date.getDate() - 6;
  333. if (d < 0) {
  334. m = date.getMonth();
  335. var d1 = new Date(y, m, 0);
  336. var d2 = d1.getDate();
  337. return y + '/' + (m < 10 ? '0' + m : m) + '/' + (d2 + d);
  338. } else {
  339. return y + '/' + (m < 10 ? '0' + m : m) + '/' + (d < 10 ? '0' + d : d);
  340. }
  341. },
  342. getDay(day) {
  343. var today = new Date();
  344. var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  345. today.setTime(targetday_milliseconds); //注意,这行是关键代码
  346. var tYear = today.getFullYear();
  347. var tMonth = today.getMonth();
  348. var tDate = today.getDate();
  349. tMonth = this.doHandleMonth(tMonth + 1);
  350. tDate = this.doHandleMonth(tDate);
  351. return tYear + '-' + tMonth + '-' + tDate;
  352. },
  353. doHandleMonth(month) {
  354. var m = month;
  355. if (month.toString().length == 1) {
  356. m = '0' + month;
  357. }
  358. return m;
  359. },
  360. dateeconfirm() {
  361. this.startTimeshow = false;
  362. this.startTime = this.parseTime(this.startcurrentDate, '{yy}-{mm}-{dd}');
  363. this.endminDate = new Date(this.startcurrentDate);
  364. this.onSearch();
  365. },
  366. endTimeconfirm() {
  367. this.endTimeshow = false;
  368. this.endTime = this.parseTime(this.currentDate, '{yy}-{mm}-{dd}');
  369. this.startmaxDate = new Date(this.currentDate);
  370. this.onSearch();
  371. },
  372. onClickLeft() {
  373. this.$router.go(-1);
  374. },
  375. onSearch() {
  376. this.pageNum = 1;
  377. this.list = [];
  378. this.getVisitsListFn();
  379. },
  380. getVisitsListFn() {
  381. let loading1 = this.$toast.loading({
  382. duration: 0,
  383. message: '数据获取中...',
  384. forbidClick: true,
  385. });
  386. if (this.refreshing) {
  387. this.list = [];
  388. this.refreshing = false;
  389. }
  390. getVisits({
  391. startTime: this.startTime + ' 00:00:00', //
  392. stopTime: this.endTime + ' 24:00:00', //
  393. storeRequest: this.storeName.trim(),
  394. pageNum: this.pageNum,
  395. pageSize: this.pageSize,
  396. companyId: this.companyCode,
  397. regionId: this.regionCode,
  398. userId: this.userCode,
  399. deptId: this.deptCode,
  400. }).then((res) => {
  401. loading1.clear();
  402. if (res.code == 200) {
  403. this.loading = false;
  404. this.list = this.list.concat(res.data);
  405. if (this.list.length >= res.total) {
  406. this.finished = true;
  407. } else {
  408. this.finished = false;
  409. }
  410. this.pageNum = this.pageNum + 1;
  411. } else {
  412. this.$toast.fail(res.msg);
  413. }
  414. });
  415. },
  416. regionClick() {
  417. // if(this.powerGrade>4){
  418. this.RegionShow = true;
  419. // }
  420. },
  421. SalesRegionClick(val) {
  422. // if(this.powerGrade>3){
  423. this.SalesRegionShow = true;
  424. // }
  425. },
  426. SalesDepartmentClick() {
  427. // if(this.powerGrade>2){
  428. this.SalesDepartmentShow = true;
  429. // }
  430. },
  431. StaffClick() {
  432. this.StaffShow = true;
  433. },
  434. StartTimeClick() {
  435. this.StartTimeShow = true;
  436. },
  437. onregionConfirm(val) {
  438. this.RegionShow = false;
  439. this.companyName = val.deptName;
  440. this.companyCode = val.deptId;
  441. this.regionName = '全部大区';
  442. this.regionCode = '';
  443. this.deptName = '全部销售部';
  444. this.deptCode = '';
  445. this.userName = '全部业务员';
  446. this.userCode = '';
  447. this.getDeptInfo('dept', 1);
  448. },
  449. onSalesRegionConfirm(val) {
  450. this.SalesRegionShow = false;
  451. this.regionName = val.deptName;
  452. this.regionCode = val.deptId;
  453. if (val.deptId != '') {
  454. this.getDeptInfo('dept', 2);
  455. }
  456. this.deptName = '全部销售部';
  457. this.deptCode = '';
  458. this.userName = '全部业务员';
  459. this.userCode = '';
  460. this.userList = [];
  461. },
  462. onSalesDepartmentConfirm(val) {
  463. this.SalesDepartmentShow = false;
  464. this.deptName = val.deptName;
  465. this.deptCode = val.deptId;
  466. if (val.deptId != '') {
  467. this.getDeptInfo('user');
  468. }
  469. this.userName = '全部业务员';
  470. this.userCode = '';
  471. },
  472. onStaffConfirm(val) {
  473. this.StaffShow = false;
  474. this.userName = val.nickName;
  475. this.userCode = val.userId;
  476. },
  477. getDeptInfo(type, grade) {
  478. this.deptForm.type = type;
  479. if (type == 'dept') {
  480. if (grade == '1') {
  481. this.deptForm.parentId = this.companyCode;
  482. } else if (grade == '2') {
  483. this.deptForm.parentId = this.regionCode;
  484. } else {
  485. this.deptForm.type = '';
  486. this.deptForm.parentId = '';
  487. }
  488. } else if (type == 'user') {
  489. this.deptForm.parentId = this.deptCode;
  490. }
  491. getvisitDeptInfo(this.deptForm).then((res) => {
  492. if (type == 'dept') {
  493. if (grade == '1') {
  494. if (res.data.region != null) {
  495. this.regionList = [{ deptName: '全部大区', deptId: '' }].concat(res.data.region);
  496. }
  497. } else if (grade == '2') {
  498. if (res.data.dept != null) {
  499. this.deptList = [{ deptName: '全部销售部', deptId: '' }].concat(res.data.dept);
  500. }
  501. } else {
  502. if (this.userDeptLevel == 0) {
  503. this.companyList = [{ deptName: '全部公司', deptId: '' }].concat(res.data.company);
  504. } else {
  505. this.companyList = res.data.company;
  506. }
  507. if (this.$route.query.userCode == undefined) {
  508. this.companyName = res.data.company[0].deptName;
  509. this.companyCode = res.data.company[0].deptId;
  510. }
  511. if (res.data.dept != null) {
  512. this.deptName = res.data.dept[0].deptName;
  513. this.deptCode = res.data.dept[0].deptId;
  514. this.deptList = res.data.dept;
  515. }
  516. if (res.data.region != null) {
  517. this.regionName = res.data.region[0].deptName;
  518. this.regionCode = res.data.region[0].deptId;
  519. this.regionList = res.data.region;
  520. }
  521. if (res.data.user != null) {
  522. this.userList = res.data.user;
  523. this.userCode = '';
  524. }
  525. }
  526. } else if (type == 'user') {
  527. if (res.data.user != null) {
  528. this.userList = [{ nickName: '全部业务员', userId: '' }].concat(res.data.user);
  529. }
  530. }
  531. });
  532. },
  533. },
  534. };
  535. </script>
  536. <style lang="scss">
  537. .searchDiv {
  538. .van-search {
  539. background: #fff;
  540. }
  541. .van-search__action {
  542. font-size: 14px;
  543. color: #1989fa;
  544. font-weight: bold;
  545. background: #f5f5f5;
  546. border-bottom-right-radius: 60px;
  547. border-top-right-radius: 60px;
  548. border: 1px solid #ccc;
  549. padding: 0 20px;
  550. }
  551. .van-search--show-action {
  552. padding-right: 12px;
  553. }
  554. .van-search__content {
  555. border: 1px solid #ccc;
  556. border-bottom-left-radius: 60px;
  557. border-top-left-radius: 60px;
  558. background: #f5f5f5;
  559. border-right: 0;
  560. }
  561. }
  562. .myList1 {
  563. .van-cell {
  564. padding: 10px 16px;
  565. &:after {
  566. border-bottom: none;
  567. }
  568. }
  569. }
  570. .historAllVisit {
  571. .TCFXListItem {
  572. display: inline-block;
  573. border: 1px solid #ccc;
  574. padding: 3px 5px;
  575. margin: 0 5px;
  576. border-radius: 6px;
  577. }
  578. }
  579. </style>
  580. <style lang="scss" scoped>
  581. .bgcolor {
  582. background-color: #f5f5f5;
  583. }
  584. .container {
  585. padding-bottom: 50px;
  586. }
  587. .monthNow {
  588. height: 34px;
  589. line-height: 34px;
  590. text-align: left;
  591. font-weight: bold;
  592. padding: 0 16px;
  593. box-sizing: border-box;
  594. background-color: #f1f1f1;
  595. border-radius: 20px;
  596. margin: 8px;
  597. border: 1px solid #ccc;
  598. position: relative;
  599. color: #333;
  600. font-size: 14px;
  601. .van-cell__left-icon,
  602. .van-cell__right-icon {
  603. line-height: 34px;
  604. }
  605. .CalendarIcon {
  606. float: right;
  607. font-size: 24px;
  608. color: #1989fa;
  609. margin-top: 6px;
  610. position: absolute;
  611. right: 12px;
  612. img {
  613. height: 0.8em;
  614. }
  615. }
  616. }
  617. .serchInput {
  618. padding: 0 4px;
  619. }
  620. .selectcell {
  621. width: 92%;
  622. }
  623. .card {
  624. box-sizing: border-box;
  625. .title {
  626. font-size: 16px;
  627. font-weight: bold;
  628. color: #333;
  629. line-height: 30px;
  630. width: 78%;
  631. }
  632. .info {
  633. font-size: 14px;
  634. color: #909090;
  635. line-height: 26px;
  636. }
  637. }
  638. /**/
  639. .searcTime {
  640. background-color: white;
  641. }
  642. .btnbox {
  643. padding: 0 16px;
  644. }
  645. .cellcontent .centerBtn {
  646. margin: 0 auto 10px;
  647. display: block;
  648. width: 92%;
  649. border-radius: 5px;
  650. }
  651. .statstext {
  652. background-color: #1c84c6;
  653. position: absolute;
  654. right: 0;
  655. top: 16px;
  656. padding: 2px 6px 2px 12px;
  657. border-bottom-left-radius: 60px;
  658. border-top-left-radius: 60px;
  659. color: #fff;
  660. }
  661. .stateAbnormal {
  662. position: absolute;
  663. right: 0;
  664. top: 0;
  665. color: #fff;
  666. background-color: red;
  667. border-radius: 5px;
  668. display: inline-block;
  669. padding: 0 5px;
  670. }
  671. .state {
  672. position: absolute;
  673. right: 0;
  674. top: 0;
  675. color: #fff;
  676. background-color: #1c84c6;
  677. border-radius: 5px;
  678. display: inline-block;
  679. padding: 0 5px;
  680. }
  681. .navBarTOP {
  682. position: fixed;
  683. width: 100%;
  684. z-index: 2;
  685. top: 0;
  686. }
  687. .cellcontent .textRight {
  688. float: right;
  689. color: #0057ba;
  690. }
  691. </style>