empowerOpen.vue 12 KB

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