Onlinewarranty.vue 12 KB

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