add.vue 26 KB

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