empowerOpen.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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" @change="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" @change="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. let self = this
  163. self.dataListTow = []
  164. const {
  165. data
  166. } = await laboratoryApplyGetUserInfo(this.getDataTow)
  167. if (data.code == 200) {
  168. data.data.forEach(function(item) {
  169. self.dataListTow.push({
  170. text: item.userName+(item.account?'-'+item.account:''),
  171. value: item.userId,
  172. userName: item.userName,
  173. account: item.account,
  174. })
  175. })
  176. self.$refs.picker.show()
  177. }
  178. },
  179. bindPickerChange: function(e) {
  180. let self = this;
  181. for(let i=0;i<self.dataListTow.length;i++){
  182. if(e.detail.value[0].value == self.dataListTow[i].value){
  183. this.$set(self.addForm,'userName',self.dataListTow[i].userName);
  184. this.$set(self.addForm,'userId',self.dataListTow[i].value);
  185. this.$set(self,'account',self.dataListTow[i].account?self.dataListTow[i].account:false);
  186. return
  187. }
  188. }
  189. },
  190. //授权点击
  191. authorizedClick(row) {
  192. this.$set(this, 'pageType', 2)
  193. this.$set(this.getDataTow, 'labId', row.subId)
  194. this.$set(this.addForm, 'subId', row.subId)
  195. },
  196. //滚动加载事件
  197. scrollGet() {
  198. let self = this;
  199. if (self.total / self.getData.pageSize <= self.getData.page) {
  200. this.$set(this, 'getDataType', true);
  201. } else {
  202. this.getData.page += 1;
  203. this.$nextTick(() => {
  204. this.systemSubjectGetAppSubject();
  205. })
  206. }
  207. },
  208. //获取实验室
  209. async systemSubjectGetAppSubject() {
  210. let self = this;
  211. const {
  212. data
  213. } = await systemSubjectGetAppSubject(this.getData);
  214. if (data.code == 200) {
  215. if (self.getData.page == 1) {
  216. this.dataList = data.data.records;
  217. this.total = data.data.total;
  218. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  219. this.$set(this, 'getDataType', true);
  220. }
  221. } else {
  222. this.dataList = [...this.dataList, ...data.data.records]
  223. this.total = data.data.total;
  224. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  225. this.$set(this, 'getDataType', true);
  226. }
  227. }
  228. }
  229. },
  230. //实验室搜索
  231. subNameChange() {
  232. this.$set(this, 'getDataType', false);
  233. this.$set(this, 'dataList', []);
  234. this.$set(this, 'total', 0);
  235. this.$set(this.getData, 'page', 1);
  236. this.systemSubjectGetAppSubject();
  237. },
  238. //实验室搜索框清除
  239. clearSearch(){
  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.$set(this.getData, 'searchValue', '');
  245. this.systemSubjectGetAppSubject();
  246. },
  247. cancelClick() {
  248. this.$set(this, 'pageType', 1)
  249. },
  250. //授权提交
  251. async submitForm() {
  252. let self = this;
  253. if(!self.addForm.userId){
  254. uni.showToast({
  255. title: '请选择被授权人',
  256. icon: "none",
  257. duration: 2000
  258. });
  259. return
  260. }
  261. if(!self.addForm.validBeginTime || !self.addForm.validEndTime){
  262. uni.showToast({
  263. title: '请选择授权时间',
  264. icon: "none",
  265. duration: 2000
  266. });
  267. return
  268. }
  269. let obj={
  270. userId:this.addForm.userId,
  271. subId: this.addForm.subId,
  272. validBeginTime:this.addForm.validBeginTime.replace(' ','T')+':00',
  273. validEndTime:this.addForm.validEndTime.replace(' ','T')+':59',
  274. }
  275. const {
  276. data
  277. } = await laboratoryApplyAddAddApply(obj);
  278. if (data.code == 200) {
  279. this.$set(this, 'authorizeStatus', 1)
  280. this.$set(this, 'successVisible', true)
  281. this.getCode();
  282. }else{
  283. this.$set(this, 'authorizeStatus', 2)
  284. this.$set(this, 'successVisible', true)
  285. this.getCode();
  286. }
  287. },
  288. //关闭弹框倒计时
  289. getCode() {
  290. let self = this;
  291. const TIME_COUNT = 3;
  292. if (!this.timer) {
  293. this.count = TIME_COUNT;
  294. this.show = false;
  295. this.timer = setInterval(() => {
  296. if (this.count > 0 && this.count <= TIME_COUNT) {
  297. this.count -= 1;
  298. } else {
  299. self.successVisible = false;
  300. clearInterval(this.timer);
  301. this.timer = null;
  302. }
  303. }, 1000);
  304. }
  305. },
  306. closeTip() {
  307. this.$set(this, 'successVisible', false)
  308. },
  309. }
  310. }
  311. </script>
  312. <style lang="stylus" scoped>
  313. #empowerOpen {
  314. height: 100%;
  315. display flex;
  316. flex-direction column;
  317. .page-one {
  318. flex:1;
  319. display flex;
  320. flex-direction column;
  321. overflow: hidden;
  322. .header {
  323. width: 749rpx;
  324. height: 120rpx;
  325. background: #FFFFFF;
  326. padding: 20rpx 30rpx;
  327. box-sizing: border-box;
  328. border-bottom: 1rpx solid #D8D8D8;
  329. .header-n{
  330. position: relative;
  331. width: 690rpx;
  332. height: 80rpx;
  333. border-radius: 10rpx 10rpx 10rpx 10rpx;
  334. border: 1rpx solid #E0E0E0;
  335. padding-left: 20rpx;
  336. box-sizing: border-box;
  337. .header-l {
  338. width: 590rpx;
  339. height: 80rpx;
  340. }
  341. .header-r{
  342. position: absolute;
  343. top: 0rpx;
  344. right: 0rpx;
  345. width: 68rpx;
  346. height: 80rpx;
  347. >img{
  348. width: 24rpx;
  349. height: 24rpx;
  350. margin-top: 24rpx;
  351. margin-left: 24rpx;
  352. }
  353. }
  354. }
  355. }
  356. .list {
  357. flex: 1;
  358. overflow-y scroll;
  359. padding: 0 30rpx;
  360. box-sizing: border-box;
  361. background: #fff;
  362. .list-li {
  363. // height: 90rpx;
  364. display: flex;
  365. // justify-content: space-between;
  366. // align-items: center;
  367. border-bottom: 1rpx solid #D8D8D8;
  368. .list-li-l {
  369. flex: 1;
  370. font-family: PingFang SC, PingFang SC;
  371. font-weight: 400;
  372. font-size: 30rpx;
  373. color: #333333;
  374. line-height: 40rpx;
  375. padding: 25rpx 25rpx 25rpx 0;
  376. }
  377. .list-li-r {
  378. font-family: PingFang SC, PingFang SC;
  379. font-weight: 400;
  380. font-size: 28rpx;
  381. color: #0183FA;
  382. line-height: 90rpx;
  383. display: flex;
  384. flex-direction: column;
  385. text-align: right;
  386. width: 80rpx;
  387. }
  388. .null-p {
  389. flex: 1;
  390. }
  391. }
  392. .list-li:last-child{
  393. border-bottom: none;
  394. }
  395. }
  396. .get-data-null-p {
  397. text-align: center;
  398. line-height: 100rpx;
  399. padding-bottom: 80px;
  400. color: #999;
  401. }
  402. }
  403. .page-tow {
  404. .list-tow {
  405. padding: 0 30rpx 50rpx;
  406. box-sizing: border-box;
  407. background: #fff;
  408. .list-tow-li {
  409. overflow: hidden;
  410. .list-tow-li-t {
  411. font-family: PingFang SC, PingFang SC;
  412. font-weight: 400;
  413. font-size: 30rpx;
  414. color: #333333;
  415. line-height: 42rpx;
  416. text-align: left;
  417. margin: 24rpx 0;
  418. }
  419. .list-user-name-box{
  420. display: flex;
  421. width: 690rpx;
  422. height: 80rpx;
  423. border-radius: 10rpx 10rpx 10rpx 10rpx;
  424. border: 1rpx solid #e0e0e0;
  425. padding-left: 20rpx;
  426. box-sizing: border-box;
  427. view{
  428. line-height:78rpx;
  429. }
  430. view:nth-child(1){
  431. paddin:0 10rpx;
  432. flex:1;
  433. }
  434. view:nth-child(2){
  435. width:100rpx;
  436. text-align: center;
  437. border-left: 1rpx solid #e0e0e0;
  438. }
  439. }
  440. .list-tow-li-b {
  441. width: 690rpx;
  442. height: 80rpx;
  443. border-radius: 10rpx 10rpx 10rpx 10rpx;
  444. border: 1rpx solid #E0E0E0;
  445. padding-left: 20rpx;
  446. box-sizing: border-box;
  447. }
  448. .time {
  449. display: flex;
  450. justify-content: flex-start;
  451. align-items: center;
  452. width: 690rpx;
  453. height: 80rpx;
  454. border-radius: 10rpx 10rpx 10rpx 10rpx;
  455. //border: 1rpx solid #E0E0E0;
  456. .time-l {
  457. height: 80rpx;
  458. width: 324rpx;
  459. font-family: PingFang SC, PingFang SC;
  460. font-weight: 400;
  461. font-size: 28rpx;
  462. color: #333333;
  463. line-height: 80rpx;
  464. text-align: center;
  465. }
  466. .time-c {
  467. height: 80rpx;
  468. width: 40rpx;
  469. text-align: center;
  470. line-height: 80rpx;
  471. //border-top: 1rpx solid #E0E0E0;
  472. //border-bottom: 1rpx solid #E0E0E0;
  473. }
  474. .time-r {
  475. height: 80rpx;
  476. width: 324rpx;
  477. //background: #E0E0E0;
  478. font-family: PingFang SC, PingFang SC;
  479. font-weight: 400;
  480. font-size: 28rpx;
  481. color: #333333;
  482. line-height: 80rpx;
  483. text-align: center;
  484. .right-end-time{
  485. width:320rpx;
  486. height: 74rpx;
  487. line-height: 74rpx;
  488. font-size: 28rpx;
  489. text-align: center;
  490. background-color: #e5e5e5;
  491. color: #666;
  492. border-radius: 4px;
  493. border: 1px solid #e5e5e5;
  494. }
  495. }
  496. }
  497. }
  498. }
  499. }
  500. .bottom {
  501. display: flex;
  502. justify-content: space-between;
  503. position: fixed;
  504. bottom: 0;
  505. .bottom-l {
  506. width: 375rpx;
  507. height: 90rpx;
  508. background: #FFFFFF;
  509. font-family: PingFang SC, PingFang SC;
  510. font-weight: 400;
  511. font-size: 30rpx;
  512. color: #333333;
  513. line-height: 90rpx;
  514. text-align: center;
  515. }
  516. .bottom-r {
  517. font-family: PingFang SC, PingFang SC;
  518. font-weight: 400;
  519. font-size: 30rpx;
  520. color: #FFFFFF;
  521. line-height: 90rpx;
  522. text-align: center;
  523. width: 375rpx;
  524. height: 90rpx;
  525. background: #0183FA;
  526. }
  527. }
  528. .success {
  529. height: 100%;
  530. width: 100%;
  531. position: fixed;
  532. top: 0;
  533. display: flex;
  534. flex-direction: column;
  535. z-index: 10;
  536. background: rgba(0, 0, 0, 0.2);
  537. .null-box {
  538. flex: 1;
  539. }
  540. .panel {
  541. width: 550rpx;
  542. height: 255rpx;
  543. background: #FFFFFF;
  544. border-radius: 20rpx 20rpx 20rpx 20rpx;
  545. position: absolute;
  546. top: 320rpx;
  547. left: 100rpx;
  548. display: flex;
  549. flex-direction: column;
  550. align-items: center;
  551. .panel-t {
  552. width: 80rpx;
  553. height: 80rpx;
  554. margin: 40rpx 0 18rpx 0;
  555. }
  556. .panel-m {
  557. font-family: PingFang SC, PingFang SC;
  558. font-weight: 400;
  559. font-size: 30rpx;
  560. color: #3D3D3D;
  561. line-height: 42rpx;
  562. margin-bottom: 8rpx;
  563. }
  564. .panel-b {
  565. font-family: PingFang SC, PingFang SC;
  566. font-weight: 400;
  567. font-size: 30rpx;
  568. color: #999999;
  569. line-height: 42rpx;
  570. }
  571. }
  572. }
  573. }
  574. /deep/.input-value-border {
  575. display: none !important;
  576. }
  577. </style>
  578. <style>
  579. .uni-date-x .icon-calendar {
  580. padding-left: 3px;
  581. display: none !important;
  582. }
  583. .uni-date__x-input {
  584. height: 74rpx !important;
  585. line-height: 74rpx !important;
  586. font-size: 28rpx !important;
  587. }
  588. .uni-date__icon-clear{
  589. height: 74rpx !important;
  590. font-size: 28rpx !important;
  591. }
  592. .uni-date__icon-clear text{
  593. font-size: 32rpx !important;
  594. }
  595. </style>