addPage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <!-- 权限申请新增 -->
  2. <template>
  3. <view class="permissionApplyAddPage">
  4. <view class="check-big-box" v-if="!dialogRulesType">
  5. <view class="check-text-p">*</view>
  6. <view class="check-title-p">所需权限</view>
  7. <view class="check-box" @click="checkButton(item)"
  8. v-if="!item.checkSwitch"
  9. v-for="(item,index) in permConfigList" :key="index">
  10. <img v-if="!item.checkType" class="left-box" :src="imagesUrl('commonality/icon_12.png')">
  11. <img v-if="item.checkType" class="left-box" :src="imagesUrl('commonality/icon_13.png')">
  12. <view>{{item.permName}}</view>
  13. </view>
  14. <!-- <view class="check-box" @click="checkButton(1)">
  15. <img v-if="!newData.checkType1" class="left-box" :src="imagesUrl('commonality/icon_12.png')">
  16. <img v-if="newData.checkType1" class="left-box" :src="imagesUrl('commonality/icon_13.png')">
  17. <view>回收报备</view>
  18. </view>
  19. <view class="check-box" @click="checkButton(2)">
  20. <img v-if="!newData.checkType2" class="left-box" :src="imagesUrl('commonality/icon_12.png')">
  21. <img v-if="newData.checkType2" class="left-box" :src="imagesUrl('commonality/icon_13.png')">
  22. <view>称重登记</view>
  23. </view> -->
  24. </view>
  25. <view class="check-big-box">
  26. <view class="check-text-p">*</view>
  27. <view class="check-title-p">申请实验室</view>
  28. <input @click="inputClick(2)" v-model="subject.subName" class="picker-input-box" disabled type="text"
  29. placeholder="请选择实验室">
  30. <view v-if="subject.subName" class="picker-button-box" @click="inputClick(2)">修改</view>
  31. </view>
  32. <view style="margin-top:40rpx;">
  33. <view class="text-color-p" v-if="subject.subName">基础信息:{{subject.deptName}}</view>
  34. <view class="text-color-p" v-if="subject.subName">{{subject.buildName}} - {{subject.floorName}} - {{subject.roomNum}}</view>
  35. <view class="text-color-p" v-if="subject.subName">实验室负责人:{{subject.adminName}}</view>
  36. </view>
  37. <view class="submit-button-p" style="margin-top:60rpx;" v-if="!dialogRulesType" @click="submitButton()">立 即 申 请</view>
  38. <view class="submit-button-p-2" style="margin-top:60rpx;" v-if="dialogRulesType">您已申请了该实验室所有权限</view>
  39. <!-- 实验室选择页面 -->
  40. <view class="pageTwo" v-if="pageType == 2">
  41. <view class="pageTwo-input-box">
  42. <input type="text" placeholder="请输入实验室名称/房间号" v-model="subjectName">
  43. <view @click="subjectList">查找</view>
  44. </view>
  45. <view class="for-max-box">
  46. <view class="for-null-text" v-if="!searchList[0]">{{nullText}}</view>
  47. <view class="for-box" v-for="(item,index) in searchList" :key="index">
  48. <view class="button-text-view">{{item.subName}}{{item.roomNum?'('+item.roomNum+')':''}}</view>
  49. <view class="button-big-view">
  50. <view class="button-null-view"></view>
  51. <view class="button-view" @click="checkClick(item)">选择</view>
  52. <view class="button-null-view"></view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="out-button" @click="inputClick(1)">返回</view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. laboratorySubRelInfoGetRelList,
  63. } from '@/api/index.js'
  64. import {
  65. hwmsAppRegisterApprovalFindBySubIdAndUserId,
  66. hwmsPermConfigList,
  67. hwmsAppRegisterApprovalAdd,
  68. } from '@/pages_hazardousWasteRecycling/api/index.js'
  69. export default {
  70. data() {
  71. return {
  72. pageType:1,
  73. //搜索回的实验室列表
  74. searchList: [],
  75. subject:{},
  76. //实验室名称
  77. subjectName: "",
  78. //暂无数据提示
  79. nullText: "请输入实验室名称进行搜索",
  80. newData:{
  81. checkType1:true,
  82. checkType2:true
  83. },
  84. permConfigList:[],
  85. dialogRulesType:false,
  86. }
  87. },
  88. onLoad(option) {
  89. },
  90. onShow() {
  91. this.hwmsPermConfigList();
  92. },
  93. mounted() {
  94. },
  95. methods: {
  96. checkButton(item){
  97. item.checkType = !item.checkType;
  98. },
  99. submitButton(){
  100. let self = this;
  101. let num = 0;
  102. for(let i=0;i<self.permConfigList.length;i++){
  103. if(self.permConfigList[i].checkType){
  104. num++
  105. }
  106. }
  107. if(num == 0){
  108. uni.showToast({
  109. title: '请勾选所需权限',
  110. icon: "none",
  111. mask: true,
  112. duration: 2000
  113. });
  114. return
  115. }
  116. if(!this.subject.subId){
  117. uni.showToast({
  118. title: '请选择实验室',
  119. icon: "none",
  120. mask: true,
  121. duration: 2000
  122. });
  123. return
  124. }
  125. uni.showModal({
  126. content: '是否确认提交?',
  127. cancelColor: "#999",
  128. confirmColor: "#0183FA",
  129. success: function(res) {
  130. if (res.confirm) {
  131. self.hwmsAppRegisterApprovalAdd();
  132. } else if (res.cancel) {}
  133. }
  134. });
  135. },
  136. async hwmsAppRegisterApprovalAdd(){
  137. let self = this;
  138. let obj = {
  139. perm : [],
  140. buildId : this.subject.buildId,
  141. buildName : this.subject.buildName,
  142. deptId : this.subject.deptId,
  143. deptName : this.subject.deptName,
  144. roomNum : this.subject.roomNum,
  145. subId : this.subject.subId,
  146. subName : this.subject.subName,
  147. };
  148. for(let i=0;i<self.permConfigList.length;i++){
  149. if(self.permConfigList[i].checkType){
  150. obj.perm.push(self.permConfigList[i].id)
  151. }
  152. }
  153. obj.perm = obj.perm + '';
  154. const {
  155. data
  156. } = await hwmsAppRegisterApprovalAdd(obj)
  157. if (data.code == 200) {
  158. uni.showToast({
  159. title: '提交成功',
  160. icon: "none",
  161. mask: true,
  162. duration: 2000
  163. });
  164. setTimeout(function() {
  165. uni.navigateBack();
  166. }, 2000);
  167. }
  168. },
  169. async hwmsPermConfigList(){
  170. const {
  171. data
  172. } = await hwmsPermConfigList()
  173. if (data.code == 200) {
  174. for(let i=0;i<data.data.length;i++){
  175. data.data[i].checkType = true;
  176. data.data[i].checkSwitch = false;
  177. }
  178. this.$set(this,'permConfigList',data.data);
  179. }
  180. },
  181. //选择搜索页面
  182. inputClick(type) {
  183. if (this.pageType != type) {
  184. this.pageType = type;
  185. this.$set(this, "subjectName", '');
  186. this.$set(this, "searchList", []);
  187. }
  188. },
  189. //查询实验室
  190. async subjectList() {
  191. if(!this.subjectName){
  192. uni.showToast({
  193. title: '请输入实验室名称/房间号',
  194. icon: "none",
  195. mask: true,
  196. duration: 2000
  197. });
  198. return
  199. }
  200. const {
  201. data
  202. } = await laboratorySubRelInfoGetRelList({
  203. searchValue: this.subjectName
  204. })
  205. if (data.code == 200) {
  206. this.searchList = data.data;
  207. if (!data.data[0]) {
  208. this.nullText = "暂无数据"
  209. }
  210. }
  211. },
  212. //实验室选择
  213. checkClick(item) {
  214. this.hwmsAppRegisterApprovalFindBySubIdAndUserId(item);
  215. },
  216. //查询实验室与人员是否有报备权限
  217. async hwmsAppRegisterApprovalFindBySubIdAndUserId(item){
  218. let self = this;
  219. let obj = {
  220. subId:item.subId,
  221. userId:uni.getStorageSync('userId'),
  222. }
  223. const {
  224. data
  225. } = await hwmsAppRegisterApprovalFindBySubIdAndUserId(obj)
  226. if (data.code == 200) {
  227. if(data.data[0]){
  228. let dataList = [];
  229. for(let i=0;i<data.data.length;i++){
  230. let permId = data.data[i].permId.split(',');
  231. dataList = dataList.concat(permId)
  232. }
  233. for(let i=0;i<dataList.length;i++){
  234. for(let o=0;o<self.permConfigList.length;o++){
  235. if(dataList[i]==self.permConfigList[o].id){
  236. self.permConfigList[o].checkSwitch = true
  237. }
  238. }
  239. }
  240. let newList = [];
  241. for(let o=0;o<self.permConfigList.length;o++){
  242. if(!self.permConfigList[o].checkSwitch){
  243. newList.push(self.permConfigList[o].id)
  244. self.permConfigList[o].checkType = true;
  245. }else{
  246. self.permConfigList[o].checkType = false;
  247. }
  248. }
  249. if(newList[0]){
  250. this.$set(this,'dialogRulesType',false);
  251. }else{
  252. this.$set(this,'dialogRulesType',true);
  253. }
  254. }else{
  255. for(let i = 0;i<self.permConfigList.length;i++){
  256. self.permConfigList[i].checkSwitch = false;
  257. }
  258. this.$set(this,'dialogRulesType',false);
  259. }
  260. this.$set(this, "subject", item);
  261. this.inputClick(1);
  262. }
  263. },
  264. },
  265. }
  266. </script>
  267. <style lang="stylus" scoped>
  268. .permissionApplyAddPage{
  269. height: 100%;
  270. display flex;
  271. flex-direction column;
  272. background-color: #fff;
  273. .check-big-box{
  274. display: flex;
  275. padding:0 0 0 40rpx;
  276. margin-top:30rpx;
  277. .check-text-p{
  278. color:#FF6A6A;
  279. height:80rpx;
  280. line-height:80rpx;
  281. }
  282. .check-title-p{
  283. font-size:32rpx;
  284. height:80rpx;
  285. line-height:80rpx;
  286. }
  287. .check-box{
  288. display: flex;
  289. font-size:32rpx;
  290. margin-left:40rpx;
  291. img{
  292. width:40rpx;
  293. height:40rpx;
  294. margin-top:21rpx;
  295. }
  296. view{
  297. margin-left:20rpx;
  298. height:80rpx;
  299. line-height:80rpx;
  300. }
  301. }
  302. .picker-input-box{
  303. padding: 0 20rpx;
  304. display flex;
  305. height: 80rpx;
  306. width: 330rpx;
  307. border: 1rpx solid #a2a2a2;
  308. border-radius: 10rpx;
  309. margin: 0 20rpx;
  310. }
  311. .picker-button-box{
  312. font-size:30rpx;
  313. height: 80rpx;
  314. width: 100rpx;
  315. line-height:80rpx;
  316. text-align: center;
  317. color:#fff;
  318. background-color:#0183FA;
  319. border-radius: 10rpx;
  320. }
  321. }
  322. .text-color-p{
  323. color:#666;
  324. margin:0 50rpx;
  325. line-height:80rpx;
  326. }
  327. .submit-button-p{
  328. background-color:#0183FA;
  329. color:#fff;
  330. width:400rpx;
  331. height:80rpx;
  332. line-height:80rpx;
  333. text-align: center;
  334. font-size:30rpx;
  335. margin:20rpx 175rpx;
  336. border-radius:10rpx;
  337. }
  338. .submit-button-p-2{
  339. background-color:#999;
  340. color:#fff;
  341. width:500rpx;
  342. height:80rpx;
  343. line-height:80rpx;
  344. text-align: center;
  345. font-size:30rpx;
  346. margin:20rpx 125rpx;
  347. border-radius:10rpx;
  348. }
  349. .pageTwo {
  350. flex: 1;
  351. display flex;
  352. flex-direction column;
  353. overflow-y hidden;
  354. position: absolute;
  355. height: 100%;
  356. z-index: 100;
  357. background-color: #fff;
  358. .pageTwo-input-box {
  359. display flex;
  360. padding: 20rpx 25rpx;
  361. background #fff;
  362. margin-bottom: 20rpx;
  363. input {
  364. padding: 0 20rpx;
  365. width: 460rpx;
  366. line-height: 80rpx;
  367. height: 80rpx;
  368. border-top: 1rpx solid #a2a2a2;
  369. border-left: 1rpx solid #a2a2a2;
  370. border-bottom: 1rpx solid #a2a2a2;
  371. border-bottom-left-radius: 10rpx;
  372. border-top-left-radius: 10rpx;
  373. }
  374. view {
  375. width: 200rpx;
  376. line-height: 80rpx;
  377. height: 80rpx;
  378. border: 1rpx solid #007AFF;
  379. color: #fff;
  380. background #007AFF;
  381. text-align center;
  382. border-top-right-radius: 10rpx;
  383. border-bottom-right-radius: 10rpx;
  384. }
  385. }
  386. .for-max-box {
  387. background #fff;
  388. flex: 1;
  389. overflow-y scroll;
  390. .for-box:nth-child(1) {
  391. border: none;
  392. }
  393. .for-null-text {
  394. text-align center;
  395. line-height: 100rpx;
  396. color: #999;
  397. }
  398. .for-box {
  399. border-top: 1rpx solid #dedede;
  400. display: flex;
  401. .button-text-view {
  402. padding: 35rpx 35rpx 35rpx 20rpx;
  403. width:560rpx;
  404. }
  405. .button-big-view {
  406. padding: 20rpx 0 20rpx 0 ;
  407. width: 100rpx;
  408. display: flex;
  409. flex-direction: column;
  410. .button-null-view{
  411. flex:1;
  412. }
  413. .button-view{
  414. line-height:60rpx;
  415. width: 100rpx;
  416. text-align center;
  417. border-radius: 10rpx;
  418. background #007AFF;
  419. color: #fff;
  420. }
  421. }
  422. }
  423. }
  424. .out-button {
  425. width: 650rpx;
  426. height: 100rpx;
  427. line-height: 100rpx;
  428. margin: 20rpx 50rpx;
  429. text-align center;
  430. font-size: 32rpx;
  431. color: #fff;
  432. background #999;
  433. border-radius: 20rpx;
  434. }
  435. }
  436. }
  437. </style>