empowerOpen.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <!-- 授权开门 -->
  2. <template>
  3. <view id="empowerOpen">
  4. <view class="page-one" v-if="pageType==1">
  5. <view class="header">
  6. <view class="header-n">
  7. <input class="header-l" type="text" @confirm="subNameChange()" v-model="getData.searchValue" placeholder="实验室名称">
  8. <view class="header-r" v-if="getData.searchValue" @click="clearSearch()" >
  9. <img :src="imagesUrl('commonality/clear.png')">
  10. </view>
  11. </view>
  12. </view>
  13. <scroll-view scroll-y @scrolltolower="scrollGet" class="list">
  14. <view class="list-li" v-for="(item,index) in dataList">
  15. <view class="list-li-l">{{item.subName}}{{item.roomNum?'('+item.roomNum+')':''}}</view>
  16. <view class="list-li-r" @click="authorizedClick(item)">
  17. <view class="null-p"></view>
  18. <view>授权</view>
  19. <view class="null-p"></view>
  20. </view>
  21. </view>
  22. <view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
  23. <view class="get-data-null-p" v-else="getDataType">- 滑动加载更多 -</view>
  24. </scroll-view>
  25. </view>
  26. <view class="page-tow" v-if="pageType==2">
  27. <view class="list-tow">
  28. <view class="list-tow-li">
  29. <view class="list-tow-li-t">被授权人</view>
  30. <view class="list-user-name-box" v-if="addForm.userId">
  31. <view>{{addForm.userName}}{{account?'-'+account:''}}</view>
  32. <view @click="delUserData()">更改</view>
  33. </view>
  34. <input class="list-tow-li-b" v-if="!addForm.userId" type="text" @confirm="authorizedChange()"
  35. v-model="getDataTow.searchValue" placeholder="被授权人搜索,最少两个字">
  36. <uni-data-picker @change="bindPickerChange":localdata="dataListTow" ref='picker'>
  37. </uni-data-picker>
  38. </view>
  39. <view class="list-tow-li">
  40. <view class="list-tow-li-t">生效时间</view>
  41. <view class="time">
  42. <view class="example-body">
  43. </view>
  44. <view class="time-l">
  45. <uni-datetime-picker type="datetime" hide-second="true" :border="true"
  46. v-model="addForm.validBeginTime" @change="changeLog" placeholder="开始时间" />
  47. </view>
  48. <view class="time-c">-</view>
  49. <view class="time-r">
  50. <view class="right-end-time">{{addForm.validEndTime?addForm.validEndTime:'结束时间'}}</view>
  51. <!-- <uni-datetime-picker type="datetime" hide-second="true" :border="true"
  52. v-model="addForm.validEndTime" @change="changeLog" placeholder="结束时间" /> -->
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="bottom" v-if="pageType==2">
  59. <view class="bottom-l" @click="cancelClick()">取消</view>
  60. <view class="bottom-r" @click="submitForm()">确定</view>
  61. </view>
  62. <view class="success" v-if="successVisible">
  63. <view class="null-box" @click="closeTip()"></view>
  64. <view class="panel">
  65. <img class="panel-t" v-if="authorizeStatus==1" :src="imagesUrl('commonality/icon_kcxq_cg.png')" />
  66. <img class="panel-t" v-if="authorizeStatus==2" :src="imagesUrl('commonality/icon_kcxq_sb.png')"/>
  67. <view class="panel-m">{{authorizeStatus==1?'授权成功':'授权失败'}}</view>
  68. <view class="panel-b">({{count}}S)</view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import {
  75. config
  76. } from '@/api/request/config.js'
  77. import {
  78. systemSubjectGetAppSubject,
  79. laboratoryApplyGetUserInfo,
  80. laboratoryApplyAddAddApply
  81. } from '@/pages_manage/api/index.js'
  82. export default {
  83. components: {
  84. },
  85. data() {
  86. return {
  87. pageType: 1,
  88. baseUrl: config.base_url,
  89. datetimesingle: '',
  90. newData: {
  91. },
  92. currentDate: '',
  93. addForm: {
  94. userId: '',
  95. subId: '',
  96. validBeginTime: '',
  97. validEndTime: '',
  98. },
  99. total: 0,
  100. getData: {
  101. page: 1,
  102. pageSize: 20,
  103. searchValue: '',
  104. adminId: uni.getStorageSync('userId'),
  105. },
  106. getDataType: false,
  107. getDataTow: {
  108. searchValue: '',
  109. labId: '',
  110. },
  111. dataList: [],
  112. dataListTow: [], //被授权人
  113. authorizeStatus: 0, //1成功 2失败
  114. successVisible: false,
  115. timer: null,
  116. count: '',
  117. //展示用工号
  118. account:false,
  119. }
  120. },
  121. onLoad(option) {
  122. },
  123. onShow() {
  124. },
  125. mounted() {
  126. this.currentDate = this.getdate();
  127. this.systemSubjectGetAppSubject();
  128. },
  129. methods: {
  130. changeLog(e) {
  131. const time = e.split(' ')[0];
  132. const date = new Date(parseInt(new Date(e).getTime()+1800000));
  133. const hours = date.getHours().toString().padStart(2, '0');
  134. const minutes = date.getMinutes().toString().padStart(2, '0');
  135. let timeB = time+' '+hours+':'+minutes;
  136. this.$set(this.addForm,'validEndTime',timeB);
  137. console.log('change事件:', this.addForm.validEndTime);
  138. },
  139. getdate() {
  140. var date = new Date();
  141. var seperator1 = "-";
  142. var year = date.getFullYear();
  143. var month = date.getMonth() + 1;
  144. var strDate = date.getDate();
  145. if (month >= 1 && month <= 9) {
  146. month = "0" + month;
  147. }
  148. if (strDate >= 0 && strDate <= 9) {
  149. strDate = "0" + strDate;
  150. }
  151. var currentdate = year + "-" + month + "-" + strDate;
  152. return currentdate;
  153. },
  154. //清空选项
  155. delUserData(){
  156. this.$set(this.addForm,'userName',null);
  157. this.$set(this.addForm,'userId',null);
  158. this.$set(this,'account',false);
  159. },
  160. //被授权人搜索
  161. async authorizedChange() {
  162. if(this.getDataTow.searchValue.length<2){
  163. uni.showToast({
  164. title: '请输入最少两个字',
  165. icon: "none",
  166. duration: 2000
  167. });
  168. return
  169. }
  170. let self = this
  171. self.dataListTow = []
  172. const {
  173. data
  174. } = await laboratoryApplyGetUserInfo(this.getDataTow)
  175. if (data.code == 200) {
  176. data.data.forEach(function(item) {
  177. self.dataListTow.push({
  178. text: item.userName+(item.account?'-'+item.account:''),
  179. value: item.userId,
  180. userName: item.userName,
  181. account: item.account,
  182. })
  183. })
  184. self.$refs.picker.show()
  185. }
  186. },
  187. bindPickerChange: function(e) {
  188. let self = this;
  189. for(let i=0;i<self.dataListTow.length;i++){
  190. if(e.detail.value[0].value == self.dataListTow[i].value){
  191. this.$set(self.addForm,'userName',self.dataListTow[i].userName);
  192. this.$set(self.addForm,'userId',self.dataListTow[i].value);
  193. this.$set(self,'account',self.dataListTow[i].account?self.dataListTow[i].account:false);
  194. return
  195. }
  196. }
  197. },
  198. //授权点击
  199. authorizedClick(row) {
  200. this.$set(this, 'pageType', 2)
  201. this.$set(this.getDataTow, 'labId', row.subId)
  202. this.$set(this.addForm, 'subId', row.subId)
  203. },
  204. //滚动加载事件
  205. scrollGet() {
  206. let self = this;
  207. if (self.total / self.getData.pageSize <= self.getData.page) {
  208. this.$set(this, 'getDataType', true);
  209. } else {
  210. this.getData.page += 1;
  211. this.$nextTick(() => {
  212. this.systemSubjectGetAppSubject();
  213. })
  214. }
  215. },
  216. //获取实验室
  217. async systemSubjectGetAppSubject() {
  218. let self = this;
  219. const {
  220. data
  221. } = await systemSubjectGetAppSubject(this.getData);
  222. if (data.code == 200) {
  223. if (self.getData.page == 1) {
  224. this.dataList = data.data.records;
  225. this.total = data.data.total;
  226. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  227. this.$set(this, 'getDataType', true);
  228. }
  229. } else {
  230. this.dataList = [...this.dataList, ...data.data.records]
  231. this.total = data.data.total;
  232. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  233. this.$set(this, 'getDataType', true);
  234. }
  235. }
  236. }
  237. },
  238. //实验室搜索
  239. subNameChange() {
  240. this.$set(this, 'getDataType', false);
  241. this.$set(this, 'dataList', []);
  242. this.$set(this, 'total', 0);
  243. this.$set(this.getData, 'page', 1);
  244. this.systemSubjectGetAppSubject();
  245. },
  246. //实验室搜索框清除
  247. clearSearch(){
  248. this.$set(this, 'getDataType', false);
  249. this.$set(this, 'dataList', []);
  250. this.$set(this, 'total', 0);
  251. this.$set(this.getData, 'page', 1);
  252. this.$set(this.getData, 'searchValue', '');
  253. this.systemSubjectGetAppSubject();
  254. },
  255. cancelClick() {
  256. this.$set(this, 'pageType', 1)
  257. },
  258. //授权提交
  259. async submitForm() {
  260. let self = this;
  261. if(!self.addForm.userId){
  262. uni.showToast({
  263. title: '请选择被授权人',
  264. icon: "none",
  265. duration: 2000
  266. });
  267. return
  268. }
  269. if(!self.addForm.validBeginTime || !self.addForm.validEndTime){
  270. uni.showToast({
  271. title: '请选择授权时间',
  272. icon: "none",
  273. duration: 2000
  274. });
  275. return
  276. }
  277. let obj={
  278. userId:this.addForm.userId,
  279. subId: this.addForm.subId,
  280. validBeginTime:this.addForm.validBeginTime.replace(' ','T')+':00',
  281. validEndTime:this.addForm.validEndTime.replace(' ','T')+':59',
  282. }
  283. const {
  284. data
  285. } = await laboratoryApplyAddAddApply(obj);
  286. if (data.code == 200) {
  287. this.$set(this, 'authorizeStatus', 1)
  288. this.$set(this, 'successVisible', true)
  289. this.getCode();
  290. }else{
  291. this.$set(this, 'authorizeStatus', 2)
  292. this.$set(this, 'successVisible', true)
  293. this.getCode();
  294. }
  295. },
  296. //关闭弹框倒计时
  297. getCode() {
  298. let self = this;
  299. const TIME_COUNT = 3;
  300. if (!this.timer) {
  301. this.count = TIME_COUNT;
  302. this.show = false;
  303. this.timer = setInterval(() => {
  304. if (this.count > 0 && this.count <= TIME_COUNT) {
  305. this.count -= 1;
  306. } else {
  307. self.successVisible = false;
  308. clearInterval(this.timer);
  309. this.timer = null;
  310. }
  311. }, 1000);
  312. }
  313. },
  314. closeTip() {
  315. this.$set(this, 'successVisible', false)
  316. },
  317. }
  318. }
  319. </script>
  320. <style lang="stylus" scoped>
  321. #empowerOpen {
  322. height: 100%;
  323. display flex;
  324. flex-direction column;
  325. .page-one {
  326. flex:1;
  327. display flex;
  328. flex-direction column;
  329. overflow: hidden;
  330. .header {
  331. width: 749rpx;
  332. height: 120rpx;
  333. background: #FFFFFF;
  334. padding: 20rpx 30rpx;
  335. box-sizing: border-box;
  336. border-bottom: 1rpx solid #D8D8D8;
  337. .header-n{
  338. position: relative;
  339. width: 690rpx;
  340. height: 80rpx;
  341. border-radius: 10rpx 10rpx 10rpx 10rpx;
  342. border: 1rpx solid #E0E0E0;
  343. padding-left: 20rpx;
  344. box-sizing: border-box;
  345. .header-l {
  346. width: 590rpx;
  347. height: 80rpx;
  348. }
  349. .header-r{
  350. position: absolute;
  351. top: 0rpx;
  352. right: 0rpx;
  353. width: 68rpx;
  354. height: 80rpx;
  355. >img{
  356. width: 24rpx;
  357. height: 24rpx;
  358. margin-top: 24rpx;
  359. margin-left: 24rpx;
  360. }
  361. }
  362. }
  363. }
  364. .list {
  365. flex: 1;
  366. overflow-y scroll;
  367. padding: 0 30rpx;
  368. box-sizing: border-box;
  369. background: #fff;
  370. .list-li {
  371. // height: 90rpx;
  372. display: flex;
  373. // justify-content: space-between;
  374. // align-items: center;
  375. border-bottom: 1rpx solid #D8D8D8;
  376. .list-li-l {
  377. flex: 1;
  378. font-family: PingFang SC, PingFang SC;
  379. font-weight: 400;
  380. font-size: 30rpx;
  381. color: #333333;
  382. line-height: 40rpx;
  383. padding: 25rpx 25rpx 25rpx 0;
  384. }
  385. .list-li-r {
  386. font-family: PingFang SC, PingFang SC;
  387. font-weight: 400;
  388. font-size: 28rpx;
  389. color: #0183FA;
  390. line-height: 90rpx;
  391. display: flex;
  392. flex-direction: column;
  393. text-align: right;
  394. width: 80rpx;
  395. }
  396. .null-p {
  397. flex: 1;
  398. }
  399. }
  400. .list-li:last-child{
  401. border-bottom: none;
  402. }
  403. }
  404. .get-data-null-p {
  405. text-align: center;
  406. line-height: 100rpx;
  407. padding-bottom: 80px;
  408. color: #999;
  409. }
  410. }
  411. .page-tow {
  412. .list-tow {
  413. padding: 0 30rpx 50rpx;
  414. box-sizing: border-box;
  415. background: #fff;
  416. .list-tow-li {
  417. overflow: hidden;
  418. .list-tow-li-t {
  419. font-family: PingFang SC, PingFang SC;
  420. font-weight: 400;
  421. font-size: 30rpx;
  422. color: #333333;
  423. line-height: 42rpx;
  424. text-align: left;
  425. margin: 24rpx 0;
  426. }
  427. .list-user-name-box{
  428. display: flex;
  429. width: 690rpx;
  430. height: 80rpx;
  431. border-radius: 10rpx 10rpx 10rpx 10rpx;
  432. border: 1rpx solid #e0e0e0;
  433. padding-left: 20rpx;
  434. box-sizing: border-box;
  435. view{
  436. line-height:78rpx;
  437. }
  438. view:nth-child(1){
  439. paddin:0 10rpx;
  440. flex:1;
  441. }
  442. view:nth-child(2){
  443. width:100rpx;
  444. text-align: center;
  445. border-left: 1rpx solid #e0e0e0;
  446. }
  447. }
  448. .list-tow-li-b {
  449. width: 690rpx;
  450. height: 80rpx;
  451. border-radius: 10rpx 10rpx 10rpx 10rpx;
  452. border: 1rpx solid #E0E0E0;
  453. padding-left: 20rpx;
  454. box-sizing: border-box;
  455. }
  456. .time {
  457. display: flex;
  458. justify-content: flex-start;
  459. align-items: center;
  460. width: 690rpx;
  461. height: 80rpx;
  462. border-radius: 10rpx 10rpx 10rpx 10rpx;
  463. //border: 1rpx solid #E0E0E0;
  464. .time-l {
  465. height: 80rpx;
  466. width: 324rpx;
  467. font-family: PingFang SC, PingFang SC;
  468. font-weight: 400;
  469. font-size: 28rpx;
  470. color: #333333;
  471. line-height: 80rpx;
  472. text-align: center;
  473. }
  474. .time-c {
  475. height: 80rpx;
  476. width: 40rpx;
  477. text-align: center;
  478. line-height: 80rpx;
  479. //border-top: 1rpx solid #E0E0E0;
  480. //border-bottom: 1rpx solid #E0E0E0;
  481. }
  482. .time-r {
  483. height: 80rpx;
  484. width: 324rpx;
  485. //background: #E0E0E0;
  486. font-family: PingFang SC, PingFang SC;
  487. font-weight: 400;
  488. font-size: 28rpx;
  489. color: #333333;
  490. line-height: 80rpx;
  491. text-align: center;
  492. .right-end-time{
  493. width:320rpx;
  494. height: 74rpx;
  495. line-height: 74rpx;
  496. font-size: 28rpx;
  497. text-align: center;
  498. background-color: #e5e5e5;
  499. color: #666;
  500. border-radius: 4px;
  501. border: 1px solid #e5e5e5;
  502. }
  503. }
  504. }
  505. }
  506. }
  507. }
  508. .bottom {
  509. display: flex;
  510. justify-content: space-between;
  511. position: fixed;
  512. bottom: 0;
  513. .bottom-l {
  514. width: 375rpx;
  515. height: 90rpx;
  516. background: #FFFFFF;
  517. font-family: PingFang SC, PingFang SC;
  518. font-weight: 400;
  519. font-size: 30rpx;
  520. color: #333333;
  521. line-height: 90rpx;
  522. text-align: center;
  523. }
  524. .bottom-r {
  525. font-family: PingFang SC, PingFang SC;
  526. font-weight: 400;
  527. font-size: 30rpx;
  528. color: #FFFFFF;
  529. line-height: 90rpx;
  530. text-align: center;
  531. width: 375rpx;
  532. height: 90rpx;
  533. background: #0183FA;
  534. }
  535. }
  536. .success {
  537. height: 100%;
  538. width: 100%;
  539. position: fixed;
  540. top: 0;
  541. display: flex;
  542. flex-direction: column;
  543. z-index: 10;
  544. background: rgba(0, 0, 0, 0.2);
  545. .null-box {
  546. flex: 1;
  547. }
  548. .panel {
  549. width: 550rpx;
  550. height: 255rpx;
  551. background: #FFFFFF;
  552. border-radius: 20rpx 20rpx 20rpx 20rpx;
  553. position: absolute;
  554. top: 320rpx;
  555. left: 100rpx;
  556. display: flex;
  557. flex-direction: column;
  558. align-items: center;
  559. .panel-t {
  560. width: 80rpx;
  561. height: 80rpx;
  562. margin: 40rpx 0 18rpx 0;
  563. }
  564. .panel-m {
  565. font-family: PingFang SC, PingFang SC;
  566. font-weight: 400;
  567. font-size: 30rpx;
  568. color: #3D3D3D;
  569. line-height: 42rpx;
  570. margin-bottom: 8rpx;
  571. }
  572. .panel-b {
  573. font-family: PingFang SC, PingFang SC;
  574. font-weight: 400;
  575. font-size: 30rpx;
  576. color: #999999;
  577. line-height: 42rpx;
  578. }
  579. }
  580. }
  581. }
  582. /deep/.input-value-border {
  583. display: none !important;
  584. }
  585. /deep/.uni-date-x{
  586. height:74rpx;
  587. }
  588. </style>
  589. <style>
  590. .uni-date-x .icon-calendar {
  591. padding-left: 3px;
  592. display: none !important;
  593. }
  594. .uni-date__x-input {
  595. height: 74rpx !important;
  596. line-height: 74rpx !important;
  597. font-size: 28rpx !important;
  598. }
  599. .uni-date__icon-clear{
  600. height: 74rpx !important;
  601. font-size: 28rpx !important;
  602. }
  603. .uni-date__icon-clear text{
  604. font-size: 32rpx !important;
  605. }
  606. </style>