newAdd.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <template>
  2. <div class="main">
  3. <div></div>
  4. <div class="formContent">
  5. <div class="formContent-item">
  6. <div class="formContent-item_title">基础信息</div>
  7. <div class="formContent-formList">
  8. <zz-form :cols="formCols" :data="formData" :rules="formRules" :errors="formErrors" labelWidth="70" ref="form">
  9. <!-- 添加编辑 -->
  10. <template>
  11. <template slot="sex">
  12. <el-radio v-model="formData.sex" :label="0">未知</el-radio>
  13. <el-radio v-model="formData.sex" :label="1">男</el-radio>
  14. <el-radio v-model="formData.sex" :label="2">女</el-radio>
  15. </template>
  16. <template slot="remarks">
  17. <el-input type="textarea" v-model="formData.remark" maxlength="50" placeholder="请输入备注"> </el-input>
  18. </template>
  19. </template>
  20. </zz-form>
  21. <template>
  22. <div class="clickUpload">
  23. <div class="clickUpText">
  24. <img class="dataImg" v-if="!!formData.facePictureUrl" :src="formData.facePictureUrl" />
  25. <template v-else>
  26. <img class="bg-img" src="@/assets/img/ownerManagement/img_zhaopian2@2x.png" alt="" />
  27. <div>点击添加人脸照片</div>
  28. </template>
  29. </div>
  30. <el-upload
  31. :headers="token"
  32. ref="uploaduserlogo"
  33. class="mini-upload"
  34. limit="1"
  35. action="/sc-community/upload/uploadFile"
  36. :on-success="uploadsuccess"
  37. :before-upload="beforeAvatarUpload"
  38. :auto-upload="true"
  39. name="file"
  40. >
  41. </el-upload>
  42. </div>
  43. </template>
  44. </div>
  45. </div>
  46. <div class="formContent-item">
  47. <div class="formContent-item_title">证件信息</div>
  48. <zz-form :cols="formCols2" :data="formData" :errors="formErrors" labelWidth="70">
  49. <!-- 添加编辑 -->
  50. <template>
  51. <template slot="idType">
  52. <el-select v-model="formData.idType" clearable class="width100">
  53. <el-option v-for="(item, index) in idTypeArray" :key="index" :label="item.label" :value="item.status">{{
  54. item.label
  55. }}</el-option>
  56. </el-select>
  57. </template>
  58. <template slot="nationality">
  59. <el-select v-model="formData.nationality" clearable class="width100">
  60. <el-option
  61. v-for="(item, index) in nationalityArray"
  62. :key="index"
  63. :label="item.label"
  64. :value="item.status"
  65. >{{ item.label }}</el-option
  66. >
  67. </el-select>
  68. </template>
  69. <template slot="nativePlace">
  70. <el-select v-model="formData.nativePlace" clearable class="width100">
  71. <el-option v-for="(item, index) in nativePlaceArray" :key="index" :label="item.name" :value="item.code">{{
  72. item.name
  73. }}</el-option>
  74. </el-select>
  75. </template>
  76. <template slot="nation">
  77. <el-select v-model="formData.nation" clearable class="width100">
  78. <el-option v-for="(item, index) in nationArray" :key="index" :label="item.name" :value="item.code">{{
  79. item.name
  80. }}</el-option>
  81. </el-select>
  82. </template>
  83. <template slot="birthDate">
  84. <el-date-picker
  85. class="width100"
  86. v-model="formData.birthDate"
  87. value-format="yyyy-MM-dd HH:mm:ss"
  88. type="date"
  89. :picker-options="pickerOptions"
  90. placeholder="选择日期"
  91. >
  92. </el-date-picker>
  93. </template>
  94. <template slot="effectiveDate">
  95. <el-date-picker
  96. class="width100"
  97. v-model="effectiveDate"
  98. value-format="yyyy-MM-dd HH:mm:ss"
  99. type="daterange"
  100. range-separator="至"
  101. start-placeholder="选择开始日期"
  102. end-placeholder="选择结束日期"
  103. @change="effectiveDateToggle"
  104. :editable="false"
  105. ></el-date-picker>
  106. </template>
  107. </template>
  108. </zz-form>
  109. </div>
  110. <div class="formContent-item">
  111. <div class="formContent-item_title"><span class="show-required-icon-star"></span> 绑定房产和车位</div>
  112. <div class="ownerScroll">
  113. <div class="formContent-formList house" v-for="(item, index) in formData.houseList" :key="index">
  114. <div class="block-title">
  115. <div class="floor list-title">
  116. {{ `${item.buildingName} ${!!item.unitName ? CheckChinese(item.unitName, '单元') : ''}${item.roomNumber}` }}
  117. </div>
  118. <!-- <span class="remove list-title" @click="removeHouse(index)">移除</span> -->
  119. <img class="bg-img" src="@/assets/img/ownerManagement/bg_card@2x.png" alt="" />
  120. <img class="bg-imgIoc" src="@/assets/img/ownerManagement/icon_building@2x.png" alt="" />
  121. </div>
  122. <zz-form :cols="formCols3" :data="item" :rules="formRules" :errors="formErrors" labelWidth="70">
  123. <!-- 添加编辑 -->
  124. <template>
  125. <template slot="householdType">
  126. <el-select v-model="item.householdType" clearable @change="householdTypeHide(item)">
  127. <el-option
  128. v-for="(item, index) in householdTypeArray"
  129. :key="index"
  130. :label="item.label"
  131. :value="item.status"
  132. >{{ item.label }}</el-option
  133. >
  134. </el-select>
  135. </template>
  136. <template slot="checkInDate">
  137. <el-date-picker
  138. v-model="item.checkInDate"
  139. value-format="yyyy-MM-dd HH:mm:ss"
  140. type="date"
  141. placeholder="选择日期"
  142. >
  143. </el-date-picker> </template
  144. ></template>
  145. </zz-form>
  146. <div class="block-title car" v-for="(items, indexs) in item.parkingList" :key="indexs">
  147. <div class="floor list-title">
  148. {{ `${items.garageName}${items.areaName || items.partitionName || ''}-${items.parkingNumber}` }}
  149. </div>
  150. <span class="remove list-title" @click="removeCard(indexs, item)">移除</span>
  151. <img class="bg-img" src="@/assets/img/ownerManagement/bg_card@2x.png" alt="" />
  152. <img class="bg-imgIoc" src="@/assets/img/ownerManagement/icon_car@2x.png" alt="" />
  153. </div>
  154. <div class="addHouse block-title" v-if="!!formData.houseList.length" @click="addCard(item)">
  155. <div class="floor list-title">绑定车位</div>
  156. <img class="bg-img" src="@/assets/img/ownerManagement/bg_card@2x.png" alt="" />
  157. <img class="bg-imgIoc" src="@/assets/img/ownerManagement/icon_car@2x.png" alt="" />
  158. <img class="add" src="@/assets/img/ownerManagement/btn_add@2x.png" />
  159. </div>
  160. <el-button
  161. class="removeHouseButton"
  162. type="primary"
  163. @click="removeHouse(index)"
  164. v-if="formData.houseList.length !== 0"
  165. >删除房产</el-button
  166. >
  167. </div>
  168. <div class="addHouse block-title" v-if="formData.houseList.length == 0" @click="addHouse()">
  169. <div class="floor list-title">绑定房产</div>
  170. <img class="bg-img" src="@/assets/img/ownerManagement/bg_card@2x.png" alt="" />
  171. <img class="bg-imgIoc" src="@/assets/img/ownerManagement/icon_building@2x.png" alt="" />
  172. <img class="add" src="@/assets/img/ownerManagement/btn_add@2x.png" />
  173. </div>
  174. <el-button class="addHouseButton" type="primary" @click="addHouse()" v-if="formData.houseList.length !== 0"
  175. >新增房产</el-button
  176. >
  177. </div>
  178. </div>
  179. </div>
  180. <div class="buttons">
  181. <el-button @click="closes">取消</el-button>
  182. <el-button type="primary" @click="addEdit()">保存</el-button>
  183. </div>
  184. </div>
  185. </template>
  186. <script>
  187. export default {
  188. name: 'ownerManagementAdd',
  189. props: {
  190. params: {
  191. type: Object
  192. },
  193. islook: {
  194. type: Boolean,
  195. default: false
  196. },
  197. isAdd: {
  198. type: Boolean,
  199. default: true
  200. }
  201. },
  202. filters: {
  203. matchingVal(val, arr) {
  204. let v = '';
  205. if (!!val) {
  206. arr.forEach((item) => {
  207. if (!!item.status && item.status === val) {
  208. v = item.label;
  209. } else if (!!item.code && item.code === val) {
  210. v = item.name;
  211. }
  212. });
  213. }
  214. return v;
  215. }
  216. },
  217. data() {
  218. return {
  219. token: {
  220. [localStorage.getItem('SC_token') && 'Authorization']: 'Bearer ' + localStorage.getItem('SC_token')
  221. },
  222. pickerOptions: {
  223. disabledDate(val) {
  224. // return val.getTime() < Date.now() - 8.64e7;
  225. return +new Date(val) > +new Date();
  226. }
  227. },
  228. effectiveDate: [],
  229. formData: {
  230. name: '',
  231. phone: '',
  232. personnelNumber: '',
  233. sex: 0,
  234. remarks: '',
  235. facePictureUrl: '',
  236. id: 0,
  237. idType: '',
  238. idNumber: '',
  239. permanentAddress: '',
  240. issuingAuthority: '',
  241. effectiveDateStart: '',
  242. effectiveDateEnd: '',
  243. nationality: 1,
  244. nativePlace: '',
  245. nation: '',
  246. birthDate: '',
  247. houseList: []
  248. },
  249. formCols: [
  250. [
  251. {
  252. label: '姓名',
  253. prop: 'name',
  254. slot: 'name',
  255. input: true
  256. },
  257. {
  258. label: '手机号',
  259. prop: 'phone',
  260. slot: 'phone',
  261. input: true
  262. },
  263. {
  264. label: '人员编号',
  265. prop: 'personnelNumber',
  266. slot: 'personnelNumber',
  267. input: true
  268. },
  269. {
  270. label: '性别',
  271. prop: 'sex',
  272. slot: 'sex'
  273. },
  274. {
  275. label: '备注',
  276. prop: 'remarks',
  277. slot: 'remarks'
  278. }
  279. ]
  280. ],
  281. formCols2: [
  282. [
  283. {
  284. label: '证件类型',
  285. prop: 'idType',
  286. slot: 'idType'
  287. },
  288. {
  289. label: '证件号码',
  290. prop: 'idNumber',
  291. slot: 'idNumber',
  292. input: true
  293. },
  294. {
  295. label: '户籍地址',
  296. prop: 'permanentAddress',
  297. slot: 'permanentAddress',
  298. input: true
  299. },
  300. {
  301. label: '签发机关',
  302. prop: 'issuingAuthority',
  303. slot: 'issuingAuthority',
  304. input: true
  305. },
  306. {
  307. label: '有效期',
  308. prop: 'effectiveDate',
  309. slot: 'effectiveDate'
  310. },
  311. {
  312. label: '国籍',
  313. prop: 'nationality',
  314. slot: 'nationality'
  315. },
  316. {
  317. label: '籍贯',
  318. prop: 'nativePlace',
  319. slot: 'nativePlace'
  320. },
  321. {
  322. label: '民族',
  323. prop: 'nation',
  324. slot: 'nation'
  325. },
  326. {
  327. label: '出生日期',
  328. prop: 'birthDate',
  329. slot: 'birthDate'
  330. }
  331. ]
  332. ],
  333. formCols3: [
  334. [
  335. {
  336. label: '类型',
  337. prop: 'householdType',
  338. slot: 'householdType',
  339. showRequired: true
  340. },
  341. {
  342. label: '入住时间',
  343. prop: 'checkInDate',
  344. slot: 'checkInDate'
  345. }
  346. ]
  347. ],
  348. nationalityArray: [
  349. {
  350. status: 1,
  351. label: '中国'
  352. },
  353. {
  354. status: 2,
  355. label: '其他'
  356. }
  357. ],
  358. idTypeArray: [
  359. {
  360. status: 1,
  361. label: '居民身份证'
  362. },
  363. {
  364. status: 2,
  365. label: '居民户口簿'
  366. },
  367. {
  368. status: 3,
  369. label: '暂住证'
  370. },
  371. {
  372. status: 4,
  373. label: '其他'
  374. }
  375. ],
  376. householdTypeArray: [
  377. {
  378. status: 1,
  379. label: '业主'
  380. },
  381. {
  382. status: 2,
  383. label: '亲属'
  384. },
  385. {
  386. status: 3,
  387. label: '租客'
  388. }
  389. ],
  390. formRules: {
  391. name: [this.$valid.selectRequired('填写姓名')],
  392. phone: [this.$valid.selectRequired('填写手机号')],
  393. householdType: [this.$valid.selectRequired('填写类型')]
  394. },
  395. communityArr: [],
  396. garageArr: []
  397. };
  398. },
  399. created() {
  400. this.$store.dispatch('collapse', true);
  401. if (!!this.params.id) {
  402. this.getDetails(this.params.id);
  403. } else {
  404. if (this.$parent.thisLeftData.type == 'room') {
  405. this.formData.houseList = [
  406. {
  407. checkInDate: '',
  408. householdType: 1,
  409. buildingName: this.$parent.thisLeftData.buildingName,
  410. unitName: this.$parent.thisLeftData.unitName,
  411. roomNumber: this.$parent.thisLeftData.houseName,
  412. houseId: this.$parent.thisLeftData.houseId,
  413. parkingList: []
  414. }
  415. ];
  416. }
  417. }
  418. this.getTenantsTree();
  419. },
  420. beforeDestroy() {
  421. this.$store.dispatch('collapse', false);
  422. },
  423. computed: {
  424. nationArray() {
  425. return this.$store.getters['getNationArray'];
  426. },
  427. nativePlaceArray() {
  428. return this.$store.getters['getNativeArray'];
  429. }
  430. },
  431. methods: {
  432. getDetails(id) {
  433. let url = '/sc-community/scResident/find/' + id;
  434. this.$http
  435. .get(url)
  436. .then(({ data, status, msg }) => {
  437. if (0 === status) {
  438. let { effectiveDateStart, effectiveDateEnd } = data;
  439. if (effectiveDateStart == null || effectiveDateEnd == null) {
  440. effectiveDateStart = '';
  441. effectiveDateEnd = '';
  442. }
  443. this.effectiveDate = [effectiveDateStart, effectiveDateEnd];
  444. this.formData = data;
  445. } else {
  446. this.$message.error(msg);
  447. }
  448. })
  449. .catch(() => {});
  450. },
  451. lookFormCols(cols) {
  452. this[cols][0].forEach((item, index) => {
  453. if (!!item.input) {
  454. item.input = false;
  455. }
  456. });
  457. },
  458. uploadsuccess(response, file, fileList) {
  459. this.$refs.uploaduserlogo.clearFiles();
  460. if (0 === response.status) {
  461. this.formData.facePictureUrl = response.data;
  462. }
  463. },
  464. beforeAvatarUpload(file) {
  465. const isJPG = file.type === 'image/jpeg';
  466. const isLt2M = file.size / 1024 / 1024 < 2;
  467. if (!isJPG) {
  468. this.$message.error('上传头像图片只能是 JPG 格式!');
  469. }
  470. if (!isLt2M) {
  471. this.$message.error('上传头像图片大小不能超过 2MB!');
  472. }
  473. return isJPG && isLt2M;
  474. },
  475. effectiveDateToggle(va) {
  476. let arr = va;
  477. if (!arr) {
  478. arr = ['', ''];
  479. }
  480. this.formData.effectiveDateStart = arr[0];
  481. this.formData.effectiveDateEnd = arr[1];
  482. },
  483. addHouse() {
  484. new Promise((resolve) => {
  485. this.$store.dispatch('addPopup', {
  486. url: '/ownerManagement/stepPage/poptreeSelect.vue',
  487. width: '500px',
  488. height: '400px',
  489. props: {
  490. num: 1,
  491. list: this.formData.houseList || [],
  492. tenantsTree: this.communityArr,
  493. callback: resolve
  494. },
  495. title: '选择房产',
  496. notip: true
  497. });
  498. }).then((res) => {
  499. if (res.length > 0) {
  500. res.forEach((item, index) => {
  501. let newObj = {
  502. checkInDate: '',
  503. householdType: 1,
  504. buildingName: item.buildingName,
  505. unitName: item.unitName,
  506. roomNumber: item.roomNumber,
  507. houseId: item.houseId,
  508. parkingList: []
  509. };
  510. let isExit = this.formData['houseList'].some((is) => {
  511. return is.houseId == item.houseId;
  512. });
  513. if (!isExit) {
  514. this.formData['houseList'].push(newObj);
  515. }
  516. });
  517. }
  518. });
  519. },
  520. addCard(itemObj) {
  521. if (itemObj.householdType !== 1) {
  522. this.$message.error('只能业主才能绑定车位');
  523. return;
  524. }
  525. new Promise((resolve) => {
  526. this.$store.dispatch('addPopup', {
  527. url: '/ownerManagement/stepPage/poptreeSelect.vue',
  528. width: '500px',
  529. height: '400px',
  530. props: {
  531. num: 2,
  532. list: itemObj.parkingList || [],
  533. tenantsTree: this.garageArr,
  534. callback: resolve
  535. },
  536. title: '选择车位',
  537. notip: true
  538. });
  539. }).then((res) => {
  540. if (res.length > 0) {
  541. res.forEach((item, index) => {
  542. let newObj = {
  543. parkingId: item.parkingId,
  544. parkingNumber: item.parkingNumber,
  545. partitionName: item.partitionName,
  546. garageName: item.garageName
  547. };
  548. let isExit = itemObj['parkingList'].some((is) => {
  549. return is.parkingId == item.parkingId;
  550. });
  551. if (!isExit) {
  552. itemObj['parkingList'].push(newObj);
  553. }
  554. });
  555. }
  556. });
  557. },
  558. removeHouse(index) {
  559. this.formData['houseList'].splice(index, 1);
  560. },
  561. removeCard(index, itemObj) {
  562. itemObj['parkingList'].splice(index, 1);
  563. },
  564. closes() {
  565. if (this.$route.query.showDialog) {
  566. this.$router.replace('/workbench/index');
  567. }
  568. this.$emit('clerOwnerStatus');
  569. },
  570. addEdit() {
  571. let _this = this;
  572. if (this.formData.houseList.length === 0) {
  573. this.$message.error('房产必须绑定');
  574. return;
  575. }
  576. new Promise((resolve) => {
  577. this.$refs.form.validate(resolve);
  578. })
  579. .then(() => {
  580. let url = '/sc-community/scResident/add';
  581. let params = this.formData;
  582. if (!_this.isAdd) {
  583. url = '/sc-community/scResident/update';
  584. }
  585. this.$http
  586. .post(url, params)
  587. .then(({ status, msg }) => {
  588. if (status == 0) {
  589. this.$message.success(msg);
  590. this.closes();
  591. } else {
  592. this.$message.error(msg);
  593. }
  594. })
  595. .catch(() => {});
  596. })
  597. .catch(() => {});
  598. },
  599. getTenantsTree() {
  600. this.$http.get('/sc-community/assets/tree/community/find', { buildingType: 1 }).then(({ status, data, msg }) => {
  601. if (status === 0 && data) {
  602. this.dimension(data);
  603. this.communityArr = data;
  604. }
  605. });
  606. this.$http.get('/sc-community/assets/tree/garage/find').then(({ status, data, msg }) => {
  607. if (status === 0 && data) {
  608. this.garageArr = data;
  609. }
  610. });
  611. },
  612. dimension(arr) {
  613. arr.map((item, index) => {
  614. if (!!item.children) {
  615. this.dimension(item.children);
  616. if (item.type == 'unit') {
  617. item.name = this.CheckChinese(item.name, '单元');
  618. } else if (item.type == 'building') {
  619. item.name = this.CheckChinese(item.name, '楼栋');
  620. }
  621. }
  622. });
  623. },
  624. CheckChinese(val, name) {
  625. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  626. let newVal = val;
  627. if (!reg.test(val)) {
  628. newVal = val + name;
  629. }
  630. return newVal;
  631. },
  632. householdTypeHide(item) {
  633. if (item.householdType !== 1) {
  634. item.parkingList = [];
  635. }
  636. }
  637. }
  638. };
  639. </script>
  640. <style lang="scss" scoped>
  641. @import '../style.scss';
  642. .formContent-item .ownerScroll {
  643. height: calc(100vh - 250px);
  644. overflow: auto;
  645. padding-right: 10px;
  646. &::-webkit-scrollbar {
  647. width: 5px;
  648. }
  649. &::-webkit-scrollbar-track {
  650. border-radius: 10px;
  651. background: #f4f7f9a8;
  652. }
  653. &::-webkit-scrollbar-thumb {
  654. border-radius: 10px;
  655. background: #c6c4c4a9;
  656. }
  657. .addHouse {
  658. cursor: pointer;
  659. margin-bottom: 20px !important;
  660. img.add {
  661. margin-left: 20px;
  662. width: 13px;
  663. }
  664. }
  665. .block-title.car {
  666. margin-bottom: 20px;
  667. &:nth-of-type(2n) {
  668. margin-right: 20px;
  669. }
  670. }
  671. .formContent-formList.house {
  672. flex-wrap: wrap;
  673. &::after {
  674. content: '';
  675. width: 100%;
  676. height: 1px;
  677. background: #e0e1e3;
  678. margin-bottom: 20px;
  679. }
  680. .el-form {
  681. width: calc(100% - 220px);
  682. /deep/ .el-date-editor.el-input {
  683. width: 100%;
  684. }
  685. }
  686. }
  687. .removeHouseButton {
  688. width: 80px;
  689. height: 32px;
  690. margin-bottom: 20px;
  691. }
  692. }
  693. </style>