outabnormalVisit.vue 10 KB

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