empowerOpen.vue 11 KB

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