mrzcc
2020-03-06 15c8130f6df91bf5ff6a4340f876c84a4b7d8b6b
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
/**
 入驻小区
 **/
(function (vc) {
    vc.extends({
        data: {
            addPurchaseApplyStepInfo: {
                $step: {},
                index: 0,
                infos: [],
                purchaseApply:{
                    resourceStores:[],
                    description:'',
                    file:'',
                    resOrderType:'10000'
                }
            }
        },
        _initMethod: function () {
            vc.component._initStep();
        },
        _initEvent: function () {
            vc.on("addPurchaseApplyStep", "notify", function (viewResourceStoreInfo2) {
                console.log("收到最终参数:"+viewResourceStoreInfo2);
                vc.component.addPurchaseApplyStepInfo.purchaseApply.resourceStores = viewResourceStoreInfo2.resourceStores;
            });
 
            vc.on("addPurchaseApplyStep", "notify2", function (info) {
                vc.component.addPurchaseApplyStepInfo.purchaseApply.description = info.description;
            });
 
        },
        methods: {
            _initStep: function () {
                vc.component.addPurchaseApplyStepInfo.$step = $("#step");
                vc.component.addPurchaseApplyStepInfo.$step.step({
                    index: 0,
                    time: 500,
                    title: ["选择物品", "申请说明"]
                });
                vc.component.addPurchaseApplyStepInfo.index = vc.component.addPurchaseApplyStepInfo.$step.getIndex();
            },
            _prevStep: function () {
                vc.component.addPurchaseApplyStepInfo.$step.prevStep();
                vc.component.addPurchaseApplyStepInfo.index = vc.component.addPurchaseApplyStepInfo.$step.getIndex();
 
                vc.emit('viewResourceStoreInfo2', 'onIndex', vc.component.addPurchaseApplyStepInfo.index);
                vc.emit('addPurchaseApplyView', 'onIndex', vc.component.addPurchaseApplyStepInfo.index);
 
            },
            _nextStep: function () {
                vc.emit('viewResourceStoreInfo2', 'getSelectResourceStores', null);
                var _resourceStores = vc.component.addPurchaseApplyStepInfo.purchaseApply.resourceStores;
                if (_resourceStores.length == 0) {
                    vc.message("请完善需要采购的物品信息");
                    return;
                }
               for( var i = 0; i < _resourceStores.length; i++){
                   if(_resourceStores[i].quantity <= 0){
                       vc.message("请完善需要采购的物品信息");
                        return;
                   }
               }
                vc.component.addPurchaseApplyStepInfo.$step.nextStep();
                vc.component.addPurchaseApplyStepInfo.index = vc.component.addPurchaseApplyStepInfo.$step.getIndex();
 
                vc.emit('viewResourceStoreInfo2', 'onIndex', vc.component.addPurchaseApplyStepInfo.index);
                vc.emit('addPurchaseApplyView', 'onIndex', vc.component.addPurchaseApplyStepInfo.index);
 
            },
            _finishStep: function () {
                vc.emit('addPurchaseApplyViewInfo', 'setPurchaseApplyInfo', null);
                var _description = vc.component.addPurchaseApplyStepInfo.purchaseApply.description;
                if (_description == null || _description == '') {
                    vc.message("请填写申请说明");
                    return;
                }
                vc.http.post(
                    'addPurchaseApply',
                    'save',
                    JSON.stringify(vc.component.addPurchaseApplyStepInfo.purchaseApply),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        if (res.status == 200) {
 
                            vc.message('处理成功', true);
                            //关闭model
                            vc.jumpToPage("/flow/purchaseApplyFlow?" + vc.objToGetParam(JSON.parse(json)));
                            return;
                        }
                        vc.message(json);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
 
                        vc.message(errInfo);
                    });
            }
        }
    });
})(window.vc);