Onlinewarranty.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <view class="OutermostLayer">
  3. <view class="wfgz">
  4. <!-- 注意,如果需要兼容微信小程序,最好通过setRules方法设置rules规则 -->
  5. <u--form labelPosition="left" :model="model1" :rules="rules" ref="form1">
  6. <!-- <u-form-item labelWidth='180' label="任务名称:" prop="userInfo.contactPerson" borderBottom ref="item1">
  7. <u--input v-model="model1.userInfo.contactPerson" border="none"></u--input>
  8. </u-form-item> -->
  9. <u-form-item labelWidth='180' label="报修位置:" prop="userInfo.repairPositionName" borderBottom
  10. @click="showfloor = true;" ref="item1" :required=true>
  11. <u--input v-model="model1.userInfo.repairPositionName" disabled disabledColor="#ffffff"
  12. placeholder="请选择报修位置" border="none"></u--input>
  13. <u-icon slot="right" contactPerson="arrow-right"></u-icon>
  14. </u-form-item>
  15. <u-form-item labelWidth='180' label="报修区域:" prop="userInfo.repairRegionName" borderBottom
  16. @click="showSex = true;" ref="item1" :required=true>
  17. <u--input v-model="model1.userInfo.repairRegionName" disabled disabledColor="#ffffff"
  18. placeholder="请选择报修区域" border="none"></u--input>
  19. <u-icon slot="right" contactPerson="arrow-right"></u-icon>
  20. </u-form-item>
  21. <u-form-item labelWidth='180' label="报修类型:" prop="userInfo.repairTypeName" borderBottom
  22. @click="showtaskdegree = true;" ref="item1" :required=true>
  23. <u--input v-model="model1.userInfo.repairTypeName" disabled disabledColor="#ffffff"
  24. placeholder="请选择报修类型" border="none"></u--input>
  25. <u-icon slot="right" contactPerson="arrow-right"></u-icon>
  26. </u-form-item>
  27. <u-form-item labelWidth='180' label="联系人:" prop="userInfo.contactPerson" borderBottom ref="item1"
  28. :required=true>
  29. <u--input v-model="model1.userInfo.contactPerson" border="none"></u--input>
  30. </u-form-item>
  31. <u-form-item labelWidth='180' label="联系电话:" prop="userInfo.contactPhone" borderBottom
  32. ref="item1" :required=true>
  33. <u--input v-model="model1.userInfo.contactPhone" border="none"></u--input>
  34. </u-form-item>
  35. <u-form-item labelWidth='180' label="故障描述:" prop="userInfo.faultDes" borderBottom ref="item1"
  36. :required=true>
  37. <u--input v-model="model1.userInfo.faultDes" border="none"></u--input>
  38. </u-form-item>
  39. <u-form-item labelWidth='180' label="上传照片:" prop="userInfo.faultPics" borderBottom ref="item1">
  40. <view class="">
  41. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1"
  42. multiple :maxCount="10">
  43. <image :src="xiangji" mode="widthFix" style="width: 90rpx;height: 90rpx;"></image>
  44. </u-upload>
  45. </view>
  46. </u-form-item>
  47. </u--form>
  48. <view class="guidang">
  49. <view class="queding">
  50. <u-button type="primary" :plain="true" text="返回" @click="returndata"></u-button>
  51. </view>
  52. <view class="queding">
  53. <u-button type="primary" text="提交" @click="editdata"></u-button>
  54. </view>
  55. </view>
  56. </view>
  57. <u-picker @cancel='showtaskdegree = false' @confirm='degreeconfirm' :show="showtaskdegree"
  58. :columns="columnshowtaskdegree" keyName="label">
  59. </u-picker>
  60. <u-picker @cancel='showSex = false' @confirm='typeconfirm' :show="showSex" :columns="columnsquyu"
  61. keyName="label">
  62. </u-picker>
  63. <u-picker :show="showfloor" ref="uPicker" :loading="loading" @confirm="confirmfloor" @cancel='cancelfloor'
  64. keyName="orgName" :columns="columns" @change="changeHandler"></u-picker>
  65. </view>
  66. </template>
  67. <script>
  68. const BaseApi = require("@/http/baseApi.js");
  69. export default {
  70. components: {},
  71. data() {
  72. return {
  73. loading: false,
  74. fileList1: [],
  75. xiangji: require('@/static/index/xj.png'),
  76. columns: [
  77. [],
  78. [],
  79. []
  80. ],
  81. columnData: [],
  82. columnDatalist: [],
  83. showfloor: false,
  84. myposition: '',
  85. showSex: false,
  86. showday: false,
  87. showPicker: false,
  88. showtaskdegree: false,
  89. showtaskpeople: false,
  90. model1: {
  91. userInfo: {
  92. id: "",
  93. buildingId: "", // 楼栋ID
  94. storeyId: "", // 层数ID
  95. houseId: "", // 房间ID
  96. repairPosition: "", // 房间ID
  97. repairPositionName: "", //报修位置名称
  98. repairRegion: '', //报修修区域
  99. repairRegionName: "", //报修区域名称
  100. repairType: '', //报修类型
  101. repairTypeName: "", //报修类型
  102. contactPerson: "", //联系人
  103. contactPhone: "", //电话
  104. faultDes: "", // 故障描述
  105. faultPics: "", //图片
  106. },
  107. },
  108. columnsquyu: [
  109. [{
  110. label: '公共区域',
  111. id: 1
  112. }, {
  113. label: '室内',
  114. id: 2
  115. }]
  116. ],
  117. columnshowtaskdegree: [
  118. [{
  119. label: '水',
  120. id: 1
  121. }, {
  122. label: '电',
  123. id: 2
  124. },
  125. {
  126. label: '其他',
  127. id: 3
  128. },
  129. ]
  130. ],
  131. rules: {
  132. 'userInfo.contactPerson': {
  133. type: 'string',
  134. required: true,
  135. message: '请填写联系人',
  136. trigger: ['blur', 'change']
  137. },
  138. 'userInfo.faultDes': {
  139. type: 'string',
  140. required: true,
  141. message: '请填写故障描述',
  142. trigger: ['blur', 'change']
  143. },
  144. 'userInfo.contactPhone': [{
  145. required: true,
  146. message: '请填写联系电话',
  147. trigger: ['change', 'blur'],
  148. },
  149. {
  150. // 自定义验证函数,见上说明
  151. validator: (rule, value, callback) => {
  152. // 上面有说,返回true表示校验通过,返回false表示不通过
  153. // uni.$u.test.mobile()就是返回true或者false的
  154. return uni.$u.test.mobile(value);
  155. },
  156. message: '手机号码不正确',
  157. // 触发器可以同时用blur和change
  158. trigger: ['change', 'blur'],
  159. }
  160. ],
  161. 'userInfo.repairRegionName': {
  162. type: 'string',
  163. required: true,
  164. message: '请选择报修区域',
  165. trigger: ['blur', 'change']
  166. },
  167. 'userInfo.repairPositionName': {
  168. type: 'string',
  169. required: true,
  170. message: '请选择报修位置',
  171. trigger: ['blur', 'change']
  172. },
  173. 'userInfo.repairTypeName': {
  174. type: 'string',
  175. required: true,
  176. message: '请选择报修类型',
  177. trigger: ['blur', 'change']
  178. },
  179. },
  180. };
  181. },
  182. onLoad() {
  183. this.getfloor();
  184. // this.loadmore();
  185. },
  186. methods: {
  187. // 删除图片
  188. deletePic(event) {
  189. this.fileList1.splice(event.index, 1)
  190. },
  191. // 新增图片
  192. async afterRead(event) {
  193. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  194. let lists = [].concat(event.file)
  195. let fileListLen =this.fileList1.length
  196. lists.map((item) => {
  197. this.fileList1.push({
  198. ...item,
  199. status: 'uploading',
  200. message: '上传中'
  201. })
  202. })
  203. console.log('111111111111111111',this.fileList1)
  204. for (let i = 0; i < lists.length; i++) {
  205. const result = await this.uploadFilePromise(lists[i].url)
  206. let item = this.fileList1[fileListLen]
  207. this.fileList1.splice(fileListLen, 1, Object.assign(item, {
  208. status: 'success',
  209. message: '',
  210. url: result
  211. }))
  212. fileListLen++
  213. }
  214. },
  215. uploadFilePromise(url) {
  216. console.log('999',url)
  217. this.$api.post('/uploadFile',{data:url})
  218. .then(res=>{
  219. console.log('111111111111111111',res)
  220. })
  221. // return new Promise((resolve, reject) => {
  222. // let a = uni.uploadFile({
  223. // url: BaseApi.BaseApi + '/uploadFile',
  224. // filePath: url,
  225. // name: 'file',
  226. // formData: {
  227. // user: 'test'
  228. // },
  229. // success: (res) => {
  230. // setTimeout(() => {
  231. // resolve(res.data.data)
  232. // }, 1000)
  233. // }
  234. // });
  235. // })
  236. },
  237. changeHandler(e) {
  238. const {
  239. columnIndex,
  240. value,
  241. values, // values为当前变化列的数组内容
  242. index,
  243. indexs,
  244. picker = this.$refs.uPicker
  245. } = e
  246. console.log('999999', columnIndex, index, indexs)
  247. if (columnIndex == 0) {
  248. // this.loading = true
  249. picker.setColumnValues(1, this.alldata[index].childrenList)
  250. if (this.alldata[indexs[0]].childrenList[0].childrenList == null) {
  251. console.log('66666', )
  252. picker.setColumnValues(2, [])
  253. } else {
  254. console.log('00000000', )
  255. picker.setColumnValues(2, this.alldata[indexs[0]].childrenList[0].childrenList)
  256. }
  257. // picker.setColumnValues(2, this.alldata[indexs[0]].childrenList[0].childrenList)
  258. // this.loading = false
  259. } else if (columnIndex == 1) {
  260. // picker为选择器this实例,变化第三列对应的选项
  261. // if (this.alldata[indexs[0]].childrenList[indexs[1]] == null) {
  262. // console.log('123',)
  263. // this.alldata[indexs[0]].childrenList[indexs[1]] = []
  264. // } else {
  265. // console.log('345',)
  266. // }
  267. console.log('222', this.alldata[indexs[0]].childrenList[indexs[1]].childrenList)
  268. picker.setColumnValues(2, this.alldata[indexs[0]].childrenList[indexs[1]].childrenList)
  269. }
  270. },
  271. confirmfloor(e) {
  272. console.log('222222', e.value)
  273. this.model1.userInfo.repairPositionName = e.value[0].orgName + '/' + e.value[1].orgName + '/' + e.value[2].orgName;
  274. this.model1.userInfo.buildingId = e.value[0].orgId;
  275. this.model1.userInfo.storeyId = e.value[1].orgId;
  276. this.model1.userInfo.houseId = e.value[2].orgId;
  277. this.model1.userInfo.repairPosition = e.value[2].orgId;
  278. this.showfloor = false;
  279. // this.getalldata();
  280. },
  281. cancelfloor() {
  282. this.showfloor = false;
  283. },
  284. getfloor() {
  285. this.$api.get('/control/getOrgStructureTree', {})
  286. .then(res => {
  287. if (res.data.code == 0) {
  288. //this.dataForm.projectId = res.data.data[0].orgId;
  289. // this.model1.userInfo.myposition = res.data.data[0].orgcontactPerson;
  290. this.alldata = res.data.data[0].childrenList;
  291. this.columns = [
  292. this.alldata,
  293. this.alldata[0].childrenList,
  294. this.alldata[0].childrenList[0].childrenList
  295. ]
  296. } else {
  297. this.showdct = true
  298. }
  299. })
  300. },
  301. onShowDatePicker() { //显示
  302. this.showPicker = true;
  303. // this.value =this.model1.userInfo.repairPositioncontactPerson;
  304. },
  305. returndata() {
  306. uni.navigateBack({
  307. delta: 1
  308. });
  309. },
  310. editdata() {
  311. console.log('111111111111111111', this.model1.userInfo)
  312. this.$refs.form1.validate().then(res => {
  313. uni.$u.toast('校验通过')
  314. this.$api.post('/repairorder',this.model1.userInfo)
  315. .then(res=>{
  316. uni.navigateBack({
  317. delta: 1
  318. });
  319. })
  320. }).catch(errors => {
  321. uni.$u.toast('校验失败')
  322. })
  323. },
  324. typeconfirm(e) {
  325. // console.log('111111111111111111', e.value[0])
  326. this.model1.userInfo.repairRegion = e.value[0].id;
  327. this.model1.userInfo.repairRegionName = e.value[0].label;
  328. this.showSex = false;
  329. // this.model1.userInfo.sex = e.contactPerson
  330. this.$refs.form1.validateField('userInfo.repairRegionName')
  331. },
  332. degreeconfirm(e) {
  333. //console.log('111111111111111111', e.value[0].label)
  334. this.model1.userInfo.repairType = e.value[0].id;
  335. this.model1.userInfo.repairTypeName = e.value[0].label;
  336. this.showtaskdegree = false;
  337. // this.model1.userInfo.sex = e.contactPerson
  338. this.$refs.form1.validateField('userInfo.repairTypeName')
  339. },
  340. },
  341. onReady() {
  342. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  343. this.$refs.form1.setRules(this.rules)
  344. },
  345. };
  346. </script>
  347. <style>
  348. .guidang {
  349. display: flex;
  350. justify-content: space-between;
  351. align-items: center;
  352. margin-top: 40rpx;
  353. }
  354. .queding {
  355. width: 40%;
  356. }
  357. .wfgz {
  358. margin: 20rpx;
  359. margin-top: 0px;
  360. }
  361. </style>