123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <template>
- <view class="check">
- <uni-forms ref="form" :model="datainfo">
- <view class="cbox">
- <view class="chmain">
- <uni-forms-item label="类型" name="blackType">
- <picker range-key='dictLabel' :disabled="isdisabled" :value="hmdlxidx" :range="hmdlxList" @change='bindDateChange'>
- <view class="flexc">
- <view class="flex1 txr f13 co27" v-if="datainfo.blackType&&!hmdlx">{{statusFormats(datainfo.blackType,hmdlxList,'hmdlx')}}</view>
- <view class="flex1 txr f13" v-else :class="hmdlx?'co27':'coa'">{{hmdlx||"请选择类型"}}</view>
- <view class="rimg"><image :src="rimg"></image></view>
- </view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="阈值" name="blackNum">
- <view class="flexc">
- <uni-easyinput :disabled="isdisabled" v-model="datainfo.blackNum" :inputBorder='false' placeholder="请输入阈值" />
- <view class="rimg"></view>
- </view>
- </uni-forms-item>
- <uni-forms-item label="说明" name="blackTitle">
- <view class="flexc">
- <uni-easyinput :disabled="isdisabled" v-model="datainfo.blackTitle" :inputBorder='false' placeholder="请输入说明" />
- <view class="rimg"></view>
- </view>
- </uni-forms-item>
- <uni-forms-item label="是否启用" name="isDel">
- <view class="flexc" @click="getChangeFn">
- <view class="flex1"></view>
- <image :src="check" v-if="datainfo.isDel=='Y'" class="checkimg"></image>
- <image :src="ncheck" v-else class="checkimg"></image>
- </view>
- </uni-forms-item>
- </view>
- </view>
- </uni-forms>
- <view class="rfbtn" @click="getEditFn" v-if="isdisabled">修改</view>
- <view class="rfbtn" @click="getSubmit" v-else>发布</view>
- <loading></loading>
- </view>
- </template>
- <script>
- import config from '@/config'
- import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
- import {getDictionaryFn} from "@/api/system/user.js"
- import {selectValueKey} from "@/utils/common.js"
- import {blackManageAdd,blackManagePut,blackManageDet} from "@/api/work/manage.js"
- export default {
- components: {},
- data() {
- return {
- rimg: require('@/people/static/people/rimg.png'),
- baseUrl: config.baseUrl,
- checkflag:true,
- check: require('@/people/static/people/check.png'),
- ncheck: require('@/people/static/people/ncheck.png'),
- datainfo: {
- "blackType":"",//黑名单类型
- "blackTitle":"",//黑名单说明
- "blackNum":"",//黑名单的阈值
- "isDel":"Y",//黑名单是否启用
- },
- hmdlx:'',
- hmdlxidx:[],
- sfztList:[{dictLabel:'启用',dictValue:'Y'},{dictLabel:'禁用',dictValue:'N'}],
- id:'',
- ptype:"add",
- isdisabled:false,
- hmdlxList:[]
- }
- },
- onLoad: function(e) {
- this.init()
- if(e.id){
- this.id=e.id;
- this.ptype='edit';
- this.isdisabled=true;
- this.getDetailFn()
- }
- },
- methods: {
- checkPermi,
- checkRole,
- getEditFn(){
- this.isdisabled=false;
- },
- statusFormats(data, list,type) {
- var aite=selectValueKey(list, data);
- if(type=='hmdlx'){
- this.hmdlxidx=aite.key
- }
- return aite.actions;
- },
- bindDateChange(e){
- var val=e.detail.value;
- this.datainfo.blackType=this.hmdlxList[val].dictValue;
- this.hmdlx=this.hmdlxList[val].dictLabel;
- },
- getChangeFn(){
- if(this.isdisabled){
- return
- }
- if(this.datainfo.isDel=='Y'){
- this.datainfo.isDel='N'
- }else{
- this.datainfo.isDel='Y'
- }
- },
- init(){
- // 黑名单类型
- getDictionaryFn('heimindtype').then(res=>{
- if(res.code==200){
- if(res.data){
- this.hmdlxList = res.data.map(v => {
- return {
- dictLabel: v.dictLabel,
- dictValue: v.dictValue
- }
- })
- }
- }
- })
- },
- getDetailFn(){
- var that=this;
- blackManageDet(this.id).then(res=>{
- if(res.code==200){
- this.datainfo=res.data;
- }
- })
- },
- getSubmit(){
- var that=this;
- this.$refs.form.validate().then(res => {
- var params=JSON.parse(JSON.stringify(this.datainfo))
- if(!params.blackType){
- this.$toast('请选择类型')
- return
- }
- if(!params.blackNum){
- this.$toast('请输入阈值')
- return
- }
- if(this.ptype=='add'){
- blackManageAdd(params).then(res=>{
- if(res.code==200){
- this.$toast("新增成功")
- setTimeout(function(){
- uni.$emit("refblackList")
- uni.navigateBack({
- delta:1
- })
- },1500)
- }
- })
- }else{
- blackManagePut(params).then(res=>{
- if(res.code==200){
- this.$toast("修改成功")
- setTimeout(function(){
- uni.$emit("refblackList")
- uni.navigateBack({
- delta:1
- })
- },1500)
- }
- })
- }
-
- })
- },
-
- }
- }
- </script>
- <style>
- page{background: #F3F3F0;}
- </style>
- <style lang="scss" scoped>
- .check /deep/ .uni-date-editor--x__disabled{opacity: 1;}
- .check /deep/ .uni-forms-item{min-height: 106rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;border-bottom: 2rpx solid #E6E6E6;padding:10rpx 0;}
- .check /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
- .check /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 26rpx;color: #222327;}
- .check /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 26rpx;}
- .check /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
- .check /deep/ .uni-input-input{font-size: 26rpx;}
- .check /deep/ .uni-textarea-textarea{font-size: 26rpx;}
- .check /deep/ .uni-forms-item__label text{width: 110rpx;text-align-last: justify;}
- .check /deep/ .uni-forms-item__label .is-required{width: auto;}
- .check /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
- .check{min-height: 100vh;padding: 20rpx 18rpx 110rpx;box-sizing: border-box;}
- .cbox{background: #FFFFFF;border-radius: 20rpx;flex: 1;margin-bottom: 24rpx;
- .chmain{
- padding: 0 32rpx;
- .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
- image{width: 100%;height: 100%;}
- }
- .checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
- }
-
- }
- </style>
|