storeVisit.vue 33 KB

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