buildEdit.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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"
  21. :range="parkList" :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"
  87. :imageStyles="imageStyles" :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. this.$auth.checkLogin()
  122. },
  123. data() {
  124. return {
  125. title: '新建楼宇信息',
  126. inputForm: {
  127. id: '',
  128. parkManagement: {
  129. id: ''
  130. },
  131. buildingName: '',
  132. buildingLongitude: '',
  133. buildingLatitude: '',
  134. buildingContacts: '',
  135. buildingDescribe: '',
  136. buildingNum: '',
  137. buildingArea: '',
  138. buildingIndustry: '',
  139. placeSelectName: '盐城市/盐都区',
  140. street: '',
  141. placeDetailed: '',
  142. picture: '',
  143. notes: '',
  144. reserve2: ''
  145. },
  146. autoUpload: false,
  147. picLists: [],
  148. picUrl: [],
  149. imageStyles: {
  150. width: 90,
  151. height: 90
  152. },
  153. parkList: [],
  154. ischeck: false,
  155. }
  156. },
  157. created() {
  158. this.getParkList()
  159. },
  160. mounted() {
  161. },
  162. async onLoad(query) {
  163. console.log(query, '==============>query')
  164. if (query && query.ischeck) {
  165. this.ischeck = true
  166. this.title = "查看楼宇信息";
  167. }
  168. if (query && query.id && !query.ischeck) {
  169. this.title = "修改楼宇信息";
  170. }
  171. if (query && query.id) {
  172. let {
  173. data
  174. } = await loginService.queryByIdBuild(query.id)
  175. console.log(data)
  176. if (data.pic != null) {
  177. data.pic = data.pic.split(",")
  178. var list = data.pic
  179. list.forEach(item => {
  180. this.picUrl.push({
  181. 'url': item,
  182. 'uuid': item
  183. })
  184. this.picLists.push({
  185. 'url': item,
  186. 'uuid': item
  187. })
  188. })
  189. } else {
  190. data.pic = []
  191. }
  192. this.inputForm = this.recover(this.inputForm, data)
  193. }
  194. },
  195. methods: {
  196. getParkList() {
  197. loginService.parkList({
  198. current: 1,
  199. size: 1000000,
  200. }).then(({
  201. data
  202. }) => {
  203. this.parkList = data.records.map((item) => {
  204. return {
  205. label: item.parkName,
  206. value: item.id
  207. }
  208. })
  209. console.log(this.parkList, '=============>')
  210. }).catch(e => {
  211. console.log(e)
  212. })
  213. },
  214. // 获取上传进度
  215. progress(e) {
  216. console.log('上传进度:', e)
  217. },
  218. // 上传成功
  219. success(e) {
  220. console.log('上传成功')
  221. },
  222. // 上传失败
  223. fail(e) {
  224. console.log('上传失败:', e)
  225. },
  226. deleteFile(e) {
  227. this.picUrl.splice(e.index, 1)
  228. },
  229. // 获取上传状态
  230. select(e) {
  231. console.log('选择文件:', e)
  232. var _this = this
  233. var i = 0
  234. upload()
  235. function upload() {
  236. if (i >= e.tempFiles.length) {
  237. return;
  238. }
  239. var item = e.tempFiles[i]
  240. uni.showLoading({
  241. title: "上传中",
  242. mask: true
  243. });
  244. uni.uploadFile({
  245. url: '/file/upload?uploadPath=', // 仅为示例,非真实的接口地址
  246. filePath: item.url,
  247. name: 'file',
  248. formData: {
  249. 'fileName': item.name
  250. },
  251. header: {
  252. 'token': _this.$auth.getUserToken()
  253. },
  254. success: (res) => {
  255. var data = res.data
  256. if (typeof data['error'] != "undefined") {
  257. uni.showToast({
  258. icon: 'none',
  259. title: '上传失败,请联系开发!'
  260. });
  261. _this.$refs.picFile.clearFiles(_this.picLists.length)
  262. } else {
  263. _this.picUrl.push({
  264. url: data,
  265. uuid: item.uuid
  266. })
  267. i++;
  268. upload()
  269. }
  270. },
  271. fail: () => {
  272. uni.hideLoading();
  273. uni.showToast({
  274. icon: 'none',
  275. title: '上传失败,请联系开发!'
  276. });
  277. _this.$refs.picFile.clearFiles(_this.picLists.length)
  278. },
  279. complete: function() {
  280. uni.hideLoading();
  281. }
  282. });
  283. }
  284. },
  285. formSubmit: function(e) {
  286. //定义表单规则
  287. var rule = [{
  288. name: "buildingName",
  289. checkType: "notnull",
  290. checkRule: "",
  291. errorMsg: "楼宇名称不能为空"
  292. },
  293. ];
  294. //进行表单检查
  295. var formData = this.inputForm;
  296. var checkRes = graceChecker.check(formData, rule);
  297. console.log(checkRes, '===================>checkRes')
  298. if (checkRes) {
  299. uni.showLoading()
  300. this.inputForm.picture = [];
  301. this.picUrl.forEach(item => {
  302. this.inputForm.picture.push(item.url)
  303. })
  304. this.inputForm.picture = this.inputForm.picture.toString();
  305. loginService.buildSave(this.inputForm).then(({
  306. data
  307. }) => {
  308. uni.showToast({
  309. title: data,
  310. icon: "success"
  311. });
  312. uni.navigateTo({
  313. url: '/pages/buildList/buildList'
  314. })
  315. }).catch((e) => {
  316. })
  317. } else {
  318. uni.showToast({
  319. title: graceChecker.error,
  320. icon: "none"
  321. });
  322. }
  323. }
  324. }
  325. }
  326. </script>
  327. <style>
  328. /* .file-title) {
  329. font-size: 17px !important;
  330. } */
  331. input,textarea{
  332. color: #8799a3;
  333. }
  334. </style>