abnormalVisit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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(window.location.origin + '/mobile/deviceWithin/index');
  166. });
  167. } else {
  168. this.$toast(res.msg);
  169. }
  170. });
  171. });
  172. },
  173. formatter(value) {
  174. return value.replace(
  175. /[\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,
  176. ''
  177. );
  178. },
  179. getVisitsDetailFn() {
  180. getVisitsDetail({ visitsId: this.$route.query.visitId }).then((res) => {
  181. if (res.code == 200) {
  182. this.list = res.data;
  183. this.abnormalReason = res.data.abnormalReason + '';
  184. this.remark = res.data.remark;
  185. if (res.data.visitSource == 2) {
  186. this.imgs = res.data.sysFileInfos;
  187. }
  188. } else {
  189. this.$toast(res.msg);
  190. }
  191. });
  192. },
  193. getPhotoTypeList() {
  194. getPhotoTypeList1({}).then((res) => {
  195. this.typeList = res.data;
  196. });
  197. },
  198. newimgarr1(val) {
  199. this.imgs.push(val);
  200. },
  201. onClickLeft() {
  202. this.$router.go(-1);
  203. },
  204. addVisits() {
  205. var that = this;
  206. var map = new TMap.Map('allmap', {
  207. zoom: 14,
  208. center: new TMap.LatLng(39.986785, 116.301012),
  209. });
  210. var geocoder = new TMap.service.Geocoder();
  211. var markers = new TMap.MultiMarker({ map: map, geometries: [] });
  212. markers.setGeometries([]);
  213. var input = [that.urlParameter.marklat, that.urlParameter.marklon];
  214. var location = new TMap.LatLng(Number(input[0]), Number(input[1]));
  215. map.setCenter(location);
  216. markers.updateGeometries([{ id: 'main', position: location }]);
  217. geocoder.getAddress({ location: location }).then(
  218. function (result) {
  219. var addresses = result.result.formatted_addresses;
  220. var params = {
  221. storeId: that.storeId,
  222. storeCode: that.storeCode,
  223. visitSource: '2',
  224. visitEntry: '0',
  225. lat: that.lat,
  226. lon: that.lon,
  227. visitModel: that.$route.query.visitModel,
  228. routeDetailsId: that.rdId,
  229. locationCity: '',
  230. locationRemark: addresses.recommend,
  231. locationAccuracy: that.urlParameter.PointSum,
  232. };
  233. localStorage.setItem('address', '');
  234. if (that.visitId != null) {
  235. params.id = that.visitId;
  236. }
  237. addVisits(params).then((res) => {
  238. if (res.code == 200) {
  239. localStorage.setItem('visitId', res.data);
  240. that.visitId = res.data;
  241. } else {
  242. this.$toast(res.msg);
  243. }
  244. });
  245. },
  246. function (err) {
  247. var params = {
  248. storeId: that.storeId,
  249. storeCode: that.storeCode,
  250. visitSource: '2',
  251. visitEntry: '0',
  252. lat: that.urlParameter.lat,
  253. lon: that.urlParameter.lon,
  254. visitModel: that.$route.query.visitModel,
  255. routeDetailsId: that.rdId,
  256. locationCity: '',
  257. locationRemark: '',
  258. locationAccuracy: that.urlParameter.PointSum,
  259. };
  260. localStorage.setItem('address', '');
  261. if (that.visitId != null) {
  262. params.id = that.visitId;
  263. }
  264. addVisits(params).then((res) => {
  265. if (res.code == 200) {
  266. localStorage.setItem('visitId', res.data);
  267. that.visitId = res.data;
  268. } else {
  269. this.$toast(res.msg);
  270. }
  271. });
  272. }
  273. );
  274. },
  275. endVisitsFn() {
  276. var insert = '';
  277. if (this.$route.query.type == 'edit') {
  278. insert = false;
  279. } else {
  280. insert = true;
  281. }
  282. if (this.imgs.length == 0) {
  283. this.$toast('请上传图片');
  284. return;
  285. } else if (this.abnormalReason == '') {
  286. this.$toast('请选择事由');
  287. return;
  288. } else if (this.remark.trim() == '') {
  289. this.$toast('请填写异常内容');
  290. return;
  291. } else {
  292. let dwellTime = this.weekend(localStorage.getItem('startTime'), new Date());
  293. endVisits({
  294. visitSource: '2',
  295. dwellTime: dwellTime,
  296. remark: this.remark,
  297. visitType: '0',
  298. insert: insert,
  299. abnormalReason: this.abnormalReason,
  300. id: this.visitId,
  301. storeCode: this.storeCode,
  302. visitModel: this.$route.query.visitModel,
  303. }).then((res) => {
  304. if (res.code == 200) {
  305. this.$dialog
  306. .alert({
  307. title: '系统提示',
  308. message: '保存成功',
  309. })
  310. .then(() => {
  311. if (insert) {
  312. window.location.replace(window.location.origin + '/mobile/deviceWithin/index');
  313. } else {
  314. this.$router.go(-1);
  315. }
  316. });
  317. localStorage.removeItem('visitId');
  318. localStorage.removeItem('startTime');
  319. } else {
  320. this.$toast.fail(res.msg);
  321. }
  322. });
  323. }
  324. },
  325. weekend(time1) {
  326. var arrtime1 = new Date(time1).getTime();
  327. var arrtime2 = new Date().getTime();
  328. return Math.round((arrtime2 - arrtime1) / 1000);
  329. },
  330. },
  331. };
  332. </script>
  333. <style lang="scss" scoped>
  334. .container {
  335. padding-bottom: 50px;
  336. }
  337. .van-f-red {
  338. color: red;
  339. width: 4px;
  340. display: inline-block;
  341. }
  342. .formLabel {
  343. margin: 0 16px;
  344. border-bottom: 1px solid #f1f1f1;
  345. }
  346. .formLabel .van-cell {
  347. padding: 10px 0;
  348. }
  349. .z-checkbox .van-radio {
  350. padding: 6px 0;
  351. }
  352. </style>
  353. <style>
  354. .bgWhite {
  355. background-color: white;
  356. }
  357. .formLabel .van-field {
  358. border: 1px solid #f1f1f1;
  359. padding: 10px;
  360. width: 100%;
  361. background-color: #f1f1f1;
  362. }
  363. .formLabel .van-field__control {
  364. padding: 0 10px;
  365. }
  366. .lineGrey {
  367. height: 10px;
  368. width: 100%;
  369. background: #f1f1f1;
  370. }
  371. .van-dialog__confirm,
  372. .van-dialog__confirm:active {
  373. color: #0057ba;
  374. }
  375. .navRightBtnTop {
  376. color: white;
  377. background: #74a4d9;
  378. display: block;
  379. padding: 6px 10px;
  380. border-radius: 6px;
  381. }
  382. #allmap {
  383. width: 20px;
  384. height: 20px;
  385. left: -1000px;
  386. position: relative;
  387. }
  388. </style>