limitdetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view>
  3. <view class="navbox">
  4. <uni-nav-bar color="#ffffff" left-icon="left" title="人员权限" :background-color="backgroundColor"
  5. :border="false" statusBar='true' fixed="true" @clickLeft='getBack'>
  6. </uni-nav-bar>
  7. </view>
  8. <image :src="navbg" class="navbg"></image>
  9. <view class="zxmain" :style="'margin-top:-'+marTop+'rpx;'">
  10. <view class="ytbox">
  11. <uni-forms ref="form" class="ytforms" :modelValue="datainfo">
  12. <view class="ytsbox">
  13. <view class="yttit">人员信息</view>
  14. <view class="pt5">
  15. <uni-forms-item label="姓名" name="personneName">
  16. <uni-easyinput :inputBorder="false" v-model="datainfo.personneName" placeholder="请输入姓名">
  17. </uni-easyinput>
  18. </uni-forms-item>
  19. <uni-forms-item label="联系方式" name="personnePhone">
  20. <uni-easyinput :inputBorder="false" v-model="datainfo.personnePhone" placeholder="请输入联系方式">
  21. </uni-easyinput>
  22. </uni-forms-item>
  23. <uni-forms-item label="门禁权限" name="guard">
  24. <view class="pickbox" @click="getRecorddwFn">
  25. <view class="flexc flex1">
  26. <view class="flex1 f14" v-if="datainfo.guard&&!mjtxt">{{}}</view>
  27. <view class="flex1 f14" v-else :class="mjtxt?'':'coa'">{{mjtxt||"请选择门禁"}}</view>
  28. <image :src="hupimg" class="hupimg"></image>
  29. </view>
  30. </view>
  31. </uni-forms-item>
  32. <uni-forms-item label="是否启用" name="isEnable">
  33. <view class="pickbox">
  34. <view class="flexc flex1" >
  35. <uni-data-checkbox :selectedColor="actcolor" selectedTextColor='#222327' v-model="datainfo.isEnable" :localdata="qylist" />
  36. </view>
  37. </view>
  38. </uni-forms-item>
  39. <uni-forms-item label="部门" name="deptName">
  40. <view class="pickbox" @click="getRecordbmFn">
  41. <view class="flexc flex1">
  42. <view class="flex1 f14" :class="datainfo.deptName?'':'coa'">{{datainfo.deptName||"请选择部门"}}</view>
  43. <image :src="hupimg" class="hupimg"></image>
  44. </view>
  45. </view>
  46. </uni-forms-item>
  47. </view>
  48. <view class="ybtn flexcc" @click="getSubmit">确认提交</view>
  49. <view class="tips"></view>
  50. </view>
  51. </uni-forms>
  52. </view>
  53. </view>
  54. <!-- 选择门禁类型 -->
  55. <bartree-pickerfixed ref="treePickerzrdw" deptType='1' :multiple='true' @select-change="selectChangezrdw" title="选择门禁"
  56. :localdata="mjlist" :selectedData="selectedData" :checkVal='datainfo.guard' valueKey="value" textKey="label" childrenKey="children"></bartree-pickerfixed>
  57. <!-- 选择部门 -->
  58. <bartree-pickerfixed ref="treePickerbm" deptType='1' :multiple='false' @select-change="selectChangebm" title="选择部门"
  59. :localdata="depTree" :selectedData="selectedDatabm" :checkVal='datainfo.deptName' valueKey="id" textKey="label" childrenKey="children"></bartree-pickerfixed>
  60. </view>
  61. </template>
  62. <script>
  63. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  64. import {getManagementAdd,getManagementPut,getManagementDetail} from "@/api/mine/work.js"
  65. import {getDictionaryFn} from "@/api/mine/register.js"
  66. import {selectValueKey} from "@/utils/common.js"
  67. import {getDeptFn} from "@/api/mine/mine.js"
  68. import bartreePickerfixed from "@/work/components/ba-tree-picker/ba-tree-pickerfixed.vue"
  69. export default {
  70. components: {bartreePickerfixed},
  71. data() {
  72. return {
  73. hupimg:require("@/static/images/order/hup.png"),
  74. navbg:require("@/static/images/navbg.png"),
  75. backgroundColor: "transparent",
  76. nvaHeight: 44,
  77. marTop: 0, //距离顶部的距离
  78. stubarHeight: 0, //
  79. datainfo:{
  80. "personneId":"",//ID
  81. "personneName":"",//人员姓名
  82. "personnePhone":"",//人员手机号
  83. "deptId":"",//部门id
  84. "deptName":"",//部门名称
  85. "humanFaceData":"",//人脸数据
  86. "guard":"",//门禁
  87. "isEnable":"0"//是否启用 0:是,1:否
  88. },
  89. mjtxt:'',
  90. qylist:[{text:'是',value:'0'},{text:'否',value:'1'}],
  91. selectedData:[],
  92. selectedDatabm:[],
  93. actcolor:'#00A9F0',
  94. qyidx:[],
  95. sfqy:'',
  96. mjlist:[],
  97. depTree:[],
  98. ptype:'add',
  99. id:'',
  100. // name:this.$store.state.user.name,
  101. // userId:this.$store.state.user.userId,
  102. // deptId:this.$store.state.user.deptId,
  103. // deptName:this.$store.state.user.deptName,
  104. }
  105. },
  106. onPageScroll(e) {
  107. var scrollTop = Number(e.scrollTop);
  108. if (scrollTop > 0) {
  109. this.backgroundColor = '#0491FD'
  110. } else {
  111. this.backgroundColor = 'transparent'
  112. }
  113. },
  114. onLoad: function(e) {
  115. this.init()
  116. if(e.data){
  117. var data=JSON.parse(decodeURIComponent(e.data))
  118. if(data.type){
  119. this.ptype=data.type;
  120. this.id=data.id;
  121. this.getDetail()
  122. }
  123. }
  124. // this.getDataFn()
  125. uni.getSystemInfo({
  126. success: (e) => {
  127. this.stubarHeight = Number(e.statusBarHeight);
  128. this.nvaHeight = Number(e.statusBarHeight) + 44;
  129. this.tabscheight = Number(this.nvaHeight) * 2 + 100;
  130. }
  131. })
  132. },
  133. onShow() {},
  134. mounted() {
  135. this.getHeightFn()
  136. },
  137. methods: {
  138. checkPermi,
  139. checkRole,
  140. getBack() {
  141. uni.navigateBack({
  142. delta: 1
  143. })
  144. },
  145. statusFormat(ite,list,type) {
  146. var aite=selectValueKey(list, ite);
  147. this.qyidx=aite.key
  148. return aite.actions;
  149. },
  150. statusFormats(ite,list,type){//多选匹配
  151. if(ite&&list&&list.length){
  152. var actions = [];
  153. var newArr=[];
  154. list.forEach(s => {
  155. if(ite.indexOf(s.value)>-1){
  156. actions.push(s.label);
  157. // var obj={
  158. // deptId:s.value,
  159. // deptName:s.label
  160. // }
  161. newArr.push(s.value)
  162. }
  163. })
  164. this.selectedData=newArr
  165. return actions.join(',')
  166. }else{
  167. return ''
  168. }
  169. },
  170. init() {
  171. // 门禁
  172. getDictionaryFn('menj').then(res=>{
  173. if(res.code==200){
  174. this.mjlist = res.data.map(v => {
  175. return {
  176. label: v.dictLabel,
  177. value: v.dictValue
  178. }
  179. })
  180. }
  181. })
  182. getDeptFn().then(res=>{
  183. if(res.code==200){
  184. this.depTree=res.data
  185. }
  186. })
  187. },
  188. getRecorddwFn(){
  189. this.$refs.treePickerzrdw._show();
  190. },
  191. getRecordbmFn(){
  192. this.$refs.treePickerbm._show();
  193. },
  194. selectChangezrdw(e){
  195. var val=e;
  196. var newArr=[],newVal=[];
  197. var a=0;
  198. e.forEach((ite,idx)=>{
  199. newArr[idx]=ite.deptName
  200. newVal[idx]=ite.deptId
  201. })
  202. this.mjtxt=newArr.join(',')
  203. this.datainfo.guard=newVal.join(',');
  204. },
  205. selectChangebm(e){
  206. var val=e;
  207. this.datainfo.deptId=e[0].deptId
  208. this.datainfo.deptName=e[0].deptName
  209. },
  210. getHeightFn() {
  211. let query = uni.createSelectorQuery().in(this);
  212. //需要给黄色区域设置一个id标识,在这里是demo
  213. query.select('.navbox').boundingClientRect(data => {
  214. var top = data.top < 0 ? -data.top : data.top;
  215. var stubarHeight = Number(this.stubarHeight);
  216. this.marTop = stubarHeight > 0 ? 692 - Number(data.height) * 2 : 692 - Number(data.height) *
  217. 2 + 40 //赋值,待会要用
  218. if (top <= this.nvaHeight) {
  219. const opacity = top / 100 // 计算透明度值
  220. const color = `rgba(4, 145, 253, ${opacity})`
  221. this.backgroundColor = color // 更新盒子背景颜色
  222. } else {
  223. this.backgroundColor = '#00A9F0'
  224. }
  225. }).exec();
  226. },
  227. getSubmit() {
  228. var that=this;
  229. var params = JSON.parse(JSON.stringify(this.datainfo))
  230. if(!params.personneName){
  231. this.$toast("请输入人员姓名")
  232. return
  233. }
  234. if(!params.personnePhone){
  235. this.$toast("请输入联系方式")
  236. return
  237. }
  238. if(!this.mjtxt){
  239. this.$toast("请选择门禁权限")
  240. return
  241. }
  242. if(!params.deptName){
  243. this.$toast("请选择部门")
  244. return
  245. }
  246. let regphone = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/
  247. if (params.personnePhone && !regphone.test(params.personnePhone)) {
  248. that.$toast("请输入正确的手机号")
  249. return
  250. }
  251. uni.showLoading({
  252. title:"加载中"
  253. })
  254. if(this.ptype=='add'){
  255. getManagementAdd(params).then(res => {
  256. uni.hideLoading()
  257. if (res.code == 200) {
  258. this.$toast("新增成功")
  259. setTimeout(function(){
  260. uni.$emit('refreshlimitlist')
  261. uni.navigateBack({
  262. delta:1
  263. })
  264. },1200)
  265. } else {
  266. this.$toast(res.msg)
  267. }
  268. })
  269. }else{
  270. getManagementPut(params).then(res => {
  271. uni.hideLoading()
  272. if (res.code == 200) {
  273. this.$toast("修改成功")
  274. setTimeout(function(){
  275. uni.$emit('refreshlimitlist')
  276. uni.navigateBack({
  277. delta:1
  278. })
  279. },1200)
  280. } else {
  281. this.$toast(res.msg)
  282. }
  283. })
  284. }
  285. },
  286. getDetail(){
  287. getManagementDetail(this.id).then(res=>{
  288. if(res.code==200){
  289. this.datainfo=JSON.parse(JSON.stringify(res.data))
  290. this.mjtxt=this.statusFormats(res.data.guard,this.mjlist)
  291. var deptId=res.data.deptId;
  292. var newArr=[];
  293. newArr.push(deptId)
  294. this.selectedDatabm=newArr
  295. }
  296. })
  297. }
  298. },
  299. }
  300. </script>
  301. <style>
  302. /* page {
  303. background: #ffffff;
  304. } */
  305. </style>
  306. <style lang="scss" scoped>
  307. .ytbox /deep/ .uni-forms .uni-forms-item{padding: 10rpx 26rpx 10rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
  308. .ytbox /deep/ .uni-forms-item__label{flex: 0 0 auto;width: 144rpx !important;font-size: 28rpx;font-weight: bold;position: relative;color: #161616;text-align-last: justify;}
  309. .ytbox /deep/ .uni-forms-item__label text{flex: 1;}
  310. .ytbox /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
  311. .ytbox /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
  312. .ytbox /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  313. .ytbox /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #AAAAAA;}
  314. .ytbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  315. .ytbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
  316. .ytbox /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  317. .ytbox /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  318. .ytbox /deep/ .checklist-group{justify-content: end;}
  319. .disable{background: #EFF0F2;border: none !important;}
  320. .ytbox{width: 684rpx;margin: 0 auto;padding-top: 24rpx;position: relative;flex: 1;overflow: auto;background-color: #ffffff;padding-bottom: 4rpx;border-radius: 14rpx;}
  321. .ytforms{
  322. .yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 56rpx;
  323. color: #161616;display: flex;align-items: center;padding: 0rpx 26rpx;box-sizing: border-box;position: relative;
  324. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 0rpx;}
  325. }
  326. .ytsbox{background-color: #ffffff;padding: 32rpx 28rpx 0;border-radius: 14rpx;margin-bottom: 24rpx;
  327. .intit{font-weight: 500;flex: 1;font-size: 26rpx;text-align: right;color: #666666;}
  328. .pickbox{flex: 1;text-align: right;font-weight: 500;font-size: 28rpx;color: #161616;
  329. .hupimg{width: 18rpx;height: 14rpx;margin-left: 12rpx;flex: 0 0 auto;}
  330. }
  331. }
  332. }
  333. // 按钮
  334. .ybtn{width: 100%;height: 90rpx;background: $com-cd3;border-radius: 14rpx;margin: 100rpx auto 0;font-size: 28rpx;font-weight: 500;color: #FFFFFF;
  335. &.btn1{background-color: #9a9c9e;}
  336. }
  337. .tips{font-weight: bold;margin-top: 28rpx;
  338. font-size: 22rpx;line-height: 34rpx;
  339. color: #FF0000;}
  340. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  341. .navbg{width: 100%;height: 692rpx;}
  342. .zxmain{position: relative;padding: 20rpx 32rpx 40rpx;box-sizing: border-box;display: flex;
  343. min-height: calc(100vh - 44px);
  344. }
  345. </style>