index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <template>
  2. <div class="bgcolor">
  3. <div class="navBarTOP">
  4. <!-- 顶部条-->
  5. <van-nav-bar
  6. class="navBar"
  7. title="历史拜访"
  8. left-arrow
  9. @click-left="onClickLeft"
  10. />
  11. <div class="searcTime">
  12. <van-row class="serchInput">
  13. <van-col span="12">
  14. <div class="monthNow" @click="startTimeshow = true">
  15. <span class="month">{{ startTime }}</span>
  16. <van-icon class="CalendarIcon" :name="timeico"/>
  17. </div>
  18. </van-col>
  19. <van-col span="12">
  20. <div class="monthNow" @click="endTimeshow = true">
  21. <span class="month">{{ endTime }}</span>
  22. <van-icon class="CalendarIcon" :name="timeico"/>
  23. </div>
  24. </van-col>
  25. </van-row>
  26. </div>
  27. <div class="searchDiv">
  28. <van-search
  29. v-model="storeName"
  30. show-action
  31. placeholder="搜索名称/编号/地址"
  32. >
  33. <template #action>
  34. <div @click="onSearch">搜索</div>
  35. </template>
  36. </van-search>
  37. </div>
  38. <div class="lineGrey"></div>
  39. </div>
  40. <!-- 主体内容-->
  41. <div class="container" style="margin-top: 162px;">
  42. <!-- <van-list-->
  43. <!-- class="myList"-->
  44. <!-- v-model="loading"-->
  45. <!-- :finished="finished"-->
  46. <!-- finished-text="没有更多了"-->
  47. <!-- @load="onLoad"-->
  48. <!-- >-->
  49. <div class="cellcontent" v-for="(item,index) in list" :key="index">
  50. <van-cell @click="detilsFn(item)">
  51. <div class="card" style="position: relative;">
  52. <span v-if="item.visitSource==2" class="stateAbnormal">异常拜访</span>
  53. <!--<span v-if="item.visitModel==5" class="state">偏差过大</span>-->
  54. <span v-if="item.visitSource==1" class="state">正常拜访</span>
  55. <div class="title btn" :data-clipboard-text="item.storeCode"><span>{{ item.storeName }}</span>
  56. (<span style="color:#0057ba">{{
  57. item.storeCode
  58. }}</span>)
  59. </div>
  60. <div class="info">拜访人:{{ item.nickName }}</div>
  61. <div class="info">拜访时间:{{ item.visitsTime }}</div>
  62. <div class="info" v-if="item.dwellTime">拜访时长:{{ item.dwellTime }}</div>
  63. <div class="info">地址:{{ item.addressLine }}</div>
  64. <div class="info">经销商:{{ item.chainName }}</div>
  65. </div>
  66. </van-cell>
  67. <div class="lineGrey"></div>
  68. </div>
  69. <!-- </van-list>-->
  70. <p style="text-align: center;color: #ccc;font-size: 12px;" v-if="list.length!=0">--已经到底了--</p>
  71. <van-empty description="--已经到底了--" v-if="list.length==0"/>
  72. </div>
  73. <van-popup v-model="startTimeshow" position="bottom" :style="{ height: '30%' }">
  74. <van-datetime-picker
  75. v-model="startcurrentDate"
  76. type="date"
  77. title="开始日期"
  78. :min-date="minDate"
  79. :max-date="startmaxDate"
  80. @confirm="dateeconfirm"
  81. @cancel="startTimeshow=false"
  82. />
  83. </van-popup>
  84. <van-popup v-model="endTimeshow" position="bottom" :style="{ height: '50%' }">
  85. <van-datetime-picker
  86. v-model="currentDate"
  87. type="date"
  88. title="开始日期"
  89. :min-date="endminDate"
  90. :max-date="maxDate"
  91. @confirm="endTimeconfirm"
  92. @cancel="endTimeshow=false"
  93. />
  94. </van-popup>
  95. <van-popup v-model="RegionShow" capture position="bottom">
  96. <van-picker
  97. show-toolbar
  98. :columns="companyList"
  99. value-key="deptName"
  100. @confirm="onregionConfirm"
  101. @cancel="RegionShow = false"
  102. />
  103. </van-popup>
  104. <van-popup v-model="SalesRegionShow" capture position="bottom">
  105. <van-picker
  106. show-toolbar
  107. :columns="regionList"
  108. value-key="deptName"
  109. @confirm="onSalesRegionConfirm"
  110. @cancel="SalesRegionShow = false"
  111. />
  112. </van-popup>
  113. <van-popup v-model="SalesDepartmentShow" capture position="bottom">
  114. <van-picker
  115. show-toolbar
  116. :columns="deptList"
  117. value-key="deptName"
  118. @confirm="onSalesDepartmentConfirm"
  119. @cancel="SalesDepartmentShow = false"
  120. />
  121. </van-popup>
  122. <van-popup v-model="StaffShow" capture position="bottom">
  123. <van-picker
  124. show-toolbar
  125. :columns="userList"
  126. @confirm="onStaffConfirm"
  127. value-key="nickName"
  128. @cancel="StaffShow = false"
  129. />
  130. </van-popup>
  131. </div>
  132. </template>
  133. <script>
  134. import {getVisitsList} from "@/api/index";
  135. import timeico from "@/assets/Icon/datatims.png";
  136. export default {
  137. name: "index.vue",
  138. data() {
  139. return {
  140. timeico: timeico,
  141. defaultDate: new Date(),
  142. searchValue: '',
  143. calendarShow: '',
  144. monthNames: ['-01', '-02', '-03', '-04', '-05', '-06', '-07', '-08', '-09', '-10', '-11', '-12',],
  145. calendarIsshow: false,
  146. tabVal: 'insidePlan',
  147. list: [],
  148. loading: false,
  149. finished: true,
  150. listActive: null,
  151. query: "",
  152. show: false,
  153. minDate: new Date(2020, 0, 1),
  154. maxDate: new Date(),
  155. currentDate: new Date(),
  156. startcurrentDate: new Date(),
  157. endminDate: new Date(),
  158. startmaxDate: new Date(),
  159. endTime: "",
  160. startTime: "",
  161. endTimeshow: false,
  162. startTimeshow: false,
  163. storeName: "",
  164. companyName:"全部公司",
  165. deptName:"全部销售部",
  166. regionName:"全部大区",
  167. userName:"全部业务员",
  168. companyCode:"",
  169. deptCode:"",
  170. regionCode:"",
  171. userCode:"",
  172. companyList:[],
  173. deptList:[],
  174. regionList:[],
  175. userList:[],
  176. RegionShow: false,
  177. SalesRegionShow: false,
  178. SalesDepartmentShow: false,
  179. StaffShow: false,
  180. deptForm:{type:"",parentId:""},
  181. pageNum:1 , // 当前页码 int类型
  182. pageSize:10, // 当前每页条数 int类型
  183. formData:{
  184. companyId:"", // 公司id,必传 Long类型
  185. regionId:"", // 大区id,必传 Long类型
  186. deptId:"", // 部门id,如果为周报或日报为必传 Long类型
  187. userId:"", // 业务员id,如果为日报为必传 Long类型
  188. startTime:"", // 开始时间,必传 格式:yyyy-MM-dd String类型
  189. endTime:"", // 结束时间,必传 格式:yyyy-MM-dd String类型
  190. pageNum:1 , // 当前页码 int类型
  191. pageSize:10, // 当前每页条数 int类型
  192. },
  193. }
  194. },
  195. watch: {
  196. $route(to, from) {
  197. if (from.path == "/My/index" && to.path == "/historicalVisit/index") {
  198. this.info();
  199. this.onSearch();
  200. }
  201. }
  202. },
  203. created() {
  204. this.info();
  205. this.powerGrade = localStorage.getItem("powerGrade")
  206. this.onSearch();
  207. },
  208. methods: {
  209. info(){
  210. this.query = this.$route.query;
  211. this.startTime = this.getDay(-7)
  212. this.startcurrentDate = new Date(this.getDay(-7))
  213. this.endTime = this.parseTime(new Date(), '{y}-{m}-{d}')
  214. this.endminDate = new Date(this.getDay(-7))
  215. },
  216. detilsFn(val) {
  217. this.$router.push({
  218. path: "/historicalDetails",
  219. query: {visitId: val.id,storeId:val.storeId}
  220. })
  221. },
  222. timeBefore7(date) {
  223. if (!date) {
  224. date = new Date();
  225. }
  226. var y = date.getFullYear();
  227. var m = date.getMonth() + 1;
  228. var d = date.getDate() - 6;
  229. if (d < 0) {
  230. m = date.getMonth();
  231. var d1 = new Date(y, m, 0);
  232. var d2 = d1.getDate();
  233. return y + '/' + (m < 10 ? ('0' + m) : m) + '/' + (d2 + d);
  234. } else {
  235. return y + '/' + (m < 10 ? ('0' + m) : m) + '/' + (d < 10 ? ('0' + d) : d);
  236. }
  237. },
  238. getDay(day) {
  239. var today = new Date();
  240. var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  241. today.setTime(targetday_milliseconds); //注意,这行是关键代码
  242. var tYear = today.getFullYear();
  243. var tMonth = today.getMonth();
  244. var tDate = today.getDate();
  245. tMonth = this.doHandleMonth(tMonth + 1);
  246. tDate = this.doHandleMonth(tDate);
  247. return tYear + "-" + tMonth + "-" + tDate;
  248. },
  249. doHandleMonth(month) {
  250. var m = month;
  251. if (month.toString().length == 1) {
  252. m = "0" + month;
  253. }
  254. return m;
  255. },
  256. dateeconfirm() {
  257. this.startTimeshow = false
  258. this.startTime = this.parseTime(this.startcurrentDate, '{yy}-{mm}-{dd}')
  259. this.endminDate = new Date(this.startcurrentDate)
  260. this.getVisitsListFn()
  261. },
  262. endTimeconfirm() {
  263. this.endTimeshow = false
  264. this.endTime = this.parseTime(this.currentDate, '{yy}-{mm}-{dd}')
  265. this.startmaxDate = new Date(this.currentDate)
  266. this.getVisitsListFn()
  267. },
  268. onClickLeft() {
  269. this.$router.go(-1)
  270. },
  271. onSearch() {
  272. this.pageNum=1;
  273. this.list=[];
  274. this.getVisitsListFn();
  275. },
  276. getVisitsListFn() {
  277. let loading1 = this.$toast.loading({
  278. duration: 0,
  279. message: '数据获取中...',
  280. forbidClick: true,
  281. });
  282. getVisitsList({
  283. startTime: this.startTime + " 00:00:00",
  284. stopTime: this.endTime + " 24:00:00",
  285. storeRequest: this.storeName.trim(),
  286. pageNum:this.pageNum,
  287. pageSize:this.pageSize,
  288. companyCode: this.companyCode, regionCode: this.regionCode, userCode: this.userCode, deptCode: this.deptCode
  289. }).then(res => {
  290. loading1.clear()
  291. if (res.code == 200) {
  292. this.list = res.rows
  293. } else {
  294. this.$toast.fail(res.msg)
  295. }
  296. })
  297. },
  298. regionClick() {
  299. // if(this.powerGrade>4){
  300. this.RegionShow = true;
  301. // }
  302. },
  303. SalesRegionClick(val) {
  304. // if(this.powerGrade>3){
  305. this.SalesRegionShow = true;
  306. // }
  307. },
  308. SalesDepartmentClick() {
  309. // if(this.powerGrade>2){
  310. this.SalesDepartmentShow = true;
  311. // }
  312. },
  313. StaffClick() {
  314. this.StaffShow = true;
  315. },
  316. StartTimeClick() {
  317. this.StartTimeShow = true;
  318. },
  319. onregionConfirm(val) {
  320. this.RegionShow = false;
  321. this.companyName=val.deptName;
  322. this.companyCode=val.deptId;
  323. this.regionName="全部大区";
  324. this.regionCode="";
  325. this.deptName="全部销售部";
  326. this.deptCode="";
  327. this.userName="全部业务员";
  328. this.userCode="";
  329. this.getDeptInfo("dept",1)
  330. },
  331. onSalesRegionConfirm(val) {
  332. this.SalesRegionShow = false;
  333. this.regionName=val.deptName;
  334. this.regionCode=val.deptId;
  335. if(val.deptId!=""){
  336. this.getDeptInfo("dept",2)
  337. }
  338. this.deptName="全部销售部";
  339. this.deptCode="";
  340. this.userName="全部业务员";
  341. this.userCode="";
  342. this.userList=[]
  343. },
  344. onSalesDepartmentConfirm(val) {
  345. this.SalesDepartmentShow = false;
  346. this.deptName=val.deptName;
  347. this.deptCode=val.deptId;
  348. if(val.deptId!=""){
  349. this.getDeptInfo("user")
  350. }
  351. this.userName="全部业务员";
  352. this.userCode="";
  353. },
  354. onStaffConfirm(val) {
  355. this.StaffShow = false;
  356. this.userName=val.nickName;
  357. this.userCode=val.userId;
  358. },
  359. getDeptInfo(type,grade){
  360. this.deptForm.type=type
  361. if(type=="dept"){
  362. if(grade=="1"){
  363. this.deptForm.parentId=this.companyCode
  364. }else if(grade=="2"){
  365. this.deptForm.parentId=this.regionCode
  366. }else{
  367. this.deptForm.type=""
  368. this.deptForm.parentId=""
  369. }
  370. }else if(type=="user"){
  371. this.deptForm.parentId=this.deptCode
  372. }
  373. getvisitDeptInfo(this.deptForm).then(res=>{
  374. if(type=="dept"){
  375. if(grade=="1"){
  376. if(res.data.region!=null){
  377. this.regionList=[{deptName:"全部大区",deptId:""}].concat(res.data.region)
  378. }
  379. }else if(grade=="2"){
  380. if(res.data.dept!=null){
  381. this.deptList=[{deptName:"全部销售部",deptId:""}].concat(res.data.dept)
  382. }
  383. }else{
  384. this.companyList=res.data.company
  385. if(this.$route.query.userCode==undefined){
  386. this.companyName=res.data.company[0].deptName
  387. this.companyCode=res.data.company[0].deptId
  388. }
  389. if(res.data.dept!=null){
  390. this.deptName=res.data.dept[0].deptName
  391. this.deptCode=res.data.dept[0].deptId
  392. this.deptList=res.data.dept
  393. }
  394. if(res.data.region!=null){
  395. this.regionName=res.data.region[0].deptName
  396. this.regionCode=res.data.region[0].deptId
  397. this.regionList=res.data.region
  398. }
  399. if(res.data.user!=null){
  400. this.userList=res.data.user
  401. this.userCode=""
  402. }
  403. }
  404. }else if(type=="user"){
  405. if(res.data.user!=null){
  406. this.userList=[{nickName:"全部业务员",userId:""}].concat(res.data.user)
  407. }
  408. }
  409. })
  410. },
  411. }
  412. }
  413. </script>
  414. <style lang="scss">
  415. .searchDiv {
  416. .van-search {
  417. background: #fff;
  418. }
  419. .van-search__action {
  420. font-size: 14px;
  421. color: #0057ba;
  422. font-weight: bold;
  423. background: #f5f5f5;
  424. border-bottom-right-radius: 60px;
  425. border-top-right-radius: 60px;
  426. border: 1px solid #ccc;
  427. padding: 0 20px;
  428. }
  429. .van-search--show-action {
  430. padding-right: 12px
  431. }
  432. .van-search__content {
  433. border: 1px solid #ccc;
  434. border-bottom-left-radius: 60px;
  435. border-top-left-radius: 60px;
  436. background: #f5f5f5;
  437. border-right: 0;
  438. }
  439. }
  440. .myList {
  441. .van-cell {
  442. padding: 10px 16px;
  443. &:after {
  444. border-bottom: none;
  445. }
  446. }
  447. }
  448. </style>
  449. <style lang="scss" scoped>
  450. .bgcolor {
  451. background-color: #f5f5f5;
  452. }
  453. .container {
  454. padding-bottom: 50px;
  455. }
  456. .monthNow {
  457. height: 34px;
  458. line-height: 34px;
  459. text-align: left;
  460. font-weight: bold;
  461. padding: 0 16px;
  462. box-sizing: border-box;
  463. background-color: #f1f1f1;
  464. border-radius: 20px;
  465. margin:8px;
  466. border: 1px solid #ccc;
  467. position: relative;
  468. color: #333;
  469. font-size: 14px;
  470. .van-cell__left-icon, .van-cell__right-icon{
  471. line-height: 34px;
  472. }
  473. .CalendarIcon {
  474. float: right;
  475. font-size: 24px;
  476. color: #1989fa;
  477. margin-top: 6px;
  478. position: absolute;
  479. right: 12px;
  480. img {
  481. height: 0.8em;
  482. }
  483. }
  484. }
  485. .serchInput{
  486. padding: 0 4px ;
  487. }
  488. .selectcell{width: 92%}
  489. .card {
  490. box-sizing: border-box;
  491. .title {
  492. font-size: 16px;
  493. font-weight: bold;
  494. color: #333;
  495. line-height: 30px;
  496. width: 78%;
  497. }
  498. .info {
  499. font-size: 14px;
  500. color: #909090;
  501. line-height: 26px;
  502. }
  503. }
  504. /**/
  505. .searcTime {
  506. background-color: white;
  507. }
  508. .btnbox {
  509. padding: 0 16px
  510. }
  511. .cellcontent .centerBtn {
  512. margin: 0 auto 10px;
  513. display: block;
  514. width: 92%;
  515. border-radius: 5px;
  516. }
  517. .statstext {
  518. background-color: #1c84c6;
  519. position: absolute;
  520. right: 0;
  521. top: 16px;
  522. padding: 2px 6px 2px 12px;
  523. border-bottom-left-radius: 60px;
  524. border-top-left-radius: 60px;
  525. color: #fff;
  526. }
  527. .stateAbnormal {
  528. position: absolute;
  529. right: 0;
  530. top: 0;
  531. color: #fff;
  532. background-color: red;
  533. border-radius: 5px;
  534. display: inline-block;
  535. padding: 0 5px;
  536. }
  537. .state {
  538. position: absolute;
  539. right: 0;
  540. top: 0;
  541. color: #fff;
  542. background-color: #1c84c6;
  543. border-radius: 5px;
  544. display: inline-block;
  545. padding: 0 5px;
  546. }
  547. .navBarTOP {
  548. position: fixed;
  549. width: 100%;
  550. z-index: 2;
  551. top: 0;
  552. }
  553. </style>