list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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[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" v-model="formData.phone" placeholder="" /></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" placeholder="" />
  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"placeholder="" 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: 0,
  88. pickerData:'',
  89. roomList:null,
  90. buildHighList:null,
  91. buildRoomList:null,
  92. buildId:null,
  93. floorId:null,
  94. multiIndex: [0, 0, 0],
  95. formData:{
  96. phone:'',
  97. inputphone:'',
  98. os:''
  99. },
  100. array0:[],
  101. multiArray: [
  102. [],
  103. [],
  104. []
  105. ],
  106. showPicker: false,
  107. datetime: '2022-03-27 15:00:12',
  108. range: ['2022-03-27','2022-03-27'],
  109. rangetime:'',
  110. type: 'rangetime',
  111. timeValue: ''
  112. }
  113. },
  114. onLoad(){
  115. this.getfault()
  116. this.getbuild()
  117. },
  118. watch: {
  119. buildId:{
  120. handler(newValue,oldVaue){
  121. this.getbuildHigh()
  122. },
  123. immediate:true
  124. },
  125. floorId:{
  126. handler(newValue,oldVaue){
  127. this.getrooms()
  128. },
  129. immediate:true,
  130. deep:true
  131. }
  132. },
  133. methods: {
  134. onShowDatePicker(type){//显示
  135. this.type = type;
  136. this.showPicker = true;
  137. this.timeValue = this[type];
  138. },
  139. onSelected(e){//选择
  140. this.showPicker = false;
  141. if(e) {
  142. this[this.type] = e.value;
  143. this.timeValue = e.value;
  144. //选择的值
  145. console.log('value => '+ e.value);
  146. //原始的Date对象
  147. console.log('date => ' + e.date);
  148. }
  149. },
  150. getroom(){
  151. this.buildId=1
  152. this.floorId=1
  153. },
  154. seleckImage() {
  155. let that = this;
  156. uni.chooseImage({
  157. success: function(res) {
  158. console.log('选择图片')
  159. console.log(res.tempFilePaths)
  160. // 将图片存放在数组中
  161. that.imgArr = res.tempFilePaths
  162. }
  163. });
  164. },
  165. preview(img) {
  166. console.log('预览')
  167. // 新建一个存放预览图片的空数组
  168. var imgArr = []
  169. imgArr.push(img)
  170. uni.previewImage({
  171. urls: imgArr,
  172. current: imgArr[0]
  173. });
  174. },
  175. bindPickerChange: function(e,storage) {
  176. console.log(e)
  177. console.log(storage)
  178. this.index = e.target.value
  179. this.pickerData = storage[this.index] // 这里就是选中的对象
  180. console.log(this.pickerData.faultName)
  181. },
  182. bindMultiPickerColumnChange: function(e) {
  183. console.log('修改的列为:' + e.detail.column + ',值为:' + e.detail.value)
  184. this.multiIndex[e.detail.column] = e.detail.value
  185. switch(e.detail.column){
  186. case 0:{
  187. this.buildId = e.detail.value+1
  188. break;
  189. }
  190. case 1:{
  191. this.floorId = e.detail.value+1
  192. break;
  193. }
  194. }
  195. this.$forceUpdate()
  196. },
  197. // 故障信息
  198. async getfault(){
  199. const res = await uni.request({
  200. method:'POST',
  201. url:'/api/fault/queryAllFaultByStatus',
  202. success: (res) => {
  203. this.List = res.data.data;
  204. console.log(this.List)
  205. }
  206. })
  207. },
  208. // 宿舍楼栋
  209. async getbuild(){
  210. const res = await uni.request({
  211. method:'POST',
  212. url:'/api/build/queryAllBuild',
  213. success: (res) => {
  214. this.roomList = res.data.data
  215. console.log(res.data)
  216. console.log(this.roomList)
  217. this.roomList.forEach(item=>{
  218. this.multiArray[0].push(item.buildName)
  219. })
  220. console.log('multiArray:'+this.multiArray[0])
  221. }
  222. })
  223. },
  224. // 宿舍楼层
  225. async getbuildHigh(){
  226. const res = await uni.request({
  227. method:'POST',
  228. url:'/api/build/queryAllFloorByBuildID?buildId='+this.buildId,
  229. success: (res) => {
  230. this.buildHighList = res.data.data
  231. console.log(this.buildHighList)
  232. var tempList = new Array
  233. this.buildHighList.forEach(item=>{
  234. tempList.push(item.floorName)
  235. })
  236. this.$set(this.multiArray,1,tempList)
  237. console.log(this.buildId)
  238. }
  239. })
  240. },
  241. // 宿舍房间
  242. async getrooms(){
  243. const res = await uni.request({
  244. method:'POST',
  245. url:'/api/build/queryAllRoomByFloorID?floorId='+this.floorId,
  246. success: (res) => {
  247. this.buildRoomList = res.data.data
  248. var tempList = new Array
  249. this.buildRoomList.forEach(item=>{
  250. tempList.push(item.roomName)
  251. })
  252. this.$set(this.multiArray,2,tempList)
  253. console.log(this.floorId)
  254. }
  255. })
  256. },
  257. // 提交订单
  258. async getList(){
  259. const res = await uni.request({
  260. method:'POST',
  261. url:'/api/order/insertOrder',
  262. data:{
  263. // otherPhone: this.inputphone,
  264. // dormNumber:"10栋",
  265. // faultId:2,
  266. // studentDormitory:"6楼",
  267. // orderExpectedTime: "明天"
  268. },
  269. success: (res) => {
  270. let alldata = this.formData;
  271. let faultname = this.pickerData.faultName;
  272. console.log(JSON.stringify(alldata))
  273. console.log(JSON.stringify(faultname))
  274. }
  275. })
  276. },
  277. onInputphone(e){
  278. this.inputphone = e.target.value
  279. console.log(this.inputphone)
  280. },
  281. bindDateChange: function(e) {
  282. this.date = e.target.value
  283. },
  284. bindTimeChange: function(e) {
  285. this.time = e.target.value
  286. }
  287. }
  288. }
  289. </script>
  290. <style>
  291. .test{
  292. text-align: center;
  293. padding: 10px 0;
  294. }
  295. button{
  296. margin: 20upx;
  297. font-size: 28upx;
  298. }
  299. .head{
  300. height: 131px;
  301. font-size: 15px;
  302. color: white;
  303. border-radius: 0px 0px 15px 15px;
  304. background-color:rgba(42, 130, 228, 1);
  305. }
  306. .head text{
  307. float: left;
  308. margin-left: 140px;
  309. margin-top: 12px;
  310. }
  311. .head image{
  312. height: 17px;
  313. width: 17px;
  314. font-size: 17px;
  315. vertical-align: bottom;
  316. }
  317. .headline-1{
  318. font-size: 12px;
  319. }
  320. .headline-2{
  321. font-size: 12px;
  322. }
  323. .content{
  324. position: relative;
  325. width:359px;
  326. height: 627px;
  327. margin-top: -81px;
  328. margin-left: 7px;
  329. border: 1px solid rgba(128, 128, 128, 0.45);
  330. background-color: rgba(255, 255, 255, 1);
  331. }
  332. .uni-list-cell{
  333. float: right;
  334. width: 242px;
  335. height: 35px;
  336. margin-top: 18px;
  337. margin-right: 32px;
  338. border-radius: 16px;
  339. line-height: 22px;
  340. background-color: rgba(166, 166, 166, 0.18);
  341. }
  342. .uni-input-1{
  343. margin-left: 10px;
  344. margin-top: 5px;
  345. }
  346. .uni-input-1 image{
  347. float: right;
  348. margin-right: 5px;
  349. width: 20px;
  350. height: 20px;
  351. font-size: 20px;
  352. }
  353. .uni-list-cell-left{
  354. float: left;
  355. margin-top: 24px;
  356. margin-left: 13px;
  357. }
  358. .uni-list-cell-left-2{
  359. float: left;
  360. margin-left: 15px;
  361. margin-top: 38px;
  362. }
  363. .uni-list-cell-db-2{
  364. float: right;
  365. margin-right: 32px;
  366. margin-top: 18px;
  367. width: 242px;
  368. height: 35px;
  369. border-radius: 16px;
  370. background-color: rgba(166, 166, 166, 0.18);
  371. }
  372. .uni-input-2{
  373. margin-left: 10px;
  374. margin-top: 8px;
  375. font-size: 12px;
  376. }
  377. .uni-input-2 image{
  378. float: right;
  379. margin-right: 5px;
  380. width: 20px;
  381. height: 20px;
  382. font-size: 20px;
  383. }
  384. .timeimg{
  385. position: absolute;
  386. right:36px;
  387. top: 131px;
  388. width: 20px;
  389. height: 20px;
  390. font-size: 20px;
  391. }
  392. .photo {
  393. height: 169px;
  394. font-size: 12px;
  395. }
  396. .photo-title{
  397. float: left;
  398. margin-left: 13px;
  399. margin-top: 15px;
  400. }
  401. .image {
  402. float: left;
  403. margin-left: 13px;
  404. margin-top: 15px;
  405. height: 198px;
  406. width: 322px;
  407. box-sizing: border-box;
  408. border-radius: 14px;
  409. background-color: rgba(166, 166, 166, 0.18);
  410. }
  411. .imageText {
  412. text-align: center;
  413. border-radius: 14px;
  414. width: 100%;
  415. height: 100%;
  416. background-color:rgba(166, 166, 166, 0.18);
  417. }
  418. .imgSrc image{
  419. width: 323PX;
  420. height: 193px;
  421. }
  422. .os-headline-2{
  423. float: left;
  424. }
  425. .os-list-cell-left-2{
  426. float: left;
  427. margin-left: 13px;
  428. margin-top: 16px;
  429. font-size: 12px;
  430. }
  431. .os-input-2{
  432. margin-left: 5px;
  433. margin-top: 4px;
  434. font-size: 12px;
  435. /* cursor: not-allowed; */
  436. }
  437. .os-list-cell-db-2{
  438. float: right;
  439. width: 284px;
  440. height: 30px;
  441. margin-right: 15px;
  442. margin-top: 10px;
  443. border-radius: 14px;
  444. background-color: rgba(166, 166, 166, 0.18);
  445. }
  446. .up{
  447. position: absolute;
  448. bottom: 13px;
  449. left: 15px;
  450. }
  451. </style>