residenttransferrecord.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  4. @clickLeft="toBack">
  5. <view class="nav-title">
  6. <text>{{title}}</text>
  7. </view>
  8. </uni-nav-bar>
  9. <uni-forms ref="baseForm" :model="formData">
  10. <uni-card title="转移人员信息" :is-shadow="false">
  11. <uni-forms-item name='name' label="姓名" label-width="100px" required>
  12. <uni-easyinput v-model="formData.personName" placeholder="请录入姓名" />
  13. </uni-forms-item>
  14. <uni-forms-item name='id' label="身份证号" label-width="100px" required>
  15. <uni-easyinput v-model="formData.personId" placeholder="请录入身份证号" />
  16. </uni-forms-item>
  17. <uni-forms-item name="familyMembersTransferStatus" label="家庭户是否转移完成" label-width="100px" required>
  18. <uni-data-checkbox v-model="formData.familyMembersTransferStatus" :localdata="checkItems.items">
  19. </uni-data-checkbox>
  20. </uni-forms-item>
  21. <uni-forms-item name='remark' label="补充说明" label-width="100px">
  22. <uni-easyinput v-model="formData.remark" placeholder="请录入其他需要说明的情况" />
  23. </uni-forms-item>
  24. </uni-card>
  25. <uni-card title="留存图片" extra="点击下方按钮开始拍摄" :is-shadow="false">
  26. <view class="view-flex-rs-flex-wrap">
  27. <view v-for="(item, index) in keepPhotos" :key="index" class="view-flex-cc" style="width: 100px;">
  28. <view class="img-container">
  29. <view class="note-image-box">
  30. <view class="note-image-item">
  31. <view class="close-icon" @click="onCheckPhotoDel(index)">
  32. <uni-icons type="closeempty" size="18" color="#fff"></uni-icons>
  33. </view>
  34. <view class="image-box">
  35. <image :src="toOss(item)" mode="widthFix">
  36. </image>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="view-flex-cc" style="width: 80px;">
  43. <view class="img-container">
  44. <view class="note-image-box">
  45. <view class="note-image-item" @click="onCheckPhotoAdd()">
  46. <view class="image-box">
  47. <uni-icons type="plusempty" size="50" color="#eee"></uni-icons>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </uni-card>
  55. </uni-forms>
  56. <view class="footer">
  57. <view class="control">
  58. <view class="view-flex-rc">
  59. <view class="block"
  60. style="width: 120px;height:28px;margin-left: 10px;margin-right: 10px;border-radius:7px;background-color:lightpink"
  61. @click="toSubmit()">
  62. <view class="view-flex-cc">
  63. <uni-icons class="input-uni-icon" type="checkmarkempty" size="18" color="#999" />
  64. </view>
  65. <view class="view-flex-cc" style="padding-left:5px;">
  66. <text style="color:black;font-size:0.7rem">立即提交</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. role
  77. } from "@/api/role.js";
  78. import http from '@/http/api.js';
  79. import {
  80. oss,
  81. devUrl,
  82. prodUrl
  83. } from '@/common/setting';
  84. export default {
  85. data() {
  86. return {
  87. title: '转移登记',
  88. baseURL: '',
  89. baseOSS: '',
  90. warnId: '',
  91. formData: {
  92. personName: '',
  93. personId: '',
  94. familyMembersTransferStatus: 0,
  95. remark: '',
  96. },
  97. keepPhotos: [],
  98. checkItems: {
  99. items: [{
  100. 'value': 0,
  101. 'text': '否'
  102. }, {
  103. 'value': 1,
  104. 'text': '是'
  105. }],
  106. current: 0,
  107. },
  108. }
  109. },
  110. onLoad(option) {
  111. let that = this;
  112. this.baseOSS = oss;
  113. this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
  114. this.warnId = option.id;
  115. },
  116. computed: {
  117. },
  118. onShow() {},
  119. methods: {
  120. toOss(path) {
  121. let url = this.baseOSS + path;
  122. return url;
  123. },
  124. onBackPress() {
  125. // #ifdef APP-PLUS
  126. plus.key.hideSoftKeybord();
  127. // #endif
  128. },
  129. //返回上一页
  130. toBack() {
  131. uni.navigateBack({
  132. delta: 1
  133. })
  134. },
  135. getAddress(lng, lat) {
  136. console.log("get address " + lat + lng);
  137. let url = 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + lat + ',' + lng +
  138. '&key=4HYBZ-EB23D-SLC42-HQ5R3-LP3LQ-OZFU5';
  139. console.log(url);
  140. http.request({
  141. url: url,
  142. method: 'GET',
  143. }).then(res => {
  144. console.log('当前位置:' + JSON.stringify(res));
  145. }).catch(err => {
  146. console.log(err)
  147. })
  148. },
  149. onCheckPhotoAdd() {
  150. let that = this;
  151. uni.chooseImage({
  152. sourceType: ['camera'],
  153. sizeType: ['compressed'],
  154. success: (res) => {
  155. const len = res.tempFilePaths.length;
  156. if (len === 1) {
  157. res.tempFilePaths.forEach(path => {
  158. that.uploadCheckPhoto(path);
  159. })
  160. } else {
  161. uni.showModal({
  162. content: '只能选择一张图片,请确认!',
  163. showCancel: false
  164. });
  165. }
  166. }
  167. })
  168. },
  169. uploadCheckPhoto(imagePath) {
  170. let that = this;
  171. uni.showLoading({
  172. title: '上传中'
  173. });
  174. uni.uploadFile({
  175. url: this.baseURL + '/galaxy-resource/oss/endpoint/put-file-attach?Blade-Auth=' +
  176. uni.getStorageSync('accessToken'),
  177. fileType: 'image',
  178. filePath: imagePath,
  179. name: 'file',
  180. success: (uploadFileRes) => {
  181. if (uploadFileRes.statusCode == 200) {
  182. let data = JSON.parse(uploadFileRes.data);
  183. if (data.success) {
  184. let path = data.data['name'];
  185. that.keepPhotos.push(path);
  186. }
  187. }
  188. },
  189. fail: (err) => {
  190. console.log(err);
  191. reject('err')
  192. },
  193. complete() {
  194. uni.hideLoading()
  195. }
  196. });
  197. },
  198. onCheckPhotoDel(index) {
  199. this.keepPhotos.splice(index, 1);
  200. },
  201. toSubmit() {
  202. let that = this;
  203. this.$refs.baseForm.validate().then(res => {
  204. console.log('表单数据信息1:', res);
  205. that.submit();
  206. }).catch(err => {
  207. console.log('表单错误信息:', err);
  208. uni.showModal({
  209. content: "内容填报错误,请根据提示信息检查录入内容!",
  210. showCancel: false,
  211. success(res) {
  212. if (res.confirm) {
  213. //that.$refs.baseForm.clearValidate();
  214. }
  215. }
  216. });
  217. })
  218. },
  219. submit() {
  220. let formdata = this.formData;
  221. formdata['warnId'] = this.warnId;
  222. if (this.keepPhotos.length > 0) {
  223. let photos = '';
  224. for (let i = 0; i < this.keepPhotos.length; i++) {
  225. if (photos.length > 0) {
  226. photos = photos + ',';
  227. }
  228. photos = photos + this.keepPhotos[i];
  229. }
  230. formdata['keepPhotos'] = photos;
  231. }
  232. console.log('toSubmit事件:', JSON.stringify(formdata));
  233. let that = this;
  234. http.request({
  235. url: '/galaxy-business/yj/transfer/person/record',
  236. method: 'POST',
  237. data: formdata
  238. }).then(res => {
  239. console.log('res ', JSON.stringify(res));
  240. if (res.success) {
  241. if (res.code == 200) {
  242. //that.clearCache();
  243. uni.showModal({
  244. content: '填报信息已成功提交',
  245. showCancel: false,
  246. success(res) {
  247. if (res.confirm) {
  248. that.toBack();
  249. }
  250. }
  251. });
  252. } else {
  253. uni.showModal({
  254. content: '提交失败',
  255. showCancel: false
  256. });
  257. }
  258. } else {
  259. uni.showModal({
  260. content: '提交失败',
  261. showCancel: false
  262. });
  263. }
  264. }).catch(err => {
  265. // console.log('errr3',JSON.stringify(err));
  266. uni.showModal({
  267. content: '' + err.data.msg,
  268. showCancel: false
  269. });
  270. })
  271. },
  272. }
  273. }
  274. </script>
  275. <style lang="scss" scoped>
  276. .container {
  277. padding: 0 0 100rpx;
  278. }
  279. .view-flex-rs-flex-wrap {
  280. display: flex;
  281. flex-direction: row;
  282. justify-content: flex-start;
  283. flex-wrap: wrap;
  284. }
  285. .img-container {
  286. margin-bottom: 0px;
  287. width: 100px;
  288. height: 100px;
  289. .note-image-box {
  290. margin-top: 0px;
  291. display: flex;
  292. flex-wrap: wrap;
  293. padding: 10px;
  294. .note-image-item {
  295. position: relative;
  296. width: 100%;
  297. height: 0;
  298. padding-top: 100%;
  299. box-sizing: border-box;
  300. // background-color: #18B566;
  301. .close-icon {
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. position: absolute;
  306. right: 0px;
  307. top: 0px;
  308. width: 22px;
  309. height: 22px;
  310. border-radius: 50%;
  311. background-color: #d5d5d5;
  312. z-index: 2;
  313. }
  314. .image-box {
  315. display: flex;
  316. justify-content: center;
  317. align-items: center;
  318. position: absolute;
  319. top: 0px;
  320. right: 0px;
  321. border: 0px;
  322. left: 0px;
  323. border: 1px #eee solid;
  324. border-radius: 5px;
  325. overflow: hidden;
  326. width: 99%;
  327. height: 99%;
  328. }
  329. }
  330. }
  331. }
  332. .view-flex-rc {
  333. display: flex;
  334. flex-direction: row;
  335. justify-content: center;
  336. align-items: center;
  337. }
  338. .view-flex-cc {
  339. display: flex;
  340. flex-direction: column;
  341. justify-content: center;
  342. align-items: center;
  343. }
  344. .footer {
  345. position: fixed;
  346. bottom: 0;
  347. left: 0;
  348. right: 0;
  349. z-index: 1;
  350. height: 100rpx;
  351. padding: 20rpx;
  352. box-sizing: border-box;
  353. display: flex;
  354. align-items: center;
  355. justify-content: flex-end;
  356. background-color: whitesmoke;
  357. .ipt {
  358. width: 380rpx;
  359. height: 77rpx;
  360. background: #f7f7f7;
  361. border-radius: 38px;
  362. padding: 0 37rpx;
  363. box-sizing: border-box;
  364. margin-right: 20rpx;
  365. }
  366. .control {
  367. flex: 1;
  368. display: flex;
  369. align-items: center;
  370. justify-content: flex-end;
  371. .block {
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. flex: 1;
  376. }
  377. .icon {
  378. height: auto;
  379. }
  380. .c {
  381. width: 41rpx;
  382. margin-right: 10rpx;
  383. }
  384. .s {
  385. width: 36rpx;
  386. }
  387. .t {
  388. width: 31rpx;
  389. }
  390. }
  391. }
  392. </style>