storeVisit.vue 37 KB

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