storeVisit.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  1. <template>
  2. <div>
  3. <div class="navBarTOP">
  4. <van-nav-bar class="navBar" title="拜访" left-arrow @click-left="onClickLeft"></van-nav-bar>
  5. </div>
  6. <div class="container">
  7. <div class="lineGrey"></div>
  8. <div class="lineGrey"></div>
  9. <div class="lineGrey"></div>
  10. <div class="lineGrey"></div>
  11. <div class="lineGrey"></div>
  12. <div class="card mt10">
  13. <div class="title f-blue">
  14. {{ storeName }}(<span style="color: #0057ba">{{ urlParameter.storeCode }}</span
  15. >)
  16. </div>
  17. <div class="info1" v-if="insert">类型:{{ storeCategory }}</div>
  18. <div class="info1" v-if="addressLine != null">地址:{{ addressLine }}</div>
  19. <div class="info1" v-if="notes != null && insert">上次拜访备注:{{ notes }}</div>
  20. <div class="info1" v-if="timeShow">拜访时长:{{ showTime }}</div>
  21. <div class="info1">
  22. <span v-if="insert">上次拜访时间:{{ parseTime(urlParameter.genDate) }}</span
  23. ><span @click="shows = true" class="f-blue" v-if="visitsRemarks" style="font-weight: bold"
  24. ><van-icon name="browsing-history-o" />查看最近三次</span
  25. >
  26. </div>
  27. <van-button
  28. type="info"
  29. style="background: rgb(0, 87, 186); color: #fff; margin: 10px 0; border-radius: 5px"
  30. size="small"
  31. plain
  32. class="centerBtn"
  33. @click="visitFn(urlParameter.storeCode)"
  34. >经营情况</van-button
  35. >
  36. <van-button
  37. type="info"
  38. style="background: rgb(0, 87, 186); color: #fff; margin: 10px; border-radius: 5px"
  39. size="small"
  40. plain
  41. v-if="showOrderButton"
  42. class="centerBtn"
  43. @click="overbookingFn(urlParameter)"
  44. >去下单</van-button
  45. >
  46. <van-button
  47. type="info"
  48. style="background: rgb(0, 87, 186); color: #fff; margin: 10px; border-radius: 5px"
  49. size="small"
  50. plain
  51. class="centerBtn"
  52. @click="wuliaoLog(urlParameter)"
  53. >物料历史</van-button
  54. >
  55. <van-button
  56. v-if="insert"
  57. type="info"
  58. style="
  59. float: right;
  60. background: #ed5565;
  61. border-color: #ed5565;
  62. color: #fff;
  63. margin: 10px 0;
  64. border-radius: 5px;
  65. "
  66. size="small"
  67. plain
  68. class="centerBtn"
  69. @click="onstopVisit"
  70. >取消拜访</van-button
  71. >
  72. </div>
  73. <div
  74. v-if="addShow1"
  75. style="color: #999; font-size: 12px; padding: 10px; background-color: #f5f5f5">
  76. <van-icon
  77. name="info-o" />&nbsp;可控店及金牌店的店招任务中,若拍摄两次仍不通过,允许提交,不影响正常拜访。
  78. </div>
  79. <div class="card">
  80. <div
  81. class="info"
  82. v-for="(item, index) in list"
  83. :key="index"
  84. @click="addStoreVisit(item, index)">
  85. <span class="must" v-show="item.isMust == '0' || item.isMust == '2'">*</span>
  86. <span class="must" v-show="item.isMust != '0' && item.isMust != '2'">&nbsp;</span>
  87. <p style="width: 72%; margin: 0; line-height: 24px; display: inline-block">
  88. {{ item.taskName }}
  89. </p>
  90. <span v-show="item.processKey != null" class="processIco">
  91. <span v-show="item.processKey == 1" style="color: #0057ba; font-size: 12px"
  92. >审批中</span
  93. >
  94. <span v-show="item.processKey == 2" style="color: #07c160; font-size: 12px"
  95. >审批完成</span
  96. >
  97. <span v-show="item.processKey == 3" style="color: red; font-size: 12px">拒绝</span>
  98. <van-icon :name="sp" size="16" style="float: right; margin-left: 6px" />
  99. </span>
  100. <span v-show="!item.success" class="arrow" style="background-color: #fff; color: #444"
  101. ><van-icon name="arrow"
  102. /></span>
  103. <span v-show="item.success" class="arrow" style="background-color: #0057ba"
  104. ><van-icon name="success"
  105. /></span>
  106. </div>
  107. </div>
  108. </div>
  109. <div class="tc" style="padding: 0 16px" v-if="insert">
  110. <!-- &&!LCshow-->
  111. <van-button class="submitBtn" block type="info" color="#0057ba" @click="endVisitsFn"
  112. >提交拜访</van-button
  113. >
  114. </div>
  115. <div class="tc" style="padding: 0 16px" v-if="restartProcessButtion">
  116. <van-button class="submitBtn" block type="info" color="#0057ba" @click="endVisitsFn('t')"
  117. >重新提交</van-button
  118. >
  119. </div>
  120. <!-- <div class="tc" style="padding: 0 16px" v-if="LCshow">-->
  121. <!-- <van-button class="submitBtn" block type="info" color="#0057ba" @click="endVisitsFn('t')">退回提交</van-button>-->
  122. <!-- </div>-->
  123. <br />
  124. <van-dialog v-model="shows">
  125. <div class="tipTitleBox" style="padding: 10px">
  126. <p class="p">近三次拜访备注</p>
  127. <div
  128. v-for="item in visitsRemarks"
  129. style="border-bottom: 1px solid #e8e8e8; font-size: 14px; padding: 10px 0">
  130. <p>拜访时间:{{ item.stopTime }}</p>
  131. <p>备注:{{ item.visitRemark }}</p>
  132. </div>
  133. </div>
  134. </van-dialog>
  135. <div id="allmap"></div>
  136. <!-- 物料历史列表 -->
  137. <el-dialog
  138. :visible.sync="wuliaoTable"
  139. width="90%"
  140. :append-to-body="true"
  141. :close-on-click-modal="false"
  142. @close="wuliaoTableClose"
  143. custom-class="wuliaoTable">
  144. <el-table :data="wuliaoList" border style="width: 100%">
  145. <el-table-column label="物料名称" prop="materialDataName" align="center" />
  146. <el-table-column label="发放时间" prop="issuerTime" align="center" />
  147. <el-table-column label="数量" prop="inventoryNum" width="60" align="center" />
  148. <el-table-column label="签收状态" prop="receiptState" width="60" align="center" />
  149. </el-table>
  150. </el-dialog>
  151. </div>
  152. </template>
  153. <script>
  154. import {
  155. getStoreGroupTask,
  156. endVisits,
  157. editDwellTime,
  158. suishenbangStoreSale,
  159. stopVisit,
  160. restartProcess,
  161. buryingPoint,
  162. getMaterialHistory,
  163. getVisitTasks,
  164. } from '@/api/index';
  165. import axios from 'axios';
  166. import sp from './../../assets/sp.png';
  167. import { saveVisitsParams, getOrderUrlByStoreId } from '@/api/inventory';
  168. export default {
  169. name: 'storeVisitpage',
  170. data() {
  171. return {
  172. notes: '',
  173. shows: false,
  174. visitModel: '1',
  175. sp: sp,
  176. imgs: [],
  177. addShow1: false,
  178. html: '',
  179. LCshow: false,
  180. normalshow: true,
  181. timeShow: false,
  182. iscuxiao: false,
  183. text: '',
  184. radio: '',
  185. isEdit: false,
  186. storeId: '',
  187. rdId: '',
  188. lat: '',
  189. lon: '',
  190. timer: null,
  191. flag: true,
  192. list: [],
  193. storeGroupId: '',
  194. visitId: '',
  195. addressLine: '',
  196. storeCategory: '',
  197. storeName: '',
  198. contactName: '',
  199. insert: true,
  200. showTime: '00:00:00',
  201. startTime: null,
  202. visitsRemarks: [],
  203. location: {
  204. lat: '34.6174',
  205. lon: '112.44039',
  206. },
  207. address: '',
  208. city: '',
  209. locationAccuracy: '',
  210. uType: '-1',
  211. showOrderButton: null,
  212. restartProcessButtion: false,
  213. wuliaoTable: false,
  214. wuliaoList: [],
  215. };
  216. },
  217. created() {
  218. this.urlParameter = this.$route.query;
  219. this.storeId = this.$route.query.storeId + '';
  220. this.visitId = this.$route.query.visitId;
  221. this.rdId = this.$route.query.rdId + '';
  222. this.addressLine = this.$route.query.addressLine + '';
  223. this.storeCategory = this.$route.query.storeCategory + '';
  224. this.storeName = this.$route.query.storeName + '';
  225. this.contactName = this.$route.query.contactName + '';
  226. this.visitModel = this.$route.query.visitModel + '';
  227. this.lat = this.$route.query.lat + '';
  228. this.lon = this.$route.query.lon + '';
  229. sessionStorage.setItem('visitModel', '1');
  230. this.uType = localStorage.getItem('uType');
  231. },
  232. beforeRouteLeave(to, from, next) {
  233. if (to.path == '/deviceWithin/index' && from.path == '/storeVisitpage') {
  234. if (this.visitId != null && this.visitId != '') {
  235. this.editDwellTimes();
  236. }
  237. }
  238. next();
  239. },
  240. activated() {
  241. this.urlParameter = this.$route.query;
  242. this.storeId = this.$route.query.storeId + '';
  243. this.visitId = this.$route.query.visitId;
  244. this.rdId = this.$route.query.rdId + '';
  245. this.addressLine = this.$route.query.addressLine + '';
  246. this.storeCategory = this.$route.query.storeCategory + '';
  247. this.storeName = this.$route.query.storeName + '';
  248. this.contactName = this.$route.query.contactName + '';
  249. this.visitModel = this.$route.query.visitModel + '';
  250. this.lat = this.$route.query.lat + '';
  251. this.lon = this.$route.query.lon + '';
  252. // this.list = [];
  253. this.uType = localStorage.getItem('uType');
  254. // 是否请求任务列表接口
  255. let getRequestFlage = localStorage.getItem('getRequestFlage');
  256. if (getRequestFlage != 'true') return;
  257. this.list = [];
  258. if (this.$route.query.type != 'edit') {
  259. this.timeShow = true;
  260. if (localStorage.getItem('visitId') != null) {
  261. this.visitId = localStorage.getItem('visitId');
  262. setTimeout(() => {
  263. this.addVisits();
  264. });
  265. } else {
  266. setTimeout(() => {
  267. this.addVisits();
  268. });
  269. }
  270. } else {
  271. this.timeShow = false;
  272. this.addVisits();
  273. }
  274. },
  275. methods: {
  276. animation() {
  277. var times = new Date().getTime() - new Date(this.startTime).getTime();
  278. var house = Math.floor(times / 3600000); //毫秒转化为分钟
  279. var minutes = Math.floor(times / 60000 - house * 60); //毫秒转化为分钟
  280. var minutes1 = Math.floor(times / 60000); //毫秒转化为分钟
  281. var seconds = Math.floor((times - minutes1 * 60000) / 1000); //已知分钟将time减去分钟 除去1000得出 秒
  282. var ms = Math.floor((times - minutes1 * 60000 - seconds * 1000) / 10); //
  283. this.showTime =
  284. (house < 10 ? '0' + house : house) +
  285. ':' +
  286. (minutes < 10 ? '0' + minutes : minutes) +
  287. ':' +
  288. (seconds < 10 ? '0' + seconds : seconds);
  289. // +":"
  290. // +(ms<10 ? "0"+ms : ms);
  291. },
  292. overbookingFn(val) {
  293. buryingPoint({
  294. systemModel: '拜访页',
  295. buryingPointType: 1,
  296. buryingPointValue: val.storeName + '(' + val.storeCode + ')',
  297. buryingPointName: '去下单',
  298. buryingPointPosition: '拜访页',
  299. });
  300. this.toastLoading(0, '加载中...', true);
  301. getOrderUrlByStoreId({
  302. storeId: this.$route.query.storeId,
  303. from: this.$route.query.from,
  304. }).then((res) => {
  305. this.toastLoading().clear();
  306. if (res.code == 200 && res.data) {
  307. window.location.href = res.data;
  308. } else {
  309. this.Toast({
  310. message: res.msg,
  311. duration: 5000,
  312. });
  313. }
  314. });
  315. },
  316. // 结束拜访
  317. onstopVisit() {
  318. this.$dialog
  319. .confirm({
  320. confirmButtonText: '确定',
  321. cancelButtonText: '取消',
  322. title: '系统提示',
  323. message: '取消拜访会清空填写的拜访内容和照片,是否确认?',
  324. })
  325. .then(() => {
  326. stopVisit({ visitsId: this.visitId }).then((res) => {
  327. if (res.code == 200) {
  328. this.$dialog
  329. .alert({
  330. title: '系统提示',
  331. message: '拜访中任务结束成功!',
  332. })
  333. .then(() => {
  334. window.location.replace(window.location.origin + '/mobile/deviceWithin/index');
  335. });
  336. } else {
  337. this.$toast(res.msg);
  338. }
  339. });
  340. });
  341. },
  342. editDwellTimes() {
  343. let dwellTime = this.weekend(localStorage.getItem('startTime'), new Date()) + '';
  344. editDwellTime({ dwellTime: dwellTime, visitsId: this.visitId }).then((res) => {
  345. if (res.code != 200) {
  346. this.$toast.fail(res.msg);
  347. }
  348. localStorage.removeItem('visitId');
  349. });
  350. },
  351. visitFn(val) {
  352. var that = this;
  353. suishenbangStoreSale({ storeCode: val }).then((res) => {
  354. if (res.code == 200) {
  355. if (res.data.num != '0') {
  356. window.location.href =
  357. process.env.VUE_APP_SSB_LINK + '/order/storeDetail/index?shopCode=' + val;
  358. } else {
  359. that.$toast(res.data.msg);
  360. }
  361. }
  362. });
  363. },
  364. weekend(time1) {
  365. var arrtime1 = new Date(time1).getTime();
  366. var arrtime2 = new Date().getTime();
  367. return Math.round((arrtime2 - arrtime1) / 1000);
  368. },
  369. addVisits() {
  370. var that = this;
  371. var insert = '';
  372. var postType = localStorage.getItem('postType');
  373. if (postType == 'GZ') {
  374. this.addShow1 = false;
  375. } else {
  376. this.addShow1 = true;
  377. }
  378. // this.LCshow=this.$route.query.LCshow
  379. if (this.$route.query.type == 'edit') {
  380. insert = false;
  381. } else {
  382. insert = true;
  383. }
  384. this.insert = insert;
  385. var map = new TMap.Map('allmap', {
  386. zoom: 14,
  387. center: new TMap.LatLng(39.986785, 116.301012),
  388. });
  389. var geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类
  390. var markers = new TMap.MultiMarker({
  391. map: map,
  392. geometries: [],
  393. });
  394. markers.setGeometries([]);
  395. var input = [that.urlParameter.marklat, that.urlParameter.marklon];
  396. var location = new TMap.LatLng(Number(input[0]), Number(input[1]));
  397. map.setCenter(location);
  398. markers.updateGeometries([
  399. {
  400. id: 'main', // 点标注数据数组
  401. position: location,
  402. },
  403. ]);
  404. geocoder.getAddress({ location: location }).then(
  405. function (result) {
  406. var addresses = result.result.formatted_addresses;
  407. let address_component = result.result.address_component;
  408. let province = address_component.province;
  409. let city = address_component.city;
  410. let district = address_component.district;
  411. console.log('province=' + province);
  412. console.log('city=' + city);
  413. console.log('district=' + district);
  414. let recommend = '';
  415. if (addresses) {
  416. recommend = addresses.recommend;
  417. }
  418. if (that.$route.query.type == 'edit') {
  419. var params = {
  420. storeId: that.storeId,
  421. storeCode: that.urlParameter.storeCode,
  422. visitEntry: '0',
  423. lat: '',
  424. lon: '',
  425. visitModel: that.visitModel,
  426. routeDetailsId: '',
  427. storeGroupId: that.urlParameter.storeGroupId,
  428. visitSource: '1',
  429. insert: insert,
  430. locationCity: '',
  431. locationRemark: recommend,
  432. locationAccuracy: that.urlParameter.PointSum,
  433. province: address_component.province,
  434. city: address_component.city,
  435. district: address_component.district,
  436. };
  437. that.locationAccuracy = '';
  438. that.city = '';
  439. that.address = '';
  440. if (that.visitId != null) {
  441. params.id = that.visitId;
  442. }
  443. let loading2 = that.$toast.loading({
  444. duration: 0,
  445. message: '加载中...',
  446. forbidClick: true,
  447. });
  448. that.list = [];
  449. getVisitTasks(params).then((res) => {
  450. loading2.clear();
  451. if (res.code == 200) {
  452. that.notes = res.data.notes;
  453. that.restartProcessButtion = res.data.restartProcessButtion;
  454. if (res.data.visitId != undefined) {
  455. localStorage.setItem('visitId', res.data.visitId);
  456. that.visitId = res.data.visitId;
  457. }
  458. that.list = res.data.sfaTaskList;
  459. that.storeGroupId = res.data.storeGroupId;
  460. that.showOrderButton = res.data.showOrderButton;
  461. that.startTime = res.data.startTime;
  462. that.timeN = setInterval(that.animation, 16);
  463. that.visitsRemarks = res.data.visitsRemarks;
  464. }
  465. });
  466. } else {
  467. var params = {
  468. storeId: that.storeId,
  469. storeCode: that.urlParameter.storeCode,
  470. visitEntry: '0',
  471. lat: that.urlParameter.latNew,
  472. lon: that.urlParameter.lonNew,
  473. visitModel: that.visitModel,
  474. routeDetailsId: that.rdId,
  475. visitSource: '1',
  476. insert: insert,
  477. locationCity: '',
  478. locationRemark: recommend,
  479. locationAccuracy: that.urlParameter.PointSum,
  480. province: address_component.province,
  481. city: address_component.city,
  482. district: address_component.district,
  483. };
  484. that.locationAccuracy = that.urlParameter.PointSum;
  485. that.city = '';
  486. that.address = recommend;
  487. localStorage.setItem('address', '');
  488. if (that.visitId != null) {
  489. params.id = that.visitId;
  490. }
  491. let loading2 = that.$toast.loading({
  492. duration: 0,
  493. message: '加载中...',
  494. forbidClick: true,
  495. });
  496. that.list = [];
  497. getVisitTasks(params).then((res) => {
  498. loading2.clear();
  499. if (res.code == 200) {
  500. that.notes = res.data.notes;
  501. that.restartProcessButtion = res.data.restartProcessButtion;
  502. if (res.data.visitId != undefined) {
  503. localStorage.setItem('visitId', res.data.visitId);
  504. that.visitId = res.data.visitId;
  505. }
  506. that.list = res.data.sfaTaskList;
  507. that.storeGroupId = res.data.storeGroupId;
  508. that.showOrderButton = res.data.showOrderButton;
  509. that.startTime = res.data.startTime;
  510. that.timeN = setInterval(that.animation, 16);
  511. that.visitsRemarks = res.data.visitsRemarks;
  512. } else {
  513. this.$toast(res.msg);
  514. }
  515. });
  516. }
  517. },
  518. function (err) {
  519. if (that.$route.query.type == 'edit') {
  520. var params = {
  521. storeId: that.storeId,
  522. storeCode: that.urlParameter.storeCode,
  523. visitEntry: '0',
  524. lat: '',
  525. lon: '',
  526. visitModel: that.visitModel,
  527. routeDetailsId: '',
  528. storeGroupId: that.urlParameter.storeGroupId,
  529. visitSource: '1',
  530. insert: insert,
  531. locationCity: '',
  532. locationRemark: '',
  533. locationAccuracy: that.urlParameter.PointSum,
  534. };
  535. that.locationAccuracy = '';
  536. that.city = '';
  537. that.address = '';
  538. if (that.visitId != null) {
  539. params.id = that.visitId;
  540. }
  541. let loading2 = that.$toast.loading({
  542. duration: 0,
  543. message: '加载中...',
  544. forbidClick: true,
  545. });
  546. that.list = [];
  547. getVisitTasks(params).then((res) => {
  548. loading2.clear();
  549. if (res.code == 200) {
  550. that.notes = res.data.notes;
  551. that.restartProcessButtion = res.data.restartProcessButtion;
  552. if (res.data.visitId != undefined) {
  553. localStorage.setItem('visitId', res.data.visitId);
  554. that.visitId = res.data.visitId;
  555. }
  556. that.list = res.data.sfaTaskList;
  557. that.storeGroupId = res.data.storeGroupId;
  558. that.showOrderButton = res.data.showOrderButton;
  559. that.startTime = res.data.startTime;
  560. that.timeN = setInterval(that.animation, 16);
  561. that.visitsRemarks = res.data.visitsRemarks;
  562. } else {
  563. that.$toast(res.msg);
  564. }
  565. });
  566. } else {
  567. var params = {
  568. storeId: that.storeId,
  569. storeCode: that.urlParameter.storeCode,
  570. visitEntry: '0',
  571. lat: that.urlParameter.latNew,
  572. lon: that.urlParameter.lonNew,
  573. visitModel: that.visitModel,
  574. routeDetailsId: that.rdId,
  575. visitSource: '1',
  576. insert: insert,
  577. locationCity: '',
  578. locationRemark: '',
  579. locationAccuracy: that.urlParameter.PointSum,
  580. };
  581. that.locationAccuracy = that.urlParameter.PointSum;
  582. that.city = '';
  583. that.address = '';
  584. localStorage.setItem('address', '');
  585. if (that.visitId != null) {
  586. params.id = that.visitId;
  587. }
  588. let loading2 = that.$toast.loading({
  589. duration: 0,
  590. message: '加载中...',
  591. forbidClick: true,
  592. });
  593. that.list = [];
  594. getVisitTasks(params).then((res) => {
  595. loading2.clear();
  596. if (res.code == 200) {
  597. that.notes = res.data.notes;
  598. that.restartProcessButtion = res.data.restartProcessButtion;
  599. if (res.data.visitId != undefined) {
  600. localStorage.setItem('visitId', res.data.visitId);
  601. that.visitId = res.data.visitId;
  602. }
  603. that.list = res.data.sfaTaskList;
  604. that.storeGroupId = res.data.storeGroupId;
  605. that.showOrderButton = res.data.showOrderButton;
  606. that.startTime = res.data.startTime;
  607. that.timeN = setInterval(that.animation, 16);
  608. that.visitsRemarks = res.data.visitsRemarks;
  609. } else {
  610. that.$toast(res.msg);
  611. }
  612. });
  613. }
  614. }
  615. );
  616. },
  617. getLocation() {
  618. let loading1 = this.$toast.loading({
  619. duration: 0,
  620. message: '加载中...',
  621. forbidClick: true,
  622. });
  623. let url = window.location.href;
  624. let wx = this.wx;
  625. this.list = [];
  626. let that = this;
  627. let qiyeData;
  628. const instance = axios.create();
  629. instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
  630. instance
  631. .get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket', {
  632. params: {
  633. url: url,
  634. },
  635. })
  636. .then((response) => {
  637. if (response.status == 200) {
  638. loading1.clear();
  639. qiyeData = response.data.data;
  640. wx.config({
  641. beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
  642. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  643. appId: qiyeData.appId, // 必填,企业微信的corpID
  644. timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
  645. nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
  646. signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
  647. jsApiList: ['ready', 'getLocation'], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
  648. });
  649. wx.ready(function () {
  650. wx.getLocation({
  651. type: 'gcj02',
  652. success: function (res) {
  653. var location = that.CJ02BD(res.latitude, res.longitude);
  654. that.location = location;
  655. if (that.urlParameter.lat == '' || that.urlParameter.lat == null) {
  656. that.lat = that.location.lat;
  657. that.lon = that.location.lon;
  658. } else {
  659. that.lat = that.urlParameter.lat;
  660. that.lon = that.urlParameter.lon;
  661. }
  662. let PointSum = that
  663. .twoPointSum(that.lat, that.lon, location.lat, location.lon)
  664. .toFixed(2);
  665. that.locationAccuracy = PointSum;
  666. if (PointSum > 500) {
  667. that.visitModel = '5';
  668. localStorage.setItem('visitModel', '5');
  669. that.$dialog
  670. .confirm({
  671. confirmButtonText: '确定',
  672. cancelButtonText: '重新定位',
  673. title: '系统提示',
  674. message: '距离本店距离差距太大',
  675. })
  676. .then(() => {
  677. that.addVisits();
  678. })
  679. .catch(() => {
  680. that.getLocation();
  681. });
  682. } else {
  683. that.addVisits();
  684. }
  685. },
  686. fail: function () {
  687. that.$dialog
  688. .alert({
  689. message: 'GPS未开启',
  690. })
  691. .then(() => {
  692. that.getLocation();
  693. });
  694. },
  695. });
  696. });
  697. }
  698. });
  699. },
  700. addStoreVisit(val, index) {
  701. if (this.flag) {
  702. this.flag = false;
  703. this.timer = null;
  704. this.timer = setTimeout(() => {
  705. this.flag = true;
  706. }, 2000);
  707. localStorage.setItem('getRequestFlage', 'false');
  708. this.$router.push({
  709. path: '/addStoreVisit',
  710. query: {
  711. visitSource: '1',
  712. storeId: this.storeId,
  713. storeCode: this.urlParameter.storeCode,
  714. visitId: this.visitId,
  715. ids: index,
  716. taskId: val.taskId,
  717. type: this.urlParameter.type,
  718. storeGroupId: this.storeGroupId,
  719. taskType: val.taskType,
  720. photoType: val.photoType,
  721. lat: this.lat,
  722. lon: this.lon,
  723. visitModel: this.visitModel,
  724. locationCity: this.city,
  725. locationRemark: this.address,
  726. types: this.$route.query.type,
  727. locationAccuracy: this.locationAccuracy,
  728. insert: this.insert,
  729. photoIdentifyType: val.photoIdentifyType,
  730. deviceCode: val.deviceCode,
  731. putInCode: val.putInCode,
  732. equipmentCode: val.equipmentCode,
  733. inspectionType: val.inspectionType,
  734. },
  735. });
  736. }
  737. // this.$router.push({path: "/addStoreVisit", query:
  738. // {storeId:this.storeId,storeCode:that.urlParameter.storeCode,visitId:this.visitId,ids:index,taskId:val.taskId,storeGroupId:this.storeGroupId,taskType:val.taskType,photoType:val.photoType}})
  739. // localStorage.setItem('collectionItemList', JSON.stringify(val.collectionItemList));
  740. },
  741. onClickLeft() {
  742. localStorage.setItem('getRequestFlage', 'true');
  743. if (this.$route.query.urltype == 2) {
  744. window.location.replace(window.location.origin + '/mobile/home');
  745. } else {
  746. this.$router.go(-1);
  747. }
  748. },
  749. // 物料历史
  750. wuliaoLog() {
  751. this.toastLoading(0, '加载中...', true);
  752. getMaterialHistory({ storeId: this.storeId })
  753. .then((res) => {
  754. this.toastLoading().clear();
  755. if (res.code == 200 && res.data) {
  756. this.wuliaoList = res.data;
  757. this.wuliaoTable = true;
  758. }
  759. })
  760. .catch(() => {
  761. this.toastLoading().clear();
  762. });
  763. },
  764. wuliaoTableClose() {
  765. this.wuliaoTable = false;
  766. },
  767. endVisitsFn(val) {
  768. let loading1 = this.$toast.loading({
  769. duration: 0,
  770. message: '加载中...',
  771. forbidClick: true,
  772. });
  773. if (val != 't') {
  774. if (this.list.length == 0) {
  775. this.$toast('暂无任务提交');
  776. return;
  777. }
  778. for (var vl = 0; vl < this.list.length; vl++) {
  779. if (this.list[vl].isMust == '0') {
  780. if (!this.list[vl].success) {
  781. this.$toast(this.list[vl].taskName + '任务未完成');
  782. return;
  783. }
  784. }
  785. }
  786. let dwellTime = this.weekend(localStorage.getItem('startTime'), new Date());
  787. // dwellTime:dwellTime,
  788. if (this.flag) {
  789. this.flag = false;
  790. this.timer = null;
  791. this.timer = setTimeout(() => {
  792. this.flag = true;
  793. }, 2000);
  794. endVisits({
  795. visitSource: '1',
  796. visitType: '0',
  797. dwellTime: dwellTime,
  798. storeGroupId: this.storeGroupId,
  799. id: this.visitId,
  800. visitModel: this.$route.query.visitModel,
  801. taskId: this.$route.query.taskId,
  802. pass: true,
  803. instanceId: this.$route.query.instanceId,
  804. storeCode: this.urlParameter.storeCode,
  805. }).then((res) => {
  806. this.flag = true;
  807. loading1.clear();
  808. if (res.code == 200) {
  809. this.editDwellTimes();
  810. if (this.$route.query.urltype == 2) {
  811. window.location.replace(window.location.origin + '/mobile/home');
  812. } else {
  813. this.$router.go(-1);
  814. // window.location.replace(window.location.origin + '/mobile/deviceWithin/index');
  815. }
  816. } else {
  817. this.$toast({
  818. message: res.msg,
  819. duration: 5000,
  820. });
  821. }
  822. });
  823. }
  824. } else {
  825. if (this.flag) {
  826. this.flag = false;
  827. this.timer = null;
  828. this.timer = setTimeout(() => {
  829. this.flag = true;
  830. }, 2000);
  831. restartProcess({
  832. visitsId: this.visitId,
  833. }).then((res) => {
  834. this.flag = true;
  835. loading1.clear();
  836. if (res.code == 200) {
  837. if (this.$route.query.urltype == 2) {
  838. window.location.replace(window.location.origin + '/mobile/home');
  839. } else {
  840. window.location.replace(window.location.origin + '/mobile/historAllVisit');
  841. }
  842. } else {
  843. this.$toast({
  844. message: res.msg,
  845. duration: 5000,
  846. });
  847. }
  848. });
  849. }
  850. }
  851. },
  852. },
  853. };
  854. </script>
  855. <style lang="scss" scoped>
  856. .container {
  857. margin-bottom: 10px;
  858. background-color: white;
  859. }
  860. .card {
  861. background: #fff;
  862. box-sizing: border-box;
  863. padding: 10px 16px;
  864. .title {
  865. line-height: 32px;
  866. font-size: 16px;
  867. font-weight: bold;
  868. color: #333;
  869. }
  870. .info {
  871. font-size: 14px;
  872. color: #484848;
  873. padding: 14px;
  874. border-bottom: 1px solid #f1f1f1;
  875. position: relative;
  876. .arrow {
  877. float: right;
  878. display: inline-block;
  879. height: 20px;
  880. width: 20px;
  881. line-height: 20px;
  882. text-align: center;
  883. border-radius: 50%;
  884. background: #1989fa;
  885. color: #fff;
  886. font-weight: bold;
  887. font-size: 14px;
  888. position: absolute;
  889. margin-top: -10px;
  890. right: 0;
  891. top: 50%;
  892. }
  893. }
  894. .info1 {
  895. font-size: 14px;
  896. color: #666;
  897. line-height: 18px;
  898. padding: 4px 0;
  899. position: relative;
  900. .arrow {
  901. float: right;
  902. display: inline-block;
  903. height: 20px;
  904. width: 20px;
  905. line-height: 20px;
  906. text-align: center;
  907. border-radius: 50%;
  908. background: #0057ba;
  909. color: #fff;
  910. font-weight: bold;
  911. font-size: 14px;
  912. margin-top: 9px;
  913. position: absolute;
  914. margin-top: -10px;
  915. right: 0;
  916. top: 50%;
  917. }
  918. }
  919. }
  920. .must {
  921. font-size: 18px;
  922. color: #f56c6c;
  923. margin-right: 2px;
  924. }
  925. .zw {
  926. display: inline-block;
  927. width: 7px;
  928. height: 100%;
  929. }
  930. .submitBtn {
  931. margin: 16px 0;
  932. font-size: 18px;
  933. }
  934. .card .f-blue {
  935. color: #0057ba;
  936. }
  937. </style>
  938. <style lang="scss">
  939. .van-dialog__confirm,
  940. .van-dialog__confirm:active {
  941. color: #0057ba;
  942. }
  943. #allmap {
  944. width: 20px;
  945. height: 20px;
  946. left: -1000px;
  947. position: relative;
  948. }
  949. .el-dialog__wrapper {
  950. z-index: 9999 !important;
  951. display: flex;
  952. justify-content: center;
  953. align-items: center;
  954. background: rgba(0, 0, 0, 0.5) !important;
  955. .wuliaoTable {
  956. overflow: hidden;
  957. display: flex;
  958. flex-direction: column;
  959. max-height: 70%;
  960. margin-top: 0 !important;
  961. .el-dialog__header {
  962. height: 40px;
  963. display: flex;
  964. justify-content: right;
  965. .el-dialog__headerbtn {
  966. position: static !important;
  967. }
  968. }
  969. .el-dialog__body {
  970. padding: 30px 20px !important;
  971. overflow-y: auto;
  972. flex: 1;
  973. }
  974. .cell {
  975. font-size: 12px;
  976. }
  977. }
  978. }
  979. </style>