コード例 #1
0
ファイル: common.php プロジェクト: VampireMe/admin-9939-com
<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/1/29
 * Time: 15:03
 */
//include the file
defined("TMP_PATH") or define("TMP_PATH", "D:/gaoqing/software/wamp/www/PHPStorm");
require TMP_PATH . "/admin-9939-com/librarys/helpers/utils/Spell.php";
$name = "高青";
$pin = \librarys\helpers\utils\Spell::Pinyin($name, 'UTF-8', true);
$Bpin = strtoupper($pin[0]);
echo $Bpin;
コード例 #2
0
 /**
  * 添加症状
  * @return type
  */
 public function actionAdd()
 {
     $this->getView()->title = '添加症状';
     //        $this->request = \Yii::$app->request;
     if ($this->request->isPost) {
         $symptomFormData = $this->request->post('symptomForm');
         //主表信息
         $symptomContentFormData = $this->request->post('symptomContentForm');
         //分表信息
         $symptomRelateFormData = $this->request->post('symptomRelate');
         //相关症状
         $diseaseRelateFormData = $this->request->post('diseaseRelate');
         //相关疾病
         $partRelateFormData = $this->request->post('partRelate');
         //所属部位
         //图片信息
         $imagesArr = [];
         $images = json_decode($this->request->post('diseaseImage'), true);
         foreach ($images as $k => $v) {
             //头图数据写入主表缩略图字段
             if ($v['weight'] == 1) {
                 $symptomFormData['thumbnail'] = $v['name'];
             }
         }
         //主表默认值字段
         $symptomFormData['userid'] = $this->user['id'];
         $symptomFormData['username'] = $this->user['login_name'];
         $symptomFormData['createtime'] = time();
         $symptomFormData['updatetime'] = time();
         //拼音部分
         $pinyin_initial = Spell::Pinyin($symptomFormData['name'], 'utf-8', true);
         $capital = strtoupper($pinyin_initial[0]);
         $map_pinyin_sn = $this->getPinYinSnDic();
         $pinyin_initial_sn = isset($map_pinyin_sn[$capital]) ? $map_pinyin_sn[$capital] + 1 : 0;
         $symptomFormData['capital'] = $capital;
         $symptomFormData['capital_sn'] = $pinyin_initial_sn;
         $symptomFormData['pinyin'] = Spell::Pinyin($symptomFormData['name']);
         $symptomFormData['pinyin_initial'] = $pinyin_initial;
         $symptomFormData['source_pinyin'] = Spell::Pinyin($symptomFormData['name']);
         //            print_r($symptomFormData);
         //            print_r($symptomFormData);
         //            exit;
         $flag[] = $this->symptom->addSymptom($symptomFormData);
         $lastInsertId = $this->symptom->attributes['id'];
         if ((int) $partRelateFormData['part_level2'] == 0) {
             $partRelateFormData['part_level2'] = '';
             $partRelateFormData['partid'] = $partRelateFormData['part_level1'];
         } else {
             $partRelateFormData['partid'] = $partRelateFormData['part_level2'];
         }
         $partRelateFormData['symptomid'] = $lastInsertId;
         foreach ($images as $k => $v) {
             $imagesArr[$k]['name'] = $v['name'];
             $imagesArr[$k]['flag'] = 2;
             $imagesArr[$k]['weight'] = $v['weight'];
             $imagesArr[$k]['createtime'] = time();
             $imagesArr[$k]['updatetime'] = time();
             $imagesArr[$k]['relid'] = $lastInsertId;
             //头图数据写入主表缩略图字段
             if ($v['weight'] == 1) {
                 $symptomFormData['thumbnail'] = $v['name'];
             }
         }
         //            print_r($imagesArr);
         //            exit;
         //            echo $lastInsertId;
         //            exit;
         $flag[] = $this->relate->insertImage($imagesArr);
         $flag[] = $this->symptomContent->addSymptomContent($lastInsertId, $symptomContentFormData);
         $flag[] = $this->relateSymptomInsert($lastInsertId, $symptomRelateFormData);
         $flag[] = $this->relateDiseaseInsert($lastInsertId, $diseaseRelateFormData);
         $flag[] = $this->relate->addRelPart($lastInsertId, $partRelateFormData);
         $num = count($flag);
         //当前删除记录操作的总个数
         $n = 0;
         foreach ($flag as $v) {
             //循环出所有的值,值分为0 1 ,成功是1,失败是0
             $n = $v + $n;
         }
         if ($n < $num) {
             //如果结果小于总个数,说明有失败
             Yii::$app->getSession()->setFlash('error', '添加失败!');
             return $this->redirect(Url::toRoute('symptom/add'));
         }
         Yii::$app->getSession()->setFlash('success', '添加成功!');
         return $this->redirect(Url::toRoute('symptom/index'));
     }
     $allSymptom['allSymptom'] = $this->symptom->getSymptom();
     //所有的症状,供选择相关症状时使用
     $allSymptom['relateSymptoms'] = 0;
     //所有与当前症状相关联的症状,因为是添加,所以默认为空
     $allSymptom['relatePart'] = 0;
     //所有与当前症状相关联的症状
     $allSymptom['diseaseImage'] = 0;
     //所有与当前症状相关联的症状,因为是添加,所以默认为空
     $allSymptom['relSymptom']['part'] = $this->relate->getAllPart();
     //相关疾病弹窗条件 部位
     $allSymptom['relSymptom']['department'] = $this->depart->getDepartmentLevel1();
     //相关疾病弹窗条件 科室
     $allSymptom['relSymptom']['symptom'] = null;
     $allSymptom['relateDiseases'] = 0;
     //所有与当前症状相关联的症状,因为是添加,所以默认为空
     //生成上传签名串
     $moduleName = 'symptom';
     $allSymptom['sign'] = \Yii::$app->params['uploadPath'][$moduleName]['api_id'];
     return $this->render('add', ['model' => false, 'allSymptom' => $allSymptom]);
 }
コード例 #3
0
 /**
  * 从 request 中,得到新增疾病信息的数组
  * @author gaoqing
  * 2016年1月15日
  * @param Request $request 请求对象
  * @param boolean $isAdd 是否是新增操作(默认是新增操作)
  * @return array 新增疾病信息的数组
  */
 private function getAddMapArr($request, $isAdd = true)
 {
     $addMapArr = [];
     if ($request->post("disease", -1) != -1) {
         $disease = $request->post("disease");
         if ($isAdd) {
             $pinyin_initial = Spell::Pinyin($disease['name'], 'utf-8', true);
             $capital = strtoupper($pinyin_initial[0]);
             $map_pinyin_sn = $this->getPinYinSnDic();
             $pinyin_initial_sn = isset($map_pinyin_sn[$capital]) ? $map_pinyin_sn[$capital] + 1 : 0;
             $addMapArr['disease'] = $this->setDefaultValues($disease, ['status' => 2, 'userid' => $this->user->id, 'username' => $this->user->login_name, 'inputtime' => time(), 'updatetime' => time(), 'type' => '0', 'capital' => $capital, 'capital_sn' => $pinyin_initial_sn, 'pinyin' => Spell::Pinyin($disease['name']), 'pinyin_initial' => $pinyin_initial, 'source_pinyin' => Spell::Pinyin($disease['name'])]);
         } else {
             $addMapArr['disease'] = $this->setDefaultValues($disease, ['userid' => $this->user->id, 'username' => $this->user->login_name, 'updatetime' => time()]);
         }
     }
     if ($request->post("diseaseDepartment", -1) != -1) {
         $diseaseDepartment = $request->post("diseaseDepartment");
         $addMapArr['diseaseDepartment'] = $this->splitDatasByJSON($diseaseDepartment);
     }
     if ($request->post("diseaseDisease", -1) != -1) {
         $diseaseDisease = $request->post("diseaseDisease");
         $addMapArr['diseaseDisease'] = $this->splitDatas($diseaseDisease, "rel_diseaseid");
     }
     if ($request->post("diseaseSymptom", -1) != -1) {
         $diseaseSymptom = $request->post("diseaseSymptom");
         $addMapArr['diseaseSymptom'] = $this->splitDatas($diseaseSymptom, "symptomid");
     }
     if ($request->post("diseaseImage", -1) != -1) {
         $diseaseImage = $request->post("diseaseImage");
         $diseaseImage = $this->splitDatasByJSON($diseaseImage);
         if (isset($diseaseImage) && !empty($diseaseImage)) {
             foreach ($diseaseImage as $image) {
                 $singleImage = $this->setDefaultValues($image, ['flag' => 1, 'createtime' => time(), 'updatetime' => time()]);
                 $addMapArr['diseaseImage'][] = $singleImage;
             }
         }
     }
     if ($request->post("diseaseContent", -1) != -1) {
         $addMapArr['diseaseContent'] = $request->post("diseaseContent");
     }
     return $addMapArr;
 }
コード例 #4
0
 /**
  * 编辑保存
  */
 public function actionEditSave()
 {
     $id = $this->helpGpost('id', '');
     $name = $this->helpGpost('name', '');
     $disease = $this->helpGpost('disease', []);
     $diseaseid = $disease[0]['diseaseid'];
     $res = Keywords::findOne($id);
     if (!$res) {
         return Json::encode(['error' => 1]);
     }
     $pinyin_initial = Spell::Pinyin($name, 'utf-8', true) . $id;
     $params = ['name' => $name, 'pinyin_initial' => $pinyin_initial, 'disease_id' => $diseaseid];
     $obj_keywords = new Keywords();
     $res = $obj_keywords->edit($id, $params);
     $message['error'] = $res ? 0 : 1;
     return Json::encode($message);
 }