add.vue 26 KB

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