basicInfo.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. import { lbsAmapRegion } from '@/api/common.js'
  2. import { listPageV2, getDetail } from "@/api/engineeringMaintenance/basicData";
  3. import geographicalPosi from '@/components/geographicalPosi/index.vue'
  4. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  5. export default {
  6. data() {
  7. return {
  8. provinceList: [],
  9. cityList: [],
  10. areaList: [],
  11. streetList: [],
  12. }
  13. },
  14. computed: {
  15. // 基本信息数据模型
  16. basicInfo() {
  17. return [
  18. {
  19. name: 'el-input',
  20. md: 6,
  21. attributes: { disabled: false, placeholder: '请输入' },
  22. formItemAttributes: {
  23. label: '客户名称',
  24. prop: 'userName',
  25. rules: [...required]
  26. },
  27. events: {
  28. input: (v) => {
  29. this.addFormData.linkName = v
  30. }
  31. }
  32. },
  33. {
  34. name: 'el-input',
  35. md: 6,
  36. attributes: { disabled: false, placeholder: '请输入', maxlength: 11 },
  37. formItemAttributes: {
  38. label: '客户电话',
  39. prop: 'userMobile',
  40. rules: [...mobileRequired]
  41. }
  42. },
  43. {
  44. name: 'slot-component',
  45. md: 12,
  46. formItemAttributes: {
  47. 'label-width': '0px',
  48. prop: '',
  49. },
  50. render: (h, { props }) => {
  51. return null
  52. }
  53. },
  54. // {
  55. // name: 'el-select',
  56. // md: 6,
  57. // formItemAttributes: {
  58. // label: '客户地址', //省
  59. // prop: 'provinceId',
  60. // rules: [required],
  61. // errLabel: '省'
  62. // },
  63. // options: this.provinceList.map((v, i) => ({ value: v.id, label: v.name })),
  64. // attributes: { disabled: true, clearable: true, filterable: true, placeholder: '请选择' },
  65. // events: {
  66. // change: () => {
  67. // // 获取省名称
  68. // this.addFormData.province = this.provinceList.find(item => item.id === val)?.name || ''
  69. // // 清除市区街道以及详细地址数据
  70. // this.delDataK(1)
  71. // lbsAmapRegion({ pid: val }).then(res => {
  72. // this.cityList = res.data
  73. // })
  74. // }
  75. // }
  76. // },
  77. // {
  78. // name: 'el-select',
  79. // md: 5,
  80. // formItemAttributes: {
  81. // 'label-width': '0px',
  82. // label: '', //市
  83. // prop: 'cityId',
  84. // rules: [required],
  85. // errLabel: '市'
  86. // },
  87. // options: this.cityList.map((v, i) => ({ value: v.id, label: v.name })),
  88. // attributes: { disabled: true, clearable: true, filterable: true, placeholder: '请选择' },
  89. // events: {
  90. // change: () => {
  91. // // 获取市名称
  92. // this.addFormData.city = this.cityList.find(item => item.id === val).name
  93. // // 清除区街道以及详细地址数据
  94. // this.delDataK(2)
  95. // lbsAmapRegion({ pid: val }).then(res => {
  96. // this.areaList = res.data
  97. // })
  98. // }
  99. // }
  100. // },
  101. // {
  102. // name: 'el-select',
  103. // md: 5,
  104. // formItemAttributes: {
  105. // 'label-width': '0px',
  106. // label: '', //区
  107. // prop: 'areaId',
  108. // rules: [required],
  109. // errLabel: '区'
  110. // },
  111. // options: this.areaList.map((v, i) => ({ value: v.id, label: v.name })),
  112. // attributes: { disabled: true, clearable: true, filterable: true, placeholder: '请选择' },
  113. // events: {
  114. // change: () => {
  115. // // 获取区名称
  116. // this.addFormData.area = this.areaList.find(item => item.id === val).name
  117. // // 清除街道以及详细地址数据
  118. // this.delDataK(3)
  119. // lbsAmapRegion({ pid: val }).then(res => {
  120. // this.streetList = res.data
  121. // })
  122. // }
  123. // }
  124. // },
  125. // {
  126. // name: 'el-select',
  127. // md: 5,
  128. // formItemAttributes: {
  129. // 'label-width': '0px',
  130. // label: '', //街道
  131. // prop: 'streetId',
  132. // rules: [required],
  133. // errLabel: '街道'
  134. // },
  135. // options: this.streetList.map((v, i) => ({ value: v.id, label: v.name })),
  136. // attributes: { disabled: true, clearable: true, filterable: true, placeholder: '请选择' },
  137. // events: {
  138. // change: () => {
  139. // // 获取街道名称
  140. // this.addFormData.street = this.streetList.find(item => item.id === val).name
  141. // // 清除详细地址数据
  142. // this.delDataK(4)
  143. // }
  144. // }
  145. // },
  146. {
  147. name: 'el-input',
  148. md: 21,
  149. formItemAttributes: { label: '客户地址', prop: 'userAddress', rules: [...required] },
  150. attributes: { disabled: false, placeholder: '详细地址' }
  151. },
  152. {
  153. name: 'slot-component',
  154. md: 3,
  155. formItemAttributes: {
  156. 'label-width': '0px',
  157. prop: '',
  158. },
  159. render: (h, { props }) => {
  160. return (
  161. <geographicalPosi
  162. disabled={false}
  163. formData={this.addFormData}
  164. onSelectPosi={data => {
  165. // 赋值GPS详细地址
  166. this.addFormData.userAddress = data.name
  167. // // 获取经纬度
  168. // this.addFormData.lng = data.center[0]
  169. // this.addFormData.lat = data.center[1]
  170. // // 获取定位的省市区街道
  171. // var { province, city, district, township } = data.data.addressComponent
  172. // // 获取选中省名称id
  173. // var { id, name } = this.provinceList.find(item => item.name === province)
  174. // this.addFormData.provinceId = id
  175. // this.addFormData.province = name
  176. // // 请求市选项
  177. // lbsAmapRegion({ pid: this.addFormData.provinceId }).then(res => {
  178. // // 赋值市选项
  179. // this.cityList = res.data
  180. // // 获取选中市名称id
  181. // var { id, name } = res.data.find(item => item.name === city)
  182. // this.addFormData.cityId = id
  183. // this.addFormData.city = name
  184. // // 请求区选项
  185. // lbsAmapRegion({ pid: this.addFormData.cityId }).then(res => {
  186. // // 赋值区选项
  187. // this.areaList = res.data
  188. // // 获取选中区名称id
  189. // var { id, name } = res.data.find(item => item.name === district)
  190. // this.addFormData.areaId = id
  191. // this.addFormData.area = name
  192. // // 请求街道选项
  193. // lbsAmapRegion({ pid: this.addFormData.areaId }).then(res => {
  194. // // 赋值街道选项
  195. // this.streetList = res.data
  196. // // 获取选中街道名称id
  197. // var { id, name } = res.data.find(item => item.name === township)
  198. // this.addFormData.streetId = id
  199. // this.addFormData.street = name
  200. // // 赋值GPS详细地址
  201. // this.addFormData.userAddress = data.name
  202. // })
  203. // })
  204. // })
  205. }}
  206. />
  207. )
  208. }
  209. },
  210. {
  211. name: 'el-input',
  212. md: 24,
  213. attributes: {
  214. disabled: false,
  215. type: 'textarea',
  216. rows: 3,
  217. placeholder: '请输入'
  218. },
  219. formItemAttributes: {
  220. label: '备注',
  221. prop: 'remark',
  222. rules: []
  223. }
  224. }
  225. ]
  226. }
  227. },
  228. methods: {
  229. getinitlbslist() {
  230. // 初始化请求省市区街道下拉选项数据
  231. lbsAmapRegion({ pid: 0 }).then(res => {
  232. this.provinceList = res.data
  233. // 创建工单时获取ip地址定位赋值
  234. if (!this.addFormData.id && this.$IpAdd.province) {
  235. var item = this.provinceList.find(item => item.name === this.$IpAdd.province)
  236. if (item) {
  237. this.addFormData.provinceId = item.id
  238. this.addFormData.province = item.name
  239. }
  240. }
  241. if (this.addFormData.provinceId) {
  242. lbsAmapRegion({ pid: this.addFormData.provinceId }).then(res => {
  243. this.cityList = res.data
  244. // 创建工单时获取ip地址定位赋值
  245. if (!this.id && this.$IpAdd.city) {
  246. var item2 = this.cityList.find(item => item.name === this.$IpAdd.city)
  247. if (item2) {
  248. this.addFormData.cityId = item2.id
  249. this.addFormData.city = item2.name
  250. }
  251. }
  252. if (this.addFormData.cityId) {
  253. lbsAmapRegion({ pid: this.addFormData.cityId }).then(res => {
  254. this.areaList = res.data
  255. })
  256. }
  257. if (this.addFormData.areaId) {
  258. lbsAmapRegion({ pid: this.addFormData.areaId }).then(res => {
  259. this.streetList = res.data
  260. })
  261. }
  262. })
  263. }
  264. })
  265. },
  266. delDataK(num) {
  267. if (num <= 1) {
  268. // 删除市
  269. this.addFormData.cityId = ''
  270. this.addFormData.city = ''
  271. // 删除市选项
  272. this.cityList = []
  273. }
  274. if (num <= 2) {
  275. // 删除区
  276. this.addFormData.areaId = ''
  277. this.addFormData.area = ''
  278. // 删除区选项
  279. this.areaList = []
  280. }
  281. if (num <= 3) {
  282. // 删除街道
  283. this.addFormData.streetId = ''
  284. this.addFormData.street = ''
  285. // 删除街道选项
  286. this.streetList = []
  287. }
  288. // 删除gps地址
  289. this.addFormData.userAddress = ''
  290. }
  291. }
  292. }