add.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. <template>
  2. <div class="main">
  3. <!-- <div class="blockName">{{ !isAdd ? '编辑' : '新增' }}房屋(<span class="show-required-icon-star"></span>为必填项)</div> -->
  4. <el-form
  5. :model="ruleForm"
  6. :rules="rules"
  7. ref="ruleForm"
  8. label-width="130px"
  9. >
  10. <div class="formContent">
  11. <div class="formContent-item">
  12. <el-form-item
  13. label="社区名称"
  14. prop="communityId"
  15. >
  16. <el-select
  17. v-model="ruleForm.communityId"
  18. placeholder="请选择社区名称"
  19. class="width100"
  20. @change="communityIdChange"
  21. >
  22. <el-option
  23. v-for="(item, index) in communityList"
  24. :label="item.communityName"
  25. :value="item.id"
  26. :key="index"
  27. ></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="单元">
  31. <el-select
  32. v-model="ruleForm.unitName"
  33. placeholder="请选择单元"
  34. class="width100"
  35. @change="unitNameChange"
  36. >
  37. <el-option
  38. v-for="(item, index) in resunitList"
  39. :label="item.unitName"
  40. :value="item.unitName"
  41. :key="index"
  42. ></el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item
  46. label="房屋号"
  47. prop="roomNumber"
  48. >
  49. <el-input
  50. v-model="ruleForm.roomNumber"
  51. placeholder="请输入房屋号"
  52. ></el-input>
  53. </el-form-item>
  54. <el-form-item
  55. label="住宅类型"
  56. prop="residenceType"
  57. >
  58. <el-select
  59. v-model="ruleForm.residenceType"
  60. placeholder="请选择住宅类型"
  61. class="width100"
  62. >
  63. <el-option
  64. v-for="(item, index) in residenceTypeArr"
  65. :label="item.label"
  66. :value="item.value"
  67. :key="index"
  68. ></el-option>
  69. </el-select>
  70. </el-form-item>
  71. <el-form-item label="房屋编号">
  72. <el-input
  73. v-model="ruleForm.assetNumber"
  74. placeholder="请输入房屋编号"
  75. ></el-input>
  76. </el-form-item>
  77. <el-form-item label="使用面积">
  78. <el-input
  79. v-model="ruleForm.useArea"
  80. placeholder="请输入使用面积"
  81. ></el-input>
  82. </el-form-item>
  83. <el-form-item label="房屋朝向">
  84. <el-select
  85. v-model="ruleForm.orientationOfRoom"
  86. placeholder="请选择房屋朝向"
  87. class="width100"
  88. >
  89. <el-option
  90. label="东"
  91. :value="1"
  92. ></el-option>
  93. <el-option
  94. label="南"
  95. :value="2"
  96. ></el-option>
  97. <el-option
  98. label="西"
  99. :value="3"
  100. ></el-option>
  101. <el-option
  102. label="北"
  103. :value="4"
  104. ></el-option>
  105. <el-option
  106. label="东南"
  107. :value="5"
  108. ></el-option>
  109. <el-option
  110. label="西南"
  111. :value="6"
  112. ></el-option>
  113. <el-option
  114. label="西北"
  115. :value="7"
  116. ></el-option>
  117. <el-option
  118. label="东北"
  119. :value="8"
  120. ></el-option>
  121. </el-select>
  122. </el-form-item>
  123. <el-form-item label="房屋户型">
  124. <el-input
  125. v-model="housingType.roomNumber"
  126. placeholder=""
  127. style="width: 47px; margin-right: 5px;"
  128. ></el-input>室
  129. <el-input
  130. v-model="housingType.officeNumber"
  131. placeholder=""
  132. style="width:47px; margin: 5px;"
  133. ></el-input>厅
  134. <el-input
  135. v-model="housingType.guardNumber"
  136. placeholder=""
  137. style="width: 47px; margin-right: 5px;"
  138. ></el-input>卫
  139. </el-form-item>
  140. </div>
  141. <div class="formContent-item">
  142. <el-form-item
  143. label="楼栋"
  144. prop="buildingId"
  145. >
  146. <el-select
  147. v-model="ruleForm.buildingId"
  148. placeholder="请选择楼栋"
  149. class="width100"
  150. @change="buildingIdChange"
  151. >
  152. <el-option
  153. v-for="(item, index) in buildingList"
  154. :label="item.buildingName"
  155. :value="item.id"
  156. :key="index"
  157. ></el-option>
  158. </el-select>
  159. </el-form-item>
  160. <el-form-item
  161. label="楼层"
  162. prop="floorNumber"
  163. >
  164. <el-select
  165. v-model="ruleForm.floorNumber"
  166. placeholder="请选择楼层"
  167. class="width100"
  168. @change="floorNumberChange"
  169. >
  170. <el-option
  171. v-for="(items, indexs) in floorNumberList"
  172. :label="items"
  173. :value="items"
  174. :key="indexs"
  175. ></el-option>
  176. </el-select>
  177. </el-form-item>
  178. <el-form-item
  179. label="房屋类型"
  180. prop="buildingType"
  181. >
  182. <el-select
  183. v-model="ruleForm.buildingType"
  184. disabled
  185. placeholder="请选择房屋类型"
  186. class="width100"
  187. >
  188. <el-option
  189. label="住宅"
  190. :value="1"
  191. ></el-option>
  192. <el-option
  193. label="商用"
  194. :value="2"
  195. ></el-option>
  196. </el-select>
  197. </el-form-item>
  198. <el-form-item
  199. label="租售类型"
  200. prop="salesType"
  201. >
  202. <el-select
  203. v-model="ruleForm.salesType"
  204. placeholder="请选择租售类型"
  205. class="width100"
  206. >
  207. <el-option
  208. label="可租可售"
  209. :value="1"
  210. ></el-option>
  211. <el-option
  212. label="只租"
  213. :value="2"
  214. ></el-option>
  215. <el-option
  216. label="只售"
  217. :value="3"
  218. ></el-option>
  219. </el-select>
  220. </el-form-item>
  221. <el-form-item
  222. label="租售状态"
  223. prop="salesStatus"
  224. >
  225. <el-select
  226. v-model="ruleForm.salesStatus"
  227. placeholder="请选择租售状态"
  228. class="width100"
  229. >
  230. <el-option
  231. label="未租售"
  232. :value="0"
  233. ></el-option>
  234. <el-option
  235. label="已售"
  236. :value="1"
  237. ></el-option>
  238. <el-option
  239. label="已租"
  240. :value="2"
  241. ></el-option>
  242. </el-select>
  243. </el-form-item>
  244. <el-form-item label="建筑面积">
  245. <el-input
  246. v-model="ruleForm.buildingArea"
  247. placeholder="请输入建筑面积"
  248. ></el-input>
  249. </el-form-item>
  250. <el-form-item label="公摊面积">
  251. <el-input
  252. v-model="ruleForm.publicArea"
  253. placeholder="请输入公摊面积"
  254. ></el-input>
  255. </el-form-item>
  256. <el-form-item label="装修性质">
  257. <el-select
  258. v-model="ruleForm.decorateProperties"
  259. placeholder="请选择装修性质"
  260. class="width100"
  261. >
  262. <el-option
  263. label="毛胚"
  264. :value="1"
  265. ></el-option>
  266. <el-option
  267. label="简单装修"
  268. :value="2"
  269. ></el-option>
  270. <el-option
  271. label="中等装修"
  272. :value="3"
  273. ></el-option>
  274. <el-option
  275. label="精装修"
  276. :value="4"
  277. ></el-option>
  278. <el-option
  279. label="豪华装修"
  280. :value="5"
  281. ></el-option>
  282. </el-select>
  283. </el-form-item>
  284. </div>
  285. </div>
  286. <el-form-item label="备注信息">
  287. <el-input
  288. type="textarea"
  289. :rows="4"
  290. placeholder="请输入备注信息"
  291. v-model="ruleForm.remarks"
  292. maxlength="300"
  293. show-word-limit
  294. >
  295. </el-input>
  296. </el-form-item>
  297. </el-form>
  298. <!-- <div style="text-align: right">
  299. <el-button @click="cancelSaving">取消</el-button>
  300. <el-button
  301. type="primary"
  302. @click="submitForm('ruleForm')"
  303. >保存</el-button>
  304. </div> -->
  305. </div>
  306. </template>
  307. <script>
  308. // import { residenceTypeArr } from '../housPublic';
  309. export default {
  310. props: ['params'],
  311. data () {
  312. return {
  313. buildingList: [], //楼栋下拉选择列表
  314. unitList: [], //单元下拉选择列表
  315. floorNumberList: [],
  316. resunitList: [],
  317. addEditState: '',
  318. housingType: {
  319. //房屋户型,roomNumber为室,officeNumber为厅,guardNumber为卫
  320. roomNumber: '',
  321. officeNumber: '',
  322. guardNumber: ''
  323. },
  324. ruleForm: {
  325. communityId: '', //社区id
  326. buildingId: '', //楼栋id
  327. unitName: '', //单元
  328. floorNumber: '', //单元楼层
  329. roomNumber: '', //房屋号
  330. assetNumber: '',
  331. buildingType: 1, //房屋类型
  332. useArea: '', //使用面积
  333. buildingArea: '', //建筑面积
  334. orientationOfRoom: '', //房屋朝向
  335. publicArea: '', //公摊面积
  336. housingType: '', //房屋户型
  337. decorateProperties: '', //装修性质
  338. salesStatus: '', //租售状态
  339. residenceType: '', //商业住户类型
  340. salesType: '', //租售类型
  341. remarks: '' //备注
  342. },
  343. res: '',
  344. rules: {
  345. communityId: [this.$valid.selectRequired('社区')],
  346. roomNumber: [this.$valid.inputRequired('房屋号')],
  347. buildingId: [this.$valid.selectRequired('楼栋')],
  348. floorNumber: [this.$valid.selectRequired('楼层')],
  349. buildingType: [this.$valid.selectRequired('房屋类型')],
  350. residenceType: [this.$valid.selectRequired('住宅类型')],
  351. salesStatus: [this.$valid.selectRequired('租售状态')],
  352. salesType: [this.$valid.selectRequired('租售类型')]
  353. },
  354. // residenceTypeArr: residenceTypeArr.residence
  355. residenceTypeArr: [],
  356. };
  357. },
  358. components: {},
  359. computed: {
  360. communityList () {
  361. return this.$store.getters['getCommunityArray'];
  362. }
  363. },
  364. watch: {
  365. 'ruleForm.communityId' (newValue, oldValue) {
  366. if (newValue !== oldValue) {
  367. this.buildingNameList();
  368. if (this.ruleForm.floorNumber == '') {
  369. this.ruleForm.buildingId = '';
  370. this.ruleForm.unitName = '';
  371. this.ruleForm.floorNumber = '';
  372. this.ruleForm.roomNumber = '';
  373. }
  374. }
  375. },
  376. 'ruleForm.buildingId' (newValue, oldValue) {
  377. if (newValue !== oldValue) {
  378. this.unitNameList();
  379. this.unitChoice(newValue);
  380. if (this.ruleForm.floorNumber == '') {
  381. this.ruleForm.unitName = '';
  382. this.ruleForm.floorNumber = '';
  383. this.ruleForm.roomNumber = '';
  384. }
  385. }
  386. },
  387. 'ruleForm.unitName' (newValue, oldValue) {
  388. if (newValue !== oldValue) {
  389. this.unitChoice(newValue);
  390. if (this.ruleForm.roomNumber == '') {
  391. this.ruleForm.floorNumber = '';
  392. this.ruleForm.roomNumber = '';
  393. }
  394. }
  395. },
  396. unitList (val) {
  397. if (val.length !== 0) {
  398. this.unitChoice(this.ruleForm.unitName);
  399. }
  400. }
  401. },
  402. methods: {
  403. communityIdChange () {
  404. this.ruleForm.buildingId = '';
  405. this.ruleForm.unitName = '';
  406. this.ruleForm.floorNumber = '';
  407. this.ruleForm.roomNumber = '';
  408. },
  409. buildingIdChange () {
  410. this.ruleForm.unitName = '';
  411. this.ruleForm.floorNumber = '';
  412. this.ruleForm.roomNumber = '';
  413. },
  414. unitNameChange () {
  415. this.ruleForm.floorNumber = '';
  416. this.ruleForm.roomNumber = '';
  417. },
  418. floorNumberChange () {
  419. this.ruleForm.roomNumber = '';
  420. },
  421. submit () {
  422. this.$refs['ruleForm'].validate((valid) => {
  423. if (valid) {
  424. this.ruleForm.housingType =
  425. this.housingType.roomNumber + ':' + this.housingType.officeNumber + ':' + this.housingType.guardNumber;
  426. let url = '/czc-community/assets/house/add';
  427. if (!this.isAdd) {
  428. url = '/czc-community/assets/house/update';
  429. }
  430. this.$http
  431. .post(url, this.ruleForm)
  432. .then(({ status, msg }) => {
  433. if (status == 0) {
  434. this.$emit('close');
  435. this.$message.success(msg);
  436. this.cancelSaving();
  437. } else {
  438. this.$message.error(msg);
  439. }
  440. })
  441. .catch(() => { });
  442. }
  443. });
  444. },
  445. // cancelSaving () {
  446. // this.$emit('clerOwnerStatus');
  447. // },
  448. resetForm (formName) {
  449. this.$refs[formName].resetFields();
  450. },
  451. //查询楼栋下拉列表
  452. buildingNameList () {
  453. this.buildingList = [];
  454. this.$http
  455. .post('/czc-community/assets/building/list/building', { communityId: this.ruleForm.communityId })
  456. .then(({ data, status, msg }) => {
  457. if (0 === status) {
  458. this.buildingList = data;
  459. }
  460. });
  461. },
  462. unitNameList () {
  463. this.unitList = [];
  464. this.resunitList = [];
  465. this.$http.get('/czc-community/assets/building/house/find', { id: this.ruleForm.buildingId }).then((res) => {
  466. if (res.status == 0) {
  467. if (res.data.buildingUnitList.length != 0) {
  468. for (let i = 0; i < res.data.buildingUnitList.length; i++) {
  469. if (res.data.buildingUnitList[i].unitName != null && res.data.buildingUnitList[i].unitName != '') {
  470. this.resunitList.push(res.data.buildingUnitList[i])
  471. }
  472. }
  473. this.unitList = res.data.buildingUnitList;
  474. }
  475. }
  476. });
  477. },
  478. unitChoice (e) {
  479. this.floorNumberList = [];
  480. this.unitList.map((item) => {
  481. this.floorNumberList.push(item.unitFloorList[0].floorNumber);
  482. });
  483. this.floorNumberList = Array.from(new Set(this.floorNumberList))
  484. },
  485. getDetails (id) {
  486. this.$http.get('/czc-community/assets/house/find/' + id, {}).then((res) => {
  487. if (res.status == 0) {
  488. this.ruleForm = res.data;
  489. // this.ruleForm.buildingId = res.data.buildingId;
  490. console.log('this.ruleForm', this.ruleForm);
  491. if (!!this.ruleForm.housingType) {
  492. var housingTypes = this.ruleForm.housingType.split(':');
  493. this.housingType.roomNumber = housingTypes[0];
  494. this.housingType.officeNumber = housingTypes[1];
  495. this.housingType.guardNumber = housingTypes[2];
  496. }
  497. }
  498. });
  499. },
  500. async housingManagement () {
  501. this.residenceTypeArr = [];
  502. var housing = {};
  503. housing = await this.$http.get('/czc-user-center/dict/selectListByPCodes', { parentDictCodes: 'CZC_HOUSING_MANAGEMENT' });
  504. for (var k in housing) {
  505. this.residenceTypeArr.push({
  506. label: housing[k],
  507. value: Number(k)
  508. })
  509. }
  510. },
  511. },
  512. created () {
  513. this.housingManagement();
  514. if (!!this.params.row.id) {
  515. this.getDetails(this.params.row.id);
  516. }
  517. }
  518. };
  519. </script>
  520. <style lang="scss" scoped>
  521. @import '@assets/css/public-style.scss';
  522. .main {
  523. padding: 20px;
  524. background: white;
  525. .blockName {
  526. padding-bottom: 20px;
  527. margin-bottom: 20px;
  528. border-bottom: 1px solid #e0e1e3;
  529. }
  530. }
  531. .formContent {
  532. display: flex;
  533. justify-content: space-between;
  534. .formContent-item {
  535. width: 49%;
  536. }
  537. }
  538. .show-required-icon-star {
  539. &:before {
  540. content: '*';
  541. color: #f56c6c;
  542. }
  543. }
  544. </style>