limitdetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view :style="'padding-top:'+nvaHeight+'px;'">
  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">
  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.nickName,
  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. }
  130. })
  131. },
  132. onShow() {},
  133. methods: {
  134. checkPermi,
  135. checkRole,
  136. getBack() {
  137. uni.navigateBack({
  138. delta: 1
  139. })
  140. },
  141. statusFormat(ite,list,type) {
  142. var aite=selectValueKey(list, ite);
  143. this.qyidx=aite.key
  144. return aite.actions;
  145. },
  146. statusFormats(ite,list,type){//多选匹配
  147. if(ite&&list&&list.length){
  148. var actions = [];
  149. var newArr=[];
  150. list.forEach(s => {
  151. if(ite.indexOf(s.value)>-1){
  152. actions.push(s.label);
  153. // var obj={
  154. // deptId:s.value,
  155. // deptName:s.label
  156. // }
  157. newArr.push(s.value)
  158. }
  159. })
  160. this.selectedData=newArr
  161. return actions.join(',')
  162. }else{
  163. return ''
  164. }
  165. },
  166. init() {
  167. // 门禁
  168. getDictionaryFn('menj').then(res=>{
  169. if(res.code==200){
  170. this.mjlist = res.data.map(v => {
  171. return {
  172. label: v.dictLabel,
  173. value: v.dictValue
  174. }
  175. })
  176. }
  177. })
  178. getDeptFn().then(res=>{
  179. if(res.code==200){
  180. this.depTree=res.data
  181. }
  182. })
  183. },
  184. getRecorddwFn(){
  185. this.$refs.treePickerzrdw._show();
  186. },
  187. getRecordbmFn(){
  188. this.$refs.treePickerbm._show();
  189. },
  190. selectChangezrdw(e){
  191. var val=e;
  192. var newArr=[],newVal=[];
  193. var a=0;
  194. e.forEach((ite,idx)=>{
  195. newArr[idx]=ite.deptName
  196. newVal[idx]=ite.deptId
  197. })
  198. this.mjtxt=newArr.join(',')
  199. this.datainfo.guard=newVal.join(',');
  200. },
  201. selectChangebm(e){
  202. var val=e;
  203. this.datainfo.deptId=e[0].deptId
  204. this.datainfo.deptName=e[0].deptName
  205. },
  206. getSubmit() {
  207. var that=this;
  208. var params = JSON.parse(JSON.stringify(this.datainfo))
  209. if(!params.personneName){
  210. this.$toast("请输入人员姓名")
  211. return
  212. }
  213. if(!params.personnePhone){
  214. this.$toast("请输入联系方式")
  215. return
  216. }
  217. if(!this.mjtxt){
  218. this.$toast("请选择门禁权限")
  219. return
  220. }
  221. if(!params.deptName){
  222. this.$toast("请选择部门")
  223. return
  224. }
  225. let regphone = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/
  226. if (params.personnePhone && !regphone.test(params.personnePhone)) {
  227. that.$toast("请输入正确的手机号")
  228. return
  229. }
  230. uni.showLoading({
  231. title:"加载中"
  232. })
  233. if(this.ptype=='add'){
  234. getManagementAdd(params).then(res => {
  235. uni.hideLoading()
  236. if (res.code == 200) {
  237. this.$toast("新增成功")
  238. setTimeout(function(){
  239. uni.$emit('refreshlimitlist')
  240. uni.navigateBack({
  241. delta:1
  242. })
  243. },1200)
  244. } else {
  245. this.$toast(res.msg)
  246. }
  247. })
  248. }else{
  249. getManagementPut(params).then(res => {
  250. uni.hideLoading()
  251. if (res.code == 200) {
  252. this.$toast("修改成功")
  253. setTimeout(function(){
  254. uni.$emit('refreshlimitlist')
  255. uni.navigateBack({
  256. delta:1
  257. })
  258. },1200)
  259. } else {
  260. this.$toast(res.msg)
  261. }
  262. })
  263. }
  264. },
  265. getDetail(){
  266. getManagementDetail(this.id).then(res=>{
  267. if(res.code==200){
  268. this.datainfo=JSON.parse(JSON.stringify(res.data))
  269. this.mjtxt=this.statusFormats(res.data.guard,this.mjlist)
  270. var deptId=res.data.deptId;
  271. var newArr=[];
  272. newArr.push(deptId)
  273. this.selectedDatabm=newArr
  274. }
  275. })
  276. }
  277. },
  278. }
  279. </script>
  280. <style>
  281. /* page {
  282. background: #ffffff;
  283. } */
  284. </style>
  285. <style lang="scss" scoped>
  286. .ytbox /deep/ .uni-forms .uni-forms-item{padding: 10rpx 26rpx 10rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
  287. .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;}
  288. .ytbox /deep/ .uni-forms-item__label text{flex: 1;}
  289. .ytbox /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
  290. .ytbox /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
  291. .ytbox /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  292. .ytbox /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #AAAAAA;}
  293. .ytbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  294. .ytbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
  295. .ytbox /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  296. .ytbox /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  297. .ytbox /deep/ .checklist-group{justify-content: end;}
  298. .disable{background: #EFF0F2;border: none !important;}
  299. .ytbox{width: 684rpx;margin: 0 auto;padding-top: 24rpx;position: relative;flex: 1;overflow: auto;background-color: #ffffff;padding-bottom: 4rpx;border-radius: 14rpx;}
  300. .ytforms{
  301. .yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 56rpx;
  302. color: #161616;display: flex;align-items: center;padding: 0rpx 26rpx;box-sizing: border-box;position: relative;
  303. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 0rpx;}
  304. }
  305. .ytsbox{background-color: #ffffff;padding: 32rpx 28rpx 0;border-radius: 14rpx;margin-bottom: 24rpx;
  306. .intit{font-weight: 500;flex: 1;font-size: 26rpx;text-align: right;color: #666666;}
  307. .pickbox{flex: 1;text-align: right;font-weight: 500;font-size: 28rpx;color: #161616;
  308. .hupimg{width: 18rpx;height: 14rpx;margin-left: 12rpx;flex: 0 0 auto;}
  309. }
  310. }
  311. }
  312. // 按钮
  313. .ybtn{width: 100%;height: 90rpx;background: $com-cd3;border-radius: 14rpx;margin: 100rpx auto 0;font-size: 28rpx;font-weight: 500;color: #FFFFFF;
  314. &.btn1{background-color: #9a9c9e;}
  315. }
  316. .tips{font-weight: bold;margin-top: 28rpx;
  317. font-size: 22rpx;line-height: 34rpx;
  318. color: #FF0000;}
  319. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  320. .navbg{width: 100%;height: 692rpx;}
  321. .zxmain{position: relative;padding: 20rpx 32rpx 40rpx;box-sizing: border-box;display: flex;
  322. min-height: calc(100vh - 44px);
  323. }
  324. </style>