storeVisit.vue 33 KB

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