storeVisit.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  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(
  359. window.location.origin + this.locationOrigin + '/deviceWithin/index',
  360. );
  361. });
  362. } else {
  363. this.$toast(res.msg);
  364. }
  365. });
  366. });
  367. },
  368. editDwellTimes() {
  369. let dwellTime = this.weekend(localStorage.getItem('startTime'), new Date()) + '';
  370. editDwellTime({ dwellTime: dwellTime, visitsId: this.visitId }).then((res) => {
  371. if (res.code != 200) {
  372. this.$toast.fail(res.msg);
  373. }
  374. localStorage.removeItem('visitId');
  375. });
  376. },
  377. visitFn(val) {
  378. var that = this;
  379. suishenbangStoreSale({ storeCode: val }).then((res) => {
  380. if (res.code == 200) {
  381. if (res.data.num != '0') {
  382. window.location.href =
  383. process.env.VUE_APP_SSB_LINK + '/order/storeDetail/index?shopCode=' + val;
  384. } else {
  385. that.$toast(res.data.msg);
  386. }
  387. }
  388. });
  389. },
  390. weekend(time1) {
  391. var arrtime1 = new Date(time1).getTime();
  392. var arrtime2 = new Date().getTime();
  393. return Math.round((arrtime2 - arrtime1) / 1000);
  394. },
  395. addVisits() {
  396. var that = this;
  397. var insert = '';
  398. var postType = localStorage.getItem('postType');
  399. if (postType == 'GZ') {
  400. this.addShow1 = false;
  401. } else {
  402. this.addShow1 = true;
  403. }
  404. // this.LCshow=this.$route.query.LCshow
  405. if (this.$route.query.type == 'edit') {
  406. insert = false;
  407. } else {
  408. insert = true;
  409. }
  410. this.insert = insert;
  411. var map = new TMap.Map('allmap', {
  412. zoom: 14,
  413. center: new TMap.LatLng(39.986785, 116.301012),
  414. });
  415. var geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类
  416. var markers = new TMap.MultiMarker({
  417. map: map,
  418. geometries: [],
  419. });
  420. markers.setGeometries([]);
  421. var input = [that.urlParameter.marklat, that.urlParameter.marklon];
  422. var location = new TMap.LatLng(Number(input[0]), Number(input[1]));
  423. map.setCenter(location);
  424. markers.updateGeometries([
  425. {
  426. id: 'main', // 点标注数据数组
  427. position: location,
  428. },
  429. ]);
  430. geocoder.getAddress({ location: location }).then(
  431. function (result) {
  432. var addresses = result.result.formatted_addresses;
  433. let address_component = result.result.address_component;
  434. let province = address_component.province;
  435. let city = address_component.city;
  436. let district = address_component.district;
  437. console.log('province=' + province);
  438. console.log('city=' + city);
  439. console.log('district=' + district);
  440. let recommend = '';
  441. if (addresses) {
  442. recommend = addresses.recommend;
  443. }
  444. if (that.$route.query.type == 'edit') {
  445. var params = {
  446. storeId: that.storeId,
  447. storeCode: that.urlParameter.storeCode,
  448. visitEntry: '0',
  449. lat: '',
  450. lon: '',
  451. visitModel: that.visitModel,
  452. routeDetailsId: '',
  453. storeGroupId: that.urlParameter.storeGroupId,
  454. visitSource: '1',
  455. insert: insert,
  456. locationCity: '',
  457. locationRemark: recommend,
  458. locationAccuracy: that.urlParameter.PointSum,
  459. province: address_component.province,
  460. city: address_component.city,
  461. district: address_component.district,
  462. };
  463. that.locationAccuracy = '';
  464. that.city = '';
  465. that.address = '';
  466. if (that.visitId != null) {
  467. params.id = that.visitId;
  468. }
  469. let loading2 = that.$toast.loading({
  470. duration: 0,
  471. message: '加载中...',
  472. forbidClick: true,
  473. });
  474. that.list = [];
  475. getVisitTasks(params).then((res) => {
  476. loading2.clear();
  477. if (res.code == 200) {
  478. that.notes = res.data.notes;
  479. that.restartProcessButtion = res.data.restartProcessButtion;
  480. if (res.data.visitId != undefined) {
  481. localStorage.setItem('visitId', res.data.visitId);
  482. that.visitId = res.data.visitId;
  483. }
  484. that.list = that.filterSfaTaskList(res.data.sfaTaskList);
  485. that.storeGroupId = res.data.storeGroupId;
  486. that.showOrderButton = res.data.showOrderButton;
  487. that.startTime = res.data.startTime;
  488. that.timeN = setInterval(that.animation, 16);
  489. that.visitsRemarks = res.data.visitsRemarks;
  490. let sfaStoreType = res.data.sfaStoreType;
  491. if (
  492. (sfaStoreType && (sfaStoreType.jz || sfaStoreType.gz)) ||
  493. res.data.approvalStatus == null ||
  494. res.data.approvalStatus == 0
  495. ) {
  496. that.isToOtherSystem = false;
  497. } else {
  498. that.isToOtherSystem = true;
  499. }
  500. }
  501. });
  502. } else {
  503. var params = {
  504. storeId: that.storeId,
  505. storeCode: that.urlParameter.storeCode,
  506. visitEntry: '0',
  507. lat: that.urlParameter.latNew,
  508. lon: that.urlParameter.lonNew,
  509. visitModel: that.visitModel,
  510. routeDetailsId: that.rdId,
  511. visitSource: '1',
  512. insert: insert,
  513. locationCity: '',
  514. locationRemark: recommend,
  515. locationAccuracy: that.urlParameter.PointSum,
  516. province: address_component.province,
  517. city: address_component.city,
  518. district: address_component.district,
  519. };
  520. that.locationAccuracy = that.urlParameter.PointSum;
  521. that.city = '';
  522. that.address = recommend;
  523. localStorage.setItem('address', '');
  524. if (that.visitId != null) {
  525. params.id = that.visitId;
  526. }
  527. let loading2 = that.$toast.loading({
  528. duration: 0,
  529. message: '加载中...',
  530. forbidClick: true,
  531. });
  532. that.list = [];
  533. getVisitTasks(params).then((res) => {
  534. loading2.clear();
  535. if (res.code == 200) {
  536. that.notes = res.data.notes;
  537. that.restartProcessButtion = res.data.restartProcessButtion;
  538. if (res.data.visitId != undefined) {
  539. localStorage.setItem('visitId', res.data.visitId);
  540. that.visitId = res.data.visitId;
  541. }
  542. that.list = that.filterSfaTaskList(res.data.sfaTaskList);
  543. that.storeGroupId = res.data.storeGroupId;
  544. that.showOrderButton = res.data.showOrderButton;
  545. that.startTime = res.data.startTime;
  546. that.timeN = setInterval(that.animation, 16);
  547. that.visitsRemarks = res.data.visitsRemarks;
  548. let sfaStoreType = res.data.sfaStoreType;
  549. if (
  550. (sfaStoreType && (sfaStoreType.jz || sfaStoreType.gz)) ||
  551. res.data.approvalStatus == null ||
  552. res.data.approvalStatus == 0
  553. ) {
  554. that.isToOtherSystem = false;
  555. } else {
  556. that.isToOtherSystem = true;
  557. }
  558. } else {
  559. this.$toast(res.msg);
  560. }
  561. });
  562. }
  563. },
  564. function (err) {
  565. if (that.$route.query.type == 'edit') {
  566. var params = {
  567. storeId: that.storeId,
  568. storeCode: that.urlParameter.storeCode,
  569. visitEntry: '0',
  570. lat: '',
  571. lon: '',
  572. visitModel: that.visitModel,
  573. routeDetailsId: '',
  574. storeGroupId: that.urlParameter.storeGroupId,
  575. visitSource: '1',
  576. insert: insert,
  577. locationCity: '',
  578. locationRemark: '',
  579. locationAccuracy: that.urlParameter.PointSum,
  580. };
  581. that.locationAccuracy = '';
  582. that.city = '';
  583. that.address = '';
  584. if (that.visitId != null) {
  585. params.id = that.visitId;
  586. }
  587. let loading2 = that.$toast.loading({
  588. duration: 0,
  589. message: '加载中...',
  590. forbidClick: true,
  591. });
  592. that.list = [];
  593. getVisitTasks(params).then((res) => {
  594. loading2.clear();
  595. if (res.code == 200) {
  596. that.notes = res.data.notes;
  597. that.restartProcessButtion = res.data.restartProcessButtion;
  598. if (res.data.visitId != undefined) {
  599. localStorage.setItem('visitId', res.data.visitId);
  600. that.visitId = res.data.visitId;
  601. }
  602. that.list = that.filterSfaTaskList(res.data.sfaTaskList);
  603. that.storeGroupId = res.data.storeGroupId;
  604. that.showOrderButton = res.data.showOrderButton;
  605. that.startTime = res.data.startTime;
  606. that.timeN = setInterval(that.animation, 16);
  607. that.visitsRemarks = res.data.visitsRemarks;
  608. let sfaStoreType = res.data.sfaStoreType;
  609. if (
  610. (sfaStoreType && (sfaStoreType.jz || sfaStoreType.gz)) ||
  611. res.data.approvalStatus == null ||
  612. res.data.approvalStatus == 0
  613. ) {
  614. that.isToOtherSystem = false;
  615. } else {
  616. that.isToOtherSystem = true;
  617. }
  618. } else {
  619. that.$toast(res.msg);
  620. }
  621. });
  622. } else {
  623. var params = {
  624. storeId: that.storeId,
  625. storeCode: that.urlParameter.storeCode,
  626. visitEntry: '0',
  627. lat: that.urlParameter.latNew,
  628. lon: that.urlParameter.lonNew,
  629. visitModel: that.visitModel,
  630. routeDetailsId: that.rdId,
  631. visitSource: '1',
  632. insert: insert,
  633. locationCity: '',
  634. locationRemark: '',
  635. locationAccuracy: that.urlParameter.PointSum,
  636. };
  637. that.locationAccuracy = that.urlParameter.PointSum;
  638. that.city = '';
  639. that.address = '';
  640. localStorage.setItem('address', '');
  641. if (that.visitId != null) {
  642. params.id = that.visitId;
  643. }
  644. let loading2 = that.$toast.loading({
  645. duration: 0,
  646. message: '加载中...',
  647. forbidClick: true,
  648. });
  649. that.list = [];
  650. getVisitTasks(params).then((res) => {
  651. loading2.clear();
  652. if (res.code == 200) {
  653. that.notes = res.data.notes;
  654. that.restartProcessButtion = res.data.restartProcessButtion;
  655. if (res.data.visitId != undefined) {
  656. localStorage.setItem('visitId', res.data.visitId);
  657. that.visitId = res.data.visitId;
  658. }
  659. that.list = that.filterSfaTaskList(res.data.sfaTaskList);
  660. that.storeGroupId = res.data.storeGroupId;
  661. that.showOrderButton = res.data.showOrderButton;
  662. that.startTime = res.data.startTime;
  663. that.timeN = setInterval(that.animation, 16);
  664. that.visitsRemarks = res.data.visitsRemarks;
  665. let sfaStoreType = res.data.sfaStoreType;
  666. if (
  667. (sfaStoreType && (sfaStoreType.jz || sfaStoreType.gz)) ||
  668. res.data.approvalStatus == null ||
  669. res.data.approvalStatus == 0
  670. ) {
  671. that.isToOtherSystem = false;
  672. } else {
  673. that.isToOtherSystem = true;
  674. }
  675. } else {
  676. that.$toast(res.msg);
  677. }
  678. });
  679. }
  680. },
  681. );
  682. },
  683. getLocation() {
  684. let loading1 = this.$toast.loading({
  685. duration: 0,
  686. message: '加载中...',
  687. forbidClick: true,
  688. });
  689. let url = window.location.href;
  690. let wx = this.wx;
  691. this.list = [];
  692. let that = this;
  693. let qiyeData;
  694. const instance = axios.create();
  695. instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
  696. instance
  697. .get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket', {
  698. params: {
  699. url: url,
  700. },
  701. })
  702. .then((response) => {
  703. if (response.status == 200) {
  704. loading1.clear();
  705. qiyeData = response.data.data;
  706. wx.config({
  707. beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
  708. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  709. appId: qiyeData.appId, // 必填,企业微信的corpID
  710. timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
  711. nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
  712. signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
  713. jsApiList: ['ready', 'getLocation'], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
  714. });
  715. wx.ready(function () {
  716. wx.getLocation({
  717. type: 'gcj02',
  718. success: function (res) {
  719. var location = that.CJ02BD(res.latitude, res.longitude);
  720. that.location = location;
  721. if (that.urlParameter.lat == '' || that.urlParameter.lat == null) {
  722. that.lat = that.location.lat;
  723. that.lon = that.location.lon;
  724. } else {
  725. that.lat = that.urlParameter.lat;
  726. that.lon = that.urlParameter.lon;
  727. }
  728. let PointSum = that
  729. .twoPointSum(that.lat, that.lon, location.lat, location.lon)
  730. .toFixed(2);
  731. that.locationAccuracy = PointSum;
  732. if (PointSum > 500) {
  733. that.visitModel = '5';
  734. localStorage.setItem('visitModel', '5');
  735. that.$dialog
  736. .confirm({
  737. confirmButtonText: '确定',
  738. cancelButtonText: '重新定位',
  739. title: '系统提示',
  740. message: '距离本店距离差距太大',
  741. })
  742. .then(() => {
  743. that.addVisits();
  744. })
  745. .catch(() => {
  746. that.getLocation();
  747. });
  748. } else {
  749. that.addVisits();
  750. }
  751. },
  752. fail: function () {
  753. that.$dialog
  754. .alert({
  755. message: 'GPS未开启',
  756. })
  757. .then(() => {
  758. that.getLocation();
  759. });
  760. },
  761. });
  762. });
  763. }
  764. });
  765. },
  766. filterSfaTaskList(list) {
  767. let taskTypeArr = list.filter((val) => val.taskType !== '5');
  768. let taskType5Index = list.findIndex((val) => val.taskType == '5');
  769. if (taskType5Index != -1) {
  770. let taskType5Arr = list.filter((val) => val.taskType == '5');
  771. let taskIds = [];
  772. taskType5Arr.forEach((val) => {
  773. taskIds.push(val.taskId);
  774. });
  775. let taskType5 = {
  776. ...list[taskType5Index],
  777. taskIds: taskIds,
  778. };
  779. taskType5.taskName = '生动化陈列(拍全产品和道具)';
  780. taskTypeArr.splice(taskType5Index, 0, taskType5);
  781. }
  782. console.log(taskTypeArr);
  783. return taskTypeArr;
  784. },
  785. addStoreVisit(val, index) {
  786. if (this.flag) {
  787. this.flag = false;
  788. this.timer = null;
  789. this.timer = setTimeout(() => {
  790. this.flag = true;
  791. }, 2000);
  792. localStorage.setItem('getRequestFlage', 'false');
  793. if (val.taskType == '5') {
  794. // getCljlaToDBLabel({ visitsId: this.visitId }).then((res) => {
  795. // if (res.code == 200) {
  796. this.$router.push({
  797. path: '/taskPhotoTaking',
  798. query: {
  799. storeCode: this.urlParameter.storeCode,
  800. visitsId: this.visitId,
  801. taskIds: val.taskIds.join(','),
  802. storeGroupId: this.storeGroupId,
  803. photoType: val.photoType,
  804. insert: this.insert,
  805. storeId: this.storeId,
  806. },
  807. });
  808. // } else {
  809. // this.$toast(res.msg);
  810. // }
  811. // });
  812. } else {
  813. this.$router.push({
  814. path: '/addStoreVisit',
  815. query: {
  816. visitSource: '1',
  817. storeId: this.storeId,
  818. storeCode: this.urlParameter.storeCode,
  819. visitId: this.visitId,
  820. ids: index,
  821. taskId: val.taskId,
  822. type: this.urlParameter.type,
  823. storeGroupId: this.storeGroupId,
  824. taskType: val.taskType,
  825. photoType: val.photoType,
  826. lat: this.lat,
  827. lon: this.lon,
  828. visitModel: this.visitModel,
  829. locationCity: this.city,
  830. locationRemark: this.address,
  831. types: this.$route.query.type,
  832. locationAccuracy: this.locationAccuracy,
  833. insert: this.insert,
  834. photoIdentifyType: val.photoIdentifyType,
  835. deviceCode: val.deviceCode,
  836. putInCode: val.putInCode,
  837. equipmentCode: val.equipmentCode,
  838. inspectionType: val.inspectionType,
  839. },
  840. });
  841. }
  842. }
  843. // this.$router.push({path: "/addStoreVisit", query:
  844. // {storeId:this.storeId,storeCode:that.urlParameter.storeCode,visitId:this.visitId,ids:index,taskId:val.taskId,storeGroupId:this.storeGroupId,taskType:val.taskType,photoType:val.photoType}})
  845. // localStorage.setItem('collectionItemList', JSON.stringify(val.collectionItemList));
  846. },
  847. onClickLeft() {
  848. localStorage.setItem('getRequestFlage', 'true');
  849. if (this.$route.query.urltype == 2) {
  850. window.location.replace(window.location.origin + this.locationOrigin + '/home');
  851. } else {
  852. this.$router.go(-1);
  853. }
  854. },
  855. // 物料历史
  856. wuliaoLog() {
  857. this.toastLoading(0, '加载中...', true);
  858. getMaterialHistory({ storeId: this.storeId })
  859. .then((res) => {
  860. this.toastLoading().clear();
  861. if (res.code == 200 && res.data) {
  862. this.wuliaoList = res.data;
  863. this.wuliaoTable = true;
  864. }
  865. })
  866. .catch(() => {
  867. this.toastLoading().clear();
  868. });
  869. },
  870. wuliaoTableClose() {
  871. this.wuliaoTable = false;
  872. },
  873. endVisitsFn(val) {
  874. let loading1 = this.$toast.loading({
  875. duration: 0,
  876. message: '加载中...',
  877. forbidClick: true,
  878. });
  879. if (val != 't') {
  880. if (this.list.length == 0) {
  881. this.$toast('暂无任务提交');
  882. return;
  883. }
  884. for (var vl = 0; vl < this.list.length; vl++) {
  885. if (this.list[vl].isMust == '0') {
  886. if (!this.list[vl].success) {
  887. this.$toast(this.list[vl].taskName + '任务未完成');
  888. return;
  889. }
  890. }
  891. }
  892. let dwellTime = this.weekend(localStorage.getItem('startTime'), new Date());
  893. // dwellTime:dwellTime,
  894. if (this.flag) {
  895. this.flag = false;
  896. this.timer = null;
  897. this.timer = setTimeout(() => {
  898. this.flag = true;
  899. }, 2000);
  900. endVisits({
  901. visitSource: '1',
  902. visitType: '0',
  903. dwellTime: dwellTime,
  904. storeGroupId: this.storeGroupId,
  905. id: this.visitId,
  906. visitModel: this.$route.query.visitModel,
  907. taskId: this.$route.query.taskId,
  908. pass: true,
  909. instanceId: this.$route.query.instanceId,
  910. storeCode: this.urlParameter.storeCode,
  911. }).then((res) => {
  912. this.flag = true;
  913. loading1.clear();
  914. if (res.code == 200) {
  915. this.editDwellTimes();
  916. if (this.$route.query.urltype == 2) {
  917. window.location.replace(window.location.origin + this.locationOrigin + '/home');
  918. } else {
  919. this.$router.go(-1);
  920. // window.location.replace(window.location.origin + '/mobile/deviceWithin/index');
  921. }
  922. } else {
  923. this.$toast({
  924. message: res.msg,
  925. duration: 5000,
  926. });
  927. }
  928. });
  929. }
  930. } else {
  931. if (this.flag) {
  932. this.flag = false;
  933. this.timer = null;
  934. this.timer = setTimeout(() => {
  935. this.flag = true;
  936. }, 2000);
  937. restartProcess({
  938. visitsId: this.visitId,
  939. }).then((res) => {
  940. this.flag = true;
  941. loading1.clear();
  942. if (res.code == 200) {
  943. if (this.$route.query.urltype == 2) {
  944. window.location.replace(window.location.origin + this.locationOrigin + '/home');
  945. } else {
  946. window.location.replace(
  947. window.location.origin + this.locationOrigin + '/historAllVisit',
  948. );
  949. }
  950. } else {
  951. this.$toast({
  952. message: res.msg,
  953. duration: 5000,
  954. });
  955. }
  956. });
  957. }
  958. }
  959. },
  960. // 跳转好帮手门店详情
  961. goOtherSystem() {
  962. if (this.isToOtherSystem) {
  963. if (this.urlParameter.storeCode)
  964. window.location.href =
  965. process.env.VUE_APP_SSB_LINK +
  966. '/order/storeDetail/index?shopCode=' +
  967. this.urlParameter.storeCode;
  968. }
  969. },
  970. },
  971. };
  972. </script>
  973. <style lang="scss" scoped>
  974. .container {
  975. margin-bottom: 10px;
  976. background-color: white;
  977. }
  978. .card {
  979. background: #fff;
  980. box-sizing: border-box;
  981. padding: 10px 16px;
  982. .title {
  983. line-height: 32px;
  984. font-size: 16px;
  985. font-weight: bold;
  986. color: #333;
  987. }
  988. .info {
  989. font-size: 14px;
  990. color: #484848;
  991. padding: 14px;
  992. border-bottom: 1px solid #f1f1f1;
  993. position: relative;
  994. .arrow {
  995. float: right;
  996. display: inline-block;
  997. height: 20px;
  998. width: 20px;
  999. line-height: 20px;
  1000. text-align: center;
  1001. border-radius: 50%;
  1002. background: #1989fa;
  1003. color: #fff;
  1004. font-weight: bold;
  1005. font-size: 14px;
  1006. position: absolute;
  1007. margin-top: -10px;
  1008. right: 0;
  1009. top: 50%;
  1010. }
  1011. }
  1012. .info1 {
  1013. font-size: 14px;
  1014. color: #666;
  1015. line-height: 18px;
  1016. padding: 4px 0;
  1017. position: relative;
  1018. line-height: 22px;
  1019. .arrow {
  1020. float: right;
  1021. display: inline-block;
  1022. height: 20px;
  1023. width: 20px;
  1024. line-height: 20px;
  1025. text-align: center;
  1026. border-radius: 50%;
  1027. background: #0057ba;
  1028. color: #fff;
  1029. font-weight: bold;
  1030. font-size: 14px;
  1031. margin-top: 9px;
  1032. position: absolute;
  1033. margin-top: -10px;
  1034. right: 0;
  1035. top: 50%;
  1036. }
  1037. }
  1038. }
  1039. .must {
  1040. font-size: 18px;
  1041. color: #f56c6c;
  1042. margin-right: 2px;
  1043. }
  1044. .zw {
  1045. display: inline-block;
  1046. width: 7px;
  1047. height: 100%;
  1048. }
  1049. .submitBtn {
  1050. margin: 16px 0;
  1051. font-size: 18px;
  1052. }
  1053. .card .f-blue {
  1054. color: #0057ba;
  1055. }
  1056. .storeVisit {
  1057. .to-other-system {
  1058. color: #0057ba;
  1059. text-decoration: underline;
  1060. }
  1061. .storeCategory {
  1062. display: flex;
  1063. justify-content: space-between;
  1064. .storeType {
  1065. flex: 1;
  1066. display: flex;
  1067. align-items: center;
  1068. }
  1069. }
  1070. .visitsRemarks {
  1071. display: flex;
  1072. justify-content: space-between;
  1073. .f-blue {
  1074. flex: 1;
  1075. display: flex;
  1076. align-items: center;
  1077. }
  1078. }
  1079. }
  1080. </style>
  1081. <style lang="scss">
  1082. .van-dialog__confirm,
  1083. .van-dialog__confirm:active {
  1084. color: #0057ba;
  1085. }
  1086. #allmap {
  1087. width: 20px;
  1088. height: 20px;
  1089. left: -1000px;
  1090. position: relative;
  1091. }
  1092. .el-dialog__wrapper {
  1093. z-index: 9999 !important;
  1094. display: flex;
  1095. justify-content: center;
  1096. align-items: center;
  1097. background: rgba(0, 0, 0, 0.5) !important;
  1098. .wuliaoTable {
  1099. overflow: hidden;
  1100. display: flex;
  1101. flex-direction: column;
  1102. max-height: 70%;
  1103. margin-top: 0 !important;
  1104. .el-dialog__header {
  1105. height: 40px;
  1106. display: flex;
  1107. justify-content: right;
  1108. .el-dialog__headerbtn {
  1109. position: static !important;
  1110. }
  1111. }
  1112. .el-dialog__body {
  1113. padding: 30px 20px !important;
  1114. overflow-y: auto;
  1115. flex: 1;
  1116. }
  1117. .cell {
  1118. font-size: 12px;
  1119. }
  1120. }
  1121. }
  1122. </style>