zhangjiaqing
8 天以前 1cef3adee31c6934c0da4b4f0b8a6f5ac03b364f
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
/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            assetInventoryInStockInfo: {
                aiId: '',
                shId: '',
                shName: '',
                name: '',
                staffName: '',
                invTime: '',
                storehouses: [],
                remark: '',
                stateName: '',
                opinion: '',
                auditId: '',
                auditName: '',
                auditTel: '',
                auditTime: '',
                state: '',
                communityId: vc.getCurrentCommunity().communityId
            }
        },
        _initMethod: function () {
            $that.assetInventoryInStockInfo.aiId = vc.getParam('aiId');
            $that._queryAssetInventory();
            $that.queryAssetInventoryProduct();
        },
        _initEvent: function () {
        },
        methods: {
            _openChooseProductModal: function () {
                if (!$that.assetInventoryInStockInfo.shId) {
                    vc.toast('请先选择仓库');
                    return;
                }
                vc.emit('chooseProductAndSpec', 'openChooseProductModel', {
                    shId: $that.assetInventoryInStockInfo.shId
                });
            },
            _goBack: function () {
                vc.goBack();
            },
            _queryAssetInventory: function (_page, _rows) {
                var param = {
                    params: {
                        page: 1,
                        row: 1,
                        aiId: $that.assetInventoryInStockInfo.aiId,
                    }
                };
                //发送get请求
                vc.http.apiGet('assetInventory.listAssetInventory',
                    param,
                    function (json, res) {
                        var _assetInventoryManageInfo = JSON.parse(json);
                        vc.copyObject(_assetInventoryManageInfo.data[0], $that.assetInventoryInStockInfo)
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            queryAssetInventoryProduct: function () {
                var param = {
                    params: {
                        page: 1,
                        row: 100,
                        applyOrderId: $that.assetInventoryInStockInfo.aiId
                    }
                };
                //发送get请求
                vc.http.apiGet('assetInventoryDetail.listAssetInventoryWholeDetail',
                    param,
                    function (json, res) {
                        var _assetInventoryManageInfo = JSON.parse(json);
                        _assetInventoryManageInfo.data.forEach(item => {
                            $that._computeData(item);
                        })
                        $that.assetInventoryInStockInfo.storehouses = _assetInventoryManageInfo.data;
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _caculTotalMount: function () {
                let j = 0;
                vc.component.assetInventoryInStockInfo.storehouses.forEach(item => {
                    if (!isNaN(item.count) && !isNaN(item.price)) {
                        j += parseFloat(item.count) * parseFloat(item.price).toFixed(2);
                    } else {
                        $that.assetInventoryInStockInfo.totalMount = "请输入正确的数字";
                        throw Error();
                    }
                });
                $that.assetInventoryInStockInfo.totalMount = j.toFixed(2);
            },
            _computeData: function (_inoutOrderProduct) {
                _inoutOrderProduct.invProfit = parseInt(_inoutOrderProduct.invQuantity) - parseInt(_inoutOrderProduct.quantity);
                if (_inoutOrderProduct.invProfit < 0) {
                    _inoutOrderProduct.invProfit = 0;
                }
                _inoutOrderProduct.invLoss = parseInt(_inoutOrderProduct.quantity) - parseInt(_inoutOrderProduct.invQuantity);
                if (_inoutOrderProduct.invLoss < 0) {
                    _inoutOrderProduct.invLoss = 0;
                }
                _inoutOrderProduct.invProfitMoney = _inoutOrderProduct.invProfit * parseFloat(_inoutOrderProduct.price);
                _inoutOrderProduct.invLossMoney = _inoutOrderProduct.invLoss * parseFloat(_inoutOrderProduct.price);
                $that.$forceUpdate();
            },
            _printAssetInventoryInStock: function () {
                window.open("/print.html#/pages/property/printAssetInventoryInStock?aiId=" + $that.assetInventoryInStockInfo.aiId)
            }
        }
    });
})(window.vc);