newAdd.vue 26 KB

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