Admin
6 天以前 bd6818fc9d40f343547bafca0743658f3c0379dc
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
//此处是对表单的方法,组件,权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
    components: {//动态扩充组件或组件路径
        //表单header、content、footer对应位置扩充的组件
        gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
        gridBody: '',
        gridFooter: '',
        //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
        modelHeader: '',
        modelBody: '',
        modelFooter: ''
    },
    buttons: { view: [], box: [], detail: [] },//扩展的按钮
    methods: {//事件扩展
        onInit() {
            // this.editFormOptions.forEach(x => {
            //     x.forEach(z => {
            //         if (z.field == 'selection_carId') {
            //             z.onChange = (column, row, tableData) => {
            //                 this.selectChange(column);
            //                 console.log(JSON.stringify(column));
            //                 //也可以select选择后从后台加载需要的数据
            //                 //  this.http.post("xxx?参数="+row.ProductName,{},true).then(result=>{
            //                 //   // row.xxx=result.xxx
            //                 //  })
            //             }
            //         }
 
            //     })
 
            // })
 
            let materiel_modelno = this.getOption("selection_carId");
            let confignameselect = this.getOption("selection_zcId");
            let manufacturerselect = this.getOption("selection_zc_manufacturer");
 
            materiel_modelno.onChange = (val, options) => {
                let params = {
                    MainData: { "materielId": val },
                }
                this.editFormFields.selection_zcId = '';
                this.editFormFields.selection_zc_manufacturer = '';
                confignameselect.data = [];
                manufacturerselect.data = [];
                this.http.post("api/Dt_materiel_zc_info/GetZCInfoByMateriel", params, "").then(x => {
                    confignameselect.data = x.data;
                });
            };
 
            confignameselect.onChange = (val, options) => {
                let params = {
                    MainData: { "materielId": this.editFormFields.selection_carId, 'materielModel': val },
                }
                manufacturerselect.data = [];
                this.editFormFields.selection_zc_manufacturer = '';
                this.http.post("api/Dt_materiel_zc_info/GetManufacturerByMateriel", params, "").then(x => {
                    manufacturerselect.data = x.data;
                });
            };
        }, selectChange(row) {
            //找到第二个下拉框选项
            let col;
            this.editFormOptions.forEach(x => {
                let s = x.find(r => r.field == 'selection_zcId');
                if (null != s) {
                    col = s;
                    return;
                }
            });
 
            let url = 'api/Dt_materiel_zc_info/GetZCInfoByMateriel';
            let params = {
                MainData: { "materielId": row },
            }
            //从后台返回第二个下拉框满足条件的数据
            this.http.post(url, params, false).then((keys) => {
                //keys只返回第二个下拉框的key值,用于下面的判断,返回的下拉框key选项显示,没有返回的隐藏
                //  keys = ['1', '2'];
 
                col.bind.data.forEach((item) => {
                    //注意:第二个下拉框选项,在下拉框绑定页面,配置的字典sql需要将全部数据源返回
                    //如果返回的数据源有几十W,请考虑用弹出框选择数据,不要用下拉框
                    if (keys.indexOf(item.key) != -1) {
                        item.hidden = false;
                    } else {
                        item.hidden = true;
                    }
                });
            });
        },
        getOption(field) {
            let option;
            this.editFormOptions.forEach(x => {
                let col = x.find(r => r.field == field);
                if (null != col) {
                    option = col;
                    return;
                }
            });
            return option;
        }, modelOpenAfter(row) {
            let isEDIT = this.currentAction == this.const.ADD;
            this.editFormOptions.forEach(item => {
                item.forEach(x => {
                    if (x.field == "selection_zc_manufacturer" || x.field == "selection_carId" || x.field == "selection_zcId" || x.field == "selection_standard_type") {
                        x.disabled = !isEDIT;
                    }
                });
            })
        }
    }
};
export default extension;