|  | @@ -4,6 +4,7 @@ namespace app\admin\controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  use app\admin\common\AdminController;
 | 
	
		
			
				|  |  |  use app\common\api\DictApi;
 | 
	
		
			
				|  |  | +use app\common\api\UploadApi;
 | 
	
		
			
				|  |  |  use think\facade\Db;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  class CurrencyFiletype extends AdminController{
 | 
	
	
		
			
				|  | @@ -50,4 +51,172 @@ class CurrencyFiletype extends AdminController{
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return ["total" => $count, "rows" => $rows];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function currencyFiletype_add(){
 | 
	
		
			
				|  |  | +        return view("");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function add(){
 | 
	
		
			
				|  |  | +        $response_obj = new \StdClass();
 | 
	
		
			
				|  |  | +        $name = trim($this->request['name']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($name)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '附件名称不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $type = trim($this->request['type']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($type)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '申报类别不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $api = trim($this->request['api']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($api)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = 'api不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $must = trim($this->request['must']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($must)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '是否必传不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $active = trim($this->request['active']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($active)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '是否有效不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $sn = trim($this->request['sn']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($sn)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '排序不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if($this->request['templateFile']){
 | 
	
		
			
				|  |  | +            $uploadapi = new UploadApi();
 | 
	
		
			
				|  |  | +            $file_check_res = $uploadapi->uploadOne($this->request->file('templateFile'), 'system');
 | 
	
		
			
				|  |  | +            if ($file_check_res->code == 500) {
 | 
	
		
			
				|  |  | +                return \StrUtil::back($file_check_res, "CurrencyFiletypeInfoDlg.callBack");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $templateUrl = $file_check_res->filepath;
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +            $templateUrl = "";
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $data = [
 | 
	
		
			
				|  |  | +            'id' => getStringId(),
 | 
	
		
			
				|  |  | +            'type' => $type,
 | 
	
		
			
				|  |  | +            'name' => $name,
 | 
	
		
			
				|  |  | +            'api' => $api,
 | 
	
		
			
				|  |  | +            'must' => $must,
 | 
	
		
			
				|  |  | +            'active' => $active,
 | 
	
		
			
				|  |  | +            'sn' => $sn,
 | 
	
		
			
				|  |  | +            'checkCompany' => '1158293574504660993',
 | 
	
		
			
				|  |  | +            'description' => $this->request['description'],
 | 
	
		
			
				|  |  | +            'createTime' => date("Y-m-d H:i:s"),
 | 
	
		
			
				|  |  | +            'createUser' => session('user')['uid'],
 | 
	
		
			
				|  |  | +            'templateUrl' => $templateUrl
 | 
	
		
			
				|  |  | +        ];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        \app\admin\model\CurrencyFiletype::create($data);
 | 
	
		
			
				|  |  | +        $response_obj->code = 200;
 | 
	
		
			
				|  |  | +        $response_obj->msg = '添加成功';
 | 
	
		
			
				|  |  | +        return \StrUtil::back($response_obj, "CurrencyFiletypeInfoDlg.callBack");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function currencyFiletype_update(){
 | 
	
		
			
				|  |  | +        $id = trim($this->request->get('id'));
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($id)){
 | 
	
		
			
				|  |  | +            return json(['msg'=>'id不能为空']);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $cft = \app\admin\model\CurrencyFiletype::findOrEmpty($id);
 | 
	
		
			
				|  |  | +        return view("",['item'=>$cft]);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function update(){
 | 
	
		
			
				|  |  | +        $response_obj = new \StdClass();
 | 
	
		
			
				|  |  | +        $id = \StrUtil::getRequestDecodeParam($this->request,'id');
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($id)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = 'id不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $cft = \app\admin\model\CurrencyFiletype::findOrEmpty($id);
 | 
	
		
			
				|  |  | +        if(!$cft){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '找不到记录';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $cft->name = $name = trim($this->request['name']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($name)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '附件名称不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $cft->type = $type = trim($this->request['type']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($type)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '申报类别不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $cft->api = $api = trim($this->request['api']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($api)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = 'api不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $cft->must = $must = trim($this->request['must']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($must)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '是否必传不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $cft->active = $active = trim($this->request['active']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($active)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '是否有效不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $cft->sn = $sn = trim($this->request['sn']);
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($sn)){
 | 
	
		
			
				|  |  | +            $response_obj->code = 500;
 | 
	
		
			
				|  |  | +            $response_obj->msg = '排序不能为空';
 | 
	
		
			
				|  |  | +            return \StrUtil::back($response_obj,'CurrencyFiletypeInfoDlg.callBack');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if($this->request['templateFile']){
 | 
	
		
			
				|  |  | +            $uploadapi = new UploadApi();
 | 
	
		
			
				|  |  | +            $file_check_res = $uploadapi->uploadOne($this->request->file('templateFile'), 'system');
 | 
	
		
			
				|  |  | +            if ($file_check_res->code == 500) {
 | 
	
		
			
				|  |  | +                return \StrUtil::back($file_check_res, "CurrencyFiletypeInfoDlg.callBack");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $cft->templateUrl = $templateUrl = $file_check_res->filepath;
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +            $cft->templateUrl = $templateUrl = "";
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $cft->updateTime = date("Y-m-d H:i:s");
 | 
	
		
			
				|  |  | +        $cft->updateUser = session('user')['uid'];
 | 
	
		
			
				|  |  | +        $cft->save();
 | 
	
		
			
				|  |  | +        $response_obj->code = 200;
 | 
	
		
			
				|  |  | +        $response_obj->msg = '修改成功';
 | 
	
		
			
				|  |  | +        return \StrUtil::back($response_obj, "CurrencyFiletypeInfoDlg.callBack");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public function delete(){
 | 
	
		
			
				|  |  | +        $id = \StrUtil::getRequestDecodeParam($this->request,'currencyFiletypeId');
 | 
	
		
			
				|  |  | +        if(\StrUtil::isEmpOrNull($id)){
 | 
	
		
			
				|  |  | +            return json(['code' => 500,'msg' => '缺少参数']);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        \app\admin\model\CurrencyFiletype::destroy($id);
 | 
	
		
			
				|  |  | +        return json(['code' => 200,'msg' => '删除成功']);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |