add.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="check">
  3. <uni-forms ref="form" :model="datainfo">
  4. <view class="cbox">
  5. <view class="chmain">
  6. <uni-forms-item label="类型" name="blackType">
  7. <picker range-key='dictLabel' :disabled="isdisabled" :value="hmdlxidx" :range="hmdlxList" @change='bindDateChange'>
  8. <view class="flexc">
  9. <view class="flex1 txr f13 co27" v-if="datainfo.blackType&&!hmdlx">{{statusFormats(datainfo.blackType,hmdlxList,'hmdlx')}}</view>
  10. <view class="flex1 txr f13" v-else :class="hmdlx?'co27':'coa'">{{hmdlx||"请选择类型"}}</view>
  11. <view class="rimg"><image :src="rimg"></image></view>
  12. </view>
  13. </picker>
  14. </uni-forms-item>
  15. <uni-forms-item label="阈值" name="blackNum">
  16. <view class="flexc">
  17. <uni-easyinput :disabled="isdisabled" v-model="datainfo.blackNum" :inputBorder='false' placeholder="请输入阈值" />
  18. <view class="rimg"></view>
  19. </view>
  20. </uni-forms-item>
  21. <uni-forms-item label="说明" name="blackTitle">
  22. <view class="flexc">
  23. <uni-easyinput :disabled="isdisabled" v-model="datainfo.blackTitle" :inputBorder='false' placeholder="请输入说明" />
  24. <view class="rimg"></view>
  25. </view>
  26. </uni-forms-item>
  27. <uni-forms-item label="是否启用" name="isDel">
  28. <view class="flexc" @click="getChangeFn">
  29. <view class="flex1"></view>
  30. <image :src="check" v-if="datainfo.isDel=='Y'" class="checkimg"></image>
  31. <image :src="ncheck" v-else class="checkimg"></image>
  32. </view>
  33. </uni-forms-item>
  34. </view>
  35. </view>
  36. </uni-forms>
  37. <view class="rfbtn" @click="getEditFn" v-if="isdisabled">修改</view>
  38. <view class="rfbtn" @click="getSubmit" v-else>发布</view>
  39. <loading></loading>
  40. </view>
  41. </template>
  42. <script>
  43. import config from '@/config'
  44. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  45. import {getDictionaryFn} from "@/api/system/user.js"
  46. import {selectValueKey} from "@/utils/common.js"
  47. import {blackManageAdd,blackManagePut,blackManageDet} from "@/api/work/manage.js"
  48. export default {
  49. components: {},
  50. data() {
  51. return {
  52. rimg: require('@/people/static/people/rimg.png'),
  53. baseUrl: config.baseUrl,
  54. checkflag:true,
  55. check: require('@/people/static/people/check.png'),
  56. ncheck: require('@/people/static/people/ncheck.png'),
  57. datainfo: {
  58. "blackType":"",//黑名单类型
  59. "blackTitle":"",//黑名单说明
  60. "blackNum":"",//黑名单的阈值
  61. "isDel":"Y",//黑名单是否启用
  62. },
  63. hmdlx:'',
  64. hmdlxidx:[],
  65. sfztList:[{dictLabel:'启用',dictValue:'Y'},{dictLabel:'禁用',dictValue:'N'}],
  66. id:'',
  67. ptype:"add",
  68. isdisabled:false,
  69. hmdlxList:[]
  70. }
  71. },
  72. onLoad: function(e) {
  73. this.init()
  74. if(e.id){
  75. this.id=e.id;
  76. this.ptype='edit';
  77. this.isdisabled=true;
  78. this.getDetailFn()
  79. }
  80. },
  81. methods: {
  82. checkPermi,
  83. checkRole,
  84. getEditFn(){
  85. this.isdisabled=false;
  86. },
  87. statusFormats(data, list,type) {
  88. var aite=selectValueKey(list, data);
  89. if(type=='hmdlx'){
  90. this.hmdlxidx=aite.key
  91. }
  92. return aite.actions;
  93. },
  94. bindDateChange(e){
  95. var val=e.detail.value;
  96. this.datainfo.blackType=this.hmdlxList[val].dictValue;
  97. this.hmdlx=this.hmdlxList[val].dictLabel;
  98. },
  99. getChangeFn(){
  100. if(this.isdisabled){
  101. return
  102. }
  103. if(this.datainfo.isDel=='Y'){
  104. this.datainfo.isDel='N'
  105. }else{
  106. this.datainfo.isDel='Y'
  107. }
  108. },
  109. init(){
  110. // 黑名单类型
  111. getDictionaryFn('heimindtype').then(res=>{
  112. if(res.code==200){
  113. if(res.data){
  114. this.hmdlxList = res.data.map(v => {
  115. return {
  116. dictLabel: v.dictLabel,
  117. dictValue: v.dictValue
  118. }
  119. })
  120. }
  121. }
  122. })
  123. },
  124. getDetailFn(){
  125. var that=this;
  126. blackManageDet(this.id).then(res=>{
  127. if(res.code==200){
  128. this.datainfo=res.data;
  129. }
  130. })
  131. },
  132. getSubmit(){
  133. var that=this;
  134. this.$refs.form.validate().then(res => {
  135. var params=JSON.parse(JSON.stringify(this.datainfo))
  136. if(!params.blackType){
  137. this.$toast('请选择类型')
  138. return
  139. }
  140. if(!params.blackNum){
  141. this.$toast('请输入阈值')
  142. return
  143. }
  144. if(this.ptype=='add'){
  145. blackManageAdd(params).then(res=>{
  146. if(res.code==200){
  147. this.$toast("新增成功")
  148. setTimeout(function(){
  149. uni.$emit("refblackList")
  150. uni.navigateBack({
  151. delta:1
  152. })
  153. },1500)
  154. }
  155. })
  156. }else{
  157. blackManagePut(params).then(res=>{
  158. if(res.code==200){
  159. this.$toast("修改成功")
  160. setTimeout(function(){
  161. uni.$emit("refblackList")
  162. uni.navigateBack({
  163. delta:1
  164. })
  165. },1500)
  166. }
  167. })
  168. }
  169. })
  170. },
  171. }
  172. }
  173. </script>
  174. <style>
  175. page{background: #F3F3F0;}
  176. </style>
  177. <style lang="scss" scoped>
  178. .check /deep/ .uni-date-editor--x__disabled{opacity: 1;}
  179. .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;}
  180. .check /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
  181. .check /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 26rpx;color: #222327;}
  182. .check /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 26rpx;}
  183. .check /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
  184. .check /deep/ .uni-input-input{font-size: 26rpx;}
  185. .check /deep/ .uni-textarea-textarea{font-size: 26rpx;}
  186. .check /deep/ .uni-forms-item__label text{width: 110rpx;text-align-last: justify;}
  187. .check /deep/ .uni-forms-item__label .is-required{width: auto;}
  188. .check /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  189. .check{min-height: 100vh;padding: 20rpx 18rpx 110rpx;box-sizing: border-box;}
  190. .cbox{background: #FFFFFF;border-radius: 20rpx;flex: 1;margin-bottom: 24rpx;
  191. .chmain{
  192. padding: 0 32rpx;
  193. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  194. image{width: 100%;height: 100%;}
  195. }
  196. .checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
  197. }
  198. }
  199. </style>