list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view>
  3. <view class="head">
  4. <text>报修信息表<image src="../../static/笔.svg" mode=""></image></text>
  5. </view>
  6. <view class="content">
  7. <!-- 故障类型 -->
  8. <view class="headline-1">
  9. <text class="uni-list-cell-left">故障类型:</text>
  10. <view class="uni-list-cell">
  11. <view class="uni-list-cell-db">
  12. <template v-if="List!=null">
  13. <picker @change="bindPickerChange($event,List)" :value="index" :range="List" :range-key="'faultName'">
  14. <view class="uni-input-1">{{List[index].faultName}}<image src="../../static/下箭头.svg" mode=""></image></view>
  15. </picker>
  16. </template>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 宿舍楼栋 -->
  21. <view class="headline-2">
  22. <text class="uni-list-cell-left-2" >宿舍楼栋:</text>
  23. <view class="uni-list-cell">
  24. <view class="uni-list-cell-db">
  25. <template v-if="roomList!=null">
  26. <picker @click="getroom" mode="multiSelector" @columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray">
  27. <view class="uni-input-2">{{multiArray[0][multiIndex[0]]?multiArray[0][multiIndex[0]]:''}}{{multiArray[2][multiIndex[2]]?multiArray[2][multiIndex[2]]:''}}<image src="../../static/下箭头.svg" mode=""></image></view>
  28. </picker>
  29. </template>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 预期时间 -->
  34. <view class="headline-2">
  35. <text class="uni-list-cell-left-2" >预期时间:</text>
  36. <view style="line-height: 35px;" @click="onShowDatePicker('datetime')"class="uni-list-cell-db-2">
  37. <text style="margin-left: 10px;">{{timeValue}}</text>
  38. </view>
  39. <mx-date-picker :show="showPicker" :type="type" :value="timeValue" :show-tips="true" :begin-text="'开始'" :end-text="'截至'" :show-seconds="true" @confirm="onSelected" @cancel="onSelected" />
  40. <image src="../../static/下箭头.svg" mode="" class="timeimg"></image>
  41. </view>
  42. <!-- 联系电话 -->
  43. <view class="headline-2">
  44. <text class="uni-list-cell-left-2" >联系电话:</text>
  45. <view class="uni-list-cell-db-2"><input class="uni-input-2"@input="Phone" v-model="formData.phone" /></view>
  46. </view>
  47. <!-- 备选电话 -->
  48. <view class="headline-2">
  49. <text class="uni-list-cell-left-2" >备选电话:</text>
  50. <view class="uni-list-cell-db-2">
  51. <input class="uni-input-2" @input="onInputphone" v-model="formData.inputphone" />
  52. </view>
  53. </view>
  54. <!-- 照片 -->
  55. <view class="photo">
  56. <view class="photo-title">拍摄故障照片:</view>
  57. <view class="image" >
  58. <view class="imageText" @click="seleckImage()" v-if="imgSrc" style="vertical-align: top;">
  59. <view class="imgSrc"><image v-for="(item,index) in imgArr" :src="item" @click="preview(item)"></image></view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 备注 -->
  64. <view class="os-headline-2">
  65. <text class="os-list-cell-left-2" >备注:</text>
  66. <view class="os-list-cell-db-2">
  67. <input class="os-input-2" v-model="formData.os" />
  68. </view>
  69. </view>
  70. <button type="default" class="up" @click="getList" style="width: 323px; height: 36px; background-color:rgba(42, 130, 228, 1); color: white;font-size: 12px; border-radius: 14px;">立即提交</button>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import MxDatePicker from "../../util/mx-datepicker/mx-datepicker"
  77. export default {
  78. components: {
  79. MxDatePicker
  80. },
  81. data() {
  82. return {
  83. imgArr:[],//存放图片数组
  84. imgSrc:true,
  85. title: 'picker',
  86. List: null,
  87. index: '',
  88. pickerData:'',
  89. roomList:null,
  90. buildHighList:null,
  91. buildRoomList:null,
  92. buildId:null,
  93. floorId:null,
  94. roomId:null,
  95. multiIndex: ['',''],
  96. formData:{
  97. phone:'',
  98. inputphone:'',
  99. os:''
  100. },
  101. array0:[],
  102. multiArray: [
  103. [],
  104. [],
  105. []
  106. ],
  107. showPicker: false,
  108. datetime: '2022-03-27 15:00:12',
  109. range: ['2022-03-27','2022-03-27'],
  110. rangetime:'',
  111. type: 'rangetime',
  112. timeValue: '',
  113. homeUrl:"https://jtishfw.ncjti.edu.cn/baoxiu/repairApi"
  114. }
  115. },
  116. onLoad(){
  117. this.getfault()
  118. this.getbuild()
  119. },
  120. watch: {
  121. buildId:{
  122. handler(newValue,oldVaue){
  123. this.getbuildHigh()
  124. },
  125. immediate:true
  126. },
  127. floorId:{
  128. handler(newValue,oldVaue){
  129. this.getrooms()
  130. },
  131. immediate:true,
  132. deep:true
  133. }
  134. },
  135. methods: {
  136. onShowDatePicker(type){//显示
  137. this.type = type;
  138. this.showPicker = true;
  139. this.timeValue = this[type];
  140. },
  141. onSelected(e){//选择
  142. this.showPicker = false;
  143. if(e) {
  144. this[this.type] = e.value;
  145. this.timeValue = e.value;
  146. //选择的值
  147. console.log('value => '+ e.value);
  148. //原始的Date对象
  149. console.log('date => ' + e.date);
  150. }
  151. },
  152. getroom(){
  153. this.buildId=1
  154. this.floorId=1
  155. },
  156. seleckImage() {
  157. let that = this;
  158. uni.chooseImage({
  159. success: function(res) {
  160. console.log('选择图片')
  161. console.log(res.tempFilePaths)
  162. // 将图片存放在数组中
  163. that.imgArr = res.tempFilePaths
  164. console.log(JSON.stringify(that.imgArr))
  165. }
  166. });
  167. },
  168. preview(img) {
  169. console.log('预览')
  170. // 新建一个存放预览图片的空数组
  171. var imgArr = []
  172. imgArr.push(img)
  173. uni.previewImage({
  174. urls: imgArr,
  175. current: imgArr[0]
  176. });
  177. },
  178. bindPickerChange: function(e,storage) {
  179. console.log(e)
  180. console.log(storage)
  181. this.index = e.target.value
  182. this.pickerData = storage[this.index] // 这里就是选中的对象
  183. console.log(this.pickerData.faultName)
  184. },
  185. bindMultiPickerColumnChange: function(e) {
  186. console.log('修改的列为:' + e.detail.column + ',值为:' + e.detail.value)
  187. this.multiIndex[e.detail.column] = e.detail.value
  188. switch(e.detail.column){
  189. case 0:{
  190. this.buildId = e.detail.value+1
  191. break;
  192. }
  193. case 1:{
  194. this.floorId = e.detail.value+1
  195. break;
  196. }
  197. case 2:{
  198. this.roomId = e.detail.value+1
  199. }
  200. }
  201. },
  202. // 故障信息
  203. async getfault(){
  204. const res = await uni.request({
  205. method:'POST',
  206. url:`${this.homeUrl}/fault/queryAllFaultByStatus`,
  207. success: (res) => {
  208. this.List = res.data.data;
  209. console.log(this.List)
  210. }
  211. })
  212. },
  213. // 宿舍楼栋
  214. async getbuild(){
  215. const res = await uni.request({
  216. method:'POST',
  217. url:`${this.homeUrl}/build/queryAllBuild`,
  218. success: (res) => {
  219. this.roomList = res.data.data
  220. console.log(res.data)
  221. console.log(this.roomList)
  222. this.roomList.forEach(item=>{
  223. this.multiArray[0].push(item.buildName)
  224. })
  225. console.log('multiArray:'+this.multiArray[0])
  226. }
  227. })
  228. },
  229. // 宿舍楼层
  230. async getbuildHigh(){
  231. const res = await uni.request({
  232. method:'POST',
  233. url:`${this.homeUrl}/build/queryAllFloorByBuildID?buildId=`+this.buildId,
  234. success: (res) => {
  235. this.buildHighList = res.data.data
  236. console.log(this.buildHighList)
  237. var tempList = new Array
  238. this.buildHighList.forEach(item=>{
  239. tempList.push(item.floorName)
  240. })
  241. this.$set(this.multiArray,1,tempList)
  242. console.log(this.buildId)
  243. }
  244. })
  245. },
  246. // 宿舍房间
  247. async getrooms(){
  248. const res = await uni.request({
  249. method:'POST',
  250. url:`${this.homeUrl}/build/queryAllRoomByFloorID?floorId=`+this.floorId,
  251. success: (res) => {
  252. this.buildRoomList = res.data.data
  253. var tempList = new Array
  254. this.buildRoomList.forEach(item=>{
  255. tempList.push(item.roomName)
  256. })
  257. this.$set(this.multiArray,2,tempList)
  258. console.log(this.floorId)
  259. }
  260. })
  261. },
  262. // 提交订单
  263. async getList(){
  264. this.$https.post(`${this.homeUrl}/order/insertOrder?otherPhone=${this.inputphone}&faultId=${this.pickerData.faultId}&dormNumber=${this.buildId+'-'+this.floorId+'-'+this.roomId}&orderExpectedTime=${this.timeValue}&studentDormitory=${this.buildId+'栋'+this.floorId+'层'+this.roomId+'号'}`)
  265. .then(result=>{
  266. let buildId = this.buildId;
  267. let floorId = this.floorId;
  268. let roomId = this.roomId;
  269. let orderExpectedTime = this.timeValue;
  270. let alldata = this.formData;
  271. let faultId= this.pickerData.faultId;
  272. console.log(JSON.stringify(alldata))
  273. console.log(JSON.stringify(faultId))
  274. console.log(JSON.stringify(orderExpectedTime))
  275. console.log(JSON.stringify(buildId))
  276. console.log(JSON.stringify(floorId))
  277. console.log(JSON.stringify(roomId))
  278. uni.reLaunch({
  279. url:'../index/index'
  280. })
  281. },err=>{})
  282. },
  283. onInputphone(e){
  284. this.inputphone = e.target.value
  285. console.log(this.inputphone)
  286. },
  287. Phone(e){
  288. this.phone = e.target.value
  289. console.log(this.phone)
  290. },
  291. bindDateChange: function(e) {
  292. this.date = e.target.value
  293. },
  294. bindTimeChange: function(e) {
  295. this.time = e.target.value
  296. }
  297. }
  298. }
  299. </script>
  300. <style>
  301. .test{
  302. text-align: center;
  303. padding: 10px 0;
  304. }
  305. button{
  306. margin: 20upx;
  307. font-size: 28upx;
  308. }
  309. .head{
  310. height: 131px;
  311. font-size: 15px;
  312. color: white;
  313. border-radius: 0px 0px 15px 15px;
  314. background-color:rgba(42, 130, 228, 1);
  315. }
  316. .head text{
  317. float: left;
  318. margin-left: 140px;
  319. margin-top: 12px;
  320. }
  321. .head image{
  322. height: 17px;
  323. width: 17px;
  324. font-size: 17px;
  325. vertical-align: bottom;
  326. }
  327. .headline-1{
  328. font-size: 12px;
  329. }
  330. .headline-2{
  331. font-size: 12px;
  332. }
  333. .content{
  334. position: relative;
  335. width:359px;
  336. height: 627px;
  337. margin-top: -81px;
  338. margin-left: 7px;
  339. border: 1px solid rgba(128, 128, 128, 0.45);
  340. background-color: rgba(255, 255, 255, 1);
  341. }
  342. .uni-list-cell{
  343. float: right;
  344. width: 242px;
  345. height: 35px;
  346. margin-top: 18px;
  347. margin-right: 32px;
  348. border-radius: 16px;
  349. line-height: 22px;
  350. background-color: rgba(166, 166, 166, 0.18);
  351. }
  352. .uni-input-1{
  353. margin-left: 10px;
  354. margin-top: 5px;
  355. }
  356. .uni-input-1 image{
  357. float: right;
  358. margin-right: 5px;
  359. width: 20px;
  360. height: 20px;
  361. font-size: 20px;
  362. }
  363. .uni-list-cell-left{
  364. float: left;
  365. margin-top: 24px;
  366. margin-left: 13px;
  367. }
  368. .uni-list-cell-left-2{
  369. float: left;
  370. margin-left: 15px;
  371. margin-top: 38px;
  372. }
  373. .uni-list-cell-db-2{
  374. float: right;
  375. margin-right: 32px;
  376. margin-top: 18px;
  377. width: 242px;
  378. height: 35px;
  379. border-radius: 16px;
  380. background-color: rgba(166, 166, 166, 0.18);
  381. }
  382. .uni-input-2{
  383. margin-left: 10px;
  384. margin-top: 8px;
  385. font-size: 12px;
  386. }
  387. .uni-input-2 image{
  388. float: right;
  389. margin-right: 5px;
  390. width: 20px;
  391. height: 20px;
  392. font-size: 20px;
  393. }
  394. .timeimg{
  395. position: absolute;
  396. right:36px;
  397. top: 131px;
  398. width: 20px;
  399. height: 20px;
  400. font-size: 20px;
  401. }
  402. .photo {
  403. height: 169px;
  404. font-size: 12px;
  405. }
  406. .photo-title{
  407. float: left;
  408. margin-left: 13px;
  409. margin-top: 15px;
  410. }
  411. .image {
  412. float: left;
  413. margin-left: 13px;
  414. margin-top: 15px;
  415. height: 198px;
  416. width: 322px;
  417. box-sizing: border-box;
  418. border-radius: 14px;
  419. background-color: rgba(166, 166, 166, 0.18);
  420. }
  421. .imageText {
  422. text-align: center;
  423. border-radius: 14px;
  424. width: 100%;
  425. height: 100%;
  426. background-color:rgba(166, 166, 166, 0.18);
  427. }
  428. .imgSrc image{
  429. width: 323PX;
  430. height: 193px;
  431. }
  432. .os-headline-2{
  433. float: left;
  434. }
  435. .os-list-cell-left-2{
  436. float: left;
  437. margin-left: 13px;
  438. margin-top: 16px;
  439. font-size: 12px;
  440. }
  441. .os-input-2{
  442. margin-left: 5px;
  443. margin-top: 4px;
  444. font-size: 12px;
  445. /* cursor: not-allowed; */
  446. }
  447. .os-list-cell-db-2{
  448. float: right;
  449. width: 284px;
  450. height: 30px;
  451. margin-right: 15px;
  452. margin-top: 10px;
  453. border-radius: 14px;
  454. background-color: rgba(166, 166, 166, 0.18);
  455. }
  456. .up{
  457. position: absolute;
  458. bottom: 13px;
  459. left: 15px;
  460. }
  461. </style>