saveEdits.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="main">
  3. <div class="blockName">{{ !isAdd ? '编辑' : '新增' }}房屋(<span class="show-required-icon-star"></span>为必填项)</div>
  4. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px">
  5. <div class="formContent">
  6. <div class="formContent-item">
  7. <el-form-item label="社区名称" prop="communityId">
  8. <el-select v-model="ruleForm.communityId" placeholder="请选择社区名称" class="width100">
  9. <el-option
  10. v-for="(item, index) in communityList"
  11. :label="item.communityName"
  12. :value="item.id"
  13. :key="index"
  14. ></el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="单元">
  18. <el-select v-model="ruleForm.unitName" placeholder="请选择单元" class="width100">
  19. <el-option
  20. v-for="(item, index) in unitList"
  21. :label="item.unitName"
  22. :value="item.unitName"
  23. :key="index"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="房屋号" prop="roomNumber" >
  28. <el-input v-model="ruleForm.roomNumber"></el-input>
  29. </el-form-item>
  30. <el-form-item label="使用面积" >
  31. <el-input v-model="ruleForm.useArea"></el-input>
  32. </el-form-item>
  33. <el-form-item label="房屋朝向">
  34. <el-select v-model="ruleForm.orientationOfRoom" placeholder="请选择房屋朝向" class="width100">
  35. <el-option label="东" :value="1"></el-option>
  36. <el-option label="南" :value="2"></el-option>
  37. <el-option label="西" :value="3"></el-option>
  38. <el-option label="北" :value="4"></el-option>
  39. <el-option label="东南" :value="5"></el-option>
  40. <el-option label="西南" :value="6"></el-option>
  41. <el-option label="西北" :value="7"></el-option>
  42. <el-option label="东北" :value="8"></el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="房屋户型">
  46. <el-input v-model="housingType.roomNumber" style="width: 80px; margin-right: 10px"></el-input>室
  47. <el-input v-model="housingType.officeNumber" style="width: 80px; margin: 0 10px"></el-input>厅
  48. <el-input v-model="housingType.guardNumber" style="width: 80px; margin: 0 10px"></el-input>卫
  49. </el-form-item>
  50. </div>
  51. <div class="formContent-item">
  52. <el-form-item label="楼栋" prop="buildingId">
  53. <el-select v-model="ruleForm.buildingId" placeholder="请选择楼栋" class="width100">
  54. <el-option
  55. v-for="(item, index) in buildingList"
  56. :label="item.buildingName"
  57. :value="item.id"
  58. :key="index"
  59. ></el-option>
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item label="楼层" prop="floorNumber">
  63. <el-select v-model="ruleForm.floorNumber" placeholder="请选择楼层" class="width100">
  64. <el-option
  65. v-for="(item, index) in floorNumberList"
  66. :label="item.floorNumber"
  67. :value="item.floorNumber"
  68. :key="index"
  69. ></el-option>
  70. </el-select>
  71. </el-form-item>
  72. <el-form-item label="房屋类型" prop="buildingType">
  73. <el-select v-model="ruleForm.buildingType" disabled placeholder="请选择房屋类型" class="width100">
  74. <el-option label="住宅" :value="1"></el-option>
  75. <el-option label="商用" :value="2"></el-option>
  76. </el-select>
  77. </el-form-item>
  78. <el-form-item label="建筑面积">
  79. <el-input v-model="ruleForm.buildingArea"></el-input>
  80. </el-form-item>
  81. <el-form-item label="公摊面积">
  82. <el-input v-model="ruleForm.publicArea"></el-input>
  83. </el-form-item>
  84. <el-form-item label="装修性质">
  85. <el-select v-model="ruleForm.decorateProperties" placeholder="请选择装修性质" class="width100">
  86. <el-option label="毛胚" :value="1"></el-option>
  87. <el-option label="简单装修" :value="2"></el-option>
  88. <el-option label="中等装修" :value="3"></el-option>
  89. <el-option label="精装修" :value="4"></el-option>
  90. <el-option label="豪华装修" :value="5"></el-option>
  91. </el-select>
  92. </el-form-item>
  93. </div>
  94. </div>
  95. <el-row>
  96. <el-col :span="24">
  97. <el-form-item label="备注信息">
  98. <el-input type="textarea" :rows="4" v-model="ruleForm.remarks" maxlength="300"> </el-input>
  99. <span style="position: absolute; bottom: 0; right: 10px" v-if="ruleForm.remarks"
  100. >{{ ruleForm.remarks.length }}/300</span
  101. >
  102. </el-form-item>
  103. </el-col>
  104. </el-row>
  105. </el-form>
  106. <div style="text-align: right">
  107. <el-button @click="cancelSaving">取消</el-button>
  108. <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
  109. </div>
  110. </div>
  111. </template>
  112. <script>
  113. export default {
  114. props: {
  115. params: {
  116. type: Object
  117. },
  118. isAdd: {
  119. type: Boolean,
  120. default: true
  121. }
  122. },
  123. data() {
  124. return {
  125. buildingList: [], //楼栋下拉选择列表
  126. unitList: [], //单元下拉选择列表
  127. addEditState: '',
  128. housingType: {
  129. //房屋户型,roomNumber为室,officeNumber为厅,guardNumber为卫
  130. roomNumber: '',
  131. officeNumber: '',
  132. guardNumber: ''
  133. },
  134. ruleForm: {
  135. communityId: '', //社区id
  136. buildingId: '', //楼栋id
  137. unitName: '', //单元
  138. floorNumber: '', //单元楼层
  139. roomNumber: '', //房屋号
  140. buildingType: 1, //房屋类型
  141. useArea: '', //使用面积
  142. buildingArea: '', //建筑面积
  143. orientationOfRoom: '', //房屋朝向
  144. publicArea: '', //公摊面积
  145. housingType: '', //房屋户型
  146. decorateProperties: '', //装修性质
  147. remarks: '' //备注
  148. },
  149. rules: {
  150. communityId: [this.$valid.selectRequired('请选择社区')],
  151. roomNumber: [{ required: true, message: '请输入房屋号', trigger: 'change' }],
  152. buildingId: [this.$valid.selectRequired('请选择楼栋')],
  153. floorNumber: [this.$valid.selectRequired('请选择楼层')],
  154. buildingType: [this.$valid.selectRequired('请选择房屋类型')]
  155. }
  156. };
  157. },
  158. components: {},
  159. computed: {
  160. communityList() {
  161. return this.$store.getters['getCommunityArray'];
  162. }
  163. },
  164. watch: {
  165. 'ruleForm.communityId'(newValue, oldValue) {
  166. if (newValue !== oldValue) {
  167. this.buildingNameList();
  168. // this.ruleForm.buildingId = '';
  169. // this.ruleForm.unitName = '';
  170. // this.ruleForm.floorNumber = '';
  171. }
  172. },
  173. 'ruleForm.buildingId'(newValue, oldValue) {
  174. if (newValue !== oldValue) {
  175. this.unitNameList();
  176. // this.ruleForm.unitName = '';
  177. // this.ruleForm.floorNumber = '';
  178. }
  179. },
  180. 'ruleForm.unitName'(newValue, oldValue) {
  181. if (newValue !== oldValue) {
  182. this.unitChoice(newValue);
  183. // this.ruleForm.floorNumber = '';
  184. }
  185. },
  186. unitList(val) {
  187. if (val.length !== 0) {
  188. this.unitChoice(this.ruleForm.unitName);
  189. }
  190. }
  191. },
  192. methods: {
  193. submitForm(formName) {
  194. this.$refs[formName].validate((valid) => {
  195. if (valid) {
  196. this.ruleForm.housingType =
  197. this.housingType.roomNumber + ':' + this.housingType.officeNumber + ':' + this.housingType.guardNumber;
  198. let url = '/sc-community/assets/house/add';
  199. if (!this.isAdd) {
  200. url = '/sc-community/assets/house/update';
  201. }
  202. this.$http
  203. .post(url, this.ruleForm)
  204. .then(({ status, msg }) => {
  205. if (status == 0) {
  206. this.$message.success(msg);
  207. this.cancelSaving();
  208. } else {
  209. this.$message.error(msg);
  210. }
  211. })
  212. .catch(() => {});
  213. }
  214. });
  215. },
  216. cancelSaving() {
  217. this.$emit('clerOwnerStatus');
  218. },
  219. resetForm(formName) {
  220. this.$refs[formName].resetFields();
  221. },
  222. //查询楼栋下拉列表
  223. buildingNameList() {
  224. this.buildingList = [];
  225. this.$http
  226. .post('/sc-community/assets/building/list/building', { communityId: this.ruleForm.communityId })
  227. .then(({ data, status, msg }) => {
  228. if (0 === status) {
  229. this.buildingList = data;
  230. }
  231. });
  232. },
  233. unitNameList() {
  234. this.unitList = [];
  235. this.$http.get('/sc-community/assets/building/house/find', { id: this.ruleForm.buildingId }).then((res) => {
  236. if (res.status == 0) {
  237. if (res.data.buildingUnitList.length != 0) {
  238. this.unitList = res.data.buildingUnitList;
  239. }
  240. }
  241. });
  242. },
  243. unitChoice(e) {
  244. this.floorNumberList = [];
  245. this.unitList.map((item) => {
  246. if (item.unitName == e) {
  247. this.floorNumberList = item.unitFloorList;
  248. }
  249. });
  250. },
  251. getDetails(id) {
  252. this.$http.get('/sc-community/assets/house/find/' + id, {}).then((res) => {
  253. if (res.status == 0) {
  254. this.ruleForm = res.data;
  255. if (!!this.ruleForm.housingType) {
  256. var housingTypes = this.ruleForm.housingType.split(':');
  257. this.housingType.roomNumber = housingTypes[0];
  258. this.housingType.officeNumber = housingTypes[1];
  259. this.housingType.guardNumber = housingTypes[2];
  260. }
  261. }
  262. });
  263. }
  264. },
  265. created() {
  266. if (!!this.params.id) {
  267. this.getDetails(this.params.id);
  268. }
  269. }
  270. };
  271. </script>
  272. <style lang='scss' scoped>
  273. @import '@assets/css/public-style.scss';
  274. .main {
  275. padding: 20px;
  276. background: white;
  277. .blockName {
  278. padding-bottom: 20px;
  279. margin-bottom: 20px;
  280. border-bottom: 1px solid #e0e1e3;
  281. }
  282. }
  283. .formContent {
  284. display: flex;
  285. justify-content: space-between;
  286. .formContent-item {
  287. width: 49%;
  288. }
  289. }
  290. .show-required-icon-star {
  291. &:before {
  292. content: '*';
  293. color: #f56c6c;
  294. }
  295. }
  296. </style>