storeVisit.vue 37 KB

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