index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. <template>
  2. <view>
  3. <view>
  4. <csr-tab :tabList="list" :value="active" @change="changeTab" />
  5. </view>
  6. <view>
  7. <uni-section padding>
  8. <uni-forms ref="baseForm" :modelValue="baseFormData" :rules="rules" label-width="95px" label-align="right">
  9. <view v-if="active==0">
  10. <uni-forms-item label="照片">
  11. <uni-file-picker limit="1" v-model="baseFormData.head" fileMediatype="image" @select="select" />
  12. </uni-forms-item>
  13. <uni-forms-item label="姓名" required name="xm">
  14. <uni-easyinput v-model="baseFormData.xm" placeholder="请输入姓名" />
  15. </uni-forms-item>
  16. <uni-forms-item label="性别" required name="xb">
  17. <uni-data-select v-model="baseFormData.xb" placeholder="请选择性别" :localdata="dicts.C0007" />
  18. </uni-forms-item>
  19. <uni-forms-item label="民族" required name="mz">
  20. <uni-data-select v-model="baseFormData.mz" placeholder="请选择民族" :localdata="dicts.C0009" />
  21. </uni-forms-item>
  22. <uni-forms-item label="手机号" required name="sjhm">
  23. <uni-easyinput v-model="baseFormData.sjhm" placeholder="请输入手机号" />
  24. </uni-forms-item>
  25. <uni-forms-item label="出生日期">
  26. <uni-datetime-picker type="date" v-model="baseFormData.csrq" placeholder="请选择出生日期" />
  27. </uni-forms-item>
  28. <uni-forms-item label="身高">
  29. <uni-easyinput type="number" v-model="baseFormData.sg" placeholder="身高单位:cm" />
  30. </uni-forms-item>
  31. <uni-forms-item label="体重">
  32. <uni-easyinput type="number" v-model="baseFormData.tz" placeholder="体重单位:kg" />
  33. </uni-forms-item>
  34. <uni-forms-item label="婚姻状况">
  35. <uni-data-select v-model="baseFormData.hyzk" placeholder="请选择婚姻状况" :localdata="dicts.C0010" />
  36. </uni-forms-item>
  37. <uni-forms-item label="能力状况">
  38. <uni-data-select v-model="baseFormData.nlpg" placeholder="请选择能力状况" :localdata="dicts.CZ036" />
  39. </uni-forms-item>
  40. <uni-forms-item label="居住地址">
  41. <uni-easyinput v-model="baseFormData.xjd" placeholder="请输入居住地址" />
  42. </uni-forms-item>
  43. <uni-forms-item label="定位">
  44. <view @click="openChooseLocation">
  45. <uni-easyinput v-model="baseFormData.zzjwd" placeholder="请选择定位" disabled />
  46. </view>
  47. </uni-forms-item>
  48. <uni-forms-item label="监护人">
  49. <uni-easyinput v-model="baseFormData.jhr" placeholder="请输入监护人姓名" />
  50. </uni-forms-item>
  51. <uni-forms-item label="监护人手机号">
  52. <uni-easyinput v-model="baseFormData.jhrsjhm" placeholder="请输入监护人手机号码" />
  53. </uni-forms-item>
  54. <uni-forms-item label="与老人关系">
  55. <uni-data-select v-model="baseFormData.jhrgx" placeholder="请选择与老人关系" :localdata="dicts.C0032" />
  56. </uni-forms-item>
  57. <uni-forms-item label="巡访责任人">
  58. <uni-easyinput v-model="baseFormData.xfzrr" placeholder="请输入巡访责任人姓名" />
  59. </uni-forms-item>
  60. <uni-forms-item label="巡访频次">
  61. <uni-data-select v-model="baseFormData.xfpc" placeholder="请选择巡访频次" :localdata="dicts.KH005" />
  62. </uni-forms-item>
  63. <uni-forms-item label="特困老人归类">
  64. <uni-data-checkbox multiple v-model="baseFormData.tkflData" :localdata="tkflData" />
  65. </uni-forms-item>
  66. <uni-forms-item label="兴趣爱好">
  67. <uni-data-checkbox multiple v-model="baseFormData.xqahData" :localdata="xqahData" />
  68. </uni-forms-item>
  69. <uni-forms-item label="兴趣爱好备注">
  70. <uni-easyinput v-model="baseFormData.xqahbz" placeholder="请输入兴趣爱好备注" />
  71. </uni-forms-item>
  72. <uni-forms-item label="技能特长">
  73. <uni-data-checkbox multiple v-model="baseFormData.jntcData" :localdata="jntcData" />
  74. </uni-forms-item>
  75. <uni-forms-item label="技能特长备注">
  76. <uni-easyinput v-model="baseFormData.jntcbz" placeholder="请输入技能特长备注" />
  77. </uni-forms-item>
  78. <uni-forms-item label="加入助老服务">
  79. <uni-data-checkbox v-model="baseFormData.jntcIszy" :localdata="dicts.CZ035" />
  80. </uni-forms-item>
  81. <view class="bottomButton">
  82. <button type="primary" size="mini" @click="next()">下一步</button>
  83. </view>
  84. </view>
  85. <view v-else-if="active==1">
  86. <uni-forms-item label="血糖" label-width="75px">
  87. <uni-data-select v-model="baseFormData.datzXt" placeholder="请选择血糖" :localdata="dicts.KH001" />
  88. </uni-forms-item>
  89. <uni-forms-item label="血压" label-width="75px">
  90. <uni-data-select v-model="baseFormData.datzXy" placeholder="请选择血压" :localdata="dicts.KH002" />
  91. </uni-forms-item>
  92. <uni-forms-item label="血脂" label-width="75px">
  93. <uni-data-select v-model="baseFormData.datzXz" placeholder="请选择血脂" :localdata="dicts.KH002" />
  94. </uni-forms-item>
  95. <uni-forms-item label="吸烟情况" label-width="75px">
  96. <uni-data-select v-model="baseFormData.datzXyqk" placeholder="请选择吸烟情况" :localdata="dicts.KH003" />
  97. </uni-forms-item>
  98. <uni-forms-item label="饮酒情况" label-width="75px">
  99. <uni-data-select v-model="baseFormData.datzYjqk" placeholder="请选择饮酒情况" :localdata="dicts.KH003" />
  100. </uni-forms-item>
  101. <view class="line-item">
  102. <uni-forms-item label-width="0px">
  103. <uni-data-checkbox mode="button" multiple v-model="baseFormData.bs" :localdata="bsData" />
  104. </uni-forms-item>
  105. </view>
  106. <uni-forms-item label="睡眠作息" label-width="75px">
  107. <uni-easyinput type="textarea" v-model="baseFormData.daShxgSmzx" placeholder="请输入睡眠作息" />
  108. </uni-forms-item>
  109. <uni-forms-item label="饮食喜好" label-width="75px">
  110. <uni-easyinput type="textarea" v-model="baseFormData.daShxgYsxh" placeholder="请输入饮食喜好" />
  111. </uni-forms-item>
  112. <uni-forms-item label="其他习惯" label-width="75px">
  113. <uni-easyinput type="textarea" v-model="baseFormData.daShxgQtxg" placeholder="请输入其他习惯" />
  114. </uni-forms-item>
  115. <view class="bottomButton">
  116. <button type="primary" size="mini" @click="active=0">上一步</button>
  117. <button type="primary" size="mini" @click="next(true)">保存</button>
  118. </view>
  119. </view>
  120. <view v-else-if="active==2">
  121. <button type="primary" size="mini" @click="editFamily"
  122. style="width: 100rpx;padding: 0 5px;line-height: 2;">新增</button>
  123. <uni-list>
  124. <uni-list-item :title="item.jtcyxm" :note="item.jtcylxdh"
  125. :rightText="transDictLabel(dicts.C0032,item.jtcygx)" v-for="(item,idx) in familyList" :key="idx"
  126. showArrow clickable @click="editFamily(item)" />
  127. </uni-list>
  128. <!-- 输入框示例 -->
  129. <uni-popup ref="inputDialog" type="dialog">
  130. <uni-popup-dialog ref="inputClose" mode="input" title="添加家庭成员信息" before-close="true"
  131. @confirm="submitFamilyForm" @close="cance">
  132. <uni-forms ref="familyForm" :modelValue="familyForm" :rules="familyRules" label-align="right" padding>
  133. <uni-forms-item label="关系" required name="jtcygx">
  134. <uni-data-select v-model="familyForm.jtcygx" placeholder="请选择与老人关系" :localdata="dicts.C0032" />
  135. </uni-forms-item>
  136. <uni-forms-item label="姓名" required name="jtcyxm">
  137. <uni-easyinput v-model="familyForm.jtcyxm" placeholder="请输入姓名" />
  138. </uni-forms-item>
  139. <uni-forms-item label="性别" required name="jtcyxb">
  140. <uni-data-select v-model="familyForm.jtcyxb" placeholder="请选择性别" :localdata="dicts.C0007" />
  141. </uni-forms-item>
  142. <uni-forms-item label="手机号" required name="jtcylxdh">
  143. <uni-easyinput v-model="familyForm.jtcylxdh" placeholder="请输入手机号" />
  144. </uni-forms-item>
  145. <uni-forms-item label="地址" required name="jtcyjzd">
  146. <uni-easyinput v-model="familyForm.jtcyjzd" placeholder="请输入居住地址" />
  147. </uni-forms-item>
  148. </uni-forms>
  149. </uni-popup-dialog>
  150. </uni-popup>
  151. </view>
  152. <view v-else-if="active==3">
  153. <navigator :url="'/pages/lr/bhAdd?id=' + baseFormData.id + '&xm=' + baseFormData.xm">
  154. <button type="primary" size="mini" style="width: 100rpx;padding: 0 5px;line-height: 2;">新增</button>
  155. </navigator>
  156. <uni-list>
  157. <uni-list-item ellipsis="1" :title="item.bhms" :note="item.bhsj"
  158. :rightText="transDictLabel(dicts.KH004,item.bhlb)" v-for="(item,idx) in bhlsList" :key="idx" showArrow
  159. clickable @click="editBhls(item)" />
  160. </uni-list>
  161. </view>
  162. </uni-forms>
  163. </uni-section>
  164. </view>
  165. <!-- <button type="primary" size="mini" style="margin: 30px 10px; width: 100px;" @click="change">改变状态</button> -->
  166. </view>
  167. </template>
  168. <script>
  169. import amapFile from "@/libs/amap-wx.130.js";
  170. import config from "../../config.js";
  171. import { UploadOne } from '@/api/upload.js';
  172. import { addKhjbxx, updateKhjbxx, listJtxx, addJtxx, updateJtxx, listKhbhls } from '@/api/lr.js'
  173. import { decryptRowData_ECB } from '@/common/sm4.js'
  174. import { decimalToBinary } from '@/common/num.js'
  175. export default {
  176. data() {
  177. return {
  178. dicts: {
  179. C0007: [],
  180. C0009: [],
  181. C0010: [],
  182. CZ036: [],
  183. C0032: [],
  184. CZ035: [],
  185. KH001: [],
  186. KH002: [],
  187. KH003: [],
  188. KH004: [],
  189. KH005: [],
  190. },
  191. active: 0,
  192. activeName: '基本信息',
  193. list: ['基本信息', '健康档案', '家庭信息', '病史记录'],
  194. rules: {
  195. xm: {
  196. rules: [{
  197. required: true,
  198. errorMessage: '姓名不能为空'
  199. }]
  200. },
  201. xb: {
  202. rules: [{
  203. required: true,
  204. errorMessage: '请选择性别'
  205. }]
  206. },
  207. mz: {
  208. rules: [{
  209. required: true,
  210. errorMessage: '请选择民族'
  211. }]
  212. },
  213. sjhm: {
  214. rules: [{
  215. required: true,
  216. errorMessage: '请输入手机号'
  217. },
  218. {
  219. format: 'number',
  220. errorMessage: '请输入正确的手机号',
  221. },
  222. {
  223. pattern: '^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\\d{8})$',
  224. errorMessage: '请输入正确的手机号',
  225. }
  226. ]
  227. },
  228. jhrsjhm: {
  229. rules: [{
  230. format: 'number',
  231. errorMessage: '请输入正确的手机号',
  232. },
  233. {
  234. pattern: '^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\\d{8})$',
  235. errorMessage: '请输入正确的手机号',
  236. }
  237. ]
  238. }
  239. },
  240. baseData: {},
  241. baseFormData: {
  242. xm: '',
  243. xb: '',
  244. mz: '',
  245. sjhm: '',
  246. lng: '',
  247. lat: '',
  248. dw: '',
  249. jntcIszy: '0',
  250. xqahData: [],
  251. xqah: [],
  252. jntcData: [],
  253. jntc: [],
  254. tkflData: [],
  255. tkfl: [],
  256. bs: [],
  257. "tx": null,
  258. "csrq": null,
  259. "sg": null,
  260. "tz": null,
  261. "hyzk": null,
  262. "nlpg": null,
  263. "xjd": null,
  264. "jhr": null,
  265. "jhrsjhm": null,
  266. "jhrgx": null,
  267. "xfzrr": null,
  268. "xfpc": null,
  269. "xqahbz": null,
  270. "jntcbz": null,
  271. "datzXt": "0",
  272. "datzXy": "0",
  273. "datzXz": "0",
  274. "datzXyqk": "0",
  275. "datzYjqk": "0",
  276. "daIsSjxtbs": "0",
  277. "daIsHxxtbs": "0",
  278. "daIsXhxtbs": "0",
  279. "daIsXhxtbsb": "0",
  280. "daIsMnxtbs": "0",
  281. "daIsYdxtbs": "0",
  282. "daIsSzxtbs": "0",
  283. "daIsNfmxtbs": "0",
  284. "daIsZlbs": "0",
  285. "daIsXnxgbs": "0",
  286. "daIsTnbs": "0",
  287. "daIsTfbs": "0",
  288. "daShxgSmzx": null,
  289. "daShxgYsxh": null,
  290. "daShxgQtxg": null,
  291. "zzjwd": "",
  292. "zjlx": "01",
  293. "zjhm": "420101197305263488",
  294. "gj": "156",
  295. "hjlb": "03",
  296. "xzqhId": "220000000000"
  297. },
  298. tkflData: [{
  299. value: "0",
  300. text: "独居老人"
  301. },
  302. {
  303. value: "1",
  304. text: "分散供养特困老人"
  305. },
  306. {
  307. value: "2",
  308. text: "高龄老人"
  309. },
  310. {
  311. value: "3",
  312. text: "计划生育特殊家庭老人"
  313. },
  314. {
  315. value: "4",
  316. text: "空巢老人"
  317. },
  318. {
  319. value: "5",
  320. text: "农村留守老人"
  321. },
  322. {
  323. value: "6",
  324. text: "失能老人"
  325. },
  326. {
  327. value: "7",
  328. text: "重残老人"
  329. }
  330. ],
  331. xqahData: [{
  332. value: "0",
  333. text: "棋牌"
  334. },
  335. {
  336. value: "1",
  337. text: "户外活动"
  338. },
  339. {
  340. value: "2",
  341. text: "旅游出行"
  342. },
  343. {
  344. value: "3",
  345. text: "书法"
  346. },
  347. {
  348. value: "4",
  349. text: "唱歌"
  350. },
  351. {
  352. value: "5",
  353. text: "跳舞"
  354. },
  355. {
  356. value: "6",
  357. text: "花艺"
  358. },
  359. {
  360. value: "7",
  361. text: "女工"
  362. },
  363. {
  364. value: "8",
  365. text: "其他"
  366. }
  367. ],
  368. jntcData: [{
  369. value: "0",
  370. text: "水电暖"
  371. },
  372. {
  373. value: "1",
  374. text: "家电维修"
  375. },
  376. {
  377. value: "2",
  378. text: "医护"
  379. },
  380. {
  381. value: "3",
  382. text: "教辅"
  383. },
  384. {
  385. value: "4",
  386. text: "文体"
  387. },
  388. {
  389. value: "5",
  390. text: "其他"
  391. }
  392. ],
  393. lrxqData: [{
  394. value: "zc",
  395. text: "助餐"
  396. },
  397. {
  398. value: "zg",
  399. text: "助购"
  400. },
  401. {
  402. value: "zx",
  403. text: "助行"
  404. },
  405. {
  406. value: "zz",
  407. text: "助浴"
  408. },
  409. {
  410. value: "zj",
  411. text: "助洁"
  412. },
  413. {
  414. value: "zl",
  415. text: "助乐"
  416. },
  417. {
  418. value: "zy",
  419. text: "助医"
  420. },
  421. {
  422. value: "zi",
  423. text: "助急"
  424. },
  425. {
  426. value: "djfy",
  427. text: "代缴费用"
  428. },
  429. {
  430. value: "zyly",
  431. text: "住养老院"
  432. },
  433. {
  434. value: "kfxl",
  435. text: "康复训练"
  436. },
  437. {
  438. value: "qtxq",
  439. text: "其他"
  440. }
  441. ],
  442. bsData: [{
  443. value: "0",
  444. text: "神经系统病史"
  445. },
  446. {
  447. value: "1",
  448. text: "呼吸系统病史"
  449. },
  450. {
  451. value: "2",
  452. text: "消化系统病史"
  453. },
  454. {
  455. value: "3",
  456. text: "循环系统病史"
  457. },
  458. {
  459. value: "4",
  460. text: "泌尿系统病史"
  461. },
  462. {
  463. value: "5",
  464. text: "运动系统病史"
  465. },
  466. {
  467. value: "6",
  468. text: "生殖系统病史"
  469. },
  470. {
  471. value: "7",
  472. text: "内分泌系统病史"
  473. },
  474. {
  475. value: "8",
  476. text: "肿瘤病史"
  477. },
  478. {
  479. value: "9",
  480. text: "心脑血管病史"
  481. },
  482. {
  483. value: "10",
  484. text: "糖尿病史"
  485. },
  486. {
  487. value: "11",
  488. text: "痛风病史"
  489. }
  490. ],
  491. bhList: [],
  492. myAmapFunT: '',
  493. startPoint: {
  494. latitude: 43.834931,
  495. longitude: 125.289036
  496. },
  497. // 家庭信息列表请求参数
  498. familyParams: {
  499. pageNum: 1,
  500. pageSize: 10,
  501. khId: null,
  502. },
  503. familyList: [],
  504. familyForm: {
  505. jtcygx: null,
  506. jtcyxm: null,
  507. jtcyxb: null,
  508. jtcylxdh: null,
  509. jtcyjzd: null,
  510. },
  511. familyRules: {
  512. jtcygx: {
  513. rules: [{
  514. required: true,
  515. errorMessage: '请选择与老年人关系'
  516. }]
  517. },
  518. jtcyxb: {
  519. rules: [{
  520. required: true,
  521. errorMessage: '请选择性别'
  522. }]
  523. },
  524. jtcyxm: {
  525. rules: [{
  526. required: true,
  527. errorMessage: '请输入姓名'
  528. }]
  529. },
  530. jtcyjzd: {
  531. rules: [{
  532. required: true,
  533. errorMessage: '请输入地址'
  534. }]
  535. },
  536. jtcylxdh: {
  537. rules: [{
  538. required: true,
  539. errorMessage: '请输入手机号'
  540. },
  541. {
  542. format: 'number',
  543. errorMessage: '请输入正确的手机号',
  544. },
  545. {
  546. pattern: '^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\\d{8})$',
  547. errorMessage: '请输入正确的手机号',
  548. }
  549. ]
  550. },
  551. },
  552. // 病患记录列表请求参数
  553. bhlsParams: {
  554. pageNum: 1,
  555. pageSize: 10,
  556. khId: null,
  557. },
  558. bhlsList: [],
  559. }
  560. },
  561. created() {
  562. this.getDictList(Object.keys(this.dicts), this.dicts)
  563. },
  564. onLoad(option) {
  565. if (option.item) {
  566. this.baseFormData = JSON.parse(option.item)
  567. if (this.baseFormData.xm) {
  568. this.familyParams.khId = this.baseFormData.id
  569. this.bhlsParams.khId = this.baseFormData.id
  570. this.getFamilyList()
  571. this.getBhlsList()
  572. uni.setNavigationBarTitle({
  573. title: '修改客户信息'
  574. });
  575. this.bsFormatTo()
  576. }
  577. }
  578. this.myAmapFunT = new amapFile.AMapWX({
  579. key: config.gaodeKey
  580. })
  581. uni.$on('changeBhls', data => {
  582. if (data === 'bhls') {
  583. this.getBhlsList()
  584. }
  585. })
  586. },
  587. methods: {
  588. // 获取上传状态
  589. async select(e) {
  590. let ossfilePath = await UploadOne(e.tempFilePaths[0], {})
  591. this.baseFormData.tx = ossfilePath.data.url
  592. },
  593. getFamilyList() {
  594. listJtxx(this.familyParams).then(res => {
  595. if (res.code !== 200) return
  596. this.familyList = decryptRowData_ECB(res.rows, ['jtcyxm', 'jtcyzjhm', 'jtcylxdh', 'jtcyjzd'], [1, 2, 3,
  597. 4])
  598. })
  599. },
  600. editFamily(data = {}) {
  601. if (data) {
  602. this.familyForm = data
  603. }
  604. this.$refs.inputDialog.open()
  605. },
  606. submitFamilyForm(val) {
  607. this.$refs['familyForm'].validate().then(() => {
  608. const submitForm = {
  609. ...this.familyForm,
  610. khId: this.familyParams.khId,
  611. // 接口补充数据,不添加无法提交
  612. jtcyzjhm: "420101196302161908",
  613. jtcyzjlx: "01"
  614. };
  615. if (this.familyForm.id) {
  616. updateJtxx(submitForm).then(res => {
  617. if (res.code !== 200) return
  618. // 关闭窗口后,恢复默认内容
  619. uni.showToast({
  620. title: `修改成功!`,
  621. duration: 2000,
  622. success: (res) => {
  623. this.$refs.inputDialog.close()
  624. }
  625. })
  626. })
  627. } else {
  628. addJtxx(submitForm).then(res => {
  629. if (res.code !== 200) return
  630. // 关闭窗口后,恢复默认内容
  631. uni.showToast({
  632. title: `新增成功!`,
  633. duration: 2000,
  634. success: (res) => {
  635. this.getFamilyList()
  636. this.$refs.inputDialog.close()
  637. }
  638. })
  639. })
  640. }
  641. }).catch(err => {
  642. console.log('err', err);
  643. })
  644. },
  645. // 弹出取消
  646. cance() {
  647. this.$refs.familyForm.clearValidate()
  648. this.$refs.inputDialog.close()
  649. },
  650. getBhlsList() {
  651. listKhbhls(this.bhlsParams).then(res => {
  652. if (res.code !== 200) return
  653. this.bhlsList = res.rows
  654. })
  655. },
  656. editBhls(data) {
  657. uni.navigateTo({
  658. url: `/pages/lr/bhAdd?item=${JSON.stringify(data)}&id=${this.baseFormData.id}&xm=${this.baseFormData.xm}`,
  659. })
  660. },
  661. // tab切换
  662. changeTab(e) {
  663. this.active = this.list.indexOf(e.tab)
  664. this.activeName = e.tab
  665. },
  666. next(isSave) {
  667. this.$refs['baseForm'].validate().then(res => {
  668. if (isSave) {
  669. this.bsFormatFrom()
  670. if (this.baseFormData.id) {
  671. // 修改
  672. updateKhjbxx(this.baseFormData).then(r => {
  673. if (r.code !== 200) return
  674. uni.showToast({
  675. title: `修改成功!`,
  676. duration: 2000,
  677. success: function(res) {
  678. setTimeout(function() {
  679. uni.switchTab({
  680. url: '/pages/index/index'
  681. });
  682. }, 2000)
  683. }
  684. })
  685. })
  686. } else {
  687. // 新增
  688. addKhjbxx(this.baseFormData).then(r => {
  689. if (r.code !== 200) return
  690. uni.showToast({
  691. title: `新增成功!`,
  692. duration: 2000,
  693. success: function(res) {
  694. setTimeout(function() {
  695. uni.switchTab({
  696. url: '/pages/index/index'
  697. });
  698. }, 2000)
  699. }
  700. })
  701. })
  702. }
  703. } else {
  704. this.active = 1
  705. }
  706. }).catch(err => {
  707. console.log("err", err)
  708. uni.showModal({
  709. title: '错误提示',
  710. content: err[0].errorMessage,
  711. showCancel: false,
  712. success: function(res) {
  713. if (res.confirm) {
  714. console.log('用户点击确定');
  715. } else if (res.cancel) {
  716. console.log('用户点击取消');
  717. }
  718. }
  719. });
  720. })
  721. },
  722. // 地图弹出
  723. async openChooseLocation(opt) {
  724. let that = this
  725. await uni.chooseLocation({
  726. latitude: opt?.latitude || that.startPoint.latitude,
  727. longitude: opt?.longitude || that.startPoint.longitude,
  728. success: function(res) {
  729. // console.log(res)
  730. that.baseFormData.dw = res.name
  731. that.baseFormData.lng = res.longitude
  732. that.baseFormData.lat = res.latitude
  733. that.baseFormData.zzjwd = res.longitude + ',' + res.latitude
  734. if (!res.name) {
  735. return uni.showToast({
  736. title: '请重新选择位置',
  737. icon: 'none'
  738. });
  739. }
  740. },
  741. fail: function(info) { //失败回调
  742. console.log('调取失败')
  743. console.log(info)
  744. },
  745. })
  746. },
  747. // 指定位置替换
  748. replaceStringByIndex(str, oldChar, newChar, index) {
  749. return str.substring(0, index) + newChar + str.substring(index + 1);
  750. },
  751. // 数组转10进制
  752. formatInt10(value, like) {
  753. let len = like.length
  754. if (value.length == 0) {
  755. this.baseFormData.xqah = like
  756. } else {
  757. value.forEach(e => {
  758. like = this.replaceStringByIndex(like, '0', '1', e)
  759. if (like.length != len) {
  760. for (let i = 0; i < len - like.length; i++) {
  761. like += '0'
  762. }
  763. }
  764. })
  765. }
  766. return parseInt(like.toString().split('').reverse().join(''), 2)
  767. },
  768. // 数组转2进制
  769. formatInt2(value) {
  770. let xqaix = decimalToBinary(value).split('')
  771. let result = []
  772. if (xqaix != 0) {
  773. xqaix.forEach((e, i) => {
  774. if (e == 1) {
  775. result.push(i.toString())
  776. }
  777. })
  778. }
  779. return result
  780. },
  781. bsFormatFrom() {
  782. this.baseFormData.tkfl = this.formatInt10(this.baseFormData.tkflData, '00000000')
  783. this.baseFormData.xqah = this.formatInt10(this.baseFormData.xqahData, '000000000')
  784. this.baseFormData.jntc = this.formatInt10(this.baseFormData.jntcData, '000000')
  785. if (this.baseFormData.csrq) {
  786. this.baseFormData.csrq = this.baseFormData.csrq.replaceAll('-', '')
  787. }
  788. if (this.baseFormData.bs.length > 0) {
  789. this.baseFormData.bs.forEach(e => {
  790. if (e == '0') {
  791. this.baseFormData.daIsSjxtbs = '1'
  792. } else if (e == '1') {
  793. this.baseFormData.daIsHxxtbs = '1'
  794. } else if (e == '2') {
  795. this.baseFormData.daIsXhxtbs = '1'
  796. } else if (e == '3') {
  797. this.baseFormData.daIsXhxtbsb = '1'
  798. } else if (e == '4') {
  799. this.baseFormData.daIsMnxtbs = '1'
  800. } else if (e == '5') {
  801. this.baseFormData.daIsYdxtbs = '1'
  802. } else if (e == '6') {
  803. this.baseFormData.daIsSzxtbs = '1'
  804. } else if (e == '7') {
  805. this.baseFormData.daIsNfmxtbs = '1'
  806. } else if (e == '8') {
  807. this.baseFormData.daIsZlbs = '1'
  808. } else if (e == '9') {
  809. this.baseFormData.daIsXnxgbs = '1'
  810. } else if (e == '10') {
  811. this.baseFormData.daIsTnbs = '1'
  812. } else if (e == '11') {
  813. this.baseFormData.daIsTfbs = '1'
  814. }
  815. })
  816. }
  817. },
  818. bsFormatTo() {
  819. if (this.baseFormData.xqah) {
  820. this.baseFormData.xqahData = this.formatInt2(this.baseFormData.xqah)
  821. }
  822. if (this.baseFormData.jntc) {
  823. this.baseFormData.jntcData = this.formatInt2(this.baseFormData.jntc)
  824. }
  825. if (this.baseFormData.tkfl) {
  826. this.baseFormData.tkflData = this.formatInt2(this.baseFormData.tkfl)
  827. }
  828. if (this.baseFormData.csrq) {
  829. let riqi = this.baseFormData.csrq
  830. let riqi1 = riqi.slice(0, 4) + '-' + riqi.slice(4)
  831. this.baseFormData.csrq = riqi1.slice(0, 7) + '-' + riqi1.slice(7)
  832. }
  833. if (this.baseFormData.tx) {
  834. this.baseFormData.head = [{
  835. url: this.baseFormData.tx
  836. }]
  837. }
  838. this.baseFormData.bs = []
  839. if (this.baseFormData.daIsSjxtbs == '1') {
  840. this.baseFormData.bs.push('0')
  841. }
  842. if (this.baseFormData.daIsHxxtbs == '1') {
  843. this.baseFormData.bs.push('1')
  844. }
  845. if (this.baseFormData.daIsXhxtbs == '1') {
  846. this.baseFormData.bs.push('2')
  847. }
  848. if (this.baseFormData.daIsXhxtbsb == '1') {
  849. this.baseFormData.bs.push('3')
  850. }
  851. if (this.baseFormData.daIsMnxtbs == '1') {
  852. this.baseFormData.bs.push('4')
  853. }
  854. if (this.baseFormData.daIsYdxtbs == '1') {
  855. this.baseFormData.bs.push('5')
  856. }
  857. if (this.baseFormData.daIsSzxtbs == '1') {
  858. this.baseFormData.bs.push('6')
  859. }
  860. if (this.baseFormData.daIsNfmxtbs == '1') {
  861. this.baseFormData.bs.push('7')
  862. }
  863. if (this.baseFormData.daIsZlbs == '1') {
  864. this.baseFormData.bs.push('8')
  865. }
  866. if (this.baseFormData.daIsXnxgbs == '1') {
  867. this.baseFormData.bs.push('9')
  868. }
  869. if (this.baseFormData.daIsTnbs == '1') {
  870. this.baseFormData.bs.push('10')
  871. }
  872. if (this.baseFormData.daIsTfbs == '1') {
  873. this.baseFormData.bs.push('11')
  874. }
  875. }
  876. }
  877. }
  878. </script>
  879. <style lang="scss" scoped>
  880. .line {
  881. border-bottom: 10px solid #f0f0f0;
  882. height: 1px;
  883. margin-top: 10px;
  884. }
  885. .bottomButton {
  886. height: 140rpx;
  887. width: 60%;
  888. margin: 0 auto;
  889. text-align: center;
  890. button {
  891. width: 40%;
  892. }
  893. button+button {
  894. margin-left: 15px;
  895. }
  896. }
  897. .line-item {
  898. /deep/ .checklist-group {
  899. justify-content: space-around;
  900. .checklist-box.is--button {
  901. width: 36%;
  902. margin-right: 0;
  903. }
  904. }
  905. }
  906. /deep/ .uni-section .uni-section-header {
  907. padding: 0;
  908. }
  909. </style>