abnormalVisit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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 style="padding: 10px 10px 0" v-if="imgs.length > 0">
  27. <delete-upload-img :imgs="imgs" @delimg="newimgarr1"></delete-upload-img>
  28. </div>
  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. >提交</van-button
  66. >
  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, getVisitsDetail, endVisits, getPhotoTypeList1, stopVisit } from '@/api/index';
  77. export default {
  78. name: 'abnormalVisit',
  79. components: { uploadImg, deleteUploadImg },
  80. data() {
  81. return {
  82. flag: false,
  83. cont: 0,
  84. checkboxGroup: [],
  85. PhotoTypeList: [],
  86. radio: '',
  87. typeList: '',
  88. imgs: [],
  89. abnormalReason: '',
  90. uploadid2: 'uploadid2',
  91. remark: '',
  92. lat: '',
  93. lon: '',
  94. storeCode: '',
  95. dialogms: true,
  96. visitModel: '',
  97. };
  98. },
  99. created() {
  100. this.getPhotoTypeList();
  101. this.urlParameter = this.$route.query;
  102. this.storeId = this.$route.query.storeId + '';
  103. this.visitId = this.$route.query.visitId;
  104. this.rdId = this.$route.query.rdId + '';
  105. this.storeCode = this.$route.query.storeCode;
  106. this.lat = this.$route.query.lat + '';
  107. this.lon = this.$route.query.lon + '';
  108. this.visitModel = this.$route.query.visitModel + '';
  109. this.imgs = [];
  110. this.remark = '';
  111. this.abnormalReason = '';
  112. },
  113. watch: {
  114. $route(to, from) {
  115. if (from.path == '/deviceWithin/index' && to.path == '/abnormalVisit') {
  116. this.urlParameter = this.$route.query;
  117. this.storeId = this.$route.query.storeId + '';
  118. this.visitId = this.$route.query.visitId;
  119. this.rdId = this.$route.query.rdId + '';
  120. this.storeCode = this.$route.query.storeCode;
  121. this.lat = this.$route.query.lat + '';
  122. this.lon = this.$route.query.lon + '';
  123. this.visitModel = this.$route.query.visitModel + '';
  124. this.imgs = [];
  125. this.remark = '';
  126. this.abnormalReason = '';
  127. }
  128. if (from.path == '/abnormalVisit' && to.path == '/deviceWithin/index') {
  129. localStorage.removeItem('visitId');
  130. }
  131. },
  132. },
  133. activated() {
  134. this.imgs = [];
  135. this.remark = '';
  136. this.abnormalReason = '';
  137. this.visitModel = this.$route.query.visitModel + '';
  138. if (this.$route.query.type == 'edit') {
  139. this.visitId = this.$route.query.visitId + '';
  140. localStorage.setItem('visitId', this.$route.query.visitId);
  141. this.getVisitsDetailFn();
  142. } else {
  143. this.addVisits();
  144. }
  145. },
  146. methods: {
  147. // 结束拜访
  148. onstopVisit() {
  149. this.$dialog
  150. .confirm({
  151. confirmButtonText: '确定',
  152. cancelButtonText: '取消',
  153. title: '系统提示',
  154. message: '取消拜访会清空填写的拜访内容和照片,是否确认?',
  155. })
  156. .then(() => {
  157. stopVisit({ visitsId: this.visitId }).then((res) => {
  158. if (res.code == 200) {
  159. this.$dialog
  160. .alert({
  161. title: '系统提示',
  162. message: '拜访中任务结束成功!',
  163. })
  164. .then(() => {
  165. window.location.replace(
  166. window.location.origin + this.locationOrigin + '/deviceWithin/index',
  167. );
  168. });
  169. } else {
  170. this.$toast(res.msg);
  171. }
  172. });
  173. });
  174. },
  175. formatter(value) {
  176. return value.replace(
  177. /[\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,
  178. '',
  179. );
  180. },
  181. getVisitsDetailFn() {
  182. getVisitsDetail({ visitsId: this.$route.query.visitId }).then((res) => {
  183. if (res.code == 200) {
  184. this.list = res.data;
  185. this.abnormalReason = res.data.abnormalReason + '';
  186. this.remark = res.data.remark;
  187. if (res.data.visitSource == 2) {
  188. this.imgs = res.data.sysFileInfos;
  189. }
  190. } else {
  191. this.$toast(res.msg);
  192. }
  193. });
  194. },
  195. getPhotoTypeList() {
  196. getPhotoTypeList1({}).then((res) => {
  197. this.typeList = res.data;
  198. });
  199. },
  200. newimgarr1(val) {
  201. this.imgs.push(val);
  202. },
  203. onClickLeft() {
  204. this.$router.go(-1);
  205. },
  206. addVisits() {
  207. var that = this;
  208. var map = new TMap.Map('allmap', {
  209. zoom: 14,
  210. center: new TMap.LatLng(39.986785, 116.301012),
  211. });
  212. var geocoder = new TMap.service.Geocoder();
  213. var markers = new TMap.MultiMarker({ map: map, geometries: [] });
  214. markers.setGeometries([]);
  215. var input = [that.urlParameter.marklat, that.urlParameter.marklon];
  216. var location = new TMap.LatLng(Number(input[0]), Number(input[1]));
  217. map.setCenter(location);
  218. markers.updateGeometries([{ id: 'main', position: location }]);
  219. geocoder.getAddress({ location: location }).then(
  220. function (result) {
  221. var addresses = result.result.formatted_addresses;
  222. var params = {
  223. storeId: that.storeId,
  224. storeCode: that.storeCode,
  225. visitSource: '2',
  226. visitEntry: '0',
  227. lat: that.urlParameter.lat,
  228. lon: that.urlParameter.lon,
  229. visitModel: that.$route.query.visitModel,
  230. routeDetailsId: that.rdId,
  231. locationCity: '',
  232. locationRemark: addresses.recommend,
  233. locationAccuracy: that.urlParameter.PointSum,
  234. };
  235. localStorage.setItem('address', '');
  236. if (that.visitId != null) {
  237. params.id = that.visitId;
  238. }
  239. addVisits(params).then((res) => {
  240. if (res.code == 200) {
  241. localStorage.setItem('visitId', res.data);
  242. that.visitId = res.data;
  243. } else {
  244. this.$toast(res.msg);
  245. }
  246. });
  247. },
  248. function (err) {
  249. var params = {
  250. storeId: that.storeId,
  251. storeCode: that.storeCode,
  252. visitSource: '2',
  253. visitEntry: '0',
  254. lat: that.urlParameter.lat,
  255. lon: that.urlParameter.lon,
  256. visitModel: that.$route.query.visitModel,
  257. routeDetailsId: that.rdId,
  258. locationCity: '',
  259. locationRemark: '',
  260. locationAccuracy: that.urlParameter.PointSum,
  261. };
  262. localStorage.setItem('address', '');
  263. if (that.visitId != null) {
  264. params.id = that.visitId;
  265. }
  266. addVisits(params).then((res) => {
  267. if (res.code == 200) {
  268. localStorage.setItem('visitId', res.data);
  269. that.visitId = res.data;
  270. } else {
  271. this.$toast(res.msg);
  272. }
  273. });
  274. },
  275. );
  276. },
  277. endVisitsFn() {
  278. var insert = '';
  279. if (this.$route.query.type == 'edit') {
  280. insert = false;
  281. } else {
  282. insert = true;
  283. }
  284. if (this.imgs.length == 0) {
  285. this.$toast('请上传图片');
  286. return;
  287. } else if (this.abnormalReason == '') {
  288. this.$toast('请选择事由');
  289. return;
  290. } else if (this.remark.trim() == '') {
  291. this.$toast('请填写异常内容');
  292. return;
  293. } else {
  294. let dwellTime = this.weekend(localStorage.getItem('startTime'), new Date());
  295. endVisits({
  296. visitSource: '2',
  297. dwellTime: dwellTime,
  298. remark: this.remark,
  299. visitType: '0',
  300. insert: insert,
  301. abnormalReason: this.abnormalReason,
  302. id: this.visitId,
  303. storeCode: this.storeCode,
  304. visitModel: this.$route.query.visitModel,
  305. }).then((res) => {
  306. if (res.code == 200) {
  307. this.$dialog
  308. .alert({
  309. title: '系统提示',
  310. message: '保存成功',
  311. })
  312. .then(() => {
  313. if (insert) {
  314. window.location.replace(
  315. window.location.origin + this.locationOrigin + '/deviceWithin/index',
  316. );
  317. } else {
  318. this.$router.go(-1);
  319. }
  320. });
  321. localStorage.removeItem('visitId');
  322. localStorage.removeItem('startTime');
  323. } else {
  324. this.$toast.fail(res.msg);
  325. }
  326. });
  327. }
  328. },
  329. weekend(time1) {
  330. var arrtime1 = new Date(time1).getTime();
  331. var arrtime2 = new Date().getTime();
  332. return Math.round((arrtime2 - arrtime1) / 1000);
  333. },
  334. },
  335. };
  336. </script>
  337. <style lang="scss" scoped>
  338. .container {
  339. padding-bottom: 50px;
  340. }
  341. .van-f-red {
  342. color: red;
  343. width: 4px;
  344. display: inline-block;
  345. }
  346. .formLabel {
  347. margin: 0 16px;
  348. border-bottom: 1px solid #f1f1f1;
  349. }
  350. .formLabel .van-cell {
  351. padding: 10px 0;
  352. }
  353. .z-checkbox .van-radio {
  354. padding: 6px 0;
  355. }
  356. </style>
  357. <style>
  358. .bgWhite {
  359. background-color: white;
  360. }
  361. .formLabel .van-field {
  362. border: 1px solid #f1f1f1;
  363. padding: 10px;
  364. width: 100%;
  365. background-color: #f1f1f1;
  366. }
  367. .formLabel .van-field__control {
  368. padding: 0 10px;
  369. }
  370. .lineGrey {
  371. height: 10px;
  372. width: 100%;
  373. background: #f1f1f1;
  374. }
  375. .van-dialog__confirm,
  376. .van-dialog__confirm:active {
  377. color: #0057ba;
  378. }
  379. .navRightBtnTop {
  380. color: white;
  381. background: #74a4d9;
  382. display: block;
  383. padding: 6px 10px;
  384. border-radius: 6px;
  385. }
  386. #allmap {
  387. width: 20px;
  388. height: 20px;
  389. left: -1000px;
  390. position: relative;
  391. }
  392. </style>