newApplication.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. <!-- 选择实验室 -->
  2. <template>
  3. <view id="newApplication">
  4. <view class="newApplication-page" v-if="pageType == 1">
  5. <view class="picker-max-box">
  6. <view class="picker-title-box">
  7. <view>*</view>
  8. <view>申请实验室:</view>
  9. </view>
  10. <input @click="inputClick(2)" v-model="subject.subName" class="picker-input-box" disabled type="text"
  11. placeholder="请选择实验室">
  12. </view>
  13. <view class="picker-max-box" v-if="subject.subId">
  14. <view class="picker-title-box">
  15. <view>*</view>
  16. <view>申请期限:</view>
  17. </view>
  18. <view class="apply_data">
  19. <picker mode="date" v-model="validBeginTime" :start="currentDate" fields="day"
  20. @change="beginDateChange">
  21. <view class="for-top-title-time" v-if="validBeginTime.length>0">{{validBeginTime}}</view>
  22. <view class="for-top-title-time" v-if="validBeginTime.length<=0">开始时间</view>
  23. </picker>
  24. -
  25. <picker mode="date" v-model="validEndTime" :start="currentDate" fields="day"
  26. @change="endDateChange">
  27. <view class="for-top-title-time" v-if="validEndTime.length>0">{{validEndTime}}</view>
  28. <view class="for-top-title-time" v-if="validEndTime.length<=0">结束时间</view>
  29. </picker>
  30. </view>
  31. </view>
  32. <view class="picker-max-box" v-if="subject.subId">
  33. <view class="picker-title-box">
  34. <view> </view>
  35. <view>申请备注:</view>
  36. </view>
  37. <textarea class="remark" v-model="applyCause" placeholder="请输入申请备注"></textarea>
  38. </view>
  39. <view class="user-info-box" v-if="subject.subId">
  40. <view class="picker-title-box">
  41. <view>*</view>
  42. <view>身份信息:</view>
  43. <view>(关联学生信息材料)</view>
  44. </view>
  45. <view class="user-info-box-min">
  46. <view>*</view>
  47. <view>申请人:</view>
  48. <input v-model="sysUser.userName" type="text" placeholder="学生姓名">
  49. </view>
  50. <view class="user-info-box-min">
  51. <view>*</view>
  52. <view>联系电话:</view>
  53. <input v-model="sysUser.mobile" type="text" placeholder="联系电话">
  54. </view>
  55. <view class="user-info-box-min">
  56. <view>*</view>
  57. <view>学号:</view>
  58. <input v-model="sysUser.account" type="text" placeholder="学号">
  59. </view>
  60. <view class="user-info-box-min" v-if="versionField() != 'xiBeiNongLinDaXue'">
  61. <view>*</view>
  62. <view>物理卡号:</view>
  63. <input v-model="sysUser.cardNumSimple" type="text" placeholder="物理卡号">
  64. </view>
  65. <view class="user-info-box-min" v-if="versionField() != 'xiBeiNongLinDaXue'">
  66. <view>*</view>
  67. <view>班级:</view>
  68. <input v-model="sysUser.gradeName" type="text" placeholder="班级">
  69. </view>
  70. <view class="user-info-box-min">
  71. <view>*</view>
  72. <view>导师:</view>
  73. <input v-model="sysUser.tutorUserName" @change="tutorUserNameClick()" type="text"
  74. placeholder="请输入姓名,最少两个字">
  75. <uni-data-picker disabled=true @change="bindPickerChange" :localdata="tutorUserList" ref='picker'>
  76. </uni-data-picker>
  77. </view>
  78. </view>
  79. <!-- 学生 -->
  80. <view v-if="subjectData.sysUser.userType == '2'" v-for="(item,index) in subjectData.listStudent"
  81. :key="index">
  82. <!-- 院系考试证书 -->
  83. <view class="picker-max-box" v-if="item.materialType==2&&item.relationType==2">
  84. <view class="picker-title-box">
  85. <view>*</view>
  86. <view>安全考试证书:</view>
  87. </view>
  88. <img class="picker-up-img-box" v-if="subjectData.listcert[0]"
  89. :src="subjectData.listcert[0].cert_url">
  90. <view v-if="!subjectData.listcert[0]" style="margin-left:40px;color:#999;font-size:14px;">暂无证书
  91. </view>
  92. </view>
  93. <!-- 上传材料 -->
  94. <view class="picker-max-box" v-if="item.materialType==1">
  95. <view class="picker-title-box">
  96. <view>*</view>
  97. <view>{{item.materialName}}:</view>
  98. </view>
  99. <view class="picker-text-info-box">{{item.materialDescribe}}</view>
  100. <view class="picker-for-item-box" v-for="(minItem,minIndex) in item.upList" :key="minIndex">
  101. <img class="left-img-box" :src="imagesUrl('commonality/icon_pdf.png')"
  102. v-if="minItem.type == 'pdf'">
  103. <img class="left-img-box" :src="imagesUrl('commonality/icon_word.png')"
  104. v-if="minItem.type == 'doc' || minItem.type == 'docx'">
  105. <img class="left-img-box" :src="baseUrl+minItem.url"
  106. v-if="minItem.type == 'png' || minItem.type == 'jpg' || minItem.type == 'jpeg' || minItem.type == 'gif'">
  107. <view class="center-text-box">{{minItem.name}}</view>
  108. <img class="right-img-box" :src="imagesUrl('commonality/icon_sczl_sc.png')"
  109. @click="delUpData(item,minIndex)">
  110. </view>
  111. <view class="up-data-button" @click="itemUpData(item)">上传材料</view>
  112. </view>
  113. </view>
  114. </view>
  115. <!-- 实验室选择页面 -->
  116. <view class="pageTwo" v-if="pageType == 2">
  117. <view class="pageTwo-input-box">
  118. <input type="text" placeholder="请输入实验室名称/房间号" v-model="subjectName">
  119. <view @click="subjectList">查找</view>
  120. </view>
  121. <view class="for-max-box">
  122. <view class="for-null-text" v-if="!searchList[0]">{{nullText}}</view>
  123. <view class="for-box" v-for="(item,index) in searchList" :key="index">
  124. <view class="button-text-view">{{item.subName}}{{item.roomNum?'('+item.roomNum+')':''}}</view>
  125. <view class="button-big-view">
  126. <view class="button-null-view"></view>
  127. <view class="button-view" @click="checkClick(item)">选择</view>
  128. <view class="button-null-view"></view>
  129. </view>
  130. </view>
  131. </view>
  132. <view class="out-button" @click="inputClick(1)">返回</view>
  133. </view>
  134. <view class="bottom-button" v-if="pageType == 1" @click="upDataButton()">
  135. {{infoType?'准入材料修改完毕,重新提交':'准入材料上传完毕,提交申请'}}
  136. </view>
  137. <view class="shade-max-box" v-if="shadeType">
  138. <view class="shade-big-box">
  139. <img :src="imagesUrl('student/img_zrsq_bg.png')">
  140. <view @click="pageBack">返回</view>
  141. </view>
  142. </view>
  143. </view>
  144. </template>
  145. <script>
  146. import {
  147. systemUserDropList
  148. } from '@/api/commonality/permission.js'
  149. import {
  150. systemMineGetListByPower,
  151. laboratoryAppletMaterialApply,
  152. laboratoryAppletMaterialAdd,
  153. laboratoryAppletMaterialUpdate,
  154. } from '@/pages_student/api/index.js'
  155. import {
  156. config
  157. } from '@/api/request/config.js'
  158. export default {
  159. data() {
  160. return {
  161. baseUrl: config.base_url,
  162. pageType: 2,
  163. shadeType: false,
  164. //有效期
  165. buttonArray2: [],
  166. buttonArrayIndex2: 11,
  167. //搜索回的实验室列表
  168. searchList: [],
  169. //选择的实验室数据
  170. subject: {},
  171. //暂无数据提示
  172. nullText: "请输入实验室名称进行搜索",
  173. //实验室名称
  174. subjectName: "",
  175. //有效期
  176. validLength: "12",
  177. //获取的实验室配置数据
  178. subjectData: {},
  179. //是否是编辑状态
  180. infoType: false,
  181. //编辑参数
  182. infoData: {},
  183. validBeginTime: '', //申请期限开始
  184. validEndTime: '', //申请期限结束
  185. applyCause: '', //申请备注
  186. sysUser: {},
  187. tutorUserList: [],
  188. strArr: [], //存储类型
  189. currentDate: '', //当前日期
  190. uploadFileName: '', //学生上传的文件名
  191. }
  192. },
  193. onLoad(option) {
  194. if (option.item) {
  195. let newItem = JSON.parse(decodeURIComponent(option.item));
  196. let newObj = {
  197. deptId: newItem.labSecurityApply.deptId,
  198. deptName: newItem.labSecurityApply.deptName,
  199. subId: newItem.labSecurityApply.subId,
  200. subName: newItem.labSecurityApply.subName,
  201. }
  202. this.$set(this, 'validBeginTime', newItem.labSecurityApply.validBeginTime.split(' ')[0])
  203. this.$set(this, 'validEndTime', newItem.labSecurityApply.validEndTime.split(' ')[0])
  204. this.$set(this, 'applyCause', newItem.labSecurityApply.applyCause)
  205. this.$set(this, 'subject', newObj)
  206. this.$set(this, 'infoData', newItem)
  207. this.$set(this, 'infoType', true)
  208. this.$set(this, 'pageType', 2)
  209. this.materialApply();
  210. }
  211. },
  212. onShow() {
  213. this.addTime();
  214. this.clearData();
  215. this.currentDate = this.getdate();
  216. // console.log('时间')
  217. // console.log(this.currentDate)
  218. },
  219. methods: {
  220. getdate() {
  221. var date = new Date();
  222. var seperator1 = "-";
  223. var year = date.getFullYear();
  224. var month = date.getMonth() + 1;
  225. var strDate = date.getDate();
  226. if (month >= 1 && month <= 9) {
  227. month = "0" + month;
  228. }
  229. if (strDate >= 0 && strDate <= 9) {
  230. strDate = "0" + strDate;
  231. }
  232. var currentdate = year + "-" + month + "-" + strDate;
  233. return currentdate;
  234. },
  235. //清除
  236. clearData() {
  237. this.tutorUserList = [];
  238. },
  239. //导师查询
  240. async tutorUserNameClick() {
  241. let self = this
  242. self.tutorUserList = []
  243. let obj = {
  244. userName: this.sysUser.tutorUserName,
  245. userType: '1'
  246. }
  247. const {
  248. data
  249. } = await systemUserDropList(obj)
  250. if (data.code == 200) {
  251. console.log(data)
  252. data.data.forEach(function(item) {
  253. self.tutorUserList.push({
  254. text: item.userName,
  255. value: item.userId,
  256. })
  257. })
  258. console.log(self.tutorUserList)
  259. self.$refs.picker.show()
  260. }
  261. },
  262. bindPickerChange: function(e) {
  263. let self = this;
  264. console.log('picker发送选择改变,携带值为', e.detail.value)
  265. let data = e.detail.value;
  266. data.forEach(function(item) {
  267. self.sysUser.tutorUserName = item.text
  268. self.sysUser.tutorUserId = item.value
  269. })
  270. },
  271. //时间选择触发-开始
  272. beginDateChange(data) {
  273. this.validBeginTime = data.detail.value;
  274. },
  275. endDateChange(data) {
  276. this.validEndTime = data.detail.value;
  277. },
  278. pageBack() {
  279. if (this.infoType) {
  280. uni.navigateBack({
  281. delta: 2
  282. });
  283. }else{
  284. uni.navigateBack();
  285. }
  286. },
  287. //申请编辑
  288. async materialUpdate(obj) {
  289. const {
  290. data
  291. } = await laboratoryAppletMaterialUpdate(obj)
  292. if (data.code == 200) {
  293. this.shadeType = true;
  294. }
  295. },
  296. //申请提交
  297. async materialAdd(obj) {
  298. const {
  299. data
  300. } = await laboratoryAppletMaterialAdd(obj)
  301. if (data.code == 200) {
  302. this.shadeType = true;
  303. }
  304. },
  305. //提交按钮
  306. upDataButton() {
  307. let self = this;
  308. if (!this.subject.subId) {
  309. uni.showToast({
  310. title: '请选择实验室',
  311. icon: "none",
  312. mask: true,
  313. duration: 2000
  314. });
  315. return
  316. }
  317. if (!this.validBeginTime) {
  318. uni.showToast({
  319. title: '请选择开始时间',
  320. icon: "none",
  321. mask: true,
  322. duration: 2000
  323. });
  324. return
  325. }
  326. if (!this.validEndTime) {
  327. uni.showToast({
  328. title: '请选择结束时间',
  329. icon: "none",
  330. mask: true,
  331. duration: 2000
  332. });
  333. return
  334. }
  335. if (!this.sysUser.userName) {
  336. uni.showToast({
  337. title: '请输入申请人',
  338. icon: "none",
  339. mask: true,
  340. duration: 2000
  341. });
  342. return
  343. }
  344. if (!this.sysUser.mobile) {
  345. uni.showToast({
  346. title: '请输入联系电话',
  347. icon: "none",
  348. mask: true,
  349. duration: 2000
  350. });
  351. return
  352. }
  353. if (!this.sysUser.account) {
  354. uni.showToast({
  355. title: '请输入学号',
  356. icon: "none",
  357. mask: true,
  358. duration: 2000
  359. });
  360. return
  361. }
  362. let playTime = Math.floor(new Date(this.validBeginTime).getTime() / 1000);
  363. let endTime = Math.floor(new Date(this.validEndTime).getTime() / 1000);
  364. if(playTime > endTime){
  365. uni.showToast({
  366. title: '开始时间不能大于结束时间',
  367. icon: "none",
  368. mask: true,
  369. duration: 2000
  370. });
  371. return
  372. }
  373. // if (!this.sysUser.cardNumSimple) {
  374. // uni.showToast({
  375. // title: '请输入物理卡号',
  376. // icon: "none",
  377. // mask: true,
  378. // duration: 2000
  379. // });
  380. // return
  381. // }
  382. // if (!this.sysUser.gradeName) {
  383. // uni.showToast({
  384. // title: '请输入班级',
  385. // icon: "none",
  386. // mask: true,
  387. // duration: 2000
  388. // });
  389. // return
  390. // }
  391. if (!this.sysUser.tutorUserId) {
  392. uni.showToast({
  393. title: '请选择导师',
  394. icon: "none",
  395. mask: true,
  396. duration: 2000
  397. });
  398. return
  399. }
  400. let sysUser = {
  401. userName: this.sysUser.userName,
  402. userId: this.sysUser.userId,
  403. mobile: this.sysUser.mobile,
  404. account: this.sysUser.account,
  405. cardNumSimple: this.sysUser.cardNumSimple,
  406. grade: this.sysUser.gradeName,
  407. tutorUserId: this.sysUser.tutorUserId,
  408. tutorUserName: this.sysUser.tutorUserName,
  409. };
  410. let obj = {
  411. subAdminId: this.subjectData.fzrSysUser.userId, //学号/工号
  412. userNumber: this.subjectData.sysUser.account, //学号/工号
  413. userMajor: this.subjectData.sysUser.majorName, //专业
  414. userMajorId: this.subjectData.sysUser.major, //专业
  415. deptId: this.subjectData.sysUser.deptId, //NULL部门id
  416. deptName: this.subjectData.sysUser.deptName, //NULL部门名称
  417. subId: this.subject.subId, //NULL实验室id
  418. subName: this.subject.subName, //NULL实验室名称
  419. roomNum: this.subject.roomNum, //NULL实验室名称
  420. auditStatus: "0", //NULL审核状态 0待审核 1驳回 2通过
  421. //validLength: this.validLength, //NULL有效期 月份时长
  422. relList: [], //上传资料
  423. sysUserModel: sysUser, //身份卡用户信息
  424. validBeginTime: this.validBeginTime+'T00:00:00', //申请期限开始时间
  425. validEndTime: this.validEndTime+'T23:59:59', //申请期限结束时间
  426. applyCause: this.applyCause, //申请备注
  427. };
  428. if (this.subjectData.sysUser.userType == '2') {
  429. for (let i = 0; i < self.subjectData.listStudent.length; i++) {
  430. if (self.subjectData.listStudent[i].materialType == 1) {
  431. if (!self.subjectData.listStudent[i].upList[0]) {
  432. uni.showToast({
  433. title: self.subjectData.listStudent[i].materialName + "未上传",
  434. icon: "none",
  435. mask: true,
  436. duration: 2000
  437. });
  438. return
  439. } else {
  440. let upData = {
  441. materialId: self.subjectData.listStudent[i].materialId,
  442. dataName: self.subjectData.listStudent[i].materialName,
  443. dataDescribe: self.subjectData.listStudent[i].materialDescribe,
  444. dataUrl: "",
  445. };
  446. for (let o = 0; o < self.subjectData.listStudent[i].upList.length; o++) {
  447. upData.dataUrl = upData.dataUrl + self.subjectData.listStudent[i].upList[o].name +
  448. ';' + self.subjectData.listStudent[i].upList[o].url + ',';
  449. }
  450. obj.relList.push(upData);
  451. }
  452. }
  453. }
  454. }
  455. if (this.infoType) {
  456. obj.applyId = this.infoData.labSecurityApply.applyId;
  457. this.materialUpdate(obj);
  458. } else {
  459. this.materialAdd(obj);
  460. }
  461. },
  462. //删除对应材料
  463. delUpData(item, index) {
  464. item.upList.splice(index, 1);
  465. this.$forceUpdate()
  466. },
  467. itemUpData(item) {
  468. this.uploadFileName = '';
  469. this.uploadFileName = this.sysUser.userName + item.materialName; //学生上传的文件名
  470. let self = this;
  471. let fileTypeArr = item.fileType.split(',')
  472. self.strArr = [];
  473. fileTypeArr.forEach(function(item) {
  474. if (item == '1') {
  475. self.strArr.push('pdf')
  476. } else if (item == '2') {
  477. self.strArr.push('doc', 'docx')
  478. } else if (item == '3') {
  479. self.strArr.push('png', 'jpg', 'gif')
  480. }
  481. })
  482. uni.showActionSheet({
  483. // #ifdef WEB
  484. itemList: ['上传图片'],
  485. // #endif
  486. // #ifdef MP-WEIXIN
  487. itemList: ['上传文件', '上传图片'],
  488. // #endif
  489. success: function(res) {
  490. if (res.tapIndex == 0) {
  491. //上传文件
  492. // #ifdef WEB
  493. self.upImg(item);
  494. // #endif
  495. // #ifdef MP-WEIXIN
  496. self.upData(item);
  497. // #endif
  498. } else if (res.tapIndex == 1) {
  499. //上传图片
  500. self.upImg(item);
  501. }
  502. },
  503. fail: function(res) {
  504. console.log(res.errMsg);
  505. }
  506. });
  507. },
  508. blobToFile(theBlob, fileName, mimeType) {
  509. // 创建File对象
  510. const file = new File([theBlob], fileName, {
  511. type: mimeType,
  512. lastModified: new Date().getTime() // 文件最后修改时间
  513. });
  514. return file;
  515. },
  516. upImg(item) {
  517. let self = this;
  518. uni.chooseImage({
  519. count: 1,
  520. sizeType: ["original", "compressed"],
  521. sourceType: ["album", "camera"],
  522. success: function(res) {
  523. let text = [];
  524. // #ifdef WEB
  525. let tempFilePaths = res.tempFilePaths[0];
  526. self.uploadImg(item,tempFilePaths);
  527. // #endif
  528. // #ifdef MP-WEIXIN
  529. text = res.tempFilePaths[0].split('.')
  530. if (self.strArr.indexOf(text[1]) == -1) {
  531. uni.showToast({
  532. title: '请上传' + self.strArr.join(',') + '格式文件',
  533. icon: "none",
  534. mask: true,
  535. duration: 2000
  536. });
  537. return
  538. }
  539. if (text[1] != 'png' && text[1] != 'jpg' && text[1] != 'jpeg' && text[1] != 'gif' &&
  540. text[1] != 'pdf' && text[1] != 'doc' && text[1] != 'docx') {
  541. uni.showToast({
  542. title: '仅支持png/jpg/jpeg/gif/pdf/doc/docx类型的文件上传',
  543. icon: "none",
  544. mask: true,
  545. duration: 2000
  546. });
  547. return
  548. }
  549. let upObj = {
  550. name: self.uploadFileName + '.' + text[1],
  551. path: res.tempFilePaths[0],
  552. type: text[1],
  553. }
  554. self.upDataFunction(item, upObj);
  555. // #endif
  556. }
  557. });
  558. },
  559. //上传文件
  560. upData(item) {
  561. let self = this;
  562. wx.chooseMessageFile({
  563. count: 1,
  564. type: 'all',
  565. success(res) {
  566. let text = res.tempFiles[0].path.split('.')
  567. if (self.strArr.indexOf(text[1]) == -1) {
  568. uni.showToast({
  569. title: '请上传' + self.strArr.join(',') + '格式文件',
  570. icon: "none",
  571. mask: true,
  572. duration: 2000
  573. });
  574. return
  575. }
  576. if (text[1] != 'png' && text[1] != 'jpg' && text[1] != 'jpeg' && text[1] != 'gif' && text[
  577. 1] != 'pdf' && text[1] != 'doc' && text[1] != 'docx') {
  578. uni.showToast({
  579. title: '仅支持png/jpg/jpeg/gif/pdf/doc/docx类型的文件上传',
  580. icon: "none",
  581. mask: true,
  582. duration: 2000
  583. });
  584. return
  585. }
  586. let upObj = {
  587. name: self.uploadFileName + '.' + text[1],
  588. path: res.tempFiles[0].path,
  589. type: text[1],
  590. }
  591. self.upDataFunction(item, upObj);
  592. }
  593. })
  594. },
  595. async uploadImg(item,tempFilePaths) {
  596. var self = this;
  597. uni.showLoading({
  598. title: '上传中',
  599. mask: true
  600. });
  601. uni.uploadFile({
  602. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  603. header: {
  604. 'Authorization': uni.getStorageSync('token')
  605. },
  606. filePath: tempFilePaths,
  607. name: 'file',
  608. formData: {
  609. 'user': 'test'
  610. },
  611. success: (uploadFileRes) => {
  612. let res = JSON.parse(uploadFileRes.data);
  613. console.log('uploadFileRes',res);
  614. if (res.code == 200) {
  615. let obj = {
  616. name: res.data.name,
  617. url: res.data.url,
  618. type: res.data.type.split('/')[1]
  619. }
  620. item.upList.push(obj);
  621. this.$forceUpdate();
  622. } else {
  623. uni.showToast({
  624. title: res.msg,
  625. icon: "none",
  626. mask: true,
  627. duration: 2000
  628. });
  629. }
  630. },
  631. fail: err => {},
  632. complete: () => {
  633. uni.hideLoading()
  634. }
  635. });
  636. },
  637. async upDataFunction(item, upObj) {
  638. var self = this;
  639. console.log('upObj.path',upObj.path);
  640. uni.showLoading({
  641. title: '上传中',
  642. mask: true
  643. });
  644. uni.uploadFile({
  645. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  646. header: {
  647. 'Authorization': uni.getStorageSync('token')
  648. },
  649. filePath: upObj.path,
  650. name: 'file',
  651. formData: {
  652. 'user': 'test'
  653. },
  654. success: (uploadFileRes) => {
  655. let res = JSON.parse(uploadFileRes.data);
  656. if (res.code == 200) {
  657. let obj = {
  658. name: upObj.name,
  659. url: res.data.url,
  660. type: upObj.type
  661. }
  662. item.upList.push(obj);
  663. this.$forceUpdate();
  664. } else {
  665. uni.showToast({
  666. title: res.msg,
  667. icon: "none",
  668. mask: true,
  669. duration: 2000
  670. });
  671. }
  672. },
  673. fail: err => {},
  674. complete: () => {
  675. uni.hideLoading()
  676. }
  677. });
  678. },
  679. //选择搜索页面
  680. inputClick(type) {
  681. if (this.pageType != type) {
  682. this.pageType = type;
  683. }
  684. },
  685. //实验室选择
  686. checkClick(item) {
  687. this.$set(this, "subject", item);
  688. this.materialApply();
  689. },
  690. //获取实验室相关配置
  691. async materialApply() {
  692. let self = this;
  693. const {
  694. data
  695. } = await laboratoryAppletMaterialApply({
  696. subId: this.subject.subId
  697. })
  698. if (data.code == 200) {
  699. if (data.data.sysUser.userType != '2') {
  700. uni.showToast({
  701. title: '您不是学生,无法申请准入',
  702. icon: "none",
  703. mask: true,
  704. duration: 2000
  705. });
  706. return
  707. }
  708. if (data.data.sysUser.userType == '2') {
  709. if (!data.data.listStudent[0]) {
  710. uni.showToast({
  711. title: '该实验室未设置准入条件',
  712. icon: "none",
  713. mask: true,
  714. duration: 2000
  715. });
  716. return
  717. }
  718. }
  719. if (data.data.listStudent) {
  720. for (let i = 0; i < data.data.listStudent.length; i++) {
  721. if (data.data.listStudent[i].materialType == 1) {
  722. data.data.listStudent[i].upList = [];
  723. }
  724. }
  725. }
  726. if (data.data.listTeacher) {
  727. for (let i = 0; i < data.data.listTeacher.length; i++) {
  728. if (data.data.listTeacher[i].materialType == 1) {
  729. data.data.listTeacher[i].upList = [];
  730. }
  731. }
  732. }
  733. this.subjectData = data.data;
  734. this.sysUser = data.data.sysUser;
  735. this.sysUser.mobile == null ? '' : this.sysUser.mobile;
  736. this.sysUser.userName == null ? '' : this.sysUser.userName;
  737. this.sysUser.cardNum == null ? '' : this.sysUser.cardNum;
  738. this.sysUser.grade == null ? '' : this.sysUser.grade;
  739. this.sysUser.tutorUserName == null ? '' : this.sysUser.tutorUserName;
  740. if (this.infoType) {
  741. this.validLength = this.infoData.labSecurityApply.validLength;
  742. for (let i = 0; i < self.infoData.listTemp.length; i++) {
  743. if (self.infoData.listTemp[i].materialType == 1) {
  744. if (self.subjectData.sysUser.userType == '2') {
  745. for (let o = 0; o < self.subjectData.listStudent.length; o++) {
  746. if (self.subjectData.listStudent[o].materialType == 1 && self.subjectData
  747. .listStudent[o].id == self.infoData.listTemp[i].id) {
  748. self.subjectData.listStudent[o].upList = JSON.parse(JSON.stringify(self
  749. .infoData.listTemp[i].upList));
  750. }
  751. }
  752. }
  753. }
  754. }
  755. }
  756. this.pageType = 1;
  757. }
  758. },
  759. //有效期选中
  760. buttonChange2(e) {
  761. console.log("e", e.mp.detail.value);
  762. this.buttonArrayIndex2 = e.mp.detail.value;
  763. this.validLength = this.buttonArray2[e.mp.detail.value].value;
  764. },
  765. //查询实验室
  766. async subjectList() {
  767. if(!this.subjectName){
  768. uni.showToast({
  769. title: '请输入实验室名称/房间号',
  770. icon: "none",
  771. mask: true,
  772. duration: 2000
  773. });
  774. return
  775. }
  776. const {
  777. data
  778. } = await systemMineGetListByPower({
  779. searchValue: this.subjectName
  780. })
  781. if (data.code == 200) {
  782. this.searchList = data.data;
  783. if (!data.data[0]) {
  784. this.nullText = "暂无数据"
  785. }
  786. }
  787. },
  788. //生成有效期
  789. addTime() {
  790. let list = [];
  791. for (let i = 1; i < 61; i++) {
  792. let obj = {
  793. name: i + "个月",
  794. value: i,
  795. }
  796. list.push(obj)
  797. }
  798. this.$set(this, 'buttonArray2', list);
  799. },
  800. },
  801. }
  802. </script>
  803. <style lang="stylus" scoped>
  804. #newApplication {
  805. height:100%;
  806. width: 100%;
  807. display flex;
  808. flex-direction column;
  809. overflow: hidden;
  810. .user-info-box {
  811. background #fff;
  812. border-radius: 20rpx;
  813. margin: 20rpx 20rpx;
  814. padding: 20rpx 0 0;
  815. .user-info-box_title {
  816. font-size: 30rpx;
  817. font-family: PingFang SC;
  818. font-weight: 500;
  819. color: #333333;
  820. line-height: 30rpx;
  821. margin-left: 24rpx;
  822. margin-bottom: 10px;
  823. }
  824. .user-info-box-min {
  825. margin: 0 26rpx;
  826. display flex;
  827. align-items center;
  828. view {
  829. line-height: 66rpx;
  830. font-size: 28rpx;
  831. }
  832. view:nth-child(1) {
  833. color: red;
  834. line-height: 28rpx;
  835. position: relative;
  836. top: 4rpx;
  837. }
  838. view:nth-child(2) {
  839. flex: 1;
  840. color: #999;
  841. }
  842. view:nth-child(3) {
  843. flex: 1;
  844. text-align right;
  845. color: #333;
  846. }
  847. >input {
  848. width 460rpx;
  849. }
  850. }
  851. .picker-title-box {
  852. padding: 0 20rpx;
  853. display flex;
  854. justify-content flex-start;
  855. align-items center;
  856. view {
  857. line-height: 80rpx;
  858. font-size: 28rpx;
  859. }
  860. view:nth-child(1) {
  861. color: red;
  862. line-height: 28rpx;
  863. }
  864. view:nth-child(2) {}
  865. view:nth-child(3) {
  866. color: #999;
  867. }
  868. }
  869. }
  870. .newApplication-page {
  871. flex:1;
  872. background #fff;
  873. margin: 20rpx 20rpx 160rpx;
  874. padding-bottom: 20rpx;
  875. border-radius: 20rpx;
  876. overflow-y: scroll;
  877. .picker-max-box {
  878. /* 申请备注 */
  879. .remark {
  880. width: 627rpx;
  881. height: 200rpx;
  882. font-size: 28rpx;
  883. margin: 0 20rpx;
  884. border: 2rpx solid #a2a2a2;
  885. border-radius: 10rpx;
  886. padding: 20rpx;
  887. }
  888. /* 申请期限 */
  889. .apply_data {
  890. width: 667rpx;
  891. height: 82rpx;
  892. background: #FFFFFF;
  893. border: 2rpx solid #A2A2A2;
  894. border-radius: 10rpx;
  895. display: flex;
  896. justify-content: space-between;
  897. align-items center;
  898. margin: 0 20rpx;
  899. padding: 0 30rpx;
  900. box-sizing border-box;
  901. >picker {
  902. >view {
  903. font-size: 28rpx;
  904. font-family: PingFang SC;
  905. font-weight: 500;
  906. color: #999999;
  907. line-height: 82rpx;
  908. }
  909. }
  910. }
  911. .picker-title-box {
  912. padding: 0 20rpx;
  913. display flex;
  914. justify-content flex-start;
  915. align-items center;
  916. view {
  917. line-height: 80rpx;
  918. font-size: 28rpx;
  919. }
  920. view:nth-child(1) {
  921. color: red;
  922. }
  923. view:nth-child(2) {}
  924. view:nth-child(3) {
  925. color: #999;
  926. }
  927. }
  928. .picker-input-box {
  929. padding: 0 20rpx;
  930. display flex;
  931. height: 80rpx;
  932. width: 627rpx;
  933. border: 1rpx solid #a2a2a2;
  934. border-radius: 10rpx;
  935. margin: 0 20rpx;
  936. }
  937. .picker-min-box {
  938. display flex;
  939. height: 80rpx;
  940. width: 667rpx;
  941. border: 1rpx solid #a2a2a2;
  942. border-radius: 10rpx;
  943. margin: 0 20rpx;
  944. view {
  945. flex: 1;
  946. line-height: 80rpx;
  947. padding: 0 20rpx;
  948. color: #999;
  949. font-size: 28rpx;
  950. }
  951. img {
  952. width: 24rpx;
  953. height: 12rpx;
  954. margin: 35rpx 23rpx;
  955. }
  956. }
  957. .picker-text-box {
  958. padding: 0 50rpx;
  959. height: 60rpx;
  960. line-height: 60rpx;
  961. font-size: 28rpx;
  962. color: #999;
  963. }
  964. .picker-text-info-box {
  965. color: #999;
  966. font-size: 28rpx;
  967. line-height: 40rpx;
  968. padding: 0 20rpx;
  969. }
  970. .picker-up-img-box {
  971. margin: 40rpx auto;
  972. width: 640rpx;
  973. height: 250rpx;
  974. border: 2px dashed #E0E0E0;
  975. border-radius: 20rpx;
  976. background: #F8F8F8;
  977. view:nth-child(1) {
  978. margin-top: 30rpx;
  979. font-size: 80rpx;
  980. color: #e0e0e0;
  981. text-align center;
  982. }
  983. view:nth-child(2) {
  984. font-weight: 700;
  985. font-size: 28rpx;
  986. color: #999;
  987. text-align center;
  988. }
  989. }
  990. .picker-for-item-box {
  991. display flex;
  992. margin: 20rpx 0;
  993. .left-img-box {
  994. margin: 0 20rpx;
  995. width: 60rpx;
  996. height: 60rpx;
  997. }
  998. .center-text-box {
  999. flex: 1;
  1000. line-height: 60rpx;
  1001. font-size: 28rpx;
  1002. color: #333;
  1003. display: block;
  1004. overflow: hidden;
  1005. text-overflow: ellipsis;
  1006. white-space: nowrap;
  1007. }
  1008. .right-img-box {
  1009. width: 30rpx;
  1010. height: 30rpx;
  1011. margin: 15rpx 20rpx;
  1012. }
  1013. }
  1014. .up-data-button {
  1015. width: 500rpx;
  1016. height: 80rpx;
  1017. margin: 40rpx auto;
  1018. line-height: 80rpx;
  1019. text-align center;
  1020. font-size: 28rpx;
  1021. border-radius: 10rpx;
  1022. color: #0183FA;
  1023. border: 1rpx dashed #0183FA;
  1024. }
  1025. }
  1026. }
  1027. .bottom-button {
  1028. position fixed;
  1029. bottom: 20rpx;
  1030. left: 25rpx;
  1031. z-index: 500;
  1032. width: 700rpx;
  1033. line-height: 100rpx;
  1034. border-radius: 20rpx;
  1035. background #0183FA;
  1036. color: #fff;
  1037. text-align center;
  1038. }
  1039. .pageTwo {
  1040. flex: 1;
  1041. display flex;
  1042. flex-direction column;
  1043. overflow-y hidden;
  1044. .pageTwo-input-box {
  1045. display flex;
  1046. padding: 20rpx 25rpx;
  1047. background #fff;
  1048. margin-bottom: 20rpx;
  1049. input {
  1050. padding: 0 20rpx;
  1051. width: 460rpx;
  1052. line-height: 80rpx;
  1053. height: 80rpx;
  1054. border-top: 1rpx solid #a2a2a2;
  1055. border-left: 1rpx solid #a2a2a2;
  1056. border-bottom: 1rpx solid #a2a2a2;
  1057. border-bottom-left-radius: 10rpx;
  1058. border-top-left-radius: 10rpx;
  1059. }
  1060. view {
  1061. width: 200rpx;
  1062. line-height: 80rpx;
  1063. height: 80rpx;
  1064. border: 1rpx solid #007AFF;
  1065. color: #fff;
  1066. background #007AFF;
  1067. text-align center;
  1068. border-top-right-radius: 10rpx;
  1069. border-bottom-right-radius: 10rpx;
  1070. }
  1071. }
  1072. .for-max-box {
  1073. background #fff;
  1074. flex: 1;
  1075. overflow-y scroll;
  1076. .for-box:nth-child(1) {
  1077. border: none;
  1078. }
  1079. .for-null-text {
  1080. text-align center;
  1081. line-height: 100rpx;
  1082. color: #999;
  1083. }
  1084. .for-box {
  1085. border-top: 1rpx solid #dedede;
  1086. display: flex;
  1087. .button-text-view {
  1088. padding: 35rpx 35rpx 35rpx 20rpx;
  1089. width:560rpx;
  1090. }
  1091. .button-big-view {
  1092. padding: 20rpx 0 20rpx 0 ;
  1093. width: 100rpx;
  1094. display: flex;
  1095. flex-direction: column;
  1096. .button-null-view{
  1097. flex:1;
  1098. }
  1099. .button-view{
  1100. line-height:60rpx;
  1101. width: 100rpx;
  1102. text-align center;
  1103. border-radius: 10rpx;
  1104. background #007AFF;
  1105. color: #fff;
  1106. }
  1107. }
  1108. }
  1109. }
  1110. .out-button {
  1111. width: 650rpx;
  1112. height: 100rpx;
  1113. line-height: 100rpx;
  1114. margin: 20rpx 50rpx;
  1115. text-align center;
  1116. font-size: 32rpx;
  1117. color: #fff;
  1118. background #999;
  1119. border-radius: 20rpx;
  1120. }
  1121. }
  1122. .shade-max-box {
  1123. background: rgba(0, 0, 0, 0.2);
  1124. width: 100%;
  1125. height: 100%;
  1126. position fixed;
  1127. z-index 100;
  1128. .shade-big-box {
  1129. width: 626rpx;
  1130. height: 567rpx;
  1131. margin: 335rpx 63rpx;
  1132. position relative;
  1133. z-index 100;
  1134. img {
  1135. width: 626rpx;
  1136. height: 567rpx;
  1137. }
  1138. view {
  1139. position absolute;
  1140. left: 88rpx;
  1141. bottom: 100rpx;
  1142. width: 450rpx;
  1143. height: 80rpx;
  1144. line-height: 80rpx;
  1145. text-align center;
  1146. color: #fff;
  1147. background #0183FA;
  1148. border-radius: 40rpx;
  1149. }
  1150. }
  1151. }
  1152. }
  1153. /deep/.input-value-border {
  1154. display: none !important;
  1155. }
  1156. </style>