yyb
昨天 0c9f714c32e4bc9e8eaf972d860d2d9f2a1e6763
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<template>
  <view class="tag-add">
    <u-form :model="form" ref="uForm" :error-type="['toast']">
      <u-form-item label="类型" prop="type" required v-if="info.workCenter === 'ZZ-03'">
          <u-input v-model="form.type" type="select" input-align="right" placeholder="请选择"/>
          <u-icon name="arrow-right" @click="show = true"></u-icon>
      </u-form-item>
      <u-form-item label="数量" :border-bottom="false" style="width: calc(100% - 40rpx);" prop="num" required>
          <u-input v-model="form.num" input-align="right" placeholder="请输入"/>
      </u-form-item>
    </u-form>
      <u-button type="primary" style="margin: 30rpx;" :loading="loading" @click="submit" :custom-style="{
     backgroundColor: '#214DED',
     height:'80rpx'}" class="btn">提交</u-button>
      <u-select :list="actionSheetList" v-model="show" @confirm="actionSheetCallback"></u-select>
  </view>
</template>
 
<script>
import UIcon from "../../../uview-ui/components/u-icon/u-icon.vue";
 
export default {
    components: {UIcon},
  data(){
    return{
      form:{
        type: '',
        num: '',
        value: '',
          reportType: ''
      },
      show:false,
      actionSheetList:[],
      rules: {
                type: [
                    {
                        required: true,
                        message: '请选择类型',
                        trigger: ['change'],
                    }
                ],
                num: [
                    {
                        required: true,
                        message: '请输入数量',
                        trigger: ['change','blur'],
                    },
                    // 正则判断只能为数字
                    {
                        validator: (rule, value, callback) => {
                            return this.$u.test.digits(value);
                        },
                        message: '只能为数字',
                        trigger: ['change','blur'],
                    },
                ]
            },
      loading:false,
        info: {}
    }
  },
    onLoad(options) {
        this.info = JSON.parse(decodeURIComponent(options.info))
    },
  methods:{
    actionSheetCallback(item){
            this.form.type = item[0].label
            this.form.value = item[0].value
    },
    submit(){
      this.$refs.uForm.validate(valid => {
                if (valid) {
                    this.form.operationTaskId = this.info.id
                    this.form.workstationId = this.info.workstationId
                    this.form.reportType = this.info.workCenter === 'ZZ-03' ? 'CHENGTAO_PRODUCT_REPORT' : 'WAIKE_PRODUCT_REPORT'
                    let type =""
                    
                    if(this.form.type ==="高压柜" ){
                        type ="GY"
                    }else if(this.form.type ==="低压柜"){
                         type ="DY"
                    }else{
                         type ="XT"
                    }
                    
                    let param ={
                          type: type,
                          num: this.form.num,
                          value: this.form.value,
                            reportType: this.form.reportType,
                            operationTaskId:this.form.operationTaskId,
                            workstationId:this.form.workstationId,
                            reportType:this.form.reportType
                        }
                    this.$u.api.dailyPaper.generateLabel(param).then(res => {
                        console.log(res)
                        if (res.code === 0) {
                            this.$u.toast('操作成功')
                            this.loading = true;
                            uni.navigateBack({
                                //关闭当前页面,返回上一页面或多级页面。
                                delta:1
                            });
                            this.loading = false;
                        }
                    })
                } else {
                    console.log('验证失败');
                }
            });
    },
      getCabinetType () {
            this.$u.api.dictData({dictType: 'cabinet_type'}).then(res => {
                if (res.code === 0 && res.data.length > 0) {
                    res.data.forEach(i => {
                        const obj = Object.assign({
                            label: i.label,
                            value: i.value,
                        })
                        this.actionSheetList.push(obj)
                    })
                }
            })
      }
  },
  onReady() {
        this.$refs.uForm.setRules(this.rules);
        this.actionSheetList = []
        // 进入页面查询类型列表
      this.getCabinetType()
    }
}
</script>
 
<style lang="scss" scoped>
.tag-add{
  height: calc(100vh - 88rpx);
  background: linear-gradient(to bottom, #E5F0FF, #FFF);
  box-sizing: border-box;
  padding-top: 32rpx;
  .u-form{
    margin: 0 30rpx;
    background: #FFFFFF;
    border-radius: 10rpx;
    padding: 20rpx 26rpx;
  }
  .btn{
    position: fixed;
    bottom: 40rpx;
    width: calc(100% - 60rpx);
  }
}
::v-deep.uicon-arrow-down-fill:before {
    display: none;
}
::v-deep.u-form-item--left__content__label {
    width: 100rpx;
    padding-left: 26rpx;
    font-weight: 500;
    font-size: 30rpx;
    color: #4F4F4F;
    line-height: 80rpx;
}
::v-deep.u-form-item--left__content--required {
    left: 8rpx;
    top: 0;
}
</style>