outabnormalVisit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <div>
  3. <!-- 顶部条-->
  4. <van-nav-bar class="navBar" title="异常拜访" left-arrow @click-left="onClickLeft">
  5. <template #right>
  6. <span @click="onstopVisit" class="navRightBtnTop">取消拜访</span>
  7. </template>
  8. </van-nav-bar>
  9. <!-- 主体内容-->
  10. <div class="container">
  11. <div class="lineGrey"></div>
  12. <van-form class="bgWhite">
  13. <div class="formLabel">
  14. <van-cell>
  15. <template #title> <span class="van-f-red">*</span>异常信息照 </template>
  16. <template #right-icon>
  17. <upload-img
  18. :uploadid="uploadid2"
  19. :imgArr="imgs"
  20. @newimgarr="newimgarr1"
  21. :visitModel="visitModel"
  22. :visitsId="visitId"
  23. :taskId="rdId"></upload-img>
  24. </template>
  25. </van-cell>
  26. </div>
  27. <div style="padding: 10px 10px 0">
  28. <delete-upload-img :imgs="imgs" @delimg="newimgarr1"></delete-upload-img>
  29. </div>
  30. <div class="formLabel">
  31. <van-cell>
  32. <template #title> <span class="van-f-red">*</span>异常事由 </template>
  33. </van-cell>
  34. <van-radio-group v-model="abnormalReason" class="z-checkbox">
  35. <van-radio :name="item.dictValue" v-for="(item, index) in typeList" :key="index">{{
  36. item.dictLabel
  37. }}</van-radio>
  38. </van-radio-group>
  39. </div>
  40. <div class="formLabel" style="padding-bottom: 20px">
  41. <van-cell>
  42. <van-cell>
  43. <template #title> <span class="van-f-red">*</span>信息备注 </template>
  44. </van-cell>
  45. </van-cell>
  46. <van-field
  47. v-model="remark"
  48. rows="3"
  49. autosize
  50. maxlength="260"
  51. show-word-limit
  52. label=""
  53. :formatter="formatter"
  54. type="textarea"
  55. placeholder="请填写异常信息" />
  56. </div>
  57. </van-form>
  58. <div class="formLabel" style="margin: 20px 16px">
  59. <van-button
  60. block
  61. type="info"
  62. size="normal"
  63. style="background-color: #0057ba"
  64. @click="endVisitsFn"
  65. >提交
  66. </van-button>
  67. </div>
  68. </div>
  69. <div id="allmap"></div>
  70. </div>
  71. </template>
  72. <script>
  73. // import uploadImg from "@/components/uploadImg";
  74. import uploadImg from '@/components/uploadVvisit';
  75. import deleteUploadImg from '@/components/deleteUploadImg1';
  76. import { addVisits, endVisits, getPhotoTypeList1, stopVisit } from '@/api/index';
  77. import axios from 'axios';
  78. export default {
  79. name: 'outabnormalVisit',
  80. components: { uploadImg, deleteUploadImg },
  81. data() {
  82. return {
  83. PhotoTypeList: [],
  84. typeList: '',
  85. imgs: [],
  86. cont: 0,
  87. abnormalReason: '',
  88. uploadid2: 'uploadid2',
  89. remark: '',
  90. lat: '',
  91. lon: '',
  92. storeCode: '',
  93. dialogms: true,
  94. visitModel: '',
  95. };
  96. },
  97. created() {
  98. this.getPhotoTypeList();
  99. this.urlParameter = this.$route.query;
  100. this.storeId = this.$route.query.storeId + '';
  101. this.visitId = this.$route.query.visitId;
  102. this.storeCode = this.$route.query.storeCode;
  103. this.rdId = this.$route.query.rdId + '';
  104. this.lat = this.$route.query.lat + '';
  105. this.lon = this.$route.query.lon + '';
  106. this.visitModel = this.$route.query.visitModel + '';
  107. this.imgs = [];
  108. this.remark = '';
  109. this.abnormalReason = '';
  110. },
  111. watch: {
  112. $route(to, from) {
  113. if (from.path == '/outsidelist/index' && to.path == '/outabnormalVisit') {
  114. this.imgs = [];
  115. this.remark = '';
  116. this.abnormalReason = '';
  117. }
  118. if (from.path == '/outabnormalVisit' && to.path == '/outsidelist/index') {
  119. localStorage.removeItem('visitId');
  120. }
  121. },
  122. },
  123. activated() {
  124. this.addVisits();
  125. this.imgs = [];
  126. this.remark = '';
  127. this.abnormalReason = '';
  128. this.visitModel = this.$route.query.visitModel + '';
  129. this.urlParameter = this.$route.query;
  130. this.storeId = this.$route.query.storeId + '';
  131. this.visitId = this.$route.query.visitId;
  132. this.storeCode = this.$route.query.storeCode;
  133. this.rdId = this.$route.query.rdId + '';
  134. this.lat = this.$route.query.lat + '';
  135. this.lon = this.$route.query.lon + '';
  136. },
  137. methods: {
  138. // 结束拜访
  139. onstopVisit() {
  140. this.$dialog
  141. .confirm({
  142. confirmButtonText: '确定',
  143. cancelButtonText: '取消',
  144. title: '系统提示',
  145. message: '取消拜访会清空填写的拜访内容和照片,是否确认?',
  146. })
  147. .then(() => {
  148. stopVisit({ visitsId: this.visitId }).then((res) => {
  149. if (res.code == 200) {
  150. this.$dialog
  151. .alert({
  152. title: '系统提示',
  153. message: '拜访中任务结束成功!',
  154. })
  155. .then(() => {
  156. window.location.replace(window.location.origin + '/mobile/outsidelist/index');
  157. });
  158. } else {
  159. this.$toast(res.msg);
  160. }
  161. });
  162. });
  163. },
  164. formatter(value) {
  165. return value.replace(
  166. /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/gi,
  167. ''
  168. );
  169. },
  170. getPhotoTypeList() {
  171. getPhotoTypeList1({}).then((res) => {
  172. this.typeList = res.data;
  173. });
  174. },
  175. newimgarr1(val) {
  176. this.imgs.push(val);
  177. },
  178. onClickLeft() {
  179. this.$router.go(-1);
  180. },
  181. addVisits() {
  182. var that = this;
  183. var visitEntry = '';
  184. if (this.urlParameter.tabVal == '0') {
  185. visitEntry = '2';
  186. } else {
  187. visitEntry = '1';
  188. }
  189. var map = new TMap.Map('allmap', {
  190. zoom: 14,
  191. center: new TMap.LatLng(39.986785, 116.301012),
  192. });
  193. var geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类
  194. var markers = new TMap.MultiMarker({
  195. map: map,
  196. geometries: [],
  197. });
  198. markers.setGeometries([]);
  199. var input = [that.urlParameter.marklat, that.urlParameter.marklon];
  200. var location = new TMap.LatLng(Number(input[0]), Number(input[1]));
  201. map.setCenter(location);
  202. markers.updateGeometries([
  203. {
  204. id: 'main', // 点标注数据数组
  205. position: location,
  206. },
  207. ]);
  208. geocoder.getAddress({ location: location }).then(
  209. function (result) {
  210. var addresses = result.result.formatted_addresses;
  211. var params = {
  212. storeId: that.storeId,
  213. storeCode: that.storeCode,
  214. visitEntry: visitEntry,
  215. lat: that.urlParameter.lat,
  216. lon: that.urlParameter.lon,
  217. visitModel: that.$route.query.visitModel,
  218. visitSource: '2',
  219. routeDetailsId: that.rdId,
  220. locationCity: '',
  221. locationRemark: addresses.recommend,
  222. locationAccuracy: that.urlParameter.PointSum,
  223. };
  224. localStorage.setItem('address', '');
  225. if (that.visitId != null) {
  226. params.id = that.visitId;
  227. }
  228. addVisits(params).then((res) => {
  229. if (res.code == 200) {
  230. localStorage.setItem('visitId', res.data);
  231. that.visitId = res.data;
  232. } else {
  233. that.$toast(res.msg);
  234. }
  235. });
  236. },
  237. function (err) {
  238. var params = {
  239. storeId: that.storeId,
  240. storeCode: that.storeCode,
  241. visitEntry: visitEntry,
  242. lat: that.urlParameter.lat,
  243. lon: that.urlParameter.lon,
  244. visitModel: that.$route.query.visitModel,
  245. visitSource: '2',
  246. routeDetailsId: that.rdId,
  247. locationCity: '',
  248. locationRemark: '',
  249. locationAccuracy: that.urlParameter.PointSum,
  250. };
  251. localStorage.setItem('address', '');
  252. if (that.visitId != null) {
  253. params.id = that.visitId;
  254. }
  255. addVisits(params).then((res) => {
  256. if (res.code == 200) {
  257. localStorage.setItem('visitId', res.data);
  258. that.visitId = res.data;
  259. } else {
  260. that.$toast(res.msg);
  261. }
  262. });
  263. }
  264. );
  265. },
  266. endVisitsFn() {
  267. if (this.imgs.length == 0) {
  268. this.$toast('请上传图片');
  269. return;
  270. }
  271. if (this.abnormalReason == '') {
  272. this.$toast('请选择事由');
  273. return;
  274. } else if (this.remark.trim() == '') {
  275. this.$toast('请填写异常内容');
  276. return;
  277. } else {
  278. let dwellTime = this.weekend(localStorage.getItem('startTime'));
  279. endVisits({
  280. visitSource: '2',
  281. dwellTime: dwellTime,
  282. remark: this.remark,
  283. visitType: '0',
  284. abnormalReason: this.abnormalReason,
  285. id: this.visitId,
  286. storeCode: this.storeCode,
  287. visitModel: this.$route.query.visitModel,
  288. }).then((res) => {
  289. if (res.code == 200) {
  290. this.$dialog
  291. .alert({
  292. title: '系统提示',
  293. message: '保存成功',
  294. })
  295. .then(() => {
  296. // if(this.$route.query.linkType==6){
  297. // window.location.replace(window.location.origin + "/mobile/topStore?info=y")
  298. // }else{
  299. window.location.replace(
  300. window.location.origin + '/mobile/outsidelist/index?info=y'
  301. );
  302. // }
  303. });
  304. localStorage.removeItem('visitId');
  305. localStorage.removeItem('startTime');
  306. } else {
  307. this.$toast.fail(res.msg);
  308. }
  309. });
  310. }
  311. },
  312. weekend(time1) {
  313. var arrtime1 = new Date(time1).getTime();
  314. var arrtime2 = new Date().getTime();
  315. return Math.round((arrtime2 - arrtime1) / 1000);
  316. },
  317. },
  318. };
  319. </script>
  320. <style scoped>
  321. .bgWhite {
  322. background-color: white;
  323. }
  324. .container {
  325. padding-bottom: 50px;
  326. }
  327. .van-f-red {
  328. color: red;
  329. width: 4px;
  330. display: inline-block;
  331. }
  332. .formLabel {
  333. margin: 0 16px;
  334. border-bottom: 1px solid #f1f1f1;
  335. }
  336. .formLabel .van-cell {
  337. padding: 10px 0;
  338. }
  339. .z-checkbox .van-radio {
  340. padding: 6px 0;
  341. }
  342. </style>
  343. <style>
  344. #allmap {
  345. width: 20px;
  346. height: 20px;
  347. left: -1000px;
  348. position: relative;
  349. }
  350. .formLabel .van-field {
  351. border: 1px solid #f1f1f1;
  352. padding: 10px;
  353. width: 100%;
  354. background-color: #f1f1f1;
  355. }
  356. .formLabel .van-field__control {
  357. padding: 0 10px;
  358. }
  359. .lineGrey {
  360. height: 10px;
  361. width: 100%;
  362. background: #f1f1f1;
  363. }
  364. .van-dialog__confirm,
  365. .van-dialog__confirm:active {
  366. color: #0057ba;
  367. }
  368. .navRightBtnTop {
  369. color: white;
  370. background: #74a4d9;
  371. display: block;
  372. padding: 6px 10px;
  373. border-radius: 6px;
  374. }
  375. </style>