add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <template>
  2. <div class="formContent">
  3. <el-form
  4. ref="formData"
  5. :model="formData"
  6. :rules="rules"
  7. label-width="100px"
  8. class="demo-ruleForm"
  9. >
  10. <div class="formContent-item_title">房屋信息</div>
  11. <el-row>
  12. <el-col :span="10">
  13. <el-form-item
  14. label="招租房屋"
  15. prop="houseId"
  16. >
  17. <el-cascader
  18. :props="props"
  19. v-model="formData.houseId"
  20. :options="informTypes"
  21. @change="handleChange"
  22. clearable
  23. ></el-cascader>
  24. </el-form-item>
  25. </el-col>
  26. </el-row>
  27. <el-row
  28. :gutter="60"
  29. class="ma_bot"
  30. >
  31. <el-col :span="24">
  32. <el-col :span="8">租售类型:{{this.rentSaleType || '-'}}</el-col>
  33. <el-col :span="8">房屋类型:{{this.houseType || '-'}}</el-col>
  34. <el-col :span="8">楼层:{{this.floor || '-'}} 层</el-col>
  35. </el-col>
  36. </el-row>
  37. <el-row
  38. :gutter="60"
  39. class="ma_bot"
  40. >
  41. <el-col :span="24">
  42. <el-col :span="8">朝向:{{this.orientation || '-'}}</el-col>
  43. <el-col :span="8">户型:{{this.house || '-室-厅-卫'}}</el-col>
  44. <el-col :span="8">建筑面积:{{this.builtArea || '-'}}㎡</el-col>
  45. </el-col>
  46. </el-row>
  47. <div class="formContent-item_title">房屋配置</div>
  48. <el-form-item label="房屋配置">
  49. <el-row>
  50. <el-col
  51. :span="6"
  52. v-for="(item,index) in houseConfiguration"
  53. :key="index"
  54. >
  55. <el-checkbox-group v-model="formData.config">
  56. <el-checkbox-button
  57. :label="item.label"
  58. :key="item.value"
  59. >{{item.label}}</el-checkbox-button>
  60. </el-checkbox-group>
  61. </el-col>
  62. </el-row>
  63. </el-form-item>
  64. <el-form-item label="房屋亮点">
  65. <el-row>
  66. <el-col
  67. :span="6"
  68. v-for="(item,index) in houseHighlights"
  69. :key="index"
  70. >
  71. <el-checkbox-group v-model="formData.highLights">
  72. <el-checkbox-button
  73. :label="item.label"
  74. :key="item.value"
  75. >{{item.label}}</el-checkbox-button>
  76. </el-checkbox-group>
  77. </el-col>
  78. </el-row>
  79. </el-form-item>
  80. <el-form-item label="招租要求">
  81. <el-row>
  82. <el-col
  83. :span="6"
  84. v-for="(item,index) in rentalRequirements"
  85. :key="index"
  86. >
  87. <el-checkbox-group v-model="formData.requirement">
  88. <el-checkbox-button
  89. :label="item.label"
  90. :key="item.value"
  91. >{{item.label}}</el-checkbox-button>
  92. </el-checkbox-group>
  93. </el-col>
  94. </el-row>
  95. </el-form-item>
  96. <div class="formContent-item_title">招租信息</div>
  97. <el-form-item
  98. label="招租标题:"
  99. prop="title"
  100. >
  101. <el-col :span="24">
  102. <el-input
  103. placeholder="请输入招租标题"
  104. v-model="formData.title"
  105. clearable
  106. >
  107. </el-input>
  108. </el-col>
  109. </el-form-item>
  110. <el-row>
  111. <el-col :span="8">
  112. <el-form-item
  113. label="租赁方式:"
  114. prop="leaseType"
  115. >
  116. <el-radio-group v-model="formData.leaseType">
  117. <el-radio label="1">整租</el-radio>
  118. <el-radio label="2">合租</el-radio>
  119. </el-radio-group>
  120. </el-form-item>
  121. </el-col>
  122. <el-col :span="8">
  123. <el-form-item
  124. label="月租金额(元):"
  125. prop="amount"
  126. label-width="120px"
  127. >
  128. <el-input v-model="formData.amount"></el-input>
  129. </el-form-item>
  130. </el-col>
  131. <el-col :span="8">
  132. <el-form-item
  133. label="收租周期:"
  134. :prop="this.formData.cyclePledge != '' ? 'cyclePress' :'cyclePledge'"
  135. >
  136. <el-input
  137. v-model="formData.cyclePledge"
  138. placeholder=""
  139. style="width: 47px; margin-right: 5px;"
  140. ></el-input>
  141. <el-input
  142. v-model="formData.cyclePress"
  143. placeholder=""
  144. style="width: 47px; margin-right: 5px;"
  145. ></el-input>
  146. </el-form-item>
  147. </el-col>
  148. </el-row>
  149. <el-col :span="24">
  150. <el-form-item
  151. label="房屋图片:"
  152. prop="imageUrl"
  153. >
  154. <bz-upload-img
  155. type="img"
  156. :uploadArr="pictureArr"
  157. :limit="9"
  158. ></bz-upload-img>
  159. </el-form-item>
  160. </el-col>
  161. <el-col :span="24">
  162. <el-form-item
  163. label="房屋视频:"
  164. prop="videoUrl"
  165. >
  166. <bz-upload-img
  167. type="video"
  168. :uploadArr="pictureArred"
  169. :limit="1"
  170. ></bz-upload-img>
  171. </el-form-item>
  172. </el-col>
  173. <el-col :span="24">
  174. <el-form-item label="招商描述:">
  175. <tinymce
  176. v-model="formData.introduce"
  177. ref="endit"
  178. :height="150"
  179. />
  180. </el-form-item>
  181. </el-col>
  182. </el-form>
  183. </div>
  184. </template>
  185. <script>
  186. import Tinymce from '@/components/Tinymce';
  187. export default {
  188. components: { Tinymce },
  189. props: ['params'],
  190. data () {
  191. return {
  192. props: { value: 'value', label: 'name', children: 'children', },
  193. token: {
  194. [localStorage.getItem('CZC_token') && 'Authorization']: 'Bearer ' + localStorage.getItem('CZC_token')
  195. },
  196. formData: {
  197. houseId: '',
  198. config: [],
  199. highLights: [],
  200. requirement: [],
  201. title: '',
  202. leaseType: '1',
  203. cycle: '',
  204. cyclePledge: '',
  205. cyclePress: '',
  206. amount: '',
  207. imageUrl: '',
  208. videoUrl: '',
  209. introduce: '',
  210. residentId: ''
  211. },
  212. pictureArr: [],//房屋图片
  213. pictureArred: [],//房屋视频
  214. informTypes: [],//招租房屋
  215. rentSaleType: '',//租售类型
  216. houseType: '',//房屋类型
  217. floor: '',//楼层
  218. orientation: '',//朝向
  219. house: '',//户型
  220. builtArea: '',//建筑面积
  221. houseConfiguration: [],//房屋配置
  222. houseHighlights: [],//房屋亮点
  223. rentalRequirements: [],//招租要求
  224. rules: {
  225. houseId: [
  226. { required: true, message: '请选择招租房屋', trigger: 'change' },
  227. ],
  228. title: [
  229. { required: true, message: '请输入招租标题', trigger: 'blur' },
  230. ],
  231. leaseType: [
  232. { required: true, message: '请选择租赁方式', trigger: 'change' },
  233. ],
  234. amount: [
  235. { required: true, message: '请输入月租金额', trigger: 'blur' },
  236. ],
  237. cyclePledge: [
  238. { required: true, message: '请输入收租周期', trigger: 'blur' },
  239. ],
  240. cyclePress: [
  241. { required: true, message: '请输入收租周期', trigger: 'blur' },
  242. ],
  243. imageUrl: [
  244. { required: true, message: '请选择图片', trigger: 'change' }
  245. ],
  246. videoUrl: [
  247. { required: true, message: '请选择视频', trigger: 'change' }
  248. ]
  249. }
  250. }
  251. },
  252. watch: {
  253. pictureArr (val) {
  254. this.formData.imageUrl = val.join();
  255. },
  256. pictureArred (val) {
  257. this.formData.videoUrl = val.join();
  258. }
  259. },
  260. methods: {
  261. submit () {
  262. this.$refs.formData.validate((valid) => {
  263. if (valid) {
  264. this.formData.houseId = this.formData.houseId[this.formData.houseId.length - 1];
  265. this.formData.config = this.formData.config.toString();
  266. this.formData.highLights = this.formData.highLights.toString();
  267. this.formData.requirement = this.formData.requirement.toString();
  268. this.formData.cycle = this.formData.cyclePledge + ':' + this.formData.cyclePress;
  269. let url;
  270. url = '/czc-community/house/rent/out/add'
  271. if (this.params.title == 'edit') {
  272. url = '/czc-community/house/rent/out/update'
  273. }
  274. this.$http.post(url, this.formData).then(({ status, data, msg }) => {
  275. if (status == 0) {
  276. this.$emit('close');
  277. this.params.callback()
  278. this.$message.success(msg);
  279. }
  280. })
  281. } else {
  282. }
  283. })
  284. },
  285. configuration () {
  286. this.$api.common.getDictionaryData('CZC_INVESTMENT_CONFIGURATION').then(({ msg, status, data }) => {
  287. if (status == 0) {
  288. this.houseConfiguration = [];
  289. data.map((item, index) => {
  290. this.houseConfiguration.push({
  291. label: item.dictValue,
  292. value: item.dictCode
  293. })
  294. })
  295. }
  296. })
  297. },
  298. highlights () {
  299. this.$api.common.getDictionaryData('CZC_INVESTMENT_HIGHLIGHTS').then(({ msg, status, data }) => {
  300. if (status == 0) {
  301. this.houseHighlights = [];
  302. data.map((item, index) => {
  303. this.houseHighlights.push({
  304. label: item.dictValue,
  305. value: item.dictCode
  306. })
  307. })
  308. }
  309. })
  310. },
  311. requirements () {
  312. this.$api.common.getDictionaryData('CZC_INVESTMENT_REQUIREMENTS').then(({ msg, status, data }) => {
  313. if (status == 0) {
  314. this.rentalRequirements = [];
  315. data.map((item, index) => {
  316. this.rentalRequirements.push({
  317. label: item.dictValue,
  318. value: item.dictCode
  319. })
  320. })
  321. }
  322. })
  323. },
  324. handleChange (value) {
  325. if (value.length != 0) {
  326. this.$http.get('/czc-community/assets/house/find/' + value[value.length - 1]).then(({ status, data, msg }) => {
  327. if (status == 0) {
  328. this.formData.residentId = data.residentId;
  329. this.rentSaleType = data.salesType == 1 ? '可租可售' : data.salesType == 2 ? '只租' : '只售';
  330. this.houseType = data.buildingType == 1 ? '住宅' : '商用';
  331. this.floor = data.floorNumber;
  332. this.orientation = data.orientationOfRoom == 1 ? '东' : data.orientationOfRoom == 2 ? '南' : data.orientationOfRoom == 3 ? '西' : data.orientationOfRoom == 4 ? '北' : data.orientationOfRoom == 5 ? '东南' : data.orientationOfRoom == 6 ? '西南' : data.orientationOfRoom == 7 ? '西北' : '东北';
  333. if (data.housingType != null) {
  334. let housingTypes = data.housingType.split(':');
  335. this.house = (housingTypes[0] == '' ? '-' : housingTypes[0]) + '室' + (housingTypes[1] == '' ? '-' : housingTypes[1]) + '厅' + (housingTypes[2] == '' ? '-' : housingTypes[2]) + '卫'
  336. } else {
  337. this.house = '';
  338. }
  339. this.builtArea = data.buildingArea == null ? '-' : data.buildingArea;
  340. }
  341. })
  342. } else {
  343. this.rentSaleType = '';
  344. this.houseType = '';
  345. this.floor = '';
  346. this.orientation = '';
  347. this.house = '';
  348. this.builtArea = '';
  349. }
  350. },
  351. // 获取招租房屋
  352. getOrgTreeList () {
  353. this.$http.get('/czc-community/assets/tree/community/find', { buildingType: 1 }).then(({ status, data, msg }) => {
  354. if (status == 0) {
  355. this.informTypes = data;
  356. }
  357. })
  358. },
  359. houseRentFind () {
  360. this.$http.post(`/czc-community/house/rent/out/find/${this.params.data.rentOutId}`).then(({ status, data, msg }) => {
  361. if (status == 0) {
  362. // debugger
  363. var dataHouseId = data.houseId;
  364. this.formData = data;
  365. this.formData.config = (data.config).split(',');
  366. this.formData.highLights = (data.highLights).split(',');
  367. this.formData.requirement = (data.requirement).split(',');
  368. this.formData.cycle = (data.cycle).split(':');
  369. this.formData.cyclePledge = this.formData.cycle[0];
  370. this.formData.cyclePress = this.formData.cycle[1];
  371. this.formData.leaseType = this.formData.leaseType + '';
  372. this.formData.houseId = [];
  373. if (data.unitName != null) {
  374. this.formData.houseId.push(data.communityId + '');
  375. this.formData.houseId.push(data.buildingId + '');
  376. this.formData.houseId.push(data.unitName);
  377. this.formData.houseId.push(dataHouseId + '');
  378. this.handleChange(this.formData.houseId);
  379. } else {
  380. this.formData.houseId.push(data.communityId + '');
  381. this.formData.houseId.push(data.buildingId + '');
  382. this.formData.houseId.push(dataHouseId + '');
  383. this.handleChange(this.formData.houseId);
  384. }
  385. this.pictureArr = (this.formData.imageUrl).split(',');
  386. this.pictureArred = (this.formData.videoUrl).split(',');
  387. }
  388. })
  389. }
  390. },
  391. created () {
  392. this.getOrgTreeList();
  393. this.configuration();
  394. this.highlights();
  395. this.requirements();
  396. if (this.params.title == "edit") {
  397. this.houseRentFind();
  398. }
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped>
  403. .ma_bot {
  404. margin-bottom: 20px;
  405. }
  406. /deep/ .el-checkbox-button:last-child .el-checkbox-button__inner {
  407. border-radius: 0px !important;
  408. margin-bottom: 20px;
  409. width: 130px;
  410. }
  411. .clickUpload {
  412. display: flex;
  413. .clickUpText {
  414. height: 76px;
  415. width: 76px;
  416. border: 1px solid #e0e1e3;
  417. box-sizing: border-box;
  418. background: white;
  419. border-radius: 5px;
  420. margin-right: 5px;
  421. z-index: 1;
  422. img.dataImg {
  423. width: 100%;
  424. height: 100%;
  425. object-fit: cover;
  426. border-radius: 5px;
  427. }
  428. .addImg {
  429. line-height: 76px;
  430. text-align: center;
  431. cursor: pointer;
  432. & > i {
  433. font-size: 30px;
  434. }
  435. }
  436. video {
  437. width: 100%;
  438. height: 100%;
  439. }
  440. }
  441. }
  442. </style>