buildEditcf.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true" v-if="title == '新建楼宇信息'">
  4. <block slot="backText">返回</block>
  5. <block slot="content">新建楼宇信息</block>
  6. </cu-custom>
  7. <cu-custom bgColor="bg-blue" :isBack="true" v-if="title == '修改楼宇信息'">
  8. <block slot="backText">返回</block>
  9. <block slot="content">修改楼宇信息</block>
  10. </cu-custom>
  11. <cu-custom bgColor="bg-blue" :isBack="true" v-if="title == '查看楼宇信息'">
  12. <block slot="backText">返回</block>
  13. <block slot="content">查看楼宇信息</block>
  14. </cu-custom>
  15. <form @submit="formSubmit" class="cu-list menu">
  16. <view class="cu-form-group margin-top">
  17. <view class="title">
  18. 所属园区
  19. </view>
  20. <jp-picker v-model="inputForm.parkManagement.id" rangeKey="label" rangeValue="value" :range="parkList"
  21. :disabled="ischeck">
  22. </jp-picker>
  23. </view>
  24. <view class="cu-form-group margin-top">
  25. <view class="title">
  26. <text class="red-color ">* </text> 楼宇名称
  27. </view>
  28. <input v-model="inputForm.buildingName" placeholder="请填写楼宇名称" :disabled="ischeck"></input>
  29. </view>
  30. <view class="cu-form-group margin-top">
  31. <view class="title">
  32. 楼宇经度
  33. </view>
  34. <input v-model="inputForm.buildingLongitude" placeholder="请填写楼宇经度" :disabled="ischeck"></input>
  35. </view>
  36. <view class="cu-form-group margin-top">
  37. <view class="title">
  38. 楼宇纬度
  39. </view>
  40. <input v-model="inputForm.buildingLatitude" placeholder="请填写楼宇纬度" :disabled="ischeck"></input>
  41. </view>
  42. <view class="cu-form-group margin-top">
  43. <view class="title">
  44. 楼宇联系人
  45. </view>
  46. <input v-model="inputForm.buildingContacts" placeholder="请填写楼宇联系人" :disabled="ischeck"></input>
  47. </view>
  48. <view class="cu-form-group margin-top">
  49. <view class="title">
  50. 楼宇联系人电话
  51. </view>
  52. <input v-model="inputForm.reserve2" placeholder="请填写楼宇联系人电话" :disabled="ischeck"></input>
  53. </view>
  54. <view class="cu-form-group margin-top">
  55. <view class="title">
  56. 楼宇层数
  57. </view>
  58. <input v-model="inputForm.buildingNum" placeholder="请填写楼宇层数" :disabled="ischeck"></input>
  59. </view>
  60. <view class="cu-form-group margin-top">
  61. <view class="title">
  62. 楼宇总面积
  63. </view>
  64. <input v-model="inputForm.buildingArea" placeholder="请填写楼宇总面积" :disabled="ischeck"></input>
  65. </view>
  66. <view class="cu-form-group margin-top">
  67. <view class="title">
  68. 地点
  69. </view>
  70. <input v-model="inputForm.placeSelectName" placeholder="请填写地点" disabled="disabled"></input>
  71. </view>
  72. <view class="cu-form-group margin-top">
  73. <view class="title">
  74. 街道
  75. </view>
  76. <jp-picker v-model="inputForm.street" rangeKey="label" rangeValue="value"
  77. :range="$dictUtils.getDictList('region_management')" :disabled="ischeck">
  78. <view class="picker">
  79. {{$dictUtils.getDictLabel('region_management', inputForm.street ,'请选择')}}
  80. </view>
  81. </jp-picker>
  82. </view>
  83. <view class="cu-form-group margin-top">
  84. <uni-file-picker style="margin-bottom: 10px;" limit="3" ref="picFile" v-model="picLists"
  85. fileMediatype="image" mode="grid" title="图片上传" :auto-upload="autoUpload" @select="select"
  86. @progress="progress" @success="success" @fail="fail" @delete="deleteFile" :imageStyles="imageStyles"
  87. :disabled="ischeck">
  88. </uni-file-picker>
  89. </view>
  90. <view class="cu-form-group margin-top">
  91. <view class="title">
  92. 楼宇产业定位
  93. </view>
  94. <textarea v-model="inputForm.buildingIndustry" placeholder="请填写楼宇产业定位" :disabled="ischeck"></textarea>
  95. </view>
  96. <view class="cu-form-group margin-top">
  97. <view class="title">
  98. 楼宇描述
  99. </view>
  100. <textarea v-model="inputForm.buildingDescribe" placeholder="请填写楼宇描述" :disabled="ischeck"></textarea>
  101. </view>
  102. <view class="cu-form-group margin-top">
  103. <view class="title">
  104. 备注
  105. </view>
  106. <textarea placeholder='请填写备注' v-model="inputForm.notes" :disabled="ischeck"></textarea>
  107. </view>
  108. <view style="height: 40rpx;"></view>
  109. <view class="padding-xl" v-if="!ischeck">
  110. <button form-type="submit" class="cu-btn block bg-blue margin-tb-sm lg">提交</button>
  111. </view>
  112. </form>
  113. </view>
  114. </template>
  115. <script>
  116. var graceChecker = require("@/common/graceChecker.js");
  117. import revenueListService from '@/api/revenue/revenueListService'
  118. import loginService from '@/api/auth/loginService.js'
  119. export default {
  120. onShow() {},
  121. data() {
  122. return {
  123. title: '新建楼宇信息',
  124. inputForm: {
  125. "id": "23082c03aeb4464ea1b4577125a56767",
  126. "createDate": "2024-12-17 17:52:47",
  127. "createBy": {
  128. "id": "1506167921787850753",
  129. "admin": false,
  130. "roleIdList": [],
  131. "roleIds": "",
  132. "postIdList": [],
  133. "roleNames": ""
  134. },
  135. "updateDate": "2024-12-19 11:39:38",
  136. "updateBy": {
  137. "id": "1",
  138. "admin": false,
  139. "roleIdList": [],
  140. "roleIds": "",
  141. "postIdList": [],
  142. "roleNames": ""
  143. },
  144. "delFlag": 0,
  145. "parkManagement": {
  146. "id": "c8c61706e1e3430ca4fdd8413e7b6704",
  147. "parkName": "人工智能港",
  148. "propertyPerson": "洪晶晶",
  149. "propertyPhone": "13515140456"
  150. },
  151. "buildingName": "B3",
  152. "buildingLongitude": "120.11693",
  153. "buildingLatitude": "33.328376",
  154. "buildingContacts": "吉祥",
  155. "buildingDescribe": "",
  156. "buildingNum": "8",
  157. "buildingArea": "8081",
  158. "buildingIndustry": "",
  159. "placeSelectName": "盐城市/盐都区",
  160. "place": "320900/320903/320903004",
  161. "street": "1",
  162. "placeDetailed": "",
  163. "placeSelectType3": "320900",
  164. "placeSelectType4": "320903",
  165. "placeSelectType5": "320903004",
  166. "picture": "",
  167. "notes": "",
  168. "reserve2": "13813223933",
  169. "reserve3": "",
  170. "reserve4": "1",
  171. "reserve9": "00003"
  172. },
  173. autoUpload: false,
  174. picLists: [],
  175. picUrl: [],
  176. imageStyles: {
  177. width: 90,
  178. height: 90
  179. },
  180. parkList: [],
  181. ischeck: false,
  182. }
  183. },
  184. created() {},
  185. mounted() {
  186. },
  187. async onLoad(query) {
  188. console.log(query, '==============>query')
  189. if (query && query.ischeck) {
  190. this.ischeck = true
  191. this.title = "查看楼宇信息";
  192. }
  193. if (query && query.id && !query.ischeck) {
  194. this.title = "修改楼宇信息";
  195. }
  196. },
  197. methods: {
  198. getParkList() {
  199. loginService.parkList({
  200. current: 1,
  201. size: 1000000,
  202. }).then(({
  203. data
  204. }) => {
  205. this.parkList = data.records.map((item) => {
  206. return {
  207. label: item.parkName,
  208. value: item.id
  209. }
  210. })
  211. console.log(this.parkList, '=============>')
  212. }).catch(e => {
  213. console.log(e)
  214. })
  215. },
  216. // 获取上传进度
  217. progress(e) {
  218. console.log('上传进度:', e)
  219. },
  220. // 上传成功
  221. success(e) {
  222. console.log('上传成功')
  223. },
  224. // 上传失败
  225. fail(e) {
  226. console.log('上传失败:', e)
  227. },
  228. deleteFile(e) {
  229. this.picUrl.splice(e.index, 1)
  230. },
  231. // 获取上传状态
  232. select(e) {
  233. console.log('选择文件:', e)
  234. var _this = this
  235. var i = 0
  236. upload()
  237. function upload() {
  238. if (i >= e.tempFiles.length) {
  239. return;
  240. }
  241. var item = e.tempFiles[i]
  242. uni.showLoading({
  243. title: "上传中",
  244. mask: true
  245. });
  246. uni.uploadFile({
  247. url: '/file/upload?uploadPath=', // 仅为示例,非真实的接口地址
  248. filePath: item.url,
  249. name: 'file',
  250. formData: {
  251. 'fileName': item.name
  252. },
  253. header: {
  254. 'token': _this.$auth.getUserToken()
  255. },
  256. success: (res) => {
  257. var data = res.data
  258. if (typeof data['error'] != "undefined") {
  259. uni.showToast({
  260. icon: 'none',
  261. title: '上传失败,请联系开发!'
  262. });
  263. _this.$refs.picFile.clearFiles(_this.picLists.length)
  264. } else {
  265. _this.picUrl.push({
  266. url: data,
  267. uuid: item.uuid
  268. })
  269. i++;
  270. upload()
  271. }
  272. },
  273. fail: () => {
  274. uni.hideLoading();
  275. uni.showToast({
  276. icon: 'none',
  277. title: '上传失败,请联系开发!'
  278. });
  279. _this.$refs.picFile.clearFiles(_this.picLists.length)
  280. },
  281. complete: function() {
  282. uni.hideLoading();
  283. }
  284. });
  285. }
  286. },
  287. formSubmit: function(e) {
  288. //定义表单规则
  289. var rule = [{
  290. name: "buildingName",
  291. checkType: "notnull",
  292. checkRule: "",
  293. errorMsg: "楼宇名称不能为空"
  294. }, ];
  295. //进行表单检查
  296. var formData = this.inputForm;
  297. var checkRes = graceChecker.check(formData, rule);
  298. console.log(checkRes, '===================>checkRes')
  299. if (checkRes) {
  300. uni.showLoading()
  301. this.inputForm.picture = [];
  302. this.picUrl.forEach(item => {
  303. this.inputForm.picture.push(item.url)
  304. })
  305. this.inputForm.picture = this.inputForm.picture.toString();
  306. loginService.buildSave(this.inputForm).then(({
  307. data
  308. }) => {
  309. uni.showToast({
  310. title: data,
  311. icon: "success"
  312. });
  313. uni.navigateTo({
  314. url: '/pages/buildList/buildList'
  315. })
  316. }).catch((e) => {
  317. })
  318. } else {
  319. uni.showToast({
  320. title: graceChecker.error,
  321. icon: "none"
  322. });
  323. }
  324. }
  325. }
  326. }
  327. </script>
  328. <style>
  329. /* .file-title) {
  330. font-size: 17px !important;
  331. } */
  332. input,
  333. textarea {
  334. color: #8799a3;
  335. }
  336. </style>