Onlinewarranty.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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. // 当设置 mutiple 为 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(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. rl: result
  211. }))
  212. fileListLen++
  213. }
  214. console.log(this.fileList1);
  215. //this.problemPhotos=this.fileList1;
  216. },
  217. uploadFilePromise(url) {
  218. console.log('111111111111111111',url)
  219. let _self=this;
  220. return new Promise((resolve, reject) => {
  221. let a = uni.uploadFile({
  222. url: BaseApi.BaseApi + '/uploadFile',
  223. header: {
  224. 'content-type': 'application/json',
  225. "token": uni.getStorageSync('tokendata'),
  226. },
  227. filePath: url,
  228. name: 'file',
  229. success: (res) => {
  230. let result = JSON.parse(res.data)
  231. // console.log(result.fileName);
  232. setTimeout(() => {
  233. resolve(JSON.parse(res.data).fileName)
  234. }, 1000)
  235. }
  236. });
  237. })
  238. },
  239. // 新增图片
  240. // async afterRead(event) {
  241. // // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  242. // let lists = [].concat(event.file)
  243. // let fileListLen =this.fileList1.length
  244. // lists.map((item) => {
  245. // this.fileList1.push({
  246. // ...item,
  247. // status: 'uploading',
  248. // message: '上传中'
  249. // })
  250. // })
  251. //
  252. // // console.log('111111111111111111',this.fileList1)
  253. // for (let i = 0; i < lists.length; i++) {
  254. // const result = await this.uploadFilePromise(lists[i])
  255. //
  256. // let item = this.fileList1[fileListLen]
  257. // this.fileList1.splice(fileListLen, 1, Object.assign(item, {
  258. // status: 'success',
  259. // message: '',
  260. // url: result
  261. // }))
  262. // fileListLen++
  263. // }
  264. // },
  265. // uploadFilePromise(url) {
  266. // console.log('999',url)
  267. //
  268. // // 这时候我们创建一个formData对象实例
  269. // const formData = new FormData();
  270. // formData.append("file", url);
  271. // console.log('222222',formData)
  272. //
  273. // //
  274. // // this.$api.post('/uploadFile',{file:url})
  275. // // .then(res=>{
  276. // // console.log('111111111111111111',res)
  277. // // })
  278. //
  279. //
  280. //
  281. //
  282. // // return new Promise((resolve, reject) => {
  283. // // let a = uni.uploadFile({
  284. // // url: BaseApi.BaseApi + '/uploadFile',
  285. // // filePath: url,
  286. // // name: 'file',
  287. // // formData: {
  288. // // user: 'test'
  289. // // },
  290. // // success: (res) => {
  291. // // setTimeout(() => {
  292. // // resolve(res.data.data)
  293. // // }, 1000)
  294. // // }
  295. // // });
  296. // // })
  297. // },
  298. changeHandler(e) {
  299. const {
  300. columnIndex,
  301. value,
  302. values, // values为当前变化列的数组内容
  303. index,
  304. indexs,
  305. picker = this.$refs.uPicker
  306. } = e
  307. console.log('999999', columnIndex, index, indexs)
  308. if (columnIndex == 0) {
  309. // this.loading = true
  310. picker.setColumnValues(1, this.alldata[index].childrenList)
  311. if (this.alldata[indexs[0]].childrenList[0].childrenList == null) {
  312. console.log('66666', )
  313. picker.setColumnValues(2, [])
  314. } else {
  315. console.log('00000000', )
  316. picker.setColumnValues(2, this.alldata[indexs[0]].childrenList[0].childrenList)
  317. }
  318. // picker.setColumnValues(2, this.alldata[indexs[0]].childrenList[0].childrenList)
  319. // this.loading = false
  320. } else if (columnIndex == 1) {
  321. // picker为选择器this实例,变化第三列对应的选项
  322. // if (this.alldata[indexs[0]].childrenList[indexs[1]] == null) {
  323. // console.log('123',)
  324. // this.alldata[indexs[0]].childrenList[indexs[1]] = []
  325. // } else {
  326. // console.log('345',)
  327. // }
  328. console.log('222', this.alldata[indexs[0]].childrenList[indexs[1]].childrenList)
  329. picker.setColumnValues(2, this.alldata[indexs[0]].childrenList[indexs[1]].childrenList)
  330. }
  331. },
  332. confirmfloor(e) {
  333. console.log('222222', e.value)
  334. this.model1.userInfo.repairPositionName = e.value[0].orgName + '/' + e.value[1].orgName + '/' + e.value[2].orgName;
  335. this.model1.userInfo.buildingId = e.value[0].orgId;
  336. this.model1.userInfo.storeyId = e.value[1].orgId;
  337. this.model1.userInfo.houseId = e.value[2].orgId;
  338. this.model1.userInfo.repairPosition = e.value[2].orgId;
  339. this.showfloor = false;
  340. // this.getalldata();
  341. },
  342. cancelfloor() {
  343. this.showfloor = false;
  344. },
  345. getfloor() {
  346. this.$api.get('/control/getOrgStructureTree', {})
  347. .then(res => {
  348. if (res.data.code == 0) {
  349. //this.dataForm.projectId = res.data.data[0].orgId;
  350. // this.model1.userInfo.myposition = res.data.data[0].orgcontactPerson;
  351. this.alldata = res.data.data[0].childrenList;
  352. this.columns = [
  353. this.alldata,
  354. this.alldata[0].childrenList,
  355. this.alldata[0].childrenList[0].childrenList
  356. ]
  357. } else {
  358. this.showdct = true
  359. }
  360. })
  361. },
  362. onShowDatePicker() { //显示
  363. this.showPicker = true;
  364. // this.value =this.model1.userInfo.repairPositioncontactPerson;
  365. },
  366. returndata() {
  367. uni.navigateBack({
  368. delta: 1
  369. });
  370. },
  371. editdata() {
  372. console.log('111111111111111111', this.model1.userInfo)
  373. this.$refs.form1.validate().then(res => {
  374. uni.$u.toast('校验通过')
  375. this.$api.post('/repairorder',this.model1.userInfo)
  376. .then(res=>{
  377. uni.navigateBack({
  378. delta: 1
  379. });
  380. })
  381. }).catch(errors => {
  382. uni.$u.toast('校验失败')
  383. })
  384. },
  385. typeconfirm(e) {
  386. // console.log('111111111111111111', e.value[0])
  387. this.model1.userInfo.repairRegion = e.value[0].id;
  388. this.model1.userInfo.repairRegionName = e.value[0].label;
  389. this.showSex = false;
  390. // this.model1.userInfo.sex = e.contactPerson
  391. this.$refs.form1.validateField('userInfo.repairRegionName')
  392. },
  393. degreeconfirm(e) {
  394. //console.log('111111111111111111', e.value[0].label)
  395. this.model1.userInfo.repairType = e.value[0].id;
  396. this.model1.userInfo.repairTypeName = e.value[0].label;
  397. this.showtaskdegree = false;
  398. // this.model1.userInfo.sex = e.contactPerson
  399. this.$refs.form1.validateField('userInfo.repairTypeName')
  400. },
  401. },
  402. onReady() {
  403. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  404. this.$refs.form1.setRules(this.rules)
  405. },
  406. };
  407. </script>
  408. <style>
  409. .guidang {
  410. display: flex;
  411. justify-content: space-between;
  412. align-items: center;
  413. margin-top: 40rpx;
  414. }
  415. .queding {
  416. width: 40%;
  417. }
  418. .wfgz {
  419. margin: 20rpx;
  420. margin-top: 0px;
  421. }
  422. </style>