historAllVisit copy.vue 19 KB

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