add.vue 27 KB

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