add.vue 28 KB

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