empowerOpen.vue 14 KB

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