田源
2025-01-09 8a166a60cfd1a2e593ffa103d10c0dc224fc8628
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
package com.vci.client.uif.actions.client;
 
import com.vci.client.bof.ClientBusinessObject;
import com.vci.client.bof.ClientLinkObject;
import com.vci.client.fm.FileObject;
import com.vci.client.uif.engine.common.IDataNode;
import com.vci.mw.ClientContextVariable;
 
/**
 * 文档文件上传按钮
 * @author VCI-STGK006
 *
 */
public class ChooseDocAction extends DoseNotSelectDataHasRightCheckAction {
    
    /**
     * 文件上传下载方法
     */
    private FileOperation fopreation = new FileOperation(); 
 
    public ChooseDocAction(){
        super();
    }
    
    @Override
    public String getKey() {
        return CHOOSE_DOC;
    }
    
    @Override
    public boolean checkHasRight(){
        // 按BO进行数据权限检查
        setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_B);
        return super.checkHasRight();
    }
 
 
    @Override
    public boolean doPost() {
        try {
            //显示创建窗口
            Object obj = getRegionPanel().getSourceData();
            String fromoid = "";
            if(obj instanceof IDataNode){
                if(((IDataNode) obj).getMaterObject() instanceof ClientBusinessObject){
                    ClientBusinessObject cbo = (ClientBusinessObject) ((IDataNode) obj).getMaterObject();
                    fromoid = cbo.getBusinessObject().oid;
                } else if (((IDataNode) obj).getMaterObject() instanceof ClientLinkObject) {
                    ClientLinkObject clo = (ClientLinkObject) ((IDataNode) obj).getMaterObject();
                    fromoid = clo.getLinkObject().toOid;
                }
            }
            if(fromoid == null ||fromoid.equals("")){
                UIFUtils.showErrorMessage(ClientContextVariable.getFrame(),
                        "uifmodel.plm.uif.actions.uploadfileerror", new Exception("文件上传失败:需要添加附件的对象不存在!"));
                return false;
            }
            FileObject[] fos = fopreation.selectUploadFile(
                    ClientContextVariable.getFrame(), "", null, true, 9, fromoid);
            if(fos != null && fos.length > 0){
                UIFUtils.showMessage(ClientContextVariable.getFrame(),
                        "uifmodel.plm.uif.actions.uploadfilesuccessmsg");
            }
            return true;
        } catch (Exception e){
            UIFUtils.showErrorMessage(ClientContextVariable.getFrame(),
                    "uifmodel.plm.uif.actions.uploadfileerror", e);
            return false;
        }
    }
}