addoredit.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. <template>
  2. <div class="device-info_install addinstall">
  3. <div class="device_content">
  4. <div class="left_content">
  5. <div class="form_head">
  6. <p>基本信息</p>
  7. </div>
  8. <div class="form_content">
  9. <el-scrollbar
  10. class="app-list-scroll"
  11. style="height: 100%"
  12. >
  13. <div class="form_content_disform">
  14. <zz-form
  15. :cols="detailCols"
  16. :data="formdata"
  17. :rules="formrules"
  18. labelWidth="98"
  19. ref="detailform"
  20. >
  21. <el-select
  22. v-model="formdata.communityId"
  23. placeholder="请选择社区名称"
  24. slot="communityId"
  25. class="width100"
  26. >
  27. <el-option
  28. v-for="(item, index) in communityArray"
  29. :label="item.communityName"
  30. :value="item.id"
  31. :key="index"
  32. ></el-option>
  33. </el-select>
  34. <el-select
  35. v-model="formdata.buildingType"
  36. placeholder="请选择楼栋类型"
  37. slot="buildingTypeList"
  38. class="width100"
  39. >
  40. <el-option
  41. label="高层"
  42. :value="1"
  43. ></el-option>
  44. <el-option
  45. label="低层"
  46. :value="2"
  47. ></el-option>
  48. </el-select>
  49. <el-select
  50. v-model="formdata.buildingPurpose"
  51. placeholder="请选择楼栋用途"
  52. slot="buildingPurpose"
  53. class="width100"
  54. >
  55. <el-option
  56. v-for="(item, index) in buildingPurposeType"
  57. :label="item.label"
  58. :value="item.id"
  59. :key="index"
  60. ></el-option>
  61. </el-select>
  62. <el-select
  63. v-model="formdata.buildingStructure"
  64. placeholder="请选择楼栋用途"
  65. slot="buildingStructure"
  66. class="width100"
  67. >
  68. <el-option
  69. v-for="(item, index) in buildingStructureType"
  70. :label="item.label"
  71. :value="item.id"
  72. :key="index"
  73. ></el-option>
  74. </el-select>
  75. <el-input
  76. type="textarea"
  77. :rows="4"
  78. slot="remarks"
  79. show-word-limit
  80. v-model="formdata.remarks"
  81. maxlength="300"
  82. >
  83. </el-input>
  84. </zz-form>
  85. </div>
  86. </el-scrollbar>
  87. </div>
  88. </div>
  89. <div class="right_content">
  90. <div class="right_content_head">
  91. <span class="head_text">创建房屋</span>
  92. <span
  93. class="close"
  94. @click="close"
  95. >
  96. <i class="el-icon-close"></i>
  97. </span>
  98. </div>
  99. <div class="right_content_info">
  100. <div
  101. class="head_fr"
  102. v-if="isAdd"
  103. >
  104. <div class="head_content head_add">
  105. <div class="checkbox_style">
  106. <el-checkbox
  107. disabled
  108. @change="checkedUnit"
  109. v-model="initialUnitList.checkedUnit"
  110. ></el-checkbox>
  111. </div>
  112. <div class="form_content">
  113. <zz-form
  114. :cols="unitCols"
  115. labelposition="left"
  116. :rules="unitrules"
  117. :data="formdata"
  118. :disabled="!isAdd"
  119. labelWidth="50"
  120. ref="unitform"
  121. >
  122. <template
  123. slot="unitRule"
  124. prop="unitRule"
  125. >
  126. <div class="row_class">
  127. <el-radio-group
  128. :disabled="!initialUnitList.checkedUnit"
  129. v-model="initialUnitList.unit.type"
  130. @change="radioChange('unit', $event)"
  131. >
  132. <el-radio label="Number">按数字1-20生成</el-radio>
  133. <el-radio label="Letter">按字母A-Z生成</el-radio>
  134. </el-radio-group>
  135. <el-select
  136. :disabled="!initialUnitList.checkedUnit"
  137. class="w120 wfirst"
  138. v-model="initialUnitList.unit.start"
  139. prop="floorstart"
  140. placeholder="起始单元"
  141. >
  142. <el-option
  143. v-for="item in unitOptions"
  144. :key="item.value"
  145. :label="item.label"
  146. :value="item.value"
  147. >
  148. </el-option>
  149. </el-select>
  150. <el-select
  151. class="w120 wsecond"
  152. :disabled="!initialUnitList.checkedUnit"
  153. v-model="initialUnitList.unit.end"
  154. placeholder="单元数"
  155. >
  156. <el-option
  157. v-for="item in unitOptions"
  158. :key="item.value"
  159. :label="item.label"
  160. :value="item.value"
  161. >
  162. </el-option>
  163. </el-select>
  164. </div>
  165. <div class="row_class addfloo">
  166. <div class="last_level">
  167. <label class="label_text">每栋层数</label>
  168. <el-select
  169. class="w120"
  170. v-model="formdata.floorsNumber"
  171. placeholder="请选择楼栋层数"
  172. >
  173. <el-option
  174. v-for="item in floorlevelOptions"
  175. :key="item.value"
  176. :label="item.label"
  177. :value="item.value"
  178. >
  179. </el-option>
  180. </el-select>
  181. </div>
  182. <div class="last_level">
  183. <label class="label_text">每层户数</label>
  184. <el-select
  185. class="w120"
  186. v-model="formdata.householdsPerFloor"
  187. placeholder="请选择每层户数"
  188. >
  189. <el-option
  190. v-for="item in unithouseOptions"
  191. :key="item.value"
  192. :label="item.label"
  193. :value="item.value"
  194. >
  195. </el-option>
  196. </el-select>
  197. </div>
  198. <div
  199. class="last_level"
  200. v-if="isAdd"
  201. >
  202. <label class="label_text">房屋类型</label>
  203. <el-select
  204. class="w120"
  205. v-model="formdata.houseType"
  206. @change="toggleUnithOptions"
  207. placeholder="请选择每层户数"
  208. >
  209. <el-option
  210. label="住宅"
  211. :value="1"
  212. ></el-option>
  213. <el-option
  214. label="商业"
  215. :value="2"
  216. ></el-option>
  217. </el-select>
  218. </div>
  219. </div>
  220. </template>
  221. </zz-form>
  222. </div>
  223. <div class="btn_unit">
  224. <el-button
  225. type="primary"
  226. class="el-mgRight-md"
  227. :disabled="!isAdd"
  228. @click="createDoor"
  229. >{{ doorData.length ? '重新' : '' }}生成房屋</el-button>
  230. <el-button
  231. @click="clearDoor"
  232. :disabled="!isAdd"
  233. >清空房屋</el-button>
  234. </div>
  235. </div>
  236. <div class="title_class">
  237. <span class="title_txt">楼栋信息</span>
  238. <el-tooltip
  239. v-if="doorData && doorData.length > 0"
  240. class="item text-wrapper"
  241. effect="light"
  242. placement="right"
  243. >
  244. <div slot="content">
  245. 双击可对楼栋、单元名称进行自定义修改<br />单击选中楼栋、单元、单元户信息根据选中的楼栋、单元进行展示
  246. </div>
  247. <img
  248. src="@/assets/img/menuicon/icon_tishi_zhengchang.png"
  249. alt=""
  250. />
  251. </el-tooltip>
  252. </div>
  253. </div>
  254. <div class="floorinfo">
  255. <div class="door-wrap door_install">
  256. <div
  257. class="top_content"
  258. :class="!isAdd ? 'is-disabled' : ''"
  259. >
  260. <el-scrollbar
  261. class="app-list-scroll"
  262. style="height: 100%"
  263. >
  264. <div
  265. class="floor_unit"
  266. v-if="doorData && doorData.length > 0"
  267. >
  268. <div class="box clearfix">
  269. <div class="label_left">楼栋</div>
  270. <div class="el-fl-left tags">
  271. <el-tag
  272. :disable-transitions="false"
  273. data-code="build"
  274. class="active"
  275. >
  276. {{ formdata.buildingName }}
  277. </el-tag>
  278. </div>
  279. </div>
  280. <div
  281. class="box clearfix"
  282. v-if="
  283. initialUnitList.enableUnit &&
  284. doorData[buildingIndex] &&
  285. doorData[buildingIndex].unitFloorList &&
  286. doorData[buildingIndex].unitFloorList.length
  287. "
  288. >
  289. <div class="label_left">单元</div>
  290. <div class="el-fl-left tags">
  291. <el-tag
  292. :key="index2"
  293. v-for="(unit, index2) in doorData"
  294. closable
  295. :disable-transitions="false"
  296. data-code="unit"
  297. @close="handleClose('unit', index2, doorData)"
  298. @click="unitIndex = index2"
  299. :class="{ active: unitIndex === index2 }"
  300. style="position: relative ; top: 14px;"
  301. >
  302. <span @dblclick="showInput">{{ unit.unitName }}</span>
  303. <el-input
  304. style="display: none"
  305. v-model="unit.unitName"
  306. @keyup.enter.native="inputConfirm($event, doorData)"
  307. @blur="inputConfirm($event, doorData)"
  308. data-code="unit"
  309. maxlength="20"
  310. ></el-input>
  311. </el-tag>
  312. <el-button
  313. class="el-icon-plus button-new-tag"
  314. size="small"
  315. @click="showInput"
  316. style="position: relative; top: -17px;"
  317. ></el-button>
  318. <el-input
  319. class="input-new-tag"
  320. style="display: none"
  321. size="small"
  322. placeholder="请输入单元号"
  323. v-model="inputValue.unit"
  324. @keyup.enter.native="handleInputConfirm($event, doorData)"
  325. @blur="handleInputConfirm($event, doorData)"
  326. data-code="unit"
  327. maxlength="20"
  328. >
  329. </el-input>
  330. </div>
  331. </div>
  332. </div>
  333. <div
  334. v-else
  335. class="empty_floor"
  336. >
  337. <p>暂无相关信息</p>
  338. </div>
  339. <div class="title_class border_hr">
  340. <span class="title_txt">单元户信息</span>
  341. {{doorData[buildingIndex]}}
  342. <el-tooltip
  343. v-if="
  344. doorData[buildingIndex] &&
  345. doorData[buildingIndex].unitFloorList &&
  346. doorData[buildingIndex].unitFloorList.length
  347. "
  348. class="item"
  349. effect="light"
  350. placement="right"
  351. :content="unitMsg"
  352. >
  353. <img
  354. src="@/assets/img/menuicon/icon_tishi_zhengchang.png"
  355. alt=""
  356. />
  357. </el-tooltip>
  358. </div>
  359. <div
  360. class="unit"
  361. v-if="
  362. doorData[buildingIndex] &&
  363. doorData[buildingIndex].unitFloorList &&
  364. doorData[buildingIndex].unitFloorList.length
  365. "
  366. >
  367. <div
  368. class="floor"
  369. v-if="
  370. doorData[buildingIndex].unitFloorList[unitIndex] &&
  371. doorData[buildingIndex].unitFloorList[unitIndex].roomList &&
  372. doorData[buildingIndex].unitFloorList[unitIndex].roomList.length
  373. "
  374. >
  375. <!-- <h2>单元户<span>鼠标双击修改名称; 修改楼层名称后,请自行修改单元户的名称</span></h2> -->
  376. <div
  377. class="box clearfix"
  378. :key="index3"
  379. v-for="(floor, index3) in doorData[buildingIndex].unitFloorList"
  380. >
  381. <!-- <span class="el-fl-left label">楼层:</span> -->
  382. <div class="unit_left">
  383. <el-tag
  384. closable
  385. :disable-transitions="false"
  386. data-code="floor"
  387. @close="handleClose('floor', index3, doorData[buildingIndex].unitFloorList)"
  388. >
  389. <span @dblclick="showInput">{{ floor.floorNumber }}</span>
  390. <el-input
  391. style="display: none"
  392. v-model="floor.floorNumber"
  393. @keyup.enter.native="
  394. inputConfirm($event, doorData[buildingIndex].unitFloorList)
  395. "
  396. @blur="inputConfirm($event, doorData[buildingIndex].unitFloorList)"
  397. data-code="floor"
  398. maxlength="20"
  399. ></el-input>
  400. </el-tag>
  401. <span class="unit_text">层</span>
  402. </div>
  403. <span class="el-fl-left tags">
  404. <div
  405. class="door"
  406. v-if="floor"
  407. >
  408. <el-tag
  409. :key="index4"
  410. v-for="(door, index4) in floor.roomList"
  411. closable
  412. :disable-transitions="false"
  413. data-code="door"
  414. @close="handleClose('door', index4, floor.roomList)"
  415. >
  416. <span @dblclick="showInput">{{ door.roomNumber }}</span>
  417. <el-input
  418. style="display: none"
  419. v-model="door.roomNumber"
  420. @keyup.enter.native="inputConfirm($event, floor.roomList)"
  421. @blur="inputConfirm($event, floor.roomList)"
  422. data-code="door"
  423. maxlength="20"
  424. ></el-input>
  425. </el-tag>
  426. <el-button
  427. class="el-icon-plus button-new-tag"
  428. size="small"
  429. @click="showInput"
  430. ></el-button>
  431. <el-input
  432. class="input-new-tag"
  433. style="display: none"
  434. size="small"
  435. placeholder="请输入户号"
  436. v-model="inputValue.door"
  437. @keyup.enter.native="handleInputConfirm($event, floor.roomList)"
  438. @blur="handleInputConfirm($event, floor.roomList)"
  439. data-code="door"
  440. maxlength="20"
  441. >
  442. </el-input>
  443. </div>
  444. </span>
  445. </div>
  446. <div class="add-floor">
  447. <el-button
  448. class="el-icon-plus button-new-tag"
  449. size="small"
  450. @click="showInput"
  451. ></el-button>
  452. <el-input
  453. class="input-new-tag"
  454. style="display: none"
  455. size="small"
  456. placeholder="请输入楼层号"
  457. v-model="inputValue.floor"
  458. @keyup.enter.native="handleInputConfirm($event, doorData[buildingIndex].unitFloorList)"
  459. @blur="handleInputConfirm($event, doorData[buildingIndex].unitFloorList)"
  460. data-code="floor"
  461. maxlength="20"
  462. >
  463. </el-input>
  464. </div>
  465. </div>
  466. </div>
  467. <div
  468. v-else
  469. class="unit_empty"
  470. >
  471. <div class="center_text">
  472. <img
  473. src="@assets/img/menuicon/img_wuxiaoxi@2x.png"
  474. alt=""
  475. />
  476. <span>暂无相关信息</span>
  477. </div>
  478. </div>
  479. </el-scrollbar>
  480. </div>
  481. <div class="btns footer_btn">
  482. <el-button @click="resetForm">重置</el-button>
  483. <el-button @click="close">取消</el-button>
  484. <el-button
  485. type="primary"
  486. @click="submit"
  487. >保存</el-button>
  488. </div>
  489. </div>
  490. </div>
  491. </div>
  492. </div>
  493. </div>
  494. </div>
  495. </template>
  496. <script>
  497. import initList from '../mixins/initList';
  498. import { initDoor, calcDoor } from './basedata';
  499. const createContinueData = (type, num) => {
  500. //type--类型,num生成的个数
  501. let objArr = [];
  502. if (type == 'Number') {
  503. [...new Array(Number(num)).keys()].map((idx) => {
  504. let obj = { label: Number(idx) + 1, value: Number(idx) + 1 };
  505. objArr.push(obj);
  506. });
  507. } else {
  508. for (let i = 0; i < num; i++) {
  509. let letter = String.fromCharCode(65 + i);
  510. let obj = { label: letter, value: letter };
  511. objArr.push(obj);
  512. }
  513. }
  514. return objArr;
  515. };
  516. const txtI18n = {
  517. build: '楼栋',
  518. unit: '单元',
  519. floor: '楼层',
  520. door: '单元户'
  521. };
  522. export default {
  523. mixins: [initList],
  524. name: 'editBuilding',
  525. data () {
  526. return {
  527. unitCols: [[{ label: '单元', slot: 'unitRule', prop: 'unitRule' }]],
  528. detailCols: [
  529. [
  530. {
  531. label: '所属社区',
  532. prop: 'communityId',
  533. slot: 'communityId'
  534. },
  535. {
  536. label: '楼栋名称',
  537. prop: 'buildingName',
  538. input: 'true'
  539. },
  540. {
  541. label: '楼栋编号',
  542. prop: 'buildingNumber',
  543. input: 'true'
  544. },
  545. {
  546. label: '楼栋类型',
  547. prop: 'buildingTypeList',
  548. slot: 'buildingTypeList'
  549. },
  550. {
  551. label: '楼栋用途',
  552. prop: 'buildingPurpose',
  553. slot: 'buildingPurpose'
  554. },
  555. {
  556. label: '建筑结构',
  557. prop: 'buildingStructure',
  558. slot: 'buildingStructure'
  559. },
  560. {
  561. label: '建成日期',
  562. prop: 'builtDate',
  563. date: 'true',
  564. widt: true
  565. },
  566. {
  567. label: '验收日期',
  568. prop: 'acceptanceDate',
  569. date: 'true',
  570. widt: true
  571. },
  572. {
  573. label: '建筑面积',
  574. prop: 'buildingArea',
  575. input: true
  576. },
  577. {
  578. label: '使用面积',
  579. prop: 'useArea',
  580. input: 'true'
  581. },
  582. {
  583. label: '备注信息',
  584. prop: 'remarks',
  585. slot: 'remarks'
  586. }
  587. ]
  588. ],
  589. formdata: {
  590. communityId: '',
  591. buildingName: '',
  592. buildingNumber: '', //楼栋编号
  593. buildingType: '',
  594. buildingPurpose: '',
  595. buildingStructure: '',
  596. builtDate: '',
  597. acceptanceDate: '',
  598. buildingArea: '',
  599. useArea: '',
  600. remarks: '',
  601. houseType: 1,
  602. floorsNumber: '1', //每栋层数
  603. unitNumber: 1, //单元数
  604. householdsPerFloor: '1' //每层户数
  605. },
  606. initialUnitList: {
  607. checkedUnit: true,
  608. enableUnit: 1, //勾选了复选框
  609. unit: {
  610. type: 'Number', // Number letter
  611. start: '1', // 1 A单元的起始单元
  612. end: '1'
  613. }
  614. },
  615. formrules: {
  616. communityId: this.$valid.selectRequired(['社区']),
  617. buildingName: [this.$valid.inputRequired('楼栋名称')]
  618. },
  619. buildingPurposeType: [
  620. {
  621. label: '住宅楼',
  622. id: 1
  623. },
  624. {
  625. label: '商场',
  626. id: 2
  627. },
  628. {
  629. label: '写字楼',
  630. id: 3
  631. },
  632. {
  633. label: '公寓',
  634. id: 4
  635. },
  636. {
  637. label: '别墅',
  638. id: 5
  639. },
  640. {
  641. label: '自建楼',
  642. id: 6
  643. },
  644. {
  645. label: '其他',
  646. id: 7
  647. }
  648. ],
  649. buildingStructureType: [
  650. {
  651. label: '钢结构',
  652. id: 1
  653. },
  654. {
  655. label: '钢筋混凝土结构',
  656. id: 2
  657. },
  658. {
  659. label: '筋混凝土结构',
  660. id: 3
  661. },
  662. {
  663. label: '混合结构',
  664. id: 4
  665. },
  666. {
  667. label: '砖木结构',
  668. id: 5
  669. },
  670. {
  671. label: '其他结构',
  672. id: 6
  673. }
  674. ]
  675. };
  676. },
  677. props: {
  678. params: {
  679. type: Object
  680. },
  681. isAdd: {
  682. type: Boolean,
  683. default: true
  684. }
  685. },
  686. methods: {
  687. radioChange (type, val) {
  688. let length = val == 'Number' ? '20' : '26';
  689. if (val == 'Letter') {
  690. this.unitOptions = createContinueData(val, length);
  691. this.initialUnitList.unit.type = 'Letter';
  692. this.initialUnitList.unit.start = 'A';
  693. this.initialUnitList.unit.end = 'A';
  694. } else {
  695. this.initialUnitList.unit = this.copyrules.unit;
  696. this.unitOptions = createContinueData(val, length);
  697. }
  698. },
  699. resetForm () {
  700. this.formdata = {};
  701. this.formdata = this.copyformdata;
  702. // this.doorData = [];
  703. this.$refs.detailform.validateField('communityId');
  704. },
  705. checkedUnit (val) {
  706. if (val) {
  707. this.initialUnitList.enableUnit = 1;
  708. } else {
  709. this.formdata.unitNumber = 1;
  710. this.initialUnitList.enableUnit = 0;
  711. }
  712. },
  713. createDoor () {
  714. if (this.formdata.buildingName == '') {
  715. this.$message.error('先输入楼栋名称');
  716. return;
  717. }
  718. new Promise((resolve) => {
  719. this.$refs.unitform.validate(resolve);
  720. }).then((v) => {
  721. if (this.initialUnitList.checkedUnit) {
  722. this.initialUnitList.enableUnit = 1;
  723. } else {
  724. this.formdata.unitNumber = 1;
  725. this.initialUnitList.enableUnit = 0;
  726. }
  727. let isNumberUnitFlag = this.initialUnitList.unit.type == 'Number' ? true : false;
  728. let checkUnit = this.initialUnitList.unit.start <= this.initialUnitList.unit.end ? true : false;
  729. if (this.initialUnitList.checkedUnit) {
  730. if (checkUnit && isNumberUnitFlag) {
  731. this.formdata.unitNumber = this.initialUnitList.unit.end - this.initialUnitList.unit.start + 1;
  732. } else if (!isNumberUnitFlag && checkUnit) {
  733. this.formdata.unitNumber =
  734. this.initialUnitList.unit.end.charCodeAt() - this.initialUnitList.unit.start.charCodeAt() + 1;
  735. } else {
  736. this.formdata.unitNumber = 1;
  737. this.$message.error('单元起始和结束设置出错');
  738. return;
  739. }
  740. }
  741. this.doorData = initDoor(this.formdata, this.initialUnitList).generateUnit;
  742. });
  743. },
  744. handleInputConfirm (e, arr) {
  745. const { value, dataset } = e.target;
  746. if (value && dataset) {
  747. const { code } = dataset;
  748. const querySame = () => _.isEmpty(_.filter(arr, (v) => v.name == value));
  749. const generate = {
  750. unit: initDoor(this.formdata, this.initialUnitList).generateUnit,
  751. floor: initDoor(this.formdata, this.initialUnitList).generateFloor,
  752. door: initDoor(this.formdata, this.initialUnitList).generateDoor(value)
  753. };
  754. if (querySame()) {
  755. if (code == 'unit') {
  756. arr.push({
  757. unitName: value,
  758. unitFloorList: code != 'door' ? generate['floor'] : undefined
  759. });
  760. } else if (code == 'door') {
  761. arr.push({
  762. roomNumber: value
  763. });
  764. } else if (code == 'floor') {
  765. arr.push({
  766. floorNumber: value,
  767. roomList: code != 'door' ? generate['door'] : undefined
  768. });
  769. }
  770. this.inputValue[code] = '';
  771. } else {
  772. this.$message.error(`${txtI18n[code]}名称重复,请重新添加`);
  773. }
  774. }
  775. e.target.parentElement.style.display = 'none';
  776. e.target.parentElement.previousElementSibling.style.display = 'inline-block';
  777. e.target.value = '';
  778. },
  779. submit () {
  780. new Promise((resolve) => {
  781. this.$refs.detailform.validate(resolve);
  782. }).then((v) => {
  783. const { buildNumber, unitNumber, floorNumber, doorNumber } = calcDoor(this.doorData, this.initialUnitList.checkedUnit);
  784. const txt = `请检查信息是否填写完整(包含重复名称,名称为空现象)<br>确认提交单元户信息:<br>总楼栋数:${buildNumber}${this.initialUnitList.enableUnit ? `<br>总单元数:${unitNumber}` : ''
  785. }<br>总楼层数:${floorNumber}<br>总单元户数:${doorNumber}`;
  786. this.__confirm(txt, '提交')
  787. .then((v) => {
  788. if (!this.initialUnitList.checkedUnit) {
  789. this.doorData[0].unitName = '';
  790. this.formdata.unitNumber = 0;
  791. }
  792. this.formdata.buildingUnitList = this.doorData;
  793. let url = '/czc-community/assets/building/add';
  794. if (!!this.params.id) {
  795. url = '/czc-community/assets/building/update';
  796. }
  797. this.$http
  798. .post(url, this.formdata)
  799. .then(({ msg, status }) => {
  800. this.$message({
  801. type: status === 0 ? 'success' : 'error',
  802. message: msg
  803. });
  804. if (status === 0) {
  805. this.close();
  806. }
  807. })
  808. .catch(() => { });
  809. })
  810. .catch(() => { });
  811. });
  812. },
  813. getDetailData (id) {
  814. this.$http.get('/czc-community/assets/building/house/find', { id: id }).then(({ status, data, msg }) => {
  815. if (0 === status) {
  816. if (data.buildingUnitList.length !== 0) {
  817. this.formdata = data;
  818. debugger
  819. this.formdata.householdsPerFloor = data.buildingUnitList[0].unitFloorList[0].roomList.length;
  820. this.initialUnitList = {
  821. checkedUnit: data.unitNumber !== 0 ? true : false,
  822. enableUnit: data.unitNumber !== 0 ? 1 : 0,
  823. unit: {
  824. type: 'Number', // Number letter
  825. start: data.buildingUnitList[0]['unitName'], // 1 A单元的起始单元
  826. end: data.buildingUnitList[data.buildingUnitList.length - 1]['unitName']
  827. }
  828. };
  829. debugger
  830. let resDate = [];
  831. data.buildingUnitList.map((item, index) => {
  832. resDate.push(item.unitFloorList)
  833. })
  834. // this.doorData = data.buildingUnitList;
  835. debugger
  836. this.doorData = resDate;
  837. } else {
  838. this.formdata = data;
  839. }
  840. }
  841. });
  842. }
  843. },
  844. mounted () { },
  845. created () {
  846. this.copyformdata = this.deepClone(this.formdata);
  847. if (!!this.params.id) {
  848. this.getDetailData(this.params.id);
  849. }
  850. this.copyrules = JSON.parse(JSON.stringify(this.initialUnitList));
  851. }
  852. };
  853. </script>
  854. <style lang="scss" >
  855. @import './popup.scss';
  856. </style>