saveEdits.vue 9.9 KB

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