AddOrEdit.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <!--
  2. * @Author: zouwenying
  3. * @Date: 2020-10-27 09:51:50
  4. * @LastEditTime: 2021-04-19 09:27:00
  5. * @LastEditors: zwy
  6. * @Description: In User Settings Edit
  7. * @FilePath: \UMIS\src\views\system\dictionarys\popups\AddOrEdit.vue
  8. -->
  9. <template>
  10. <div class="alert-body__main_content">
  11. <div class="blockName">新增社区</div>
  12. <div>
  13. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" class="demo-ruleForm">
  14. <el-row>
  15. <el-col :span="12">
  16. <div class=""><i></i>新增信息</div>
  17. <el-form-item label="社区名称" prop="communityName">
  18. <el-input v-model="ruleForm.communityName"></el-input>
  19. </el-form-item>
  20. <el-form-item label="所在地区" prop="region">
  21. <el-select v-model="ruleForm.regionId" placeholder="请选择地区">
  22. <el-option v-for="(item,index) in ruleForm.locationList" :label="item.label" :value="item.id"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="所属公司" required>
  26. <el-select v-model="ruleForm.companyOrgId" placeholder="请选择公司">
  27. <el-option label="区域一" value="shanghai"></el-option>
  28. <el-option label="区域二" value="beijing"></el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="所属部门" prop="delivery">
  32. <el-select v-model="ruleForm.deptOrgId" placeholder="请选择部门">
  33. <el-option label="区域一" value="shanghai"></el-option>
  34. <el-option label="区域二" value="beijing"></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="详细地址" prop="type">
  38. <div @click="addressQueryClick">
  39. <el-input v-model="ruleForm.address" suffix-icon="el-icon-location-outline"></el-input>
  40. </div>
  41. </el-form-item>
  42. <el-form-item label="占地面积">
  43. <el-input v-model="ruleForm.coveredArea"></el-input>
  44. </el-form-item>
  45. <el-form-item label="建筑面积">
  46. <el-input v-model="ruleForm.buildingArea"></el-input>
  47. </el-form-item>
  48. <el-form-item label="商业面积">
  49. <el-input v-model="ruleForm.commercialArea"></el-input>
  50. </el-form-item>
  51. <el-form-item label="住宅面积">
  52. <el-input v-model="ruleForm.dwellingArea"></el-input>
  53. </el-form-item>
  54. <el-form-item label="绿化面积">
  55. <el-input v-model="ruleForm.greenArea"></el-input>
  56. </el-form-item>
  57. <el-form-item label="车位面积">
  58. <el-input v-model="ruleForm.parkingArea"></el-input>
  59. </el-form-item>
  60. <el-form-item label="社区图片">
  61. <el-upload
  62. class="avatar-uploader"
  63. action="https://jsonplaceholder.typicode.com/posts/"
  64. :show-file-list="false"
  65. :on-success="handleAvatarSuccess"
  66. :before-upload="beforeAvatarUpload">
  67. <img v-if="imageUrl" :src="imageUrl" class="avatar">
  68. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  69. </el-upload>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="12">
  73. <div>负责人</div>
  74. <el-form-item label="负责人姓名" prop="name">
  75. <el-input v-model="ruleForm.contactPerson"></el-input>
  76. </el-form-item>
  77. <el-form-item label="手机号码" prop="phoneNumber">
  78. <el-input v-model="ruleForm.phone"></el-input>
  79. </el-form-item>
  80. <el-form-item label="固定电话">
  81. <el-input v-model="ruleForm.telephone"></el-input>
  82. </el-form-item>
  83. <el-form-item label="备注信息">
  84. <el-input type="textarea" :rows="4" v-model="ruleForm.remarks" maxlength="300">
  85. </el-input>
  86. <span style="position:absolute;bottom:0;right:10px">{{ruleForm.remark.length}}/300</span>
  87. </el-form-item>
  88. </el-col>
  89. </el-row>
  90. </el-form>
  91. </div>
  92. <div style="text-align: right;">
  93. <el-button type="primary" @click="submit">提交</el-button>
  94. <el-button>取消</el-button>
  95. </div>
  96. <!--地图详情地址弹出框-->
  97. <map-popup :mapPopUpStatus="mapPopUpStatus"></map-popup>
  98. </div>
  99. </template>
  100. <script>
  101. import MapPopup from '@/components/mapPopup/index.vue'
  102. export default {
  103. data() {
  104. return {
  105. ruleForm: {
  106. communityName: '',
  107. locationList:[],
  108. regionId:100000,//所在地区
  109. companyOrgList:[],
  110. companyOrgId:2,//所属公司
  111. deptOrgId:1,//所属部门
  112. coveredArea:'',//占地面积
  113. buildingArea:'',//建筑面积
  114. commercialArea:'',//商业面积
  115. dwellingArea:'',//住宅面积
  116. greenArea:'',//绿化面积
  117. parkingArea:'',//车位面积
  118. contactPerson:'',//负责人
  119. phone:'',//负责人手机号
  120. telephone:'',//固定电话
  121. address:'',//详细地址
  122. region: '',
  123. delivery: false,
  124. type: [],
  125. resource: '',
  126. desc: '',
  127. remark:'',//备注
  128. },
  129. rules: {
  130. communityName: [
  131. { required: true, message: '请输入社区名称', trigger: 'change' },
  132. // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
  133. ],
  134. region: [
  135. { required: true, message: '请选择地区', trigger: 'blur' },
  136. // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
  137. ],
  138. phoneNumber:[
  139. { required: true, message: '请输入手机号码', trigger: 'change' }
  140. ],
  141. date1: [
  142. { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
  143. ],
  144. date2: [
  145. { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
  146. ],
  147. type: [
  148. { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
  149. ],
  150. resource: [
  151. { required: true, message: '请选择活动资源', trigger: 'change' }
  152. ],
  153. desc: [
  154. { required: true, message: '请填写活动形式', trigger: 'blur' }
  155. ]
  156. },
  157. mapPopUpStatus:false,//地图弹出框
  158. }
  159. },
  160. components:{
  161. MapPopup
  162. },
  163. computed: {},
  164. methods: {
  165. //保存
  166. submit() {
  167. let submitData='';
  168. if(this.$route.query.newEditType=="edit"){
  169. let communityInformation=JSON.parse(sessionStorage.getItem('communityInformation'))
  170. submitData={
  171. "address": this.ruleForm.address,
  172. "buildingArea": this.ruleForm.buildingArea,
  173. "cityId": 440300,
  174. "commercialArea": this.ruleForm.commercialArea,
  175. "communityName": this.ruleForm.communityName,
  176. "companyOrgId": 0,
  177. "contactPerson": this.ruleForm.contactPerson,
  178. "coveredArea": this.ruleForm.coveredArea,
  179. "deptOrgId": 461,
  180. "dwellingArea": this.ruleForm.dwellingArea,
  181. "greenArea": this.ruleForm.greenArea,
  182. "id": communityInformation.id,
  183. 'latitude':'1',
  184. 'longitude':'2',
  185. "parkingArea": this.ruleForm.parkingArea,
  186. "phone": this.ruleForm.phone,
  187. "pictureUrl": "",
  188. "provinceId": 440000,
  189. "regionId": this.ruleForm.regionId,
  190. "remarks": "",
  191. "telephone": this.ruleForm.telephone
  192. }
  193. this.$http.post('/sc-community/assets/community/update', submitData).then((data) => {
  194. // this.deviceOptions = data;
  195. let locationObj='';
  196. data.map(resData=>{
  197. locationObj={
  198. label:resData.name,
  199. id:resData.pid,
  200. }
  201. self.ruleForm.locationList.push(locationObj)
  202. })
  203. });
  204. }else{
  205. submitData={
  206. "address": this.ruleForm.address,
  207. "buildingArea": this.ruleForm.buildingArea,
  208. "cityId": 440300,
  209. "commercialArea": 0,
  210. "communityName": this.ruleForm.communityName,
  211. "companyOrgId": 0,
  212. "contactPerson": this.ruleForm.contactPerson,
  213. "coveredArea": this.ruleForm.coveredArea,
  214. "deptOrgId": 461,
  215. "dwellingArea": this.ruleForm.dwellingArea,
  216. "greenArea": this.ruleForm.greenArea,
  217. "id": 0,
  218. 'latitude':'1',
  219. 'longitude':'2',
  220. "parkingArea": this.ruleForm.parkingArea,
  221. "phone": this.ruleForm.phone,
  222. "pictureUrl": "",
  223. "provinceId": 440000,
  224. "regionId": this.ruleForm.regionId,
  225. "remarks": "",
  226. "telephone": this.ruleForm.telephone
  227. }
  228. this.$http.post('/sc-community/assets/community/add', submitData).then((data) => {
  229. // this.deviceOptions = data;
  230. let locationObj='';
  231. data.map(resData=>{
  232. locationObj={
  233. label:resData.name,
  234. id:resData.pid,
  235. }
  236. self.ruleForm.locationList.push(locationObj)
  237. })
  238. });
  239. }
  240. },
  241. //所属地区
  242. regionalQuery(){
  243. let self=this;
  244. this.$http.postForm('/sc-user-center/area/selectAll', {id:123}).then(({ data }) => {
  245. // this.deviceOptions = data;
  246. let locationObj='';
  247. data.map(resData=>{
  248. locationObj={
  249. label:resData.name,
  250. id:resData.pid,
  251. }
  252. self.ruleForm.locationList.push(locationObj)
  253. })
  254. });
  255. },
  256. //所属公司
  257. companyQuery(){
  258. let self=this;
  259. this.$http.postForm('/sc-user-center/org/getOrgUserTree', {orgType:'company',id:'000'}).then(({ data }) => {
  260. console.log(data,'+++++++++++++++++++++++++++++++')
  261. });
  262. },
  263. //所属部门
  264. departmentQuery(){
  265. let self=this;
  266. this.$http.postForm('/sc-user-center/org/getOrgUserTree', {orgType:'department',id:'460'}).then(({ data }) => {
  267. console.log(data,'+++++++++++++++++++++++++++++++')
  268. });
  269. },
  270. resetForm(formName) {
  271. this.$refs[formName].resetFields();
  272. },
  273. handleAvatarSuccess(res, file) {
  274. this.imageUrl = URL.createObjectURL(file.raw);
  275. },
  276. beforeAvatarUpload(file) {
  277. const isJPG = file.type === 'image/jpeg';
  278. const isLt2M = file.size / 1024 / 1024 < 2;
  279. if (!isJPG) {
  280. this.$message.error('上传头像图片只能是 JPG 格式!');
  281. }
  282. if (!isLt2M) {
  283. this.$message.error('上传头像图片大小不能超过 2MB!');
  284. }
  285. return isJPG && isLt2M;
  286. },
  287. coordinateClick(){
  288. this.$confirm('确认关闭?')
  289. .then(_ => {
  290. done();
  291. })
  292. .catch(_ => {});
  293. },
  294. addressQueryClick(){
  295. this.mapPopUpStatus=true;
  296. }
  297. },
  298. created() {
  299. let self=this;
  300. this.regionalQuery();
  301. this.companyQuery();
  302. this.departmentQuery();
  303. if(self.$route.query.newEditType=="edit"){
  304. let communityInformation=JSON.parse(sessionStorage.getItem('communityInformation'))
  305. // this.ruleForm={
  306. // "communityName":communityInformation.communityName,
  307. // "locationId":communityInformation.regionId,
  308. // "coveredArea":communityInformation.coveredArea,
  309. // }
  310. this.ruleForm.address=communityInformation.address;
  311. this.ruleForm.communityName=communityInformation.communityName;
  312. this.ruleForm.regionId=communityInformation.regionId;
  313. this.ruleForm.coveredArea=communityInformation.coveredArea;
  314. this.ruleForm.contactPerson=communityInformation.contactPerson;
  315. this.ruleForm.buildingArea=communityInformation.buildingArea;
  316. this.ruleForm.commercialArea=communityInformation.commercialArea;
  317. this.ruleForm.dwellingArea=communityInformation.dwellingArea;
  318. this.ruleForm.greenArea=communityInformation.greenArea;
  319. this.ruleForm.parkingArea=communityInformation.parkingArea;
  320. this.ruleForm.phone=communityInformation.phone;
  321. this.ruleForm.telephone=communityInformation.telephone;
  322. }else{
  323. }
  324. }
  325. };
  326. </script>
  327. <style lang='scss'>
  328. .alert-body__main_content{
  329. .blockName{
  330. padding:20px;
  331. }
  332. }
  333. .avatar-uploader .el-upload {
  334. border: 1px dashed #d9d9d9;
  335. border-radius: 6px;
  336. cursor: pointer;
  337. position: relative;
  338. overflow: hidden;
  339. }
  340. .avatar-uploader .el-upload:hover {
  341. border-color: #409EFF;
  342. }
  343. .avatar-uploader-icon {
  344. font-size: 28px;
  345. color: #8c939d;
  346. width: 178px;
  347. height: 178px;
  348. line-height: 178px;
  349. text-align: center;
  350. }
  351. .avatar {
  352. width: 178px;
  353. height: 178px;
  354. display: block;
  355. }
  356. </style>