residenttransferrecord.vue 12 KB

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