drawee.vue 2.75 KB
Newer Older
1 2 3 4 5 6 7
<script setup>
import UniPopup from "@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue";

export default {
  props:{
    value:{
      type:Array,
dragondean@qq.com's avatar
dragondean@qq.com committed
8
      default: () => []
dragondean@qq.com's avatar
dragondean@qq.com committed
9 10 11 12
    },
    readonly:{
      type:Boolean,
      default:false
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    }
  },
  data(){
    return {
      customDraweeList:[]
    }
  },
  onMounted() {
    console.log('drawee')
  },
  methods: {
    open(){
      this.$refs.popup.open()
      if(!this.customDraweeList.length){
        this.loadDictData()
      }
    },
    loadDictData() {
      this.$request.getConfig('custom_drawee').then(res => {
        if(res.code==0&&res.data&&res.data.list.length>0){
          res.data.list.forEach(item => {
            const old = this.value ? this.value.find(it => it.name == item.value) : null
            this.customDraweeList.push({
              name: item.value,
Smile's avatar
Smile committed
37
              label: item[this.$lang.label],
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
              value:  old ? old.value : 1
            })
          })
        }
      })
    },
    changeDrawee(field, e){
      const index = this.customDraweeList.findIndex(item => item.name == field)
      if(index < 0) return
      this.customDraweeList[index].value = e.detail.value
    },
    submit(){
      this.$refs.popup.close()
      this.$emit("confirm", this.customDraweeList)
    },
    close(){
      this.$refs.popup.close()
    },
  }
}
</script>

<template>
  <uni-popup ref="popup" type="center" :mask-click="false">
    <view class="content">
      <view v-for="item in customDraweeList" :key="item.id" class="flex item">
        <view class="name">{{item.label}}</view>
        <radio-group @change="changeDrawee(item.name, $event)" class="flex">
          <label class="flex">
            <view class="checkbox-item">
dragondean@qq.com's avatar
dragondean@qq.com committed
68
              <radio value="1" :checked="item.value == 1" :disabled="readonly" style="transform:scale(0.8)"/>
69 70 71 72 73
            </view>
            <view>{{$lang.lang.create.consignee}}</view>
          </label>
          <label class="flex">
            <view class="checkbox-item">
dragondean@qq.com's avatar
dragondean@qq.com committed
74
              <radio value="2" :checked="item.value == 2" :disabled="readonly" style="transform:scale(0.8)"/>
75 76 77 78 79
            </view>
            <view>{{$lang.lang.create.consignor}}</view>
          </label>
        </radio-group>
      </view>
dragondean@qq.com's avatar
dragondean@qq.com committed
80 81 82
      <view class="flex action">
        <button @click="close">{{readonly ? $lang.lang.order.confirm : $lang.lang.create.cancel}}</button>
        <button @click="submit" type="primary" v-if="!readonly">{{$lang.lang.create.submit}}</button>
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
      </view>
    </view>
  </uni-popup>
</template>
<style scoped lang="scss">
.content{
  width: 80vw;
  background-color: #fff;
  padding: 10px;
  .item{
    padding: 5px;
    &:nth-child(2n){
      background: #f8f8f8;
    }
    .name{
      width: 100px;
    }
  }
  .action{
    margin-top: 20px;
  }
}
</style>