visitAbnormal.vue 10.0 KB

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