后台管理系统的常规单据通常包括数据,页面,功能;其中数据,页面,功能又可以细分如下:

分类  二级分类  主要内容  注意事项  例如
数据 数据库迁移脚本  用于数据表生成及转态回滚

1.是否需要增加索引

2.字段类型与长度

 
基本数据模型  使用代码生成器生成,包括字段基本验证规则和属性的label  1.直接用代码生成器生成  
核心业务模型的场景与验证  定义业务场景,及为场景定义验证规则

1.任何的业务场景都应该定义验证场景,不应该使用默认的场景

2.任何定义的验证规格都使用支持客户端验证

 
核心业务模型的关联  一对一关联或者一对多关联  1.任何相关联的数据模型采用一对一或一对多关联方便调用  
核心业务模型的业务实现  1.具体业务逻辑编写

1.具体业务逻辑应该尽可能调用其他函数实现,且返回的错误提示信息应该直接使用被调用函数的错误提示信息

2.业务逻辑中如果有异常必须抛出或者处理异常,并被行为接收显示在界面上

3.业务逻辑总如果无法取值设为空默认值,该值必须有则抛出异常

4.如果涉及数字,重量,金额的计算则应该使用内置函数bc开头函数处理而不是直接加减乘除

 
核心业务模型的事务与数据持久化  数据持久化及使用事务    
数据查询模型  数据查询最普遍的方法    
页面 搜索页  1.折叠隐藏  1.搜索页应该是可以被折叠或者被隐藏的  
列表页

1.作废功能

2.数字默认带合计功能

3.操作列

4.类型列

5.状态列

6.单号列

1.已作废的单据默认不显示,勾选已作废才显示

2.数字或金额字段的列表展示带合计

3.操作列最多显示常用的三项为查看,编辑,更多,其他操作点击更多

4.操作列应当根据状态和分类进行约束

5.类型列应与单号类显示为一列,标红带括号

6.状态列应为命名为待XX和已完成;且注意中间的状态是否需要锁定其他单据

7.状态列表和类型列用红绿黄颜色区分对比

8.列表页排序应当为倒序显示

 4.已经发起钉钉审批则不能编辑
详情页

1.显示作废

2.整体布局

3.信息展示

4.模块隔离

1.已作废的单据标记已作废标签

2.详情页的整体布局应该和表单页一致

3.详情页应显示该单据所有的信息以及和该单据相关联的信息

4.详情页的信息展示应该可以被拆分为一个或几个模块且模块之间应该采用带背景色标题行隔离

 
表单页

1.第三方单号重复选择

2.联动框问题

1.第三方单号在第一个单据流程没有走完时是可以重复选择的

1.联动框上级修改下级应该自动清空(例如:修改了仓库则库区应该清空为未选择状态;修改了存货名称则应该清空等级为未选择状态)

 
表单页js添加明细  1.重复生成多余详情问题  1.编辑保存详情时应该先持久化删除老的详情  
弹出页

1.选择单号提交

2.信息提示

1.选择单号提交问题如果用户没有选择单号则alert提示用户选择

2.所有的后台接口错误异常提示都应该显示在弹出层中

 
作废

1.作废应弹框提示

2.作废成功和作废失败都应该弹框提示

3.作废逻辑的3种情况

3.作废逻辑1:已经生成了其他单据或者状态不可逆则不能作废该单据

作废逻辑2:已经生成了其他单据则应该先作废其他单据

作废逻辑3:作废其他单据后再作废该单据

 
附加功能 excel导出  1.封装excel导出工具类    
tcpdf打印  1.封装pdf生成类    
钉钉审批  1.封装钉钉审批类    

例如:库存调拨功能

1.数据库设计迁移脚本:

<?php

use yii\db\Schema;
use jamband\schemadump\Migration;

class m180710_063957_create_table_wms_transfer extends Migration
{
    const TABLE_NAME = '{{%wms_transfer}}';
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT=\'库存调拨表\'';
        }

        $this->createTable(self::TABLE_NAME, [
            'id' => $this->primaryKey() . ' AUTO_INCREMENT  COMMENT \'自增ID\'',
            ) . ' COMMENT \'库存调拨单编号\'',

            ) . ' COMMENT \'加工基地ID\'',
            ) . ' COMMENT \'加工基地名称\'',

            ) . ' COMMENT \'入库单号(起)\'',
            ) . ' COMMENT \'存货类型(起)\'',
            ) . ' COMMENT \'出库单号(起)\'',

            ) . ' COMMENT \'存货ID(起)\'',
            ) . ' COMMENT \'存货名称(起)\'',
            ) . ' COMMENT \'等级ID(起)\'',
            ) . ' COMMENT \'等级名称(起)\'',
            ) . ' COMMENT \'产地ID(起)\'',
            ) . ' COMMENT \'产地名称(起)\'',

            ) . ' COMMENT \'剩余重量(起)\'',

            ) . ' COMMENT \'计件类型(起)\'',
            ) . ' COMMENT \'包装规格(起)\'',
            ) . ' COMMENT \'标准件数(起)\'',
            ) . ' COMMENT \'非标准件数(起)\'',
            ) . ' COMMENT \'总件数(起)\'',
            ) . ' COMMENT \'标准重量(起)\'',
            ) . ' COMMENT \'非标准重量(起)\'',
            ) . ' COMMENT \'总重量(起)\'',

            ) . ' COMMENT \'仓库ID(起)\'',
            ) . ' COMMENT \'仓库名称(起)\'',
            ) . ' COMMENT \'库区ID(起)\'',
            ) . ' COMMENT \'库区名称(起)\'',
            'wms_transfer_from_wms_position_info' => $this->text() . ' COMMENT \'库位信息json保存(起)\'',

            ) . ' COMMENT \'存货类型(止)\'',
            ) . ' COMMENT \'入库单号(止)\'',

            ) . ' COMMENT \'存货ID(止)\'',
            ) . ' COMMENT \'存货名称(止)\'',
            ) . ' COMMENT \'等级ID(止)\'',
            ) . ' COMMENT \'等级名称(止)\'',
            ) . ' COMMENT \'产地ID(止)\'',
            ) . ' COMMENT \'产地名称(止)\'',

            ) . ' COMMENT \'计件类型(止)\'',
            ) . ' COMMENT \'包装规格(止)\'',
            ) . ' COMMENT \'标准件数(止)\'',
            ) . ' COMMENT \'非标准件数(止)\'',
            ) . ' COMMENT \'总件数(止)\'',
            ) . ' COMMENT \'标准重量(止)\'',
            ) . ' COMMENT \'非标准重量(止)\'',
            ) . ' COMMENT \'总重量(止)\'',

            ) . ' COMMENT \'仓库ID(止)\'',
            ) . ' COMMENT \'仓库名称(止)\'',
            ) . ' COMMENT \'库区ID(止)\'',
            ) . ' COMMENT \'库区名称(止)\'',
            'wms_transfer_to_wms_position_info' => $this->text() . ' COMMENT \'库位信息json保存(止)\'',

            ) . ' COMMENT \'调拨申请人ID\'',
            ) . ' COMMENT \'调拨申请人\'',
            ) . ' COMMENT \'调拨申请日期\'',

            ) . ' COMMENT \'出库确认人ID\'',
            ) . ' COMMENT \'出库确认人\'',
            ) . ' COMMENT \'出库确认日期\'',

            ) . ' COMMENT \'入库确认人ID\'',
            ) . ' COMMENT \'入库确认人\'',
            ) . ' COMMENT \'入库确认日期\'',

            ) . ' COMMENT \'质量放行人ID\'',
            ) . ' COMMENT \'质量放行人\'',
            ) . ' COMMENT \'质量放行日期\'',

            ) . ' COMMENT \'库存调拨状态0为待调拨1为已完成\'',

            ) . ' COMMENT \'创建时间\'',
            ) . ' COMMENT \'编辑时间\'',
            ) . ' COMMENT \'是否逻辑删除\'',
        ], $tableOptions);

        $this->createIndex('wms_transfer_code',self::TABLE_NAME,'wms_transfer_code');
        $this->createIndex('common_producer_info_id',self::TABLE_NAME,'common_producer_info_id');
        $this->createIndex('wms_transfer_from_code',self::TABLE_NAME,'wms_transfer_from_code');
        $this->createIndex('wms_transfer_to_code',self::TABLE_NAME,'wms_transfer_to_code');
        $this->createIndex('wms_transfer_status',self::TABLE_NAME,'wms_transfer_status');
    }

    public function safeDown()
    {
        $this->dropTable(self::TABLE_NAME);
    }
}

注意:

(1)使用查询的字段需要增加索引

(2)必须具有created_at, updated_at, is_del这三个字段

第二 使用迁移脚本生成基本模型如下:

<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%wms_transfer}}".
 *
 * @property integer $id
 * @property string $wms_transfer_code
 * @property integer $common_producer_info_id
 * @property string $common_producer_info_name
 * @property string $wms_transfer_from_in_code
 * @property integer $wms_transfer_from_type
 * @property string $wms_transfer_from_code
 * @property integer $wms_transfer_from_herb_info_id
 * @property string $wms_transfer_from_herb_info_name
 * @property integer $wms_transfer_from_grade_info_id
 * @property string $wms_transfer_from_grade_info_name
 * @property integer $wms_transfer_from_place_info_id
 * @property string $wms_transfer_from_place_info_name
 * @property string $wms_transfer_from_surplus_weight
 * @property integer $wms_transfer_from_piece_type
 * @property string $wms_transfer_from_weight_per_package
 * @property integer $wms_transfer_from_standard_package_number
 * @property integer $wms_transfer_from_off_standard_package_number
 * @property integer $wms_transfer_from_total_package_number
 * @property string $wms_transfer_from_standard_weight
 * @property string $wms_transfer_from_off_standard_weight
 * @property string $wms_transfer_from_total_weight
 * @property integer $wms_transfer_from_wms_info_id
 * @property string $wms_transfer_from_wms_info_name
 * @property integer $wms_transfer_from_area_info_id
 * @property string $wms_transfer_from_area_info_name
 * @property string $wms_transfer_from_wms_position_info
 * @property integer $wms_transfer_to_type
 * @property string $wms_transfer_to_code
 * @property integer $wms_transfer_to_herb_info_id
 * @property string $wms_transfer_to_herb_info_name
 * @property integer $wms_transfer_to_grade_info_id
 * @property string $wms_transfer_to_grade_info_name
 * @property integer $wms_transfer_to_place_info_id
 * @property string $wms_transfer_to_place_info_name
 * @property integer $wms_transfer_to_piece_type
 * @property string $wms_transfer_to_weight_per_package
 * @property integer $wms_transfer_to_standard_package_number
 * @property integer $wms_transfer_to_off_standard_package_number
 * @property integer $wms_transfer_to_total_package_number
 * @property string $wms_transfer_to_standard_weight
 * @property string $wms_transfer_to_off_standard_weight
 * @property string $wms_transfer_to_total_weight
 * @property integer $wms_transfer_to_wms_info_id
 * @property string $wms_transfer_to_wms_info_name
 * @property integer $wms_transfer_to_area_info_id
 * @property string $wms_transfer_to_area_info_name
 * @property string $wms_transfer_to_wms_position_info
 * @property integer $wms_transfer_wms_manager_id
 * @property string $wms_transfer_wms_manager_name
 * @property integer $wms_transfer_wms_manager_date
 * @property integer $wms_transfer_from_wms_manager_id
 * @property string $wms_transfer_from_wms_manager_name
 * @property integer $wms_transfer_from_wms_manager_date
 * @property integer $wms_transfer_to_wms_manager_id
 * @property string $wms_transfer_to_wms_manager_name
 * @property integer $wms_transfer_to_wms_manager_date
 * @property integer $wms_transfer_quality_manager_id
 * @property string $wms_transfer_quality_manager_name
 * @property integer $wms_transfer_quality_manager_date
 * @property integer $wms_transfer_status
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $is_del
 */
class WmsTransfer extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%wms_transfer}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['common_producer_info_id', 'wms_transfer_from_type', 'wms_transfer_from_herb_info_id', 'wms_transfer_from_grade_info_id', 'wms_transfer_from_place_info_id', 'wms_transfer_from_surplus_weight', 'wms_transfer_from_piece_type', 'wms_transfer_from_weight_per_package', 'wms_transfer_from_standard_package_number', 'wms_transfer_from_off_standard_package_number', 'wms_transfer_from_total_package_number', 'wms_transfer_from_standard_weight', 'wms_transfer_from_off_standard_weight', 'wms_transfer_from_total_weight', 'wms_transfer_from_wms_info_id', 'wms_transfer_from_area_info_id', 'wms_transfer_to_type', 'wms_transfer_to_herb_info_id', 'wms_transfer_to_grade_info_id', 'wms_transfer_to_place_info_id', 'wms_transfer_to_piece_type', 'wms_transfer_to_weight_per_package', 'wms_transfer_to_standard_package_number', 'wms_transfer_to_off_standard_package_number', 'wms_transfer_to_total_package_number', 'wms_transfer_to_standard_weight', 'wms_transfer_to_off_standard_weight', 'wms_transfer_to_total_weight', 'wms_transfer_to_wms_info_id', 'wms_transfer_to_area_info_id', 'wms_transfer_wms_manager_id', 'wms_transfer_wms_manager_date', 'wms_transfer_from_wms_manager_id', 'wms_transfer_from_wms_manager_date', 'wms_transfer_to_wms_manager_id', 'wms_transfer_to_wms_manager_date', 'wms_transfer_quality_manager_id', 'wms_transfer_quality_manager_date', 'wms_transfer_status', 'created_at', 'updated_at', 'is_del'], 'integer'],
            [['wms_transfer_from_wms_position_info', 'wms_transfer_to_wms_position_info'], 'string'],
            [['wms_transfer_code', 'wms_transfer_from_in_code', 'wms_transfer_from_code', 'wms_transfer_from_herb_info_name', 'wms_transfer_from_grade_info_name', 'wms_transfer_from_place_info_name', 'wms_transfer_from_wms_info_name', 'wms_transfer_from_area_info_name', 'wms_transfer_to_code', 'wms_transfer_to_herb_info_name', 'wms_transfer_to_grade_info_name', 'wms_transfer_to_place_info_name', 'wms_transfer_to_wms_info_name', 'wms_transfer_to_area_info_name', 'wms_transfer_wms_manager_name', 'wms_transfer_from_wms_manager_name', 'wms_transfer_to_wms_manager_name', 'wms_transfer_quality_manager_name'], 'string', 'max' => 32],
            [['common_producer_info_name'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '自增ID',
            'wms_transfer_code' => '库存调拨单编号',
            'common_producer_info_id' => '加工基地ID',
            'common_producer_info_name' => '加工基地名称',
            'wms_transfer_from_in_code' => '入库单号(起)',
            'wms_transfer_from_type' => '存货类型(起)',
            'wms_transfer_from_code' => '出库单号(起)',
            'wms_transfer_from_herb_info_id' => '存货ID(起)',
            'wms_transfer_from_herb_info_name' => '存货名称(起)',
            'wms_transfer_from_grade_info_id' => '等级ID(起)',
            'wms_transfer_from_grade_info_name' => '等级名称(起)',
            'wms_transfer_from_place_info_id' => '产地ID(起)',
            'wms_transfer_from_place_info_name' => '产地名称(起)',
            'wms_transfer_from_surplus_weight' => '剩余重量(起)',
            'wms_transfer_from_piece_type' => '计件类型(起)',
            'wms_transfer_from_weight_per_package' => '包装规格(起)',
            'wms_transfer_from_standard_package_number' => '标准件数(起)',
            'wms_transfer_from_off_standard_package_number' => '非标准件数(起)',
            'wms_transfer_from_total_package_number' => '总件数(起)',
            'wms_transfer_from_standard_weight' => '标准重量(起)',
            'wms_transfer_from_off_standard_weight' => '非标准重量(起)',
            'wms_transfer_from_total_weight' => '总重量(起)',
            'wms_transfer_from_wms_info_id' => '仓库ID(起)',
            'wms_transfer_from_wms_info_name' => '仓库名称(起)',
            'wms_transfer_from_area_info_id' => '库区ID(起)',
            'wms_transfer_from_area_info_name' => '库区名称(起)',
            'wms_transfer_from_wms_position_info' => '库位信息json保存(起)',
            'wms_transfer_to_type' => '存货类型(止)',
            'wms_transfer_to_code' => '入库单号(止)',
            'wms_transfer_to_herb_info_id' => '存货ID(止)',
            'wms_transfer_to_herb_info_name' => '存货名称(止)',
            'wms_transfer_to_grade_info_id' => '等级ID(止)',
            'wms_transfer_to_grade_info_name' => '等级名称(止)',
            'wms_transfer_to_place_info_id' => '产地ID(止)',
            'wms_transfer_to_place_info_name' => '产地名称(止)',
            'wms_transfer_to_piece_type' => '计件类型(止)',
            'wms_transfer_to_weight_per_package' => '包装规格(止)',
            'wms_transfer_to_standard_package_number' => '标准件数(止)',
            'wms_transfer_to_off_standard_package_number' => '非标准件数(止)',
            'wms_transfer_to_total_package_number' => '总件数(止)',
            'wms_transfer_to_standard_weight' => '标准重量(止)',
            'wms_transfer_to_off_standard_weight' => '非标准重量(止)',
            'wms_transfer_to_total_weight' => '总重量(止)',
            'wms_transfer_to_wms_info_id' => '仓库ID(止)',
            'wms_transfer_to_wms_info_name' => '仓库名称(止)',
            'wms_transfer_to_area_info_id' => '库区ID(止)',
            'wms_transfer_to_area_info_name' => '库区名称(止)',
            'wms_transfer_to_wms_position_info' => '库位信息json保存(止)',
            'wms_transfer_wms_manager_id' => '调拨申请人ID',
            'wms_transfer_wms_manager_name' => '调拨申请人',
            'wms_transfer_wms_manager_date' => '调拨申请日期',
            'wms_transfer_from_wms_manager_id' => '出库确认人ID',
            'wms_transfer_from_wms_manager_name' => '出库确认人',
            'wms_transfer_from_wms_manager_date' => '出库确认日期',
            'wms_transfer_to_wms_manager_id' => '入库确认人ID',
            'wms_transfer_to_wms_manager_name' => '入库确认人',
            'wms_transfer_to_wms_manager_date' => '入库确认日期',
            'wms_transfer_quality_manager_id' => '质量放行人ID',
            'wms_transfer_quality_manager_name' => '质量放行人',
            'wms_transfer_quality_manager_date' => '质量放行日期',
            'wms_transfer_status' => '库存调拨状态0为待调拨1为已完成',
            'created_at' => '创建时间',
            'updated_at' => '编辑时间',
            'is_del' => '是否逻辑删除',
        ];
    }
}

注意:

(1)生成的基本模型中包括rules生成的定义,以及attributeLabels

3.编写核心业务逻辑

core\models\WmsTransfer.php

<?php

namespace core\models;

use Yii;

class WmsTransfer extends \common\models\WmsTransfer
{
    const WMS_TYPE_MATERIAL = 1;//原料
    const WMS_TYPE_PRODUCT = 2;//成品
    const WMS_TYPE_PARTIAL = 3;//半成品

    const WMS_TRANSFER_STATUS_NOT = 0;
    const WMS_TRANSFER_STATUS_FINISH = 1;

    public $wms_transfer_to_type_name;//入库存货类型
    public $wms_transfer_from_piece_type_name;//出库计件类型
    public $wms_transfer_to_piece_type_name;//入库计件类型
    public $wms_transfer_from_in_code_copy;//关联单号的复制样本
    public $wms_transfer_from_grade_info_describe;
    public $wms_transfer_to_grade_info_describe;

    public function rules()
    {
        return [
            [['common_producer_info_id', 'wms_transfer_from_type', 'wms_transfer_from_herb_info_id', 'wms_transfer_from_grade_info_id', 'wms_transfer_from_place_info_id', 'wms_transfer_from_piece_type', 'wms_transfer_from_standard_package_number', 'wms_transfer_from_off_standard_package_number', 'wms_transfer_from_total_package_number', 'wms_transfer_from_wms_info_id', 'wms_transfer_from_area_info_id', 'wms_transfer_to_type', 'wms_transfer_to_herb_info_id', 'wms_transfer_to_grade_info_id', 'wms_transfer_to_place_info_id', 'wms_transfer_to_piece_type', 'wms_transfer_to_standard_package_number', 'wms_transfer_to_off_standard_package_number', 'wms_transfer_to_total_package_number', 'wms_transfer_to_wms_info_id', 'wms_transfer_to_area_info_id', 'wms_transfer_wms_manager_id',  'wms_transfer_status', 'created_at', 'updated_at', 'is_del'], 'integer'],
            [['wms_transfer_from_wms_position_info', 'wms_transfer_to_wms_position_info'], 'string'],
            [['wms_transfer_code', 'wms_transfer_from_in_code', 'wms_transfer_from_code', 'wms_transfer_from_herb_info_name', 'wms_transfer_from_grade_info_name', 'wms_transfer_from_place_info_name', 'wms_transfer_from_wms_info_name', 'wms_transfer_from_area_info_name', 'wms_transfer_to_code', 'wms_transfer_to_herb_info_name', 'wms_transfer_to_grade_info_name', 'wms_transfer_to_place_info_name', 'wms_transfer_to_wms_info_name', 'wms_transfer_to_area_info_name', 'wms_transfer_wms_manager_name'], 'string', 'max' => 32],
            [['common_producer_info_name'], 'string', 'max' => 50],

            //增加字段的验证
            [['wms_transfer_from_wms_manager_id', 'wms_transfer_to_wms_manager_id', 'wms_transfer_quality_manager_id'], 'integer'],

            //验证为数字
            [['wms_transfer_from_surplus_weight'], 'number'],
            [['wms_transfer_from_weight_per_package'], 'number'],
            [['wms_transfer_from_standard_weight'], 'number'],
            [['wms_transfer_from_off_standard_weight'], 'number'],
            [['wms_transfer_from_total_weight'], 'number'],
            [['wms_transfer_to_weight_per_package'], 'number'],
            [['wms_transfer_to_standard_weight'], 'number'],
            [['wms_transfer_to_off_standard_weight'], 'number'],
            [['wms_transfer_to_total_weight'], 'number'],

            //验证为字符串
            [['wms_transfer_from_in_code_copy'], 'string'],
            [['wms_transfer_from_grade_info_describe'], 'string'],
            [['wms_transfer_to_grade_info_describe'], 'string'],
            [['wms_transfer_wms_manager_date'], 'string'],
            [['wms_transfer_from_wms_manager_name'], 'string'],
            [['wms_transfer_from_wms_manager_date'], 'string'],
            [['wms_transfer_to_wms_manager_name'], 'string'],
            [['wms_transfer_to_wms_manager_date'], 'string'],
            [['wms_transfer_quality_manager_name'], 'string'],
            [['wms_transfer_quality_manager_date'], 'string'],

            //定义验证场景及验证规则
            [['wms_transfer_from_type'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_from_in_code'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_from_total_package_number'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_from_total_weight'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_type'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_grade_info_id'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_piece_type'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_total_package_number'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_total_weight'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_wms_info_id'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_area_info_id'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_wms_manager_id'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_wms_manager_date'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_from_wms_manager_id'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_from_wms_manager_date'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_wms_manager_id'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_to_wms_manager_date'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_quality_manager_id'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            [['wms_transfer_quality_manager_date'], 'required', 'message'=>'不能为空', 'on'=>['scenario_create', 'scenario_update']],
            //验证入库库区不能和出库库区一样
            ['wms_transfer_to_area_info_id', 'compare', 'compareAttribute' => 'wms_transfer_from_area_info_id', 'operator' => '!=', 'message'=>'入库库区不能与出库库区相同']
            ];
    }

    public function __construct(array $config = [])
    {
        $this->common_producer_info_id = \core\models\WmsTransfer::getCommonProducerInfoId();
        parent::__construct($config);
        return $this;
    }

    public function beforeValidate()
    {
        return parent::beforeValidate();
    }

    /**
     * @param bool $insert
     * @return bool
     * 保存数据前
     */
    public function beforeSave($insert)
    {
        if (in_array($this->getScenario(), ['scenario_create', 'scenario_update'])) {
            $wmsInSheetInfo = \core\models\WmsTransfer::getWmsInSheetInfo($this->wms_transfer_from_in_code);

            $this->common_producer_info_name = \core\models\WmsTransfer::getCommonProducerInfoName($this->common_producer_info_id);

            $this->wms_transfer_from_herb_info_id = $wmsInSheetInfo['wms_transfer_from_herb_info_id'];
            $this->wms_transfer_from_herb_info_name = $wmsInSheetInfo['wms_transfer_from_herb_info_name'];
            $this->wms_transfer_from_grade_info_id = $wmsInSheetInfo['wms_transfer_from_grade_info_id'];
            $this->wms_transfer_from_grade_info_name = $wmsInSheetInfo['wms_transfer_from_grade_info_name'];
            $this->wms_transfer_from_place_info_id = $wmsInSheetInfo['wms_transfer_from_place_info_id'];
            $this->wms_transfer_from_place_info_name = $wmsInSheetInfo['wms_transfer_from_place_info_name'];
            $this->wms_transfer_from_piece_type = $wmsInSheetInfo['wms_transfer_from_piece_type'];
            $this->wms_transfer_from_weight_per_package = $wmsInSheetInfo['wms_transfer_from_weight_per_package'];
//            $this->wms_transfer_from_standard_package_number = $wmsInSheetInfo['wms_transfer_from_standard_package_number'];
//            $this->wms_transfer_from_off_standard_package_number = $wmsInSheetInfo['wms_transfer_from_off_standard_package_number'];
//            $this->wms_transfer_from_total_package_number = $wmsInSheetInfo['wms_transfer_from_total_package_number'];
//            $this->wms_transfer_from_standard_weight = $wmsInSheetInfo['wms_transfer_from_standard_weight'];
//            $this->wms_transfer_from_off_standard_weight = $wmsInSheetInfo['wms_transfer_from_off_standard_weight'];
//            $this->wms_transfer_from_total_weight = $wmsInSheetInfo['wms_transfer_from_total_weight'];
            $this->wms_transfer_from_wms_info_id = $wmsInSheetInfo['wms_transfer_from_wms_info_id'];
            $this->wms_transfer_from_wms_info_name = $wmsInSheetInfo['wms_transfer_from_wms_info_name'];
            $this->wms_transfer_from_area_info_id = $wmsInSheetInfo['wms_transfer_from_area_info_id'];
            $this->wms_transfer_from_area_info_name = $wmsInSheetInfo['wms_transfer_from_area_info_name'];
            $this->wms_transfer_from_wms_position_info = json_encode($wmsInSheetInfo['wms_transfer_from_wms_position_info']);

            $this->wms_transfer_to_herb_info_name = \core\models\WmsTransfer::getHerbInfoName($this->wms_transfer_to_herb_info_id, $this->wms_transfer_to_type);
            $this->wms_transfer_to_grade_info_name = \core\models\WmsTransfer::getGradeInfoName($this->wms_transfer_to_grade_info_id, $this->wms_transfer_to_type);
            $this->wms_transfer_to_place_info_name = \core\models\WmsTransfer::getPlaceInfoName($this->wms_transfer_to_place_info_id);
            $this->wms_transfer_to_wms_info_name = \core\models\WmsTransfer::getWmsInfoName($this->wms_transfer_to_wms_info_id);
            $this->wms_transfer_to_area_info_name = \core\models\WmsTransfer::getAreaInfoName($this->wms_transfer_to_area_info_id);

            $this->wms_transfer_wms_manager_name = \core\models\WmsTransfer::getUserName($this->wms_transfer_wms_manager_id);
            $this->wms_transfer_from_wms_manager_name = \core\models\WmsTransfer::getUserName($this->wms_transfer_from_wms_manager_id);
            $this->wms_transfer_to_wms_manager_name = \core\models\WmsTransfer::getUserName($this->wms_transfer_to_wms_manager_id);
            $this->wms_transfer_quality_manager_name = \core\models\WmsTransfer::getUserName($this->wms_transfer_quality_manager_id);
            $this->wms_transfer_status = \core\models\WmsTransfer::WMS_TRANSFER_STATUS_NOT;
            $this->updated_at = time();
            $this->prepareSave();
        }
        return parent::beforeSave($insert);
    }

    /**
     * 显示前处理数据
     */
    public function prepareShow(){
        $this->wms_transfer_from_surplus_weight = \common\models\Base::weightBcdiv($this->wms_transfer_from_surplus_weight);

        $this->wms_transfer_from_weight_per_package = \common\models\Base::weightBcdiv($this->wms_transfer_from_weight_per_package);
        $this->wms_transfer_from_standard_weight = \common\models\Base::weightBcdiv($this->wms_transfer_from_standard_weight);
        $this->wms_transfer_from_off_standard_weight = \common\models\Base::weightBcdiv($this->wms_transfer_from_off_standard_weight);
        $this->wms_transfer_from_total_weight = \common\models\Base::weightBcdiv($this->wms_transfer_from_total_weight);
        $this->wms_transfer_to_weight_per_package = \common\models\Base::weightBcdiv($this->wms_transfer_to_weight_per_package);
        $this->wms_transfer_to_standard_weight = \common\models\Base::weightBcdiv($this->wms_transfer_to_standard_weight);
        $this->wms_transfer_to_off_standard_weight = \common\models\Base::weightBcdiv($this->wms_transfer_to_off_standard_weight);
        $this->wms_transfer_to_total_weight = \common\models\Base::weightBcdiv($this->wms_transfer_to_total_weight);
        $this->wms_transfer_wms_manager_date = date('Y-m-d', $this->wms_transfer_wms_manager_date);
        $this->wms_transfer_from_wms_manager_date = date('Y-m-d', $this->wms_transfer_from_wms_manager_date);
        $this->wms_transfer_to_wms_manager_date = date('Y-m-d', $this->wms_transfer_to_wms_manager_date);
        $this->wms_transfer_quality_manager_date = date('Y-m-d', $this->wms_transfer_quality_manager_date);
    }

    /**
     * 保存前处理数据
     */
    public function prepareSave(){
        $this->wms_transfer_from_surplus_weight = \common\models\Base::weightBcmul($this->wms_transfer_from_surplus_weight);

        $this->wms_transfer_from_weight_per_package = \common\models\Base::weightBcmul($this->wms_transfer_from_weight_per_package);
        $this->wms_transfer_from_standard_weight = \common\models\Base::weightBcmul($this->wms_transfer_from_standard_weight);
        $this->wms_transfer_from_off_standard_weight = \common\models\Base::weightBcmul($this->wms_transfer_from_off_standard_weight);
        $this->wms_transfer_from_total_weight = \common\models\Base::weightBcmul($this->wms_transfer_from_total_weight);
        $this->wms_transfer_to_weight_per_package = \common\models\Base::weightBcmul($this->wms_transfer_to_weight_per_package);
        $this->wms_transfer_to_standard_weight = \common\models\Base::weightBcmul($this->wms_transfer_to_standard_weight);
        $this->wms_transfer_to_off_standard_weight = \common\models\Base::weightBcmul($this->wms_transfer_to_off_standard_weight);
        $this->wms_transfer_to_total_weight = \common\models\Base::weightBcmul($this->wms_transfer_to_total_weight);
        $this->wms_transfer_wms_manager_date = strtotime($this->wms_transfer_wms_manager_date);
        $this->wms_transfer_from_wms_manager_date = strtotime($this->wms_transfer_from_wms_manager_date);
        $this->wms_transfer_to_wms_manager_date = strtotime($this->wms_transfer_to_wms_manager_date);
        $this->wms_transfer_quality_manager_date = strtotime($this->wms_transfer_quality_manager_date);
    }

    /**
     * @return array
     * 保存库存调拨单及其库位信息
     */
    public function saveWmsTransferAndPosition(){
        $transaction = \Yii::$app->db->beginTransaction();
        try{
            $saveHandler = $this->save();
            if (!$saveHandler){
                throw new \yii\db\Exception('库存调拨单'.$this->wms_transfer_code.'基本信息保存失败');
            }
            $genHandler = \core\models\WmsTransfer2::genWmsSheet($this);
            if (!$genHandler['status']){
                throw new \yii\db\Exception($genHandler['message']);
            }
            $saveWmsOutPositon = $this->saveWmsOutPositon($genHandler['data']['handler_out_id']);
            if (!$saveWmsOutPositon['status']){
                throw new \yii\db\Exception($saveWmsOutPositon['errmsg']);
            }
            $saveWmsInPosition = $this->saveWmsInPosition($genHandler['data']['handler_in_id']);
            if (!$saveWmsInPosition['status']){
                throw new \yii\db\Exception($saveWmsInPosition['errmsg']);
            }

            $transaction->commit();
            return ['status'=>true, 'errcode'=>'', 'errmsg'=>'库存调拨单'.$this->wms_transfer_code.'保存成功'];
        }catch(\yii\db\Exception $e){
            $transaction->rollBack();
            die($e->getMessage());
            return ['status'=>false, 'errcode'=>'', 'errmsg'=>$e->getMessage()];
        }
    }

    /**
     * @return bool
     * 保存出库库位信息
     */
    public function saveWmsOutPositon($out_sheet_id){
        \core\models\WmsOutSheetPositionRelationRecord::deleteAll(["relative_code"=>$this->wms_transfer_code]);

        if((Yii::$app->request->post('WmsOutSheetPositionRelationRecord'))){
            $transaction = \Yii::$app->db->beginTransaction();
            try {
                foreach (Yii::$app->request->post('WmsOutSheetPositionRelationRecord') as $key => $value) {
                    $wmsOutSheetPositionRelationRecord = new WmsOutSheetPositionRelationRecord();
                    $wmsOutSheetPositionRelationRecord->setAttributes($value);
                    $wmsOutSheetPositionRelationRecord->common_producer_material_type_info_id = $this->wms_transfer_from_type;
                    $wmsAreaInfo = CommonProducerWmsAreaInfo::findOne(["id" => $this->wms_transfer_from_area_info_id]);
                    $wmsInfo = CommonProducerWmsInfo::findOne(["id" => $wmsAreaInfo->common_producer_wms_info_id]);
                    $wmsOutSheetPositionRelationRecord->common_producer_wms_position_info_code = $wmsInfo->common_producer_wms_info_wms_code . "-" . $wmsAreaInfo->common_producer_wms_area_info_area_code . "-"
                        . $wmsOutSheetPositionRelationRecord->common_producer_wms_position_info_code;
                    $wmsOutSheetPositionRelationRecord->common_producer_wms_position_info_id = CommonProducerWmsPositionInfo::findOne(["common_producer_wms_area_info_id" => $this->wms_transfer_from_area_info_id,
                        "common_producer_wms_position_info_code" => $wmsOutSheetPositionRelationRecord->common_producer_wms_position_info_code])->id;
                    $wmsOutSheetPositionRelationRecord->common_producer_info_id = $this->common_producer_info_id;
                    $wmsOutSheetPositionRelationRecord->common_producer_herb_info_id = $this->wms_transfer_from_herb_info_id;
                    $wmsOutSheetPositionRelationRecord->common_producer_herb_grade_info_id = $this->wms_transfer_from_grade_info_id;
                    $wmsOutSheetPositionRelationRecord->common_producer_herb_place_info_id = $this->wms_transfer_from_place_info_id;
                    $wmsOutSheetPositionRelationRecord->wms_out_sheet_position_relation_record_relative_id = $out_sheet_id;
                    $wmsOutSheetPositionRelationRecord->wms_out_sheet_position_relation_record_sheet_number = $this->wms_transfer_from_code;
                    $wmsOutSheetPositionRelationRecord->relative_id = $this->id;
                    $wmsOutSheetPositionRelationRecord->relative_id = $this->wms_transfer_code;
                    $wmsOutSheetPositionRelationRecord->wms_stock_position_relation_weight = \common\models\Base::weightBcmul($wmsOutSheetPositionRelationRecord->wms_stock_position_relation_weight);
                    if(!$wmsOutSheetPositionRelationRecord->save(false)){
                        throw new \yii\db\Exception('保存出库库位信息失败');
                    }
                }
                $transaction->commit();
                return ['status'=>true, 'errcode'=>'', 'errmsg'=>''];
            }catch (\yii\db\Exception $e){
                $transaction->rollBack();
                return ['status'=>false, 'errcode'=>'', 'errmsg'=>$e->getMessage()];
            }
        }else{
            return ['status'=>true, 'errcode'=>'', 'errmsg'=>''];
        }
    }

    /**
     * @return bool
     * 保存入库库位信息
     */
    public function saveWmsInPosition($in_sheet_id){

        \core\models\WmsInSheetPositionRelationRecord::deleteAll(["relative_code"=>$this->wms_transfer_code]);

        if((Yii::$app->request->post('WmsInSheetPositionRelationRecord'))){
            $transaction = \Yii::$app->db->beginTransaction();
            try {
                foreach (Yii::$app->request->post('WmsInSheetPositionRelationRecord') as $key => $value) {
                    $wmsInSheetPositionRelationRecord = new WmsInSheetPositionRelationRecord();
                    $wmsInSheetPositionRelationRecord->setAttributes($value);
                    $wmsAreaInfo = CommonProducerWmsAreaInfo::findOne(["id" => $this->wms_transfer_to_area_info_id]);
                    $wmsInfo = CommonProducerWmsInfo::findOne(["id" => $wmsAreaInfo->common_producer_wms_info_id]);
                    $wmsInSheetPositionRelationRecord->common_producer_wms_position_info_code = $wmsInfo->common_producer_wms_info_wms_code . "-" . $wmsAreaInfo->common_producer_wms_area_info_area_code . "-"
                        . $wmsInSheetPositionRelationRecord->common_producer_wms_position_info_code;
                    $wmsInSheetPositionRelationRecord->common_producer_wms_position_info_id = CommonProducerWmsPositionInfo::findOne(["common_producer_wms_area_info_id" => $wmsAreaInfo->id,
                        "common_producer_wms_position_info_code" => $wmsInSheetPositionRelationRecord->common_producer_wms_position_info_code])->id;
                    $wmsInSheetPositionRelationRecord->wms_in_sheet_position_relation_record_relative_id = 0;
                    $wmsInSheetPositionRelationRecord->common_producer_info_id = $this->common_producer_info_id;
                    $wmsInSheetPositionRelationRecord->common_producer_herb_info_id = $this->wms_transfer_to_herb_info_id;
                    $wmsInSheetPositionRelationRecord->common_producer_herb_grade_info_id = $this->wms_transfer_to_grade_info_id;
                    $wmsInSheetPositionRelationRecord->common_producer_herb_place_info_id = $this->wms_transfer_to_place_info_id;
                    $wmsInSheetPositionRelationRecord->wms_in_sheet_position_relation_record_relative_id = $in_sheet_id;
                    $wmsInSheetPositionRelationRecord->wms_in_sheet_position_relation_record_sheet_number = $this->wms_transfer_to_code;
                    $wmsInSheetPositionRelationRecord->relative_id = $this->id;
                    $wmsInSheetPositionRelationRecord->relative_code = $this->wms_transfer_code;
                    $wmsInSheetPositionRelationRecord->wms_stock_position_relation_weight = \common\models\Base::weightBcmul($wmsInSheetPositionRelationRecord->wms_stock_position_relation_weight);

                    if(!$wmsInSheetPositionRelationRecord->save(false)){
                        throw new \yii\db\Exception('保存入库库位信息失败');
                    }
                }
                $transaction->commit();
                return ['status'=>true, 'errcode'=>'', 'errmsg'=>''];
            }catch (\yii\db\Exception $e){
                $transaction->rollBack();
                return ['status'=>false, 'errcode'=>'', 'errmsg'=>$e->getMessage()];
            }
        }else{
            return ['status'=>true, 'errcode'=>'', 'errmsg'=>''];
        }
    }
    /**
     * @return \yii\db\ActiveQuery
     * 关联出库相关库位信息
     */
    public function getWmsStockPositionRelation(){
        return $this->hasMany(\core\models\WmsStockPositionRelation::className(), ['wms_stock_detail_info_relation_good_in_sheet_number'=>'wms_transfer_from_in_code']);
    }

    public function getWmsStockDetailInfo(){
        return $this->hasOne(\core\models\WmsStockDetailInfo::className(), ['wms_stock_detail_info_relation_good_in_sheet_number'=>'wms_transfer_from_in_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联原料入库单
     */
    public function getWmsMaterialInSheet(){
        return $this->hasOne(\core\models\WmsMaterialInSheet::className(), ['wms_material_in_sheet_number'=>'wms_transfer_from_in_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联成品入库单
     */
    public function getWmsProductInSheet(){
        return $this->hasOne(\core\models\WmsProductInSheet::className(), ['wms_product_in_sheet_number'=>'wms_transfer_from_in_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联半成品入库单
     */
    public function getWmsPartiallyProductInSheet(){
        return $this->hasOne(\core\models\WmsPartiallyProductInSheet::className(), ['wms_partially_product_in_sheet_number'=>'wms_transfer_from_in_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联生成的原料入库单
     */
    public function getGeneratedWmsMaterialInSheet(){
        return $this->hasOne(\core\models\WmsMaterialInSheet::className(), ['wms_material_in_sheet_number'=>'wms_transfer_to_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联生成的成品入库单
     */
    public function getGeneratedWmsProductInSheet(){
        return $this->hasOne(\core\models\WmsProductInSheet::className(), ['wms_product_in_sheet_number'=>'wms_transfer_to_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联生成的半成品入库单
     */
    public function getGeneratedWmsPartiallyProductInSheet(){
        return $this->hasOne(\core\models\WmsPartiallyProductInSheet::className(), ['wms_partially_product_in_sheet_number'=>'wms_transfer_to_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联生成的原料出库单
     */
    public function getGeneratedWmsMaterialOutSheet(){
        return $this->hasOne(\core\models\WmsMaterialOutSheet::className(), ['wms_material_out_sheet_number'=>'wms_transfer_from_code']);
    }

    public function getGeneratedWmsMaterialOutSheetDetail(){
        return $this->hasOne(\core\models\WmsMaterialOutSheetDetail::className(), ['wms_material_out_sheet_number'=>'wms_transfer_from_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联生成的成品出库单
     */
    public function getGeneratedWmsProductOutSheet(){
        return $this->hasOne(\core\models\WmsProductOutSheet::className(), ['wms_product_out_sheet_number'=>'wms_transfer_from_code']);
    }

    public function getGeneratedWmsProductOutDetailInfo(){
        return $this->hasOne(\core\models\WmsProductOutDetailInfo::className(), ['wms_product_out_sheet_number'=>'wms_transfer_from_code']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联生成的半成品出库单
     */
    public function getGeneratedWmsPartiallyProductOutSheet(){
        return $this->hasOne(\core\models\WmsPartiallyProductOutSheet::className(), ['wms_partially_product_out_sheet_number'=>'wms_transfer_from_code']);
    }

    public function getGeneratedWmsPartiallyProductOutDetailInfo(){
        return $this->hasOne(\core\models\WmsPartiallyProductOutDetailInfo::className(), ['wms_partially_product_out_sheet_number'=>'wms_transfer_from_code']);
    }

    /**
     * @param $inSheetNumber
     * @return null|static
     * 关联原料入库单
     */
    public static function getWmsMaterialInSheetByCode($inSheetNumber){
        return \core\models\WmsMaterialInSheet::findOne(['wms_material_in_sheet'=>$inSheetNumber]);
    }

    /**
     * @param $inSheetNumber
     * @return null|static
     * 关联成品入库单
     */
    public static function getWmsProductInSheetByCode($inSheetNumber){
        return \core\models\WmsProductInSheet::findOne(['wms_product_in_sheet_number'=>$inSheetNumber]);
    }

    /**
     * @param $inSheetNumber
     * @return null|static
     * 关联半成品入库单
     */
    public static function getWmsPartiallyProductInSheetByCode($inSheetNumber){
        return \core\models\WmsPartiallyProductInSheet::findOne(['wms_partially_product_in_sheet_number'=>$inSheetNumber]);
    }

    /**
     * @param $inSheetNumber
     * @return null|static
     * 获取库存快照
     */
    public static function getWmsStockDetailInfoByCode($inSheetNumber){
        return \core\models\WmsStockDetailInfo::findOne(['wms_stock_detail_info_relation_good_in_sheet_number'=>$inSheetNumber]);
    }

    public function deleteGeneratedSheet(){
        $transaction = \Yii::$app->db->beginTransaction();
        try {
            if (isset($this->generatedWmsMaterialInSheet)) {
                $generatedWmsMaterialInSheet = $this->generatedWmsMaterialInSheet;
                $generatedWmsMaterialInSheet->is_del = 1;
                if (!$generatedWmsMaterialInSheet->save(false, ['is_del'])) {
                    throw new \yii\db\Exception('原来入库单'.$generatedWmsMaterialInSheet->wms_material_in_sheet_number.'作废失败');
                }
            }
        }catch(\yii\db\Exception $e){
            throw new \yii\db\Exception($e->getMessage());
        }

    }

    /**
     * @param $inSheetNumber
     * @return static[]
     * 获取库位详细信息
     */
    public static function getWmsStockPositionRelationByCode($inSheetNumber){
        return \core\models\WmsStockPositionRelation::findNotDel()->select([
            'common_producer_wms_position_info_code AS wms_position_code',
            'wms_stock_position_relation_package_number AS package_number',
            'wms_stock_position_relation_weight AS weight',
        ])->where(['wms_stock_detail_info_relation_good_in_sheet_number'=>$inSheetNumber])->asArray()->all();
    }

    /**
     * @return array
     * 获取定义所有存货类型
     */
    public static function getWmsTypeOptions($fromWmsType=null){
        if (empty($fromWmsType)){
            return [
                1=>'原料',
                2=>'成品',
                3=>'半成品',
            ];
        }elseif(self::WMS_TYPE_MATERIAL == $fromWmsType){
            return [
                1=>'原料',
            ];
        }elseif(self::WMS_TYPE_PRODUCT == $fromWmsType){
            return [
                2=>'成品',
                3=>'半成品',
            ];
        }elseif(self::WMS_TYPE_PARTIAL == $fromWmsType){
            return [
                2=>'成品',
                3=>'半成品',
            ];
        }else{
            return [];
        }
    }

    /**
     * @param $wmsType
     * @return string
     * 获取显示存货类型名称
     */
    public function getWmsTypeName($wmsType){
        $wmsTypeName = '';
        switch ($wmsType){
            case self::WMS_TYPE_MATERIAL:
                $wmsTypeName = '原料';
                break;
            case self::WMS_TYPE_PRODUCT:
                $wmsTypeName = '成品';
                break;
            case self::WMS_TYPE_PARTIAL:
                $wmsTypeName = '半成品';
                break;
            default:
                $wmsTypeName = '';
                break;
        }
        return $wmsTypeName;
    }

    /**
     * @return string
     * 生成库存调拨编号
     */
    public static function genWmsTransferCode(){
        $prefix = 'KCDB';
        $common_producer_info_id = \core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true);
        $modelClass = new self();
        $columnName = 'wms_transfer_code';
        return self::generateCode($prefix, $common_producer_info_id, $modelClass, $columnName);
    }

    /**
     * @param $wmsType
     * @return string
     * 根据存货类型获取出库单号
     */
    public static function genWmsOutCode($wmsType){
        $common_producer_info_id = \core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true);

        switch ($wmsType){
            case self::WMS_TYPE_MATERIAL:
                $prefix = 'YLCK';
                $modelClass = new \core\models\WmsMaterialOutSheet();
                $columnName = 'wms_material_out_sheet_number';
                break;
            case self::WMS_TYPE_PRODUCT:
                $prefix = 'CPCK';
                $modelClass = new \core\models\WmsProductOutSheet();
                $columnName = 'wms_product_out_sheet_number';
                break;
            case self::WMS_TYPE_PARTIAL:
                $prefix = 'BCPCK';
                $modelClass = new \core\models\WmsPartiallyProductOutSheet();
                $columnName = 'wms_partially_product_out_sheet_number';
                break;
            default:
                $prefix = '';
                $modelClass = null;
                $columnName = '';
                break;
        }
        return self::generateCode($prefix, $common_producer_info_id, $modelClass, $columnName);
    }

    /**
     * @param $wmsType
     * @return string
     * 根据存货类型获取入库单编号
     */
    public static function genWmsInCode($wmsType){
        $common_producer_info_id = \core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true);

        switch ($wmsType){
            case self::WMS_TYPE_MATERIAL:
                $prefix = 'YLRK';
                $modelClass = new \core\models\WmsMaterialInSheet();
                $columnName = 'wms_material_in_sheet_number';
                break;
            case self::WMS_TYPE_PRODUCT:
                $prefix = 'CPRK';
                $modelClass = new \core\models\WmsProductInSheet();
                $columnName = 'wms_product_in_sheet_number';
                break;
            case self::WMS_TYPE_PARTIAL:
                $prefix = 'BCPRK';
                $modelClass = new \core\models\WmsPartiallyProductInSheet();
                $columnName = 'wms_partially_product_in_sheet_number';
                break;
            default:
                $prefix = '';
                $modelClass = null;
                $columnName = '';
                break;
        }
        return self::generateCode($prefix, $common_producer_info_id, $modelClass, $columnName);
    }

    /**
     * @param $wmsType
     * @return array
     * 根据存货类型选择入库单号列表
     */
    public static function getInSheetNumberMap($wmsType, $common_producer_info_id){
        $wmsStockDetailInfoList =  \core\models\WmsStockDetailInfo::findNotDel()->select(['wms_stock_detail_info_relation_good_in_sheet_number AS in_sheet_number'])->where(['and',
            ['>', 'wms_stock_detail_info_weight', 0],
            ['common_producer_material_type_info_id'=>$wmsType],
            ['common_producer_info_id'=>$common_producer_info_id],
        ])->orderBy(['id'=>SORT_ASC])->asArray()->all();
        return $wmsStockDetailInfoList;
    }

    /**
     * @param $inSheetNumber
     * @return array
     * 根据入库单号获取详细信息
     */
    public static function getWmsInSheetInfo($inSheetNumber){
        $wmsInSheetInfo = [];
        $wmsStockDetailInfoModel = \core\models\WmsTransfer::getWmsStockDetailInfoByCode($inSheetNumber);
        $wms_transfer_from_piece_type_name = \core\models\WmsManager::getPieceTypeName($wmsStockDetailInfoModel->piece_type);
        $wms_transfer_from_wms_info_name = '';
        if (!empty($wmsInfoModel = \core\models\CommonProducerWmsInfo::findOne(["id" => $wmsStockDetailInfoModel->common_producer_wms_info_id]))){
            $wms_transfer_from_wms_info_name = $wmsInfoModel->common_producer_wms_info_wms_name;
        }
        $wms_transfer_from_area_info_name = '';
        if (!empty($areaInfoModel = \core\models\CommonProducerWmsAreaInfo::findOne(["id" => $wmsStockDetailInfoModel->common_producer_wms_area_info_id]))){
            $wms_transfer_from_area_info_name = $areaInfoModel->common_producer_wms_area_info_wms_area;
        }
        $wms_transfer_from_wms_position_info = [];
        $wmsStockPositionRelationList = \core\models\WmsTransfer::getWmsStockPositionRelationByCode($inSheetNumber);
        foreach ($wmsStockPositionRelationList as $wmsStockPositionRelation){
            $wms_transfer_from_wms_position_info[] = [
                'wms_position_code'=>$wmsStockPositionRelation['wms_position_code'],
                'package_number'=>$wmsStockPositionRelation['package_number'],
                'weight'=>\common\models\Base::weightBcdiv($wmsStockPositionRelation['weight']),
            ];
        }
        $wmsInSheetInfo = [
            'wms_transfer_from_herb_info_id'=>!empty($wmsStockDetailInfoModel->common_producer_herb_info_id) ? $wmsStockDetailInfoModel->common_producer_herb_info_id : 0,
            'wms_transfer_from_herb_info_name'=>!empty($wmsStockDetailInfoModel->common_producer_herb_info_name) ? $wmsStockDetailInfoModel->common_producer_herb_info_name : '',
            'wms_transfer_from_grade_info_id'=>!empty($wmsStockDetailInfoModel->common_producer_herb_grade_info_id) ? $wmsStockDetailInfoModel->common_producer_herb_grade_info_id : 0,
            'wms_transfer_from_grade_info_name'=>!empty($wmsStockDetailInfoModel->common_producer_herb_grade_name) ? $wmsStockDetailInfoModel->common_producer_herb_grade_name : '',
            'wms_transfer_from_place_info_id'=>!empty($wmsStockDetailInfoModel->common_producer_herb_place_info_id) ? $wmsStockDetailInfoModel->common_producer_herb_place_info_id : 0,
            'wms_transfer_from_place_info_name'=>!empty($wmsStockDetailInfoModel->common_producer_herb_place_info_name) ? $wmsStockDetailInfoModel->common_producer_herb_place_info_name : '',
            'wms_transfer_from_piece_type'=>!empty($wmsStockDetailInfoModel->piece_type) ? $wmsStockDetailInfoModel->piece_type : 0,
            'wms_transfer_from_piece_type_name'=>$wms_transfer_from_piece_type_name,
            'wms_transfer_from_weight_per_package'=>!empty($wmsStockDetailInfoModel->wms_in_sheet_weight_per_package) ? \common\models\Base::weightBcdiv($wmsStockDetailInfoModel->wms_in_sheet_weight_per_package) : 0,
            'wms_transfer_from_standard_package_number'=>!empty($wmsStockDetailInfoModel->standard_package_number) ? $wmsStockDetailInfoModel->standard_package_number : 0,
            'wms_transfer_from_off_standard_package_number'=>!empty($wmsStockDetailInfoModel->off_standard_package_number) ? $wmsStockDetailInfoModel->off_standard_package_number : 0,
            'wms_transfer_from_total_package_number'=>!empty($wmsStockDetailInfoModel->wms_stock_detail_info_operation_package_number_after) ? $wmsStockDetailInfoModel->wms_stock_detail_info_operation_package_number_after : 0,
            'wms_transfer_from_standard_weight'=>!empty($wmsStockDetailInfoModel->standard_weight) ? \common\models\Base::weightBcdiv($wmsStockDetailInfoModel->standard_weight) : 0,
            'wms_transfer_from_off_standard_weight'=>!empty($wmsStockDetailInfoModel->off_standard_weight) ? \common\models\Base::weightBcdiv($wmsStockDetailInfoModel->off_standard_weight) : 0,
            'wms_transfer_from_total_weight'=>!empty($wmsStockDetailInfoModel->wms_stock_detail_info_weight) ? \common\models\Base::weightBcdiv($wmsStockDetailInfoModel->wms_stock_detail_info_weight) : 0,
            'wms_transfer_from_wms_info_id'=>!empty($wmsStockDetailInfoModel->common_producer_wms_info_id) ? $wmsStockDetailInfoModel->common_producer_wms_info_id : 0,
            'wms_transfer_from_wms_info_name'=>$wms_transfer_from_wms_info_name,
            'wms_transfer_from_area_info_id'=>!empty($wmsStockDetailInfoModel->common_producer_wms_area_info_id) ? $wmsStockDetailInfoModel->common_producer_wms_area_info_id : 0,
            'wms_transfer_from_area_info_name'=>$wms_transfer_from_area_info_name,
            'wms_transfer_from_wms_position_info'=>$wms_transfer_from_wms_position_info,
            'wms_transfer_to_grade_info_describe'=>\core\models\WmsTransfer::getGradeDescribeByInSheetNumber($inSheetNumber),
        ];
        return $wmsInSheetInfo;
    }

    /**
     * @return string
     * 显示调拨单号
     */
    public function getWmsTransferCode(){
        $html = \yii\helpers\Html::a($this->wms_transfer_code, ['view', 'id'=>$this->id]);
        if (!empty($this->is_del)){
            $html .= '<span style="color: red;">(已作废)</span>';
        }
        return $html;
    }

    /**
     * @return string
     * 显示调拨内容
     */
    public function getWmsTransferContent(){
        $html = '';
        $html .= \core\models\WmsTransfer::getWmsTypeName($this->wms_transfer_from_type);
        $html .= ':';
        $html .= $this->wms_transfer_from_wms_info_name.$this->wms_transfer_from_area_info_name;
        $html .= '(';
        $html .= $this->wms_transfer_from_total_package_number.'件'.\common\models\Base::weightBcdiv($this->wms_transfer_from_total_weight).'公斤';
        $html .= ')';
        $html .= '<span style="font-size: 8px;"> 调拨至  </span>';
        $html .= \core\models\WmsTransfer::getWmsTypeName($this->wms_transfer_to_type);
        $html .= ':';
        $html .= $this->wms_transfer_to_wms_info_name.$this->wms_transfer_to_area_info_name;
        $html .= '(';
        $html .= $this->wms_transfer_to_total_package_number.'件'.\common\models\Base::weightBcdiv($this->wms_transfer_to_total_weight).'公斤';
        $html .= ')';
        return $html;
    }

    /**
     * @return string
     * 获取调拨单状态
     */
    public function getWmsTrasferStatusName(){
        $html = '';
        if (\core\models\WmsTransfer::WMS_TRANSFER_STATUS_NOT == $this->wms_transfer_status){
            $html .= '<span style="color: red;">待调拨</span>';
        }elseif(\core\models\WmsTransfer::WMS_TRANSFER_STATUS_FINISH == $this->wms_transfer_status){
            $html .= '<span style="color: green;">已完成</span>';
        }else{
            $html .= '';
        }
        return $html;
    }

    public function getWmsTransferFromInCode(){
        if (empty($this->wms_transfer_from_in_code)){
            $html = '<span style="color: red;">(未设置)</span>';
        }elseif (\core\models\WmsTransfer::WMS_TYPE_MATERIAL == $this->wms_transfer_from_type) {
            $wmsMaterialInSheetModel = $this->wmsMaterialInSheet;
            $html = \yii\helpers\Html::a($wmsMaterialInSheetModel->wms_material_in_sheet_number, ['wms-material-in-sheet/view', 'id' => $wmsMaterialInSheetModel->id]);
        } elseif (\core\models\WmsTransfer::WMS_TYPE_PRODUCT == $this->wms_transfer_from_type) {
            $wmsProductInSheetModel = $this->wmsProductInSheet;
            $html = \yii\helpers\Html::a($wmsProductInSheetModel->wms_product_in_sheet_number, ['wms-product-in-sheet/view', 'id' => $wmsProductInSheetModel->id]);
        } elseif (\core\models\WmsTransfer::WMS_TYPE_PARTIAL == $this->wms_transfer_from_type) {
            $wmsPartiallyProductInSheetModel = $this->wmsPartiallyProductInSheet;
            $html = \yii\helpers\Html::a($wmsPartiallyProductInSheetModel->wms_partially_product_in_sheet_number, ['wms-partially-product-in-sheet/view', 'id' => $wmsPartiallyProductInSheetModel->id]);
        } else {
            $html = $this->wms_transfer_from_in_code;
        }
        return $html;
    }

    /**
     * @return string
     * 获取生成的出库单号
     */
    public function getWmsTransferFromCode(){
        if (empty($this->wms_transfer_from_code)){
            $html = '<span style="color: red;">(未设置)</span>';
        }elseif (\core\models\WmsTransfer::WMS_TYPE_MATERIAL == $this->wms_transfer_from_type) {
            $wmsMaterialOutSheetModel = $this->generatedWmsMaterialOutSheet;
            $html = \yii\helpers\Html::a($wmsMaterialOutSheetModel->wms_material_out_sheet_number, ['wms-material-out-sheet/common-out-view', 'id' => $wmsMaterialOutSheetModel->id], ['class' => ' ']);
        } elseif (\core\models\WmsTransfer::WMS_TYPE_PRODUCT == $this->wms_transfer_from_type) {
            $wmsProductOutSheetModel = $this->generatedWmsProductOutSheet;
            $html = \yii\helpers\Html::a($wmsProductOutSheetModel->wms_product_out_sheet_number, ['wms-product-out-sheet/common-out-view', 'id' => $wmsProductOutSheetModel->id]);
        } elseif (\core\models\WmsTransfer::WMS_TYPE_PARTIAL == $this->wms_transfer_from_type) {
            $wmsPartiallyProductOutSheetModel = $this->generatedWmsPartiallyProductOutSheet;
            $html = \yii\helpers\Html::a($wmsPartiallyProductOutSheetModel->wms_partially_product_out_sheet_number, ['wms-partially-product-out-sheet/view', 'id' => $wmsPartiallyProductOutSheetModel->id]);
        } else {
            $html = $this->wms_transfer_from_code;
        }
        return $html;
    }

    /**
     * @return string
     * 获取显示生成的入库单号
     */
    public function getWmsTransferToCode(){
        if (empty($this->wms_transfer_to_code)){
            $html = '<span style="color: red;">(未设置)</span>';
        }elseif (\core\models\WmsTransfer::WMS_TYPE_MATERIAL == $this->wms_transfer_to_type) {
            $wmsMaterialInSheetModel = $this->generatedWmsMaterialInSheet;
            $html = \yii\helpers\Html::a($wmsMaterialInSheetModel->wms_material_in_sheet_number, ['wms-material-in-sheet/view', 'id' => $wmsMaterialInSheetModel->id]);
        } elseif (\core\models\WmsTransfer::WMS_TYPE_PRODUCT == $this->wms_transfer_to_type) {
            $wmsProductInSheetModel = $this->generatedWmsProductInSheet;
            $html = \yii\helpers\Html::a($wmsProductInSheetModel->wms_product_in_sheet_number, ['wms-product-in-sheet/view', 'id' => $wmsProductInSheetModel->id]);
        } elseif (\core\models\WmsTransfer::WMS_TYPE_PARTIAL == $this->wms_transfer_to_type) {
            $wmsPartiallyProductInSheetModel = $this->generatedWmsPartiallyProductInSheet;
            $html = \yii\helpers\Html::a($wmsPartiallyProductInSheetModel->wms_partially_product_in_sheet_number, ['wms-partially-product-in-sheet/view', 'id' => $wmsPartiallyProductInSheetModel->id]);
        } else {
            $html = $this->wms_transfer_to_code;
        }
        return $html;
    }

    /**
     * @param $herb_info_id
     * @param $wms_type
     * @return mixed|string
     * 获取药材名称
     */
    public static function getHerbInfoName($herb_info_id, $wms_type){
        $herb_info_name = '';
        switch ($wms_type){
            case \core\models\WmsTransfer::WMS_TYPE_MATERIAL:
                $common_producer_herb_info = \core\models\CommonProducerHerbInfo::getCommonProducerHerbInfo($herb_info_id);
                $herb_info_name = $common_producer_herb_info['common_producer_herb_info_name'];
                break;
            case \core\models\WmsTransfer::WMS_TYPE_PRODUCT:
                $common_producer_herb_info = \core\models\CommonProducerHerbInfo::getCommonProducerHerbInfo($herb_info_id);
                $herb_info_name = $common_producer_herb_info['common_producer_herb_info_name'];
                break;
            case \core\models\WmsTransfer::WMS_TYPE_PARTIAL:
                $common_producer_herb_info = \core\models\CommonProducerHerbInfo::getCommonProducerHerbInfo($herb_info_id);
                $herb_info_name = $common_producer_herb_info['common_producer_herb_info_name'];
                break;
            default:
                break;
        }
        return $herb_info_name;
    }

    /**
     * @return int
     * 获取当前登录基地ID
     */
    public static function getCommonProducerInfoId(){
        $common_producer_info_id = \core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true);
        return $common_producer_info_id;
    }

    /**
     * @param $common_producer_info_id
     * @return mixed
     * 获取基地名称
     */
    public static function getCommonProducerInfoName($common_producer_info_id){
        $common_producer_info_name = \core\models\Division::getDivisionName($common_producer_info_id);
        return $common_producer_info_name;
    }

    /**
     * @param $herb_info_id
     * @param $wms_type
     * @return string
     * 获取等级名称
     */
    public static function getGradeInfoName($herb_info_id, $wms_type){
        $grade_info_name = '';
        switch ($wms_type){
            case \core\models\WmsTransfer::WMS_TYPE_MATERIAL:
                $common_grade_info = \core\models\mongodb\HerbMaterialGradeData::getHerbGradeInfoByGradeID($herb_info_id);
                $grade_info_name = $common_grade_info['common_producer_herb_grade_info_name'];
                break;
            case \core\models\WmsTransfer::WMS_TYPE_PRODUCT:
                $common_grade_info = \core\models\mongodb\HerbProductGradeData::getHerbGradeInfoByGradeID($herb_info_id);
                $grade_info_name = $common_grade_info['common_producer_product_grade_info_name'];
                break;
            case \core\models\WmsTransfer::WMS_TYPE_PARTIAL:
                $common_grade_info = \core\models\mongodb\HerbProductGradeData::getHerbGradeInfoByGradeID($herb_info_id);
                $grade_info_name = $common_grade_info['common_producer_product_grade_info_name'];
                break;
            default:
                break;
        }
        return $grade_info_name;
    }

    /**
     * @param $herb_info_id
     * @return string
     * 获取产地名称
     */
    public static function getPlaceInfoName($herb_info_id){
        $place_info_name = '';
        $common_place_info = \core\models\CommonProducerHerbPlaceInfo::getHerbPlaceInfo($herb_info_id);
        $place_info_name =  $common_place_info['common_producer_herb_place_info_name'];
        return $place_info_name;
    }

    /**
     * @param $wms_info_id
     * @return string
     * 获取仓库名称
     */
    public static function getWmsInfoName($wms_info_id){
        $wms_info_name = '';
        if (!empty($wmsInfoModel = \core\models\CommonProducerWmsInfo::findOne(["id" => $wms_info_id]))){
            $wms_info_name = $wmsInfoModel->common_producer_wms_info_wms_name;
        }
        return $wms_info_name;
    }

    /**
     * @param $area_info_id
     * @return string
     * 获取库区名称
     */
    public static function getAreaInfoName($area_info_id){
        $area_info_name = '';
        if (!empty($areaInfoModel = \core\models\CommonProducerWmsAreaInfo::findOne(["id" => $area_info_id]))){
            $area_info_name = $areaInfoModel->common_producer_wms_area_info_wms_area;
        }
        return $area_info_name;
    }

    /**
     * @param $user_id
     * @return mixed|string
     * 获取用户名称
     */
    public static function getUserName($user_id){
        $user_name = '';
        $userModel = \core\models\User::getUser($user_id);
        $user_name = $userModel->name;
        return $user_name;
    }

    /**
     * @param $wms_type
     * @param $herb_info_id
     * @return mixed
     * 获取等级列表
     */
    public static function getGradeInfoList($wms_type, $herb_info_id){
        if ($wms_type == \core\models\WmsTransfer::WMS_TYPE_MATERIAL){
            $out['results'] = \core\models\mongodb\HerbMaterialGradeData::getHerbGradeInfoAjaxOptions($herb_info_id);
            return $out;
        }elseif ($wms_type == \core\models\WmsTransfer::WMS_TYPE_PRODUCT){
            $out['results'] = \core\models\mongodb\HerbProductGradeData::getProductGradeInfoAjaxOptions($herb_info_id);
            return $out;
        }elseif ($wms_type == \core\models\WmsTransfer::WMS_TYPE_PARTIAL){
            $out['results'] = \core\models\mongodb\HerbProductGradeData::getProductGradeInfoAjaxOptions($herb_info_id);
            return $out;
        }
    }

    /**
     * @param $in_sheet_number
     * @return string
     * @throws \yii\db\Exception
     * 根据入库单获取等级备注
     */
    public static function getGradeDescribeByInSheetNumber($in_sheet_number){
        $gradeDescribe = '';
        if (strpos($in_sheet_number, 'YLRK') !== false){
            if (!empty($wmsInSheet = \core\models\WmsMaterialInSheet::findOne(['wms_material_in_sheet_number'=>$in_sheet_number]))){
                if (empty($wmsInSheet->common_producer_herb_grade_describe)){
                    $gradeDescribe = '';
                }else{
                    $gradeDescribe = $wmsInSheet->common_producer_herb_grade_describe;
                }
            }else{
                throw new \yii\db\Exception('未找到原料入库单'.$in_sheet_number);
            }
        }elseif (strpos($in_sheet_number, 'BCPRK') !== false){
            if (!empty($wmsInSheet = \core\models\WmsPartiallyProductInSheet::findOne(['wms_partially_product_in_sheet_number'=>$in_sheet_number]))){
                if (empty($wmsInSheet->common_producer_herb_grade_product_describe)){
                    $gradeDescribe = '';
                }else{
                    $gradeDescribe = $wmsInSheet->common_producer_herb_grade_product_describe;
                }
            }else{
                throw new \yii\db\Exception('未找到半成品入库单'.$in_sheet_number);
            }
        }elseif (strpos($in_sheet_number, 'CPRK') !== false){
            if (!empty($wmsInSheet = \core\models\WmsProductInSheet::findOne(['wms_product_in_sheet_number'=>$in_sheet_number]))){
                if (empty($wmsInSheet->common_producer_herb_grade_product_describe)){
                    $gradeDescribe = '';
                }else{
                    $gradeDescribe = $wmsInSheet->common_producer_herb_grade_product_describe;
                }
            }else{
                throw new \yii\db\Exception('未找到成品入库单'.$in_sheet_number);
            }
        }else{
            $gradeDescribe = '';
        }
        return $gradeDescribe;
    }

    /**
     * @param $position_code
     * @param $common_producer_info_id
     * @param $area_info_id
     * @return bool
     * 检测库位编码是否存在
     */
    public static function getPositionInfoId($position_code, $common_producer_info_id, $area_info_id){
        $posotionModel = \core\models\CommonProducerWmsPositionInfo::find()->where(['common_producer_wms_position_info_code'=>$position_code, 'common_producer_info_id'=>$common_producer_info_id, 'common_producer_wms_area_info_id'=>$area_info_id])->one();
        if (empty($posotionModel)){
            return false;
        }else{
            return $posotionModel->id;
        }
    }

    // 根据入库单号获取调拨单
    public static function getTransferByInSheetNumber($inSheetNumber) {
        if (empty($inSheetNumber)) {
            return null;
        }
        return self::findNotDel()->where(['wms_transfer_to_code' => $inSheetNumber, 'wms_transfer_status' => self::WMS_TRANSFER_STATUS_FINISH])->one();
    }

    // 根据调拨单号获取调拨单
    public static function getTransferBySheetNumber($sheetNumber) {
        if (empty($sheetNumber)) {
            return null;
        }
        return self::findNotDel()->where(['wms_transfer_code' => $sheetNumber, 'wms_transfer_status' => self::WMS_TRANSFER_STATUS_FINISH])->one();
    }

    // 找到追溯点
    public static function findDatabackNode($in_sheet_number) {
        $transfer = self::getTransferByInSheetNumber($in_sheet_number);
        if ($transfer) {
            return [
                'in_sheet_number' => $transfer->wms_transfer_from_in_code,
                'out_sheet_number' => $transfer->wms_transfer_from_code,
                'databack_in_sheet_number' => $in_sheet_number,
                'wms_type' => $transfer->wms_transfer_from_type,
            ];
        } else {
            return null;
        }
    }
}

注意:

(1)在核心业务逻辑完成场景定义和验证规格定义

(2)在核心业务逻辑中定义关联模型,以方便单据查询

(3)在核心业务逻辑中完成beforeValidate()以及beforeSave()等事件调用方法

(4)在核心业务逻辑中完成自定义的其他业务逻辑封装

4. 前台查询模型:

backend\models\WmsTransfer.php

<?php

namespace backend\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use core\models\WmsTransfer;

class WmsTransferSearch extends WmsTransfer
{

    public $global_search;//全局搜索,主要包括调拨标号,出库单号,入库单号,存货名称的搜索

    public function rules()
    {
        return [
            [['id', 'common_producer_info_id', 'wms_transfer_from_type', 'wms_transfer_from_herb_info_id', 'wms_transfer_from_grade_info_id', 'wms_transfer_from_place_info_id', 'wms_transfer_from_piece_type', 'wms_transfer_from_weight_per_package', 'wms_transfer_from_standard_package_number', 'wms_transfer_from_off_standard_package_number', 'wms_transfer_from_total_package_number', 'wms_transfer_from_standard_weight', 'wms_transfer_from_off_standard_weight', 'wms_transfer_from_total_weight', 'wms_transfer_from_wms_info_id', 'wms_transfer_from_area_info_id', 'wms_transfer_to_type', 'wms_transfer_to_herb_info_id', 'wms_transfer_to_grade_info_id', 'wms_transfer_to_place_info_id', 'wms_transfer_to_piece_type', 'wms_transfer_to_weight_per_package', 'wms_transfer_to_standard_package_number', 'wms_transfer_to_off_standard_package_number', 'wms_transfer_to_total_package_number', 'wms_transfer_to_standard_weight', 'wms_transfer_to_off_standard_weight', 'wms_transfer_to_total_weight', 'wms_transfer_to_wms_info_id', 'wms_transfer_to_area_info_id', 'wms_transfer_wms_manager_id', 'wms_transfer_wms_manager_date', 'wms_transfer_status', 'created_at', 'updated_at', 'is_del'], 'integer'],
            [['wms_transfer_code', 'common_producer_info_name', 'wms_transfer_from_in_code', 'wms_transfer_from_code', 'wms_transfer_from_herb_info_name', 'wms_transfer_from_grade_info_name', 'wms_transfer_from_place_info_name', 'wms_transfer_from_wms_info_name', 'wms_transfer_from_area_info_name', 'wms_transfer_from_wms_position_info', 'wms_transfer_to_code', 'wms_transfer_to_herb_info_name', 'wms_transfer_to_grade_info_name', 'wms_transfer_to_place_info_name', 'wms_transfer_to_wms_info_name', 'wms_transfer_to_area_info_name', 'wms_transfer_to_wms_position_info', 'wms_transfer_wms_manager_name'], 'safe'],
            [['global_search'], 'string'],
        ];
    }

    public function scenarios()
    {
        return Model::scenarios();
    }

    public function search($params)
    {
        $query = WmsTransfer::find();

        // add conditions that should always apply here
        //实现基地的搜索
        $common_producer_info_id = \core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true);
        if (!empty($common_producer_info_id)){
            $this->common_producer_info_id = $common_producer_info_id;
        }

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort' => [
                'defaultOrder' => [
                    'id' => SORT_DESC,
                ]
            ],
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'common_producer_info_id' => $this->common_producer_info_id,
            'wms_transfer_from_type' => $this->wms_transfer_from_type,
            'wms_transfer_from_herb_info_id' => $this->wms_transfer_from_herb_info_id,
            'wms_transfer_from_grade_info_id' => $this->wms_transfer_from_grade_info_id,
            'wms_transfer_from_place_info_id' => $this->wms_transfer_from_place_info_id,
            'wms_transfer_from_piece_type' => $this->wms_transfer_from_piece_type,
            'wms_transfer_from_weight_per_package' => $this->wms_transfer_from_weight_per_package,
            'wms_transfer_from_standard_package_number' => $this->wms_transfer_from_standard_package_number,
            'wms_transfer_from_off_standard_package_number' => $this->wms_transfer_from_off_standard_package_number,
            'wms_transfer_from_total_package_number' => $this->wms_transfer_from_total_package_number,
            'wms_transfer_from_standard_weight' => $this->wms_transfer_from_standard_weight,
            'wms_transfer_from_off_standard_weight' => $this->wms_transfer_from_off_standard_weight,
            'wms_transfer_from_total_weight' => $this->wms_transfer_from_total_weight,
            'wms_transfer_from_wms_info_id' => $this->wms_transfer_from_wms_info_id,
            'wms_transfer_from_area_info_id' => $this->wms_transfer_from_area_info_id,
            'wms_transfer_to_type' => $this->wms_transfer_to_type,
            'wms_transfer_to_herb_info_id' => $this->wms_transfer_to_herb_info_id,
            'wms_transfer_to_grade_info_id' => $this->wms_transfer_to_grade_info_id,
            'wms_transfer_to_place_info_id' => $this->wms_transfer_to_place_info_id,
            'wms_transfer_to_piece_type' => $this->wms_transfer_to_piece_type,
            'wms_transfer_to_weight_per_package' => $this->wms_transfer_to_weight_per_package,
            'wms_transfer_to_standard_package_number' => $this->wms_transfer_to_standard_package_number,
            'wms_transfer_to_off_standard_package_number' => $this->wms_transfer_to_off_standard_package_number,
            'wms_transfer_to_total_package_number' => $this->wms_transfer_to_total_package_number,
            'wms_transfer_to_standard_weight' => $this->wms_transfer_to_standard_weight,
            'wms_transfer_to_off_standard_weight' => $this->wms_transfer_to_off_standard_weight,
            'wms_transfer_to_total_weight' => $this->wms_transfer_to_total_weight,
            'wms_transfer_to_wms_info_id' => $this->wms_transfer_to_wms_info_id,
            'wms_transfer_to_area_info_id' => $this->wms_transfer_to_area_info_id,
            'wms_transfer_wms_manager_id' => $this->wms_transfer_wms_manager_id,
            'wms_transfer_wms_manager_date' => $this->wms_transfer_wms_manager_date,
            'wms_transfer_status' => $this->wms_transfer_status,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'wms_transfer_code', $this->wms_transfer_code])
            ->andFilterWhere(['like', 'common_producer_info_name', $this->common_producer_info_name])
            ->andFilterWhere(['like', 'wms_transfer_from_in_code', $this->wms_transfer_from_in_code])
            ->andFilterWhere(['like', 'wms_transfer_from_code', $this->wms_transfer_from_code])
            ->andFilterWhere(['like', 'wms_transfer_from_herb_info_name', $this->wms_transfer_from_herb_info_name])
            ->andFilterWhere(['like', 'wms_transfer_from_grade_info_name', $this->wms_transfer_from_grade_info_name])
            ->andFilterWhere(['like', 'wms_transfer_from_place_info_name', $this->wms_transfer_from_place_info_name])
            ->andFilterWhere(['like', 'wms_transfer_from_wms_info_name', $this->wms_transfer_from_wms_info_name])
            ->andFilterWhere(['like', 'wms_transfer_from_area_info_name', $this->wms_transfer_from_area_info_name])
            ->andFilterWhere(['like', 'wms_transfer_from_wms_position_info', $this->wms_transfer_from_wms_position_info])
            ->andFilterWhere(['like', 'wms_transfer_to_code', $this->wms_transfer_to_code])
            ->andFilterWhere(['like', 'wms_transfer_to_herb_info_name', $this->wms_transfer_to_herb_info_name])
            ->andFilterWhere(['like', 'wms_transfer_to_grade_info_name', $this->wms_transfer_to_grade_info_name])
            ->andFilterWhere(['like', 'wms_transfer_to_place_info_name', $this->wms_transfer_to_place_info_name])
            ->andFilterWhere(['like', 'wms_transfer_to_wms_info_name', $this->wms_transfer_to_wms_info_name])
            ->andFilterWhere(['like', 'wms_transfer_to_area_info_name', $this->wms_transfer_to_area_info_name])
            ->andFilterWhere(['like', 'wms_transfer_to_wms_position_info', $this->wms_transfer_to_wms_position_info])
            ->andFilterWhere(['like', 'wms_transfer_wms_manager_name', $this->wms_transfer_wms_manager_name]);

        //实现显示作废单据的搜索
        if ($this->is_del !== null){
            if ($this->is_del != 2){
                $query->andFilterWhere(['is_del'=>$this->is_del]);
            }
        }else{
            $this->is_del = 0;
            $query->andFilterWhere(['is_del'=>$this->is_del]);
        }

        //实现全局搜索
        $query->andFilterWhere(['or',
            ['like', 'wms_transfer_code', $this->global_search],
            ['like', 'wms_transfer_from_code', $this->global_search],
            ['like', 'wms_transfer_to_code', $this->global_search],
            ['like', 'wms_transfer_from_herb_info_name', $this->global_search],
            ['like', 'wms_transfer_to_herb_info_name', $this->global_search],
            ]);

        return $dataProvider;
    }
}

注意:

(1)可以使用搜索模型实现任何场景的搜索

(2)可以自定义全局搜索功能

5.业务控制器

<?php

namespace backend\controllers;

use Yii;
use core\models\WmsTransfer;
use backend\models\WmsTransferSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;

class WmsTransferController extends Controller
{
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                ],
            ],
        ];
    }

    /**
     * @param null $fromWmsType
     * @return array
     * ajax获取存货类型选择项
     */
    public function actionAjaxGetWmsTypeOptions($fromWmsType=null){
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        $list = [];
        $wmsTypeOptions = \core\models\WmsTransfer::getWmsTypeOptions($fromWmsType);
        foreach ($wmsTypeOptions as $id => $text){
            $list[] = ['id'=>$id, 'text'=>$text];
        }
        return $list;
    }

    /**
     * @param $wmsType
     * @return array
     * ajax获取入库单号选择列表
     */
    public function actionAjaxGetInSheetNumberMap($wmsType, $common_producer_info_id){
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        return \core\models\WmsTransfer::getInSheetNumberMap($wmsType, $common_producer_info_id);
    }

    /**
     * @param null $wmsType
     * @return string
     * ajax获取出库单编号
     */
    public function actionAjaxGetWmsOutCode($wmsType=null){
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        if (empty($wmsType)){
            $wmsType = \core\models\WmsTransfer::WMS_TYPE_PRODUCT;
        }
        return \core\models\WmsTransfer::genWmsOutCode($wmsType);
    }

    /**
     * @param null $wmsType
     * @return string
     * ajax获取入库单编号
     */
    public function actionAjaxGetWmsInCode($wmsType=null){
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        if (empty($wmsType)){
            $wmsType = \core\models\WmsTransfer::WMS_TYPE_PRODUCT;
        }
        return \core\models\WmsTransfer::genWmsInCode($wmsType);
    }

    /**
     * @param $inSheetNumber
     * @return array
     * ajax获取入库单的详细信息
     */
    public function actionAjaxGetWmsInSheetInfo($inSheetNumber){
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        return \core\models\WmsTransfer::getWmsInSheetInfo($inSheetNumber);
    }

    /**
     * @param $wms_transfer_from_in_code
     * @return string
     * 库位信息
     */
    public function actionAjaxPosition($wms_transfer_from_in_code){
        $wmsInSheetInfo = \core\models\WmsTransfer::getWmsInSheetInfo($wms_transfer_from_in_code);
        return $this->renderAjax('position', [
            'wmsInSheetInfo' => $wmsInSheetInfo,
        ]);
    }

    /**
     * @param $wms_type
     * @param $herb_info_id
     * ajax获取等级
     */
    public function actionAjaxGetWmsHerbGradeInfoList($wms_type, $herb_info_id)
    {
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        $list = \core\models\WmsTransfer::getGradeInfoList($wms_type, $herb_info_id);
        return $list;

    }

    public function actionIndex()
    {
        $searchModel = new WmsTransferSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }

    public function actionView($id)
    {
        $model = $this->findModel($id);
        $model->prepareShow();
        return $this->render('view', [
            'model' => $model,
        ]);
    }

    public function actionCreate()
    {
        $model = new WmsTransfer();
        $model->setScenario('scenario_create');
        $model->wms_transfer_code = \core\models\WmsTransfer::genWmsTransferCode();
        $model->created_at = time();

        if ($model->load(Yii::$app->request->post()) && $model->saveWmsTransferAndPosition()['status']) {
            return $this->redirect(['index']);
        } else {
//            Yii::$app->getSession()->setFlash($model->saveWmsTransferAndPosition()['errmsg']);
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }

    public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        $model->setScenario('scenario_update');
        $model->prepareShow();
        if ($model->load(Yii::$app->request->post()) && $model->saveWmsTransferAndPosition()['status']) {
            return $this->redirect(['index']);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }

    /**
     * @param $id
     * @return \yii\web\Response
     * 作废
     */
    public function actionDelete($id)
    {
        $model = $this->findModel($id);

        $model->is_del = 1;
        $deleteHandler = $model->save(false, ['is_del']);
        if (!empty($deleteHandler)){
            Yii::$app->getSession()->setFlash('success', '调拨单'.$model->wms_transfer_code.'作废成功');
        }else{
            Yii::$app->getSession()->setFlash('error', '调拨单'.$model->wms_transfer_code.'作废失败');
        }

        return $this->redirect(['index']);
    }

    public function actionPrint($id)
    {
        $model = $this->findModel($id);
        $model->prepareShow();

        $this->layout = false;
        //打印对象
        $pdf = (new \TCPDF('L', 'mm', array(240, 140), true, 'UTF-8', false));
        //设置无打印头
        $pdf->setPrintHeader(false);
        $pdf->setPrintFooter(false);
        //设置PDF打印纸张的编剧
        $pdf->SetMargins(5, 10,5);
        //设置单元格内边距
        $pdf->setCellPaddings(0, 0, 0, 0);
        //设置自动进入下一页
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_RIGHT);

        $content = $this->render('print', [
            'model'=>$model,
        ]);
        $pdf->AddPage();
        $pdf->SetFont('stsongstdlight', '', 14);
        $pdf->writeHTML($content, true, false, true, false, '');

        $pdf->lastPage();
        $pdf->get('库存调拨单.pdf');
    }

    public function actionTransfer($id){
        $model = $this->findModel($id);
        $handler = \core\models\WmsTransfer2::confirmTransfer($model);
        if (false == $handler['status']){
            Yii::$app->getSession()->setFlash('error', $handler['errmsg']);
        }else{
            Yii::$app->getSession()->setFlash('success', '单据'.$model->wms_transfer_code.'调拨成功');
        }
        return $this->redirect(['index']);
    }

    protected function findModel($id)
    {
        if (($model = WmsTransfer::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
}

6.视图之列表页(GridView的使用)

<?php

use yii\helpers\Html;
use kartik\grid\GridView;

$this->title = '库存调拨单';
$this->registerCssFile("css/css.css", ['depends' => ['dmstr\web\AdminLteAsset']]);
$this->registerCssFile(Yii::$app->urlManager->baseUrl .'/css/default_index_view_page.css');
?>

<?php
\yii\bootstrap\Modal::begin([
    'id' => 'alert-modal',
    'header' => '<h4 class="modal-title">提示</h4>',
    'footer' => '<a href="#" class="btn btn-default" data-dismiss="modal">关闭</a>',
]);
$js = <<<JS
    $(".alert-btn").click(function(){
    $('.modal-body').html($(this).attr('data-message'));
    return true;
});
JS;
$this->registerJs($js);
\yii\bootstrap\Modal::end();
?>

<div class="wms-transfer-index default-index">
<?php  echo $this->render('_search', ['model' => $searchModel]); ?>
<?= GridView::widget([
    'tableOptions' => ['class' => 'table table-striped', 'style'=>'font-size:14px;', 'id'=>'wms-transfer'],
    'layout' => "{items}{summary}{pager}",
    'bordered' => true,
    'striped' => false,
    'condensed' => false,
    'responsive' => true,
    'hover' => true,
    'floatHeader'=>false,
    'floatHeaderOptions' => ['scrollingTop' => ''],
    'showHeader'=>true,
    'showFooter'=>false,
    'beforeHeader'=>false,
    'showPageSummary' => false,
    'showOnEmpty'=>true,
    'emptyText'=>'抱歉,当前没有数据,请更换搜素条件后重试!',
    'emptyTextOptions'=>['style'=>'color:red;text-align:center;'],
    'rowOptions'=>['style'=>'background:none;'],
    'dataProvider' => $dataProvider,
    'columns' => [
        [
            'label'=>'编号',
            'attribute'=>'wms_transfer_code',
            'hAlign' => 'left',
            'vAlign' => 'middle',
            'format'=>'raw',
            'noWrap'=>true,
            'width'=>'200px',
            'pageSummary'=>false,
            'visible'=>true,
            'hidden'=>false,
            'value'=>function($model){
                return $model->getWmsTransferCode();
            }
        ],
        [
            'label'=>'存货名称',
            'attribute'=>'wms_transfer_from_herb_info_name',
            'hAlign' => 'center',
            'vAlign' => 'middle',
            'format'=>'raw',
            'noWrap'=>true,
            'width'=>'200px',
            'pageSummary'=>false,
            'visible'=>true,
            'hidden'=>false,
            'value'=>function($model){
                return $model->wms_transfer_from_herb_info_name;
            }
        ],
        [
            'label'=>'调拨',
            'attribute'=>'wms_transfer_from_wms_info_id',
            'hAlign' => 'center',
            'vAlign' => 'middle',
            'format'=>'raw',
            'noWrap'=>true,
            'width'=>'200px',
            'pageSummary'=>false,
            'visible'=>true,
            'hidden'=>false,
            'value'=>function($model){
//                $model->prepareShow();
                return $model->getWmsTransferContent();
            }
        ],
        [
            'label'=>'库管签字',
            'attribute'=>'wms_transfer_wms_manager_name',
            'hAlign' => 'center',
            'vAlign' => 'middle',
            'format'=>'raw',
            'noWrap'=>true,
            'width'=>'200px',
            'pageSummary'=>false,
            'visible'=>true,
            'hidden'=>false,
            'value'=>function($model){
                return $model->wms_transfer_wms_manager_name;
            }
        ],
        [
            'label'=>'调拨日期',
            'attribute'=>'wms_transfer_wms_manager_date',
            'hAlign' => 'center',
            'vAlign' => 'middle',
            'format'=>'raw',
            'noWrap'=>true,
            'width'=>'200px',
            'pageSummary'=>false,
            'visible'=>true,
            'hidden'=>false,
            'value'=>function($model){
                return date('Y-m-d', $model->wms_transfer_wms_manager_date);
            }
        ],
        [
            'label'=>'状态',
            'attribute'=>'wms_transfer_status',
            'hAlign' => 'center',
            'vAlign' => 'middle',
            'format'=>'raw',
            'noWrap'=>true,
            'width'=>'200px',
            'pageSummary'=>false,
            'visible'=>true,
            'hidden'=>false,
            'value'=>function($model){
                return $model->getWmsTrasferStatusName();
            }
        ],
        [
            'class' => 'kartik\grid\ActionColumn',
            'template' => '<li>{view}</li><li>{update}</li><li>{transfer}</li><li>{print}</li>',
            'header'=>'操作',
            'dropdown' => true,
            'dropdownOptions' => ['class' => 'pull-right'],
            'dropdownButton' => ['label' => '菜单','class'=>'btn btn-success'],
            'buttons' => [
                'view' => function ($url, $model, $key) {
                    return \yii\helpers\Html::a('查看', ['view', 'id'=>$model->id]);
                },
                'update' => function ($url, $model, $key) {
                    if (empty($model->is_del) && \core\models\WmsTransfer::WMS_TRANSFER_STATUS_NOT == $model->wms_transfer_status) {
                        return \yii\helpers\Html::a('编辑', ['update', 'id' => $model->id]);
                    }
                },
                'delete' => function ($url, $model, $key) {
                    if(\core\models\WmsTransfer::WMS_TRANSFER_STATUS_FINISH == $model->wms_transfer_status){
                        return Html::a('作废', ['#'], ['class' => 'alert-btn', 'style'=>($model->is_del == 1)?'display:none;':'',
                            'data-message' => '调拨单'.$model->wms_transfer_code.'已经调拨完成,无法作废;若要重新调拨,请新建调拨单完成库存的再次调拨',
                            'data-toggle' => 'modal',
                            'data-target' => '#alert-modal'
                        ]);
                    } else {
                        return Html::a('作废', ['#'], ['class' => 'alert-btn', 'style'=>($model->is_del == 1)?'display:none;':'',
                            'data-message' => '调拨单'.$model->wms_transfer_code.'不能作废;请完成调拨流程后再次新建调拨单进行恢复',
                            'data-toggle' => 'modal',
                            'data-target' => '#alert-modal'
                        ]);
                    }
                },
                'transfer' => function ($url, $model, $key) {
                    if (empty($model->is_del) && \core\models\WmsTransfer::WMS_TRANSFER_STATUS_NOT == $model->wms_transfer_status){
                        $message = $model->getWmsTypeName($model->wms_transfer_from_type).'出库单'.$model->wms_transfer_from_code.'将确认出库;'.$model->getWmsTypeName($model->wms_transfer_to_type).'入库单'.$model->wms_transfer_to_code.'将确认入库;你确认调拨吗?';
                        return \yii\helpers\Html::a('确认调拨', ['transfer', 'id'=>$model->id], [
                            'class' => '',
                            'data' => [
                                'confirm' => $message,
                                'method' => 'post',
                            ],
                        ]);
                    }
                },
                'print' => function ($url, $model, $key) {
                    return \yii\helpers\Html::a('打印', ['print', 'id'=>$model->id]);
                },
            ]
        ],
    ],
]); ?>
</div>

注意:

(1)GridView中字段的常用属性

7.视图之详情页

<?php
use yii\helpers\Html;

$this->title = '库存调拨单';

$this->registerCssFile("css/css.css",['depends' => ['dmstr\web\AdminLteAsset']]);
$this->registerCssFile(Yii::$app->urlManager->baseUrl .'/css/default_view_page.css');
?>
<style>
    .table-responsive{
        min-height: 0;
    }
</style>
<div class="wms-transfer-view hg_default-view">

    <table class="table table-bordered" style="margin: 0;">
        <tr style="background-color: #F1F1F1;">
            <td colspan="9" class="type_title">查看
                <ul class="nav pull-right">
                    <?= Html::a('返回', ['index'], ['class' => 'divider-vertical']) ?>
                </ul>
            </td>
        </tr>
        <tr>
            <td colspan="9" class="type_title">库存调拨信息</td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">编号</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_code) ? $model->getWmsTransferCode() : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">基地</label>
            </td>
            <td colspan="5" class="item-value" style="white-space:nowrap;">
                <?= isset($model->common_producer_info_name) ? $model->common_producer_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td colspan="9" class="type_title">库存调拨出库信息</td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">存货类型</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= $model->getWmsTypeName($model->wms_transfer_from_type) ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">关联单号</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_in_code) ? $model->getWmsTransferFromInCode() : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">出库单号</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_code) ? $model->getWmsTransferFromCode() : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">存货名称</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_herb_info_name) ? $model->wms_transfer_from_herb_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">等级</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_grade_info_name) ? $model->wms_transfer_from_grade_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">等级备注</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= !empty(\core\models\WmsTransfer::getGradeDescribeByInSheetNumber($model->wms_transfer_from_in_code)) ? \core\models\WmsTransfer::getGradeDescribeByInSheetNumber($model->wms_transfer_from_in_code) : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">产地</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_place_info_name) ? $model->wms_transfer_from_place_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">计件类型</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_piece_type) ? \core\models\WmsManager::getPieceTypeName($model->wms_transfer_from_piece_type) : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">包装规格</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_weight_per_package) ? $model->wms_transfer_from_weight_per_package : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">剩余重量</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_surplus_weight) ? $model->wms_transfer_from_surplus_weight : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td  class="item-label">
                <label class="control-label">标准件数</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"标准件数"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_standard_package_number) ? $model->wms_transfer_from_standard_package_number : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">非标准件数</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"非标准件数"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_off_standard_package_number) ? $model->wms_transfer_from_off_standard_package_number : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">总件数</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"总件数"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_total_package_number) ? $model->wms_transfer_from_total_package_number : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td  class="item-label">
                <label class="control-label">标准重量</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"标准重量"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_standard_weight) ? $model->wms_transfer_from_standard_weight : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">非标准重量</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"非标准重量"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_off_standard_weight) ? $model->wms_transfer_from_off_standard_weight : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">总重量</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"总重量"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_total_weight) ? $model->wms_transfer_from_total_weight : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td  class="item-label">
                <label class="control-label">仓库</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_wms_info_name) ? $model->wms_transfer_from_wms_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">库区</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_area_info_name) ? $model->wms_transfer_from_area_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td colspan="2" class="item-value">
                <?php
                $wms_stock_position_detail_list = \core\models\WmsOutSheetPositionRelationRecord::findAll([
                    'relative_id' => $model->id,
                    'relative_code' =>  $model->wms_transfer_code,
                ]);
                echo $this->render("../layouts/wms-layouts/view_stock_out_position.php", ["wms_stock_position_detail_list"=>$wms_stock_position_detail_list,
                    "wms_in_sheet_number"=>$model->wms_transfer_from_in_code?$model->wms_transfer_from_in_code:null,
                    "herb_weight"=>$model->wms_transfer_from_total_weight,
                    "herb_package_number"=>$model->wms_transfer_from_total_package_number]);
                ?>
            </td>
        </tr>
        <tr>
            <td colspan="9" class="type_title">库存调拨入库信息</td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">存货类型</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_type) ? $model->getWmsTypeName($model->wms_transfer_to_type) : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">关联单号</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_in_code) ? $model->getWmsTransferFromInCode() : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">入库单号</label>
            </td>
            <td colspan="5" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_code) ? $model->getWmsTransferToCode() : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">存货名称</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_herb_info_name) ? $model->wms_transfer_to_herb_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">等级</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_grade_info_name) ? $model->wms_transfer_to_grade_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">等级备注</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= !empty(\core\models\WmsTransfer::getGradeDescribeByInSheetNumber($model->wms_transfer_from_in_code)) ? \core\models\WmsTransfer::getGradeDescribeByInSheetNumber($model->wms_transfer_from_in_code) : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">产地</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_place_info_name) ? $model->wms_transfer_to_place_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">计件类型</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_piece_type) ? \core\models\WmsManager::getPieceTypeName($model->wms_transfer_to_piece_type) : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">包装规格</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_weight_per_package) ? $model->wms_transfer_to_weight_per_package : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td  class="item-label">
                <label class="control-label">标准件数</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"标准件数"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_standard_package_number) ? $model->wms_transfer_to_standard_package_number : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">非标准件数</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"非标准件数"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_off_standard_package_number) ? $model->wms_transfer_to_off_standard_package_number : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">总件数</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"总件数"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_total_package_number) ? $model->wms_transfer_to_total_package_number : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td  class="item-label">
                <label class="control-label">标准重量</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"标准重量"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_standard_weight) ? $model->wms_transfer_to_standard_weight : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">非标准重量</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"非标准重量"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_off_standard_weight) ? $model->wms_transfer_to_off_standard_weight : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">总重量</label>
                <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"总重量"]);?>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_total_weight) ? $model->wms_transfer_to_total_weight : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td  class="item-label">
                <label class="control-label">仓库</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_wms_info_name) ? $model->wms_transfer_to_wms_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td  class="item-label">
                <label class="control-label">库区</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_area_info_name) ? $model->wms_transfer_to_area_info_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td colspan="2" class="item-value">
                <?php
                $wms_stock_position_detail_list = \core\models\WmsInSheetPositionRelationRecord::findAll(["relative_id"=>$model->id,
                    'relative_code'=>$model->wms_transfer_code]);
                echo $this->render("../layouts/wms-layouts/view_stock_in_position.php", [
                        "wms_stock_position_detail_list"=>$wms_stock_position_detail_list,
                    "wms_in_sheet_number"=>$model->wms_transfer_to_code,
                    "herb_weight"=>$model->wms_transfer_to_total_weight,
                    "herb_package_number"=>$model->wms_transfer_to_total_package_number]);
                ?>
            </td>
        </tr>
        <tr>
            <td colspan="9" class="type_title">相关人员信息</td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">调拨申请人</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_wms_manager_name) ? $model->wms_transfer_wms_manager_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">调拨申请日期</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_wms_manager_date) ? $model->wms_transfer_wms_manager_date : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">出库确认人</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_wms_manager_name) ? $model->wms_transfer_from_wms_manager_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">出库确认日期</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_from_wms_manager_date) ? $model->wms_transfer_from_wms_manager_date : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">入库确认人</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_wms_manager_name) ? $model->wms_transfer_to_wms_manager_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">入库确认日期</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_to_wms_manager_date) ? $model->wms_transfer_to_wms_manager_date : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
        <tr>
            <td class="item-label" colspan="1">
                <label class="control-label">质量放行人</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_quality_manager_name) ? $model->wms_transfer_quality_manager_name : '<span style="color: red;">(未设置)</span>' ?>
            </td>
            <td class="item-label" colspan="1">
                <label class="control-label">质量放行日期</label>
            </td>
            <td colspan="2" class="item-value" style="white-space:nowrap;">
                <?= isset($model->wms_transfer_quality_manager_date) ? $model->wms_transfer_quality_manager_date : '<span style="color: red;">(未设置)</span>' ?>
            </td>
        </tr>
    </table>
</div>
<!--作废单据显示下面内容-->
<?php if(!empty($model->is_del)):?>
    <style>.table{  color: #999;  }</style>
    <img src="/images/obsolete.png" style="position: absolute;left: 40%;top:20%;">
<?php endif; ?>

注意:

(1)如果单据已经作废则显示作废的图标

8.视图之表单页

<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
$this->registerJsFile(Yii::$app->urlManager->baseUrl .'/js/wms-product-out-sheet.js');
$this->registerJs('material_url = '.'"' . Url::to(['wms-stock-detail-info/get-wms-product-in-data']) . '";');
$this->registerCssFile(Yii::$app->urlManager->baseUrl .'/css/default_form_page.css');
$this->registerCssFile("css/css.css",['depends' => ['dmstr\web\AdminLteAsset']]);
?>
<?php
$environment_name = 'local';
if (strpos(\Yii::$app->name, '本地')){
    $environment_name = 'local';
}elseif (strpos(\Yii::$app->name, '测试')){
    $environment_name = 'dev';
}else{
    $environment_name = 'prod';
}
$common_producer_info_id = \core\models\WmsTransfer::getCommonProducerInfoId();
$inSheetNumberMapUrl = \yii\helpers\Url::to(['ajax-get-in-sheet-number-map']);
$wmsInSheetInfoUrl = \yii\helpers\Url::to(['ajax-get-wms-in-sheet-info']);
$reloadUrl = \Yii::$app->request->absoluteUrl;
$handleOutUrl = \yii\helpers\Url::to(['wms-manager/handle-out']);
$wmsTransferToTypeUrl = \yii\helpers\Url::to(['wms-transfer/ajax-get-wms-type-options']);
$handleInUrl = \yii\helpers\Url::to(['wms-manager/handle-in']);
$wmsTransferFromCodeUrl = \yii\helpers\Url::to(['ajax-get-wms-out-code']);
$wmsTransferToCodeUrl = \yii\helpers\Url::to(['ajax-get-wms-in-code']);
$js = <<<JS
/**
* 加载入库单号列表
*/
function loadWmsInSheetList(){
    var wms_transfer_from_type = $('#wmstransfer-wms_transfer_from_type').val();
    common_producer_info_id = '{$common_producer_info_id}';
    $.get('{$inSheetNumberMapUrl}', {wmsType:wms_transfer_from_type, common_producer_info_id: common_producer_info_id}, function(data) {
        html = '<option value="">选择入库单号</option>';
        $(data).each(function(i, item){
            tempOption = '<option value="_gradeid_">_gradevalue_</option>';
            html += tempOption.replace(/_gradeid_/g, item.in_sheet_number).replace(/_gradevalue_/g, item.in_sheet_number);
        });
        $('#wmstransfer-wms_transfer_from_in_code').html(html);
    });
}
/**
* 加载入库单的详细信息
*/
function loadWmsInSheetInfo(){
    var wms_transfer_from_in_code = $('#wmstransfer-wms_transfer_from_in_code').val();
    $.get('{$wmsInSheetInfoUrl}', {inSheetNumber:wms_transfer_from_in_code}, function(data) {
        $('#wmstransfer-wms_transfer_from_herb_info_id').val(data.wms_transfer_from_herb_info_id);
        $('#wmstransfer-wms_transfer_from_herb_info_name').val(data.wms_transfer_from_herb_info_name);
        $('#wmstransfer-wms_transfer_from_grade_info_id').val(data.wms_transfer_from_grade_info_id);
        $('#wmstransfer-wms_transfer_from_grade_info_name').val(data.wms_transfer_from_grade_info_name);
        $('#wmstransfer-wms_transfer_from_grade_info_describe').val(data.wms_transfer_to_grade_info_describe);
        $('#wmstransfer-wms_transfer_from_place_info_id').val(data.wms_transfer_from_place_info_id);
        $('#wmstransfer-wms_transfer_from_place_info_name').val(data.wms_transfer_from_place_info_name);
        $('#wmstransfer-wms_transfer_from_piece_type').val(data.wms_transfer_from_piece_type);
        $('#wmstransfer-wms_transfer_from_piece_type_name').val(data.wms_transfer_from_piece_type_name);
        $('#wmstransfer-wms_transfer_from_weight_per_package').val(data.wms_transfer_from_weight_per_package);
        $('#wmstransfer-wms_transfer_from_surplus_weight').val(data.wms_transfer_from_total_weight);
        $('#wmstransfer-wms_transfer_from_standard_package_number').val(data.wms_transfer_from_standard_package_number);
        $('#wmstransfer-wms_transfer_from_off_standard_package_number').val(data.wms_transfer_from_off_standard_package_number);
        $('#wmstransfer-wms_transfer_from_total_package_number').val(data.wms_transfer_from_total_package_number);
        $('#wmstransfer-wms_transfer_from_standard_weight').val(data.wms_transfer_from_standard_weight);
        $('#wmstransfer-wms_transfer_from_off_standard_weight').val(data.wms_transfer_from_off_standard_weight);
        $('#wmstransfer-wms_transfer_from_total_weight').val(data.wms_transfer_from_total_weight);
        $('#wmstransfer-wms_transfer_from_wms_info_id').val(data.wms_transfer_from_wms_info_id);
        $('#wmstransfer-wms_transfer_from_wms_info_name').val(data.wms_transfer_from_wms_info_name);
        $('#wmstransfer-wms_transfer_from_area_info_id').val(data.wms_transfer_from_area_info_id);
        $('#wmstransfer-wms_transfer_from_area_info_name').val(data.wms_transfer_from_area_info_name);
        $('#wmstransfer-wms_transfer_to_piece_type').val($('#wmstransfer-wms_transfer_from_piece_type').val());
        $('#wmstransfer-wms_transfer_to_piece_type_name').val($('#wmstransfer-wms_transfer_from_piece_type_name').val());
        $('#wmstransfer-wms_transfer_to_weight_per_package').val($('#wmstransfer-wms_transfer_from_weight_per_package').val());
        $('#wmstransfer-wms_transfer_to_standard_package_number').val($('#wmstransfer-wms_transfer_from_standard_package_number').val());
        $('#wmstransfer-wms_transfer_to_off_standard_package_number').val($('#wmstransfer-wms_transfer_from_off_standard_package_number').val());
        $('#wmstransfer-wms_transfer_to_total_package_number').val($('#wmstransfer-wms_transfer_from_total_package_number').val());
        $('#wmstransfer-wms_transfer_to_standard_weight').val($('#wmstransfer-wms_transfer_from_standard_weight').val());
        $('#wmstransfer-wms_transfer_to_off_standard_weight').val($('#wmstransfer-wms_transfer_from_off_standard_weight').val());
        $('#wmstransfer-wms_transfer_to_total_weight').val($('#wmstransfer-wms_transfer_from_total_weight').val());

        handlePieceTypeForTotalPackageNumber();
        handlePieceTypeForTotalWeight();
    });
}
/**
* 根据存货类型加载出库单号
*/
function loadWmsTransferFromCode(){
    var wms_transfer_from_type = $('#wmstransfer-wms_transfer_from_type').val();
    $.get('{$wmsTransferFromCodeUrl}', {wmsType:wms_transfer_from_type}, function(data) {
        $('#wmstransfer-wms_transfer_from_code').val(data);
    });
}
/**
* 根据存货类型加载入库单号
*/
function loadWmsTransferToCode(){
    var wms_transfer_to_type = $('#wmstransfer-wms_transfer_from_type').val();
    $.get('{$wmsTransferToCodeUrl}', {wmsType:wms_transfer_to_type}, function(data) {
        $('#wmstransfer-wms_transfer_to_code').val(data);
    });
}

/**
* 处理总件数的只读属性
*/
function handlePieceTypeForTotalPackageNumber(){
    var wms_transfer_from_piece_type = $('#wmstransfer-wms_transfer_from_piece_type').val();
    if(wms_transfer_from_piece_type == 1){
        $('#wmstransfer-wms_transfer_from_total_package_number').attr('readOnly', true);
    }else {
        $('#wmstransfer-wms_transfer_from_total_package_number').attr('readOnly', false);
    }
}

/**
* 根据总重量计算件数和重量
*/
function handlePieceTypeForTotalWeight(){
    var wms_transfer_from_in_code = $('#wmstransfer-wms_transfer_from_in_code').val();
    var wms_transfer_from_piece_type = $('#wmstransfer-wms_transfer_from_piece_type').val();
    var wms_transfer_from_weight_per_package = $('#wmstransfer-wms_transfer_from_weight_per_package').val();
    var wms_transfer_from_total_package_number = $('#wmstransfer-wms_transfer_from_total_package_number').val();
    var wms_transfer_from_surplus_weight = $('#wmstransfer-wms_transfer_from_surplus_weight').val();
    var wms_transfer_from_total_weight = $('#wmstransfer-wms_transfer_from_total_weight').val();
    if(Number(wms_transfer_from_total_weight) > Number(wms_transfer_from_surplus_weight)){
        alert('抱歉,出库量不能大于总库存量');
        $("#wmstransfer-wms_transfer_from_total_weight").val(wms_transfer_from_surplus_weight);
    }
    $.get('{$handleOutUrl}', {wms_in_sheet_number: wms_transfer_from_in_code,
        out_total_weight: wms_transfer_from_total_weight,
        out_total_package_number: wms_transfer_from_total_package_number
    }, function(data){
        $('#wmstransfer-wms_transfer_from_standard_package_number').val(data.out_standard_package_number);
        $('#wmstransfer-wms_transfer_from_off_standard_package_number').val(data.out_off_standard_package_number);
        $('#wmstransfer-wms_transfer_from_total_package_number').val(data.out_total_package_number);
        $('#wmstransfer-wms_transfer_from_standard_weight').val(data.out_standard_weight);
        $('#wmstransfer-wms_transfer_from_off_standard_weight').val(data.out_off_standard_weight);
        $('#wmstransfer-wms_transfer_from_total_weight').val(data.out_total_weight);
        $('#wmstransfer-wms_transfer_to_standard_package_number').val($('#wmstransfer-wms_transfer_from_standard_package_number').val());
        $('#wmstransfer-wms_transfer_to_off_standard_package_number').val($('#wmstransfer-wms_transfer_from_off_standard_package_number').val());
        $('#wmstransfer-wms_transfer_to_total_package_number').val($('#wmstransfer-wms_transfer_from_total_package_number').val());
        $('#wmstransfer-wms_transfer_to_standard_weight').val($('#wmstransfer-wms_transfer_from_standard_weight').val());
        $('#wmstransfer-wms_transfer_to_off_standard_weight').val($('#wmstransfer-wms_transfer_from_off_standard_weight').val());
        $('#wmstransfer-wms_transfer_to_total_weight').val($('#wmstransfer-wms_transfer_from_total_weight').val());
    }, 'json');
}

/**
* 加载调拨入库的存货类型列表
*/
function loadWmsTransferToTypeList(){
    var wms_transfer_from_type = $('#wmstransfer-wms_transfer_from_type').val();
    $.get('{$wmsTransferToTypeUrl}', {fromWmsType:wms_transfer_from_type}, function(data) {
        html = '<option value="">选择存货类型</option>';
        $(data).each(function(i, item){
            tempOption = '<option value="_gradeid_">_gradevalue_</option>';
            html += tempOption.replace(/_gradeid_/g, item.id).replace(/_gradevalue_/g, item.text);
        });
        $('#wmstransfer-wms_transfer_to_type').html(html);
    });
}

/**
* 根据入库单号获取显示存货名称和产地
*/
function loadWmsTransferToInfo(){
    var wms_transfer_from_in_code = $('#wmstransfer-wms_transfer_from_in_code').val();
    $.get('{$wmsInSheetInfoUrl}', {inSheetNumber:wms_transfer_from_in_code}, function(data) {
        $('#wmstransfer-wms_transfer_from_in_code_copy').val($("#wmstransfer-wms_transfer_from_in_code").find("option:selected").text());
        $('#wmstransfer-wms_transfer_to_type').val($("#wmstransfer-wms_transfer_from_type").val());
        $('#wmstransfer-wms_transfer_to_type_name').val($("#wmstransfer-wms_transfer_from_type").find("option:selected").text());
        $('#wmstransfer-wms_transfer_to_herb_info_id').val(data.wms_transfer_from_herb_info_id);
        $('#wmstransfer-wms_transfer_to_herb_info_name').val(data.wms_transfer_from_herb_info_name);
        $('#wmstransfer-wms_transfer_to_grade_info_id').val(data.wms_transfer_from_grade_info_id);
        $('#wmstransfer-wms_transfer_to_grade_info_name').val(data.wms_transfer_from_grade_info_name);
        $('#wmstransfer-wms_transfer_to_place_info_id').val(data.wms_transfer_from_place_info_id);
        $('#wmstransfer-wms_transfer_to_place_info_name').val(data.wms_transfer_from_place_info_name);
        $('#wmstransfer-wms_transfer_to_grade_info_describe').val(data.wms_transfer_to_grade_info_describe);
    });
    loadWmsTransferToCode();
}

$('#wmstransfer-wms_transfer_from_total_package_number').change(function() {
  handlePieceTypeForTotalWeight();
  if($('#wmstransfer-wms_transfer_from_piece_type').val() == 2){
      $('#wmstransfer-wms_transfer_from_off_standard_package_number').val($(this).val());
      $('#wmstransfer-wms_transfer_to_standard_package_number').val($('#wmstransfer-wms_transfer_from_standard_package_number').val());
    $('#wmstransfer-wms_transfer_to_off_standard_package_number').val($('#wmstransfer-wms_transfer_from_off_standard_package_number').val());
  $('#wmstransfer-wms_transfer_to_total_package_number').val($('#wmstransfer-wms_transfer_from_total_package_number').val());
  }

});

$('#wmstransfer-wms_transfer_from_total_weight').change(function() {
  handlePieceTypeForTotalWeight();
});

//处理标准重量和非标准重量的计算
function handlePieceTypeTrigger(){
    var wms_transfer_to_total_weight = $('#wmstransfer-wms_transfer_to_total_weight').val();
    var wms_transfer_to_piece_type = $('#wmstransfer-wms_transfer_to_piece_type').val();
    var wms_transfer_to_total_package_number = $('#wmstransfer-wms_transfer_to_total_package_number').val();
    var wms_transfer_to_weight_per_package = $('#wmstransfer-wms_transfer_to_weight_per_package').val();
    $.get('{$handleInUrl}', {piece_type: wms_transfer_to_piece_type,
        weight_per_package: wms_transfer_to_weight_per_package,
        in_total_weight: wms_transfer_to_total_weight,
        in_total_package_number: wms_transfer_to_total_package_number,
    }, function(data){
        $('#wmstransfer-wms_transfer_to_standard_package_number').val(data.in_standard_package_number);
        $('#wmstransfer-wms_transfer_to_off_standard_package_number').val(data.in_off_standard_package_number);
        $('#wmstransfer-wms_transfer_to_total_package_number').val(data.in_total_package_number);
        $('#wmstransfer-wms_transfer_to_standard_weight').val(data.in_standard_weight);
        $('#wmstransfer-wms_transfer_to_off_standard_weight').val(data.in_off_standard_weight);
        $('#wmstransfer-wms_transfer_to_total_weight').val(data.in_total_weight);
    }, 'json');
}

/**
 * 根据计件类型控制件数的只读属性
 */
function handlePackageNumber(){
    if($('#wmstransfer-wms_transfer_to_piece_type').val() == '1'){
        $('#wmstransfer-wms_transfer_to_total_package_number').attr('readOnly', true);
    }else{
        $('#wmstransfer-wms_transfer_to_total_package_number').attr('readOnly', false);
    }
}

function handleWeightPerPackage(){
    if($('#wmstransfer-wms_transfer_to_piece_type').val() == '1'){
        $('#wmstransfer-wms_transfer_to_weight_per_package').attr('readOnly', false);
    }else{
        $('#wmstransfer-wms_transfer_to_weight_per_package').attr('readOnly', true);
        $('#wmstransfer-wms_transfer_to_weight_per_package').val(0);
    }
}

function afterPieceTypeSelect(){
    handlePieceTypeTrigger();
}

$('#wmstransfer-wms_transfer_to_weight_per_package').change(function() {
  handlePieceTypeTrigger();
});
$('#wmstransfer-wms_transfer_to_total_package_number').change(function() {
  handlePieceTypeTrigger();
});
$('#wmstransfer-wms_transfer_to_total_weight').change(function() {
  handlePieceTypeTrigger();
});

$("#form-wms-product-out-record-sheet").on('click', ".inline-list-select-btn-choose-positoin",function() {
    if(!initStockPositionDialogTitleInfo(
            $("#wmstransfer-wms_transfer_from_herb_info_name").val(),
            $("#wmstransfer-wms_transfer_from_total_weight").val(),
            $("#wmstransfer-wms_transfer_from_total_package_number").val(),
            $("#wmstransfer-wms_transfer_from_wms_info_name").val()?$("#wmstransfer-wms_transfer_from_wms_info_name").val():null,
            $("#wmstransfer-wms_transfer_from_area_info_name").val()?$("#wmstransfer-wms_transfer_from_area_info_name").val():null,
             $(this).parents("#current_stock_positoin_area_product"))){
             $('#stock_position_modal').modal('hide');
             return false;
     }

    choosePositionModal($(this).attr('data-url'),
        $("#wmstransfer-wms_transfer_from_in_code").val(),
        $("#current_herb_grade_stock_position #stock_position_current_date",
        $(this).parent()),$(this).parent(),
        2,
        $("#wmstransfer-wms_transfer_from_code").val());
 });
$("#form-wms-product-out-record-sheet").on('click', ".inline-list-select-btn-choose-in-positoin", function(){
       if(!initStockPositionDialogTitleInfo(
            $("#wmstransfer-wms_transfer_to_herb_info_name").val(),
            $("#wmstransfer-wms_transfer_to_total_weight").val(),
            $("#wmstransfer-wms_transfer_to_total_package_number").val(),
            $("#wmstransfer-wms_transfer_to_wms_info_id").val()?$("#wmstransfer-wms_transfer_to_wms_info_id").find("option:selected").text():null,
            $("#wmstransfer-wms_transfer_to_area_info_id").val()?$("#wmstransfer-wms_transfer_to_area_info_id").find("option:selected").text():null,
             $(this).parents("#current_stock_positoin_area_product"))){
             $('#stock_position_modal').modal('hide');
             return false;
     }

    chooseStockWmsInPositionModal($(this).attr('data-url'),
        $("#wmstransfer-wms_transfer_to_code").val(),
        $("#wmstransfer-wms_transfer_to_area_info_id").val(),
        $("#current_herb_grade_stock_position #stock_position_current_date", $(this).parent()),
        $(this).parent())
 });

$('#to-position').click(function() {
  $('#in-position-table').append('');
});
JS;

$this->registerJs($js);
?>
<?php
\yii\bootstrap\Modal::begin([
    'id' => 'position-modal',
    'header' => '<h5 class="modal-title">添加库位详情信息</h5>',
    'footer' => '<a href="javascript:void(0)" class="btn btn-success btn-size" id="position-modal-save">确定</a><button class="btn btn-default btn-size position-modal-close" data-dismiss="modal">关闭</button>',
    'options' => [
        'tabindex' => false
    ],
    'size'=>\yii\bootstrap\Modal::SIZE_DEFAULT,
]);

$requestUrl = \yii\helpers\Url::to(['ajax-position']);
$appendJs = <<<JS
$("#position").click(function() {
    var wms_transfer_from_in_code = $("#wmstransfer-wms_transfer_from_in_code").val();
    if(wms_transfer_from_in_code == '' || wms_transfer_from_in_code == null || wms_transfer_from_in_code == 'undefined'){
        alert('请先入库单号');
        return false;
    }
    $.get('{$requestUrl}', {wms_transfer_from_in_code: wms_transfer_from_in_code},
        function (data) {
            $('#position-modal').find('.modal-body').html(data);
        }
    );
});
$("#position-modal-save").click(function() {
    $('#position-list').find(':checked').each(function(key, value) {
        alert(value,val());
    });

    $("#position-modal").modal("hide");
});
JS;
$this->registerJs($appendJs);
\yii\bootstrap\Modal::end();
?>
<?php
echo $this->render("../layouts/wms-layouts/stock_in_out_position_template.php");
?>
<div class="wms-transfer-form default_page-form">
<?php $form = ActiveForm::begin([
    'options'=>[
        'class' => 'form-horizontal',
    ],
    'fieldConfig' => [
        'template' => '{input}{error}',
        'options' => ['class' => 'form-field'],
    ],
    'id'=>'form-wms-product-out-record-sheet',
]); ?>
<table class="table table-bordered" style="margin: 0;">
    <tr style="background-color: #F1F1F1;">
        <td colspan="9" class="type_title title_create"><?= $model->isNewRecord ? Yii::t('app', '新建') : Yii::t('app', '编辑') ?>
            <ul class="nav pull-right">
                <?= Html::a('返回', ['index'], ['class' => 'divider-vertical']) ?>
            </ul>
        </td>
    </tr>
    <tr>
        <td colspan="9" class="type_title">库存调拨信息</td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">编号</label>
        </td>
        <td colspan="2">
            <?php
            echo $form->field($model, 'wms_transfer_code')->textInput(['readonly' => true])
            ?>
        </td>
        <td class="item-label">
            <label class="control-label">基地</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'common_producer_info_id')->widget(\kartik\select2\Select2::className(), [
                'data' => \yii\helpers\ArrayHelper::map(core\models\CommonProducerInfo::getCommonProducerInfoList(),'division_id','common_producer_info_name'),
                'options' => ['placeholder' => '请选择基地', 'disabled'=>true],
                'hideSearch' => false,
                'pluginOptions' => ['allowClear' => true, ],
            ])
            ?>
        </td>
    </tr>
    <tr>
        <td colspan="9" class="type_title">库存调拨出库信息</td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">存货类型<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?= $form->field($model, 'wms_transfer_from_type')->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\WmsTransfer::getWmsTypeOptions(),
                'options' => [
                    'placeholder' => '存货类型',
                ],
                'pluginOptions' => ['allowClear' => true],
                'pluginEvents' => [
                    "select2:select" => 'function() {
                loadWmsInSheetList();
                loadWmsTransferFromCode();
                loadWmsTransferToCode();
                loadWmsTransferToTypeList();
                $("#wmstransfer-wms_transfer_from_in_code").val(null).trigger("change");
            }',
                ]
            ])
            ?>
        </td>
        <td class="item-label">
            <label class="control-label">关联单号<span class="error">(必填)</span></label>
        </td>
        <td colspan="2">
            <?php
            echo $form->field($model, 'wms_transfer_from_in_code')->widget(\kartik\select2\Select2::className(), [
                'data' => isset($model->wms_transfer_from_type) ? \yii\helpers\ArrayHelper::map(\core\models\WmsTransfer::getInSheetNumberMap($model->wms_transfer_from_type, $common_producer_info_id), 'in_sheet_number', 'in_sheet_number') : [],
                'options' => [
                    'placeholder' => '选择关联单号',
                    'value'=>$model->wms_transfer_from_in_code,
                ],
                'pluginOptions' => [
                    'allowClear' => true,

                ],
                'pluginEvents' => [
                    "select2:select" => 'function() {
                loadWmsInSheetInfo();
                loadWmsTransferToInfo();
            }',
                ],
            ])
            ?>
        </td>
        <td class="item-label">
            <label class="control-label">出库单号</label>
        </td>
        <td colspan="2">
            <?php
            echo $form->field($model, 'wms_transfer_from_code')->textInput(['readonly' => true])
            ?>
        </td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">存货名称</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_herb_info_id')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_from_herb_info_name')->textInput(['readonly' => true]) ?>
        </td>
        <td class="item-label">
            <label class="control-label">等级</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_grade_info_id')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_from_grade_info_name')->textInput(['readonly' => true]) ?>
        </td>
        <td class="item-label">
            <label class="control-label">等级备注</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_grade_info_describe')->textInput([
                'readonly' => true,
                'value'=>\core\models\WmsTransfer::getGradeDescribeByInSheetNumber($model->wms_transfer_from_in_code)]) ?>
        </td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">产地</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_place_info_id')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_from_place_info_name')->textInput(['readonly' => true]) ?>
        </td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">计件类型</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_piece_type')->hiddenInput(['value'=>$model->wms_transfer_from_piece_type]) ?>
            <?= $form->field($model, 'wms_transfer_from_piece_type_name')->textInput(['readonly' => true, 'value'=>\core\models\WmsManager::getPieceTypeName($model->wms_transfer_from_piece_type)]) ?>
        </td>
        <td class="item-label">
            <label class="control-label">包装规格</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_weight_per_package')->textInput([
                'readonly' => true
            ]) ?>
        </td>
        <td class="item-label">
            <label class="control-label">剩余重量</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_surplus_weight')->textInput([
                'type' => 'number',
                'step' => '0.01',
                'min' => '0',
                'readonly' => true]) ?>
        </td>
    </tr>
    <tr>
        <td  class="item-label">
            <label class="control-label">标准件数</label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"标准件数"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_standard_package_number')->textInput([
                'type' => 'number',
                'step' => '1',
                'min' => '0',
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">非标准件数</label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"非标准件数"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_off_standard_package_number')->textInput([
                'type' => 'number',
                'step' => '1',
                'min' => '0',
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">总件数<span class="error">(必填)</span></label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"总件数"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_total_package_number')->textInput([
                'type' => 'number',
                'step' => '1',
                'min' => '0',
            ]) ?>
        </td>
    </tr>
    <tr>
        <td  class="item-label">
            <label class="control-label">标准重量</label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"标准重量"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_standard_weight')->textInput([
                'type' => 'number',
                'step' => '0.01',
                'min' => '0',
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">非标准重量</label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"非标准重量"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_off_standard_weight')->textInput([
                'type' => 'number',
                'step' => '0.01',
                'min' => '0',
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">总重量<span class="error">(必填)</span></label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"总重量"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_total_weight')->textInput([
                'type' => 'number',
                'step' => '0.01',
                'min' => '0',
            ]) ?>
        </td>
    </tr>
    <tr>
        <td  class="item-label">
            <label class="control-label">仓库</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_wms_info_id')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_from_wms_info_name')->textInput([
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">库区</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_from_area_info_id')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_from_area_info_name')->textInput([
                'readOnly'=>true,
            ]) ?>
        </td>
        <td colspan="2" class="item-value">
            <?php
            $wms_stock_position_detail_list = \core\models\WmsOutSheetPositionRelationRecord::findAll([
                'relative_id' => isset($model->id)?$model->id:null,
                'relative_code' =>  $model->wms_transfer_code,
            ]);
            echo $this->render("../layouts/wms-layouts/stock_out_position_btn.php",
                ["wms_stock_position_detail_list"=>$wms_stock_position_detail_list,
                    "wms_in_sheet_number"=>$model->wms_transfer_from_in_code]);
            ?>
        </td>
    </tr>
    <tr>
        <td colspan="9" class="type_title">库存调拨入库信息</td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">存货类型<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?= $form->field($model, 'wms_transfer_to_type')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_to_type_name')->textInput(['readOnly'=>true, 'value'=>$model->getWmsTypeName($model->wms_transfer_to_type)]) ?>
            <?php
            /*
            echo $form->field($model, 'wms_transfer_to_type')->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\WmsTransfer::getWmsTypeOptions(),
                'options' => [
                    'placeholder' => '存货类型',
                ],
                'pluginOptions' => ['allowClear' => true],
                'pluginEvents' => [
                    "select2:select" => 'function() {
                loadWmsTransferToCode();
            }',
                ]
            ])
            */
            ?>
        </td>
        <td class="item-label">
            <label class="control-label">关联单号</label>
        </td>
        <td colspan="2">
            <?php
            echo $form->field($model, 'wms_transfer_from_in_code_copy')->textInput(['readonly' => true, 'value'=>$model->wms_transfer_from_in_code])
            ?>
        </td>
        <td class="item-label">
            <label class="control-label">入库单号</label>
        </td>
        <td colspan="2">
            <?php
            echo $form->field($model, 'wms_transfer_to_code')->textInput(['readonly' => true])
            ?>
        </td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">存货名称</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_herb_info_id')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_to_herb_info_name')->textInput(['readonly' => true]) ?>
        </td>
        <td class="item-label">
            <label class="control-label">等级<span class="error">(必填)</span></label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_grade_info_id')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_to_grade_info_name')->textInput(['readonly' => true]) ?>
            <?php
            /*
            echo $form->field($model, 'wms_transfer_to_grade_info_id')->widget(\kartik\select2\Select2::className(), [
                'data' => isset($model->wms_transfer_to_type) ? \yii\helpers\ArrayHelper::map(\core\models\WmsTransfer::getGradeInfoList($model->wms_transfer_to_type, $model->wms_transfer_to_herb_info_id)['results'], 'id', 'text') : [],
                'options' => ['placeholder' => '请选择等级'],
                'hideSearch' => true,
                'pluginOptions' => [
                    'allowClear' => true,
                    'ajax' => [
                        'url' => \yii\helpers\Url::to(['wms-transfer/ajax-get-wms-herb-grade-info-list']),
                        'dataType' => 'json',
                        'data' => new \yii\web\JsExpression('function(params) { return {
                                                wms_type: $("#wmstransfer-wms_transfer_to_type").val(),
                                                herb_info_id: $("#wmstransfer-wms_transfer_to_herb_info_id").val(),
                                            }; }')
                    ],
                    'escapeMarkup' => new \yii\web\JsExpression('function (markup) { return markup; }'),
                    'templateResult' => new \yii\web\JsExpression('function(content) { return content.text; }'),
                    'templateSelection' => new \yii\web\JsExpression('function (content) { return content.text; }'),],
            ]);
            */
            ?>
        </td>
        <td class="item-label">
            <label class="control-label">等级备注</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_grade_info_describe')->textInput([
                'readonly' => true,
                'value'=>\core\models\WmsTransfer::getGradeDescribeByInSheetNumber($model->wms_transfer_from_in_code)]) ?>
        </td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">产地</label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_place_info_id')->hiddenInput() ?>
            <?= $form->field($model, 'wms_transfer_to_place_info_name')->textInput(['readonly' => true]) ?>
        </td>
    </tr>
    <tr>
        <td class="item-label">
            <label class="control-label">计件类型<span class="error">(必填)</span></label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_piece_type')->hiddenInput(['value'=>$model->wms_transfer_to_piece_type]) ?>
            <?= $form->field($model, 'wms_transfer_to_piece_type_name')->textInput(['readonly' => true, 'value'=>\core\models\WmsManager::getPieceTypeName($model->wms_transfer_to_piece_type)]) ?>
            <?php
            /*
            echo $form->field($model, 'wms_transfer_to_piece_type')->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\WmsManager::getPieceTypeOptions(),
                'options' => [
                    'placeholder' => '选择计件类型',
                ],
                'pluginOptions' => ['allowClear' => true],
                'pluginEvents' => [
                    "select2:select" => 'function() {
                    handlePieceTypeTrigger();
                    handlePackageNumber();
                    handleWeightPerPackage();
            }',
                ]
            ])
            */
            ?>
        </td>
        <td class="item-label">
            <label class="control-label">包装规格<span class="error">(必填)</span></label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_weight_per_package')->textInput([
                'type' => 'number',
                'step' => '0.01',
                'min' => '0',
                'value'=>$model->wms_transfer_to_weight_per_package,
                'readonly' => true]) ?>
        </td>
    </tr>
    <tr>
        <td  class="item-label">
            <label class="control-label">标准件数</label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"标准件数"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_standard_package_number')->textInput([
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">非标准件数</label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"非标准件数"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_off_standard_package_number')->textInput([
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">总件数<span class="error">(必填)</span></label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"总件数"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_total_package_number')->textInput([
                'type' => 'number',
                'step' => '1',
                'min' => '0',
                'readOnly'=>true,
            ]) ?>
        </td>
    </tr>
    <tr>
        <td  class="item-label">
            <label class="control-label">标准重量</label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"标准重量"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_standard_weight')->textInput([
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">非标准重量</label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"非标准重量"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_off_standard_weight')->textInput([
                'readOnly'=>true,
            ]) ?>
        </td>
        <td  class="item-label">
            <label class="control-label">总重量<span class="error">(必填)</span></label>
            <?= \backend\widgets\CusTooltipsWidget::widget(["key"=>"总重量"]);?>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_total_weight')->textInput([
                'type' => 'number',
                'step' => '0.01',
                'min' => '0',
                'readOnly'=>true,
            ]) ?>
        </td>
    </tr>
    <tr>
        <td  class="item-label">
            <label class="control-label">仓库<span class="error">(必填)</span></label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_wms_info_id')->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\CommonProducerWmsInfo::getCommonProducerWmsInfoList(),
                'options' => ['placeholder' => '请选择仓库'],
                'hideSearch' => true,
                'pluginOptions' => [
                    'allowClear' => true,
                    'ajax' => [
                        'url' => \yii\helpers\Url::to(['common-producer-wms-info/get-common-producer-wms-info-list']),
                        'dataType' => 'json',
                        'data' => new \yii\web\JsExpression('function(params) { return {
                                                common_producer_info_id: $("#wmstransfer-common_producer_info_id").val(),
                                            }; }')
                    ],
                    'escapeMarkup' => new \yii\web\JsExpression('function (markup) { return markup; }'),
                    'templateResult' => new \yii\web\JsExpression('function(content) { return content.text; }'),
                    'templateSelection' => new \yii\web\JsExpression('function (content) { return content.text; }'),
                ],
                'pluginEvents' => [
                    "select2:select" => 'function() {
                        $("#wmstransfer-wms_transfer_to_area_info_id").val(null).trigger("change");
                    }',
                ]
            ])
            ?>
        </td>
        <td  class="item-label">
            <label class="control-label">库区<span class="error">(必填)</span></label>
        </td>
        <td colspan="2">
            <?= $form->field($model, 'wms_transfer_to_area_info_id'  )->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\CommonProducerWmsAreaInfo::getCommonProducerWmsAreaInfoList(),
                'options' => ['placeholder' => '请选择所属库区'],
                'hideSearch' => true,
                'pluginOptions' => ['allowClear' => true,
                    'maximumInputLength' => 100,
                    'ajax' => [
                        'url' => \yii\helpers\Url::to(['common-producer-wms-area-info/get-common-producer-wms-area-info-list']),
                        'dataType' => 'json',
                        'data' => new \yii\web\JsExpression('function(params) { return {
                                                common_producer_wms_info_id: $("#wmstransfer-wms_transfer_to_wms_info_id").val(),
                                            }; }')
                    ],
                    'escapeMarkup' => new \yii\web\JsExpression('function (markup) { return markup; }'),
                    'templateResult' => new \yii\web\JsExpression('function(content) { return content.text; }'),
                    'templateSelection' => new \yii\web\JsExpression('function (content) { return content.text; }'),
                ],
            ])
            ?>
        </td>
        <td colspan="2" class="item-value">
            <?php
            $wms_stock_position_detail_list = \core\models\WmsInSheetPositionRelationRecord::findAll([
                'relative_id' => isset($model->id)?$model->id:null,
                'relative_code' =>  $model->wms_transfer_code
            ]);
            echo $this->render("../layouts/wms-layouts/stock_in_position_btn.php", ["wms_stock_position_detail_list"=>$wms_stock_position_detail_list]);
            ?>
        </td>
    </tr>
    <tr>
        <td colspan="9" class="type_title">相关人员信息</td>
    </tr>
    <tr>
        <td class="item-label" colspan="1">
            <label class="control-label">调拨申请人<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?= $form->field($model, 'wms_transfer_wms_manager_id')->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\User::getUserOptionsByConversionBaseId(\core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true)),
                'options' => [
                    'placeholder' => '请选择调拨申请人',
                    'disabled'=> false
                ],
                'pluginOptions' => ['allowClear' => true],
            ])
            ?>
        </td>
        <td class="item-label" colspan="1">
            <label class="control-label">调拨申请日期<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?= $form->field($model, 'wms_transfer_wms_manager_date')->widget(\kartik\datetime\DateTimePicker::classname(), [
                'options' => [
                    'placeholder' => '调拨申请日期',
                    'disabled'=> false,
                    'value' => $model->wms_transfer_wms_manager_date,
                ],
                'readonly' => false,
                'pluginOptions' => [
                    'autoclose' => true,
                    'format' => 'yyyy-mm-dd',
                    'minView' => 4,
                    'maxView' => 4,
                ]
            ])
            ?>
        </td>
    </tr>
    <tr>
        <td class="item-label" colspan="1">
            <label class="control-label">出库确认人<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?= $form->field($model, 'wms_transfer_from_wms_manager_id')->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\User::getUserOptionsByConversionBaseId(\core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true)),
                'options' => [
                    'placeholder' => '请选择出库确认人',
                    'disabled'=> false
                ],
                'pluginOptions' => ['allowClear' => true],
            ])
            ?>
        </td>
        <td class="item-label" colspan="1">
            <label class="control-label">出库确认日期<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?php
            $currentMonthDateInfo = \core\models\CommonFinanceDateFacade::getCurrentMonthDateInfo();
            if (time() > $currentMonthDateInfo['commonFinanceDateEnd']){
                $commonFinanceDate = \core\models\CommonFinanceDateFacade::getCommonFinanceDate();
                $model->addError('wms_transfer_from_wms_manager_date', '已到达本月盘点日'.date('Y-m-d H:i:s', $commonFinanceDate));

                $nmfd = \core\models\CommonFinanceDateFacade::getNextMonthFirstDay();
                $currentMonthDateInfo = [
                    'commonFinanceDateBegin' => $nmfd,
                    'commonFinanceDateEnd' => $nmfd,
                ];}
            ?>
            <?= $form->field($model, 'wms_transfer_from_wms_manager_date')->widget(\kartik\datetime\DateTimePicker::classname(), [
                'options' => [
                    'placeholder' => '出库确认日期',
                    'disabled'=> false,
                    'value' => $model->wms_transfer_from_wms_manager_date,
                ],
                'readonly' => false,
                'pluginOptions' => [
                    'weekStart'=>1,
                    'format' => 'yyyy-mm-dd',
                    'startDate'=>date('Y-m-d', $currentMonthDateInfo['commonFinanceDateBegin']),
                    'endDate'=>date('Y-m-d', $currentMonthDateInfo['commonFinanceDateEnd']),
                    'daysOfWeekDisabled'=>[],
                    'autoclose' => true,
                    'startView'=>2,
                    'minView'=>2,
                    'maxView'=>4,
                    'todayHighlight'=>true,
                    'keyboardNavigation'=>true,
                    'forceParse'=>false,
                ]
            ])
            ?>
        </td>
    </tr>
    <tr>
        <td class="item-label" colspan="1">
            <label class="control-label">入库确认人<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?= $form->field($model, 'wms_transfer_to_wms_manager_id')->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\User::getUserOptionsByConversionBaseId(\core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true)),
                'options' => [
                    'placeholder' => '请选择入库确认人',
                    'disabled'=> false
                ],
                'pluginOptions' => ['allowClear' => true],
            ])
            ?>
        </td>
        <td class="item-label" colspan="1">
            <label class="control-label">入库确认日期<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?php
            $currentMonthDateInfo = \core\models\CommonFinanceDateFacade::getCurrentMonthDateInfo();
            if (time() > $currentMonthDateInfo['commonFinanceDateEnd']){
                $commonFinanceDate = \core\models\CommonFinanceDateFacade::getCommonFinanceDate();
                $model->addError('wms_transfer_to_wms_manager_date', '已到达本月盘点日'.date('Y-m-d H:i:s', $commonFinanceDate));

                $nmfd = \core\models\CommonFinanceDateFacade::getNextMonthFirstDay();
                $currentMonthDateInfo = [
                    'commonFinanceDateBegin' => $nmfd,
                    'commonFinanceDateEnd' => $nmfd,
                ];}
            ?>
            <?= $form->field($model, 'wms_transfer_to_wms_manager_date')->widget(\kartik\datetime\DateTimePicker::classname(), [
                'options' => [
                    'placeholder' => '入库确认日期',
                    'disabled'=> false,
                    'value' => $model->wms_transfer_to_wms_manager_date,
                ],
                'readonly' => false,
                'pluginOptions' => [
                    'weekStart'=>1,
                    'format' => 'yyyy-mm-dd',
                    'startDate'=>date('Y-m-d', $currentMonthDateInfo['commonFinanceDateBegin']),
                    'endDate'=>date('Y-m-d', $currentMonthDateInfo['commonFinanceDateEnd']),
                    'daysOfWeekDisabled'=>[],
                    'autoclose' => true,
                    'startView'=>2,
                    'minView'=>2,
                    'maxView'=>4,
                    'todayHighlight'=>true,
                    'keyboardNavigation'=>true,
                    'forceParse'=>false,
                ]
            ])
            ?>
        </td>
    </tr>
    <tr>
        <td class="item-label" colspan="1">
            <label class="control-label">质量放行人<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?= $form->field($model, 'wms_transfer_quality_manager_id')->widget(\kartik\select2\Select2::className(), [
                'data' => \core\models\User::getUserOptionsByConversionBaseId(\core\models\Division::getTopDivisionId(Yii::$app->user->identity->division_id,true)),
                'options' => [
                    'placeholder' => '请选择质量放行人',
                    'disabled'=> false
                ],
                'pluginOptions' => ['allowClear' => true],
            ])
            ?>
        </td>
        <td class="item-label" colspan="1">
            <label class="control-label">质量放行日期<span class="error">(必填)</span></label>
        </td>
        <td colspan="2" style="white-space:nowrap;">
            <?= $form->field($model, 'wms_transfer_quality_manager_date')->widget(\kartik\datetime\DateTimePicker::classname(), [
                'options' => [
                    'placeholder' => '质量放行日期',
                    'disabled'=> false,
                    'value' => $model->wms_transfer_quality_manager_date,
                ],
                'readonly' => false,
                'pluginOptions' => [
                    'autoclose' => true,
                    'format' => 'yyyy-mm-dd',
                    'minView' => 4,
                    'maxView' => 4,
                ]
            ])
            ?>
        </td>
    </tr>
    <tr>
        <td colspan="9" class="type_title">
            <div class="button-group" style="text-align:center;">
                <?= Html::submitButton('保存', ['class' => 'btn btn-success btn-size']) ?>
                <?= Html::a('返回', ['index'], ['class' => 'btn btn-default btn-size']) ?>
            </div>
        </td>
    </tr>
</table>
<?php ActiveForm::end(); ?>
</div>
<script>
$(function () {
    $("#out-position-table").delegate(".item_copy_out", "click", function (event) {
        index = $(this).index('.item_copy_out');
        var tr_html = $(this).parents("tr").clone();
        $(".item_copy_out").last().parents("tr").after(tr_html);
    });

    $("#out-position-table").delegate(".item_delete_out", "click", function (event) {
        var index = $(this).index('.item_delete_out');
        var len = $('a.item_delete_out').length;
        if(len > 1){
            $(this).parents("tr")[0].remove();
        }
    });

    $("#in-position-table").delegate(".item_copy", "click", function (event) {
        index = $(this).index('.item_copy');
        var tr_html = $(this).parents("tr").clone();
        $(".item_copy").last().parents("tr").after(tr_html);
    });

    $("#in-position-table").delegate(".item_delete", "click", function (event) {
        var index = $(this).index('.item_delete');
        var len = $('a.item_delete').length;
        if(len > 1){
            $(this).parents("tr")[0].remove();
        }
    });
});
</script>

Yii2后台管理系统常规单据模块最佳实践的更多相关文章

  1. [ABP项目实战]-后台管理系统-目录

    学习ABP也有一段时间了,但是总是学习了后面的忘记了前面的,为了巩固所学到的知识以及记录所学到的东西,因此有了本系列的诞生. ABP ASP.NET Boilerplate Project(ABP.N ...

  2. 【后台管理系统】—— Ant Design Pro入门学习&项目实践笔记(三)

    前言:前一篇记录了[后台管理系统]目前进展开发中遇到的一些应用点,这一篇会梳理一些自己学习Ant Design Pro源码的功能点.附:Ant Design Pro 在线预览地址. Dashboard ...

  3. 使用react全家桶制作博客后台管理系统 网站PWA升级 移动端常见问题处理 循序渐进学.Net Core Web Api开发系列【4】:前端访问WebApi [Abp 源码分析]四、模块配置 [Abp 源码分析]三、依赖注入

    使用react全家桶制作博客后台管理系统   前面的话 笔者在做一个完整的博客上线项目,包括前台.后台.后端接口和服务器配置.本文将详细介绍使用react全家桶制作的博客后台管理系统 概述 该项目是基 ...

  4. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(22)-权限管理系统-模块导航制作

    原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(22)-权限管理系统-模块导航制作 最近比较忙,系统难度独步增加,文章的发布速度明显比以前慢了. 由于我们 ...

  5. ASP.NET -- WebForm -- Cookie的使用 应用程序权限设计 权限设计文章汇总 asp.net后台管理系统-登陆模块-是否自动登陆 C# 读写文件摘要

    ASP.NET -- WebForm -- Cookie的使用 ASP.NET -- WebForm --  Cookie的使用 Cookie是存在浏览器内存或磁盘上. 1. Test3.aspx文件 ...

  6. Javascript模块化编程(一)模块的写法最佳实践六、输入全局变量 独立性是模块的重要特点,模块内部最好不与程序的其他部分直接交互。 为了在模块内部调用全局变量,必须显式地将其他变量输入模块。

    Javascript模块化编程,已经成为一个迫切的需求.理想情况下,开发者只需要实现核心的业务逻辑,其他都可以加载别人已经写好的模块但是,Javascript不是一种模块化编程语言,它不支持类clas ...

  7. nodejs 实践:express 最佳实践(七) 改造模块 connect2 解析

    nodejs 实践:express 最佳实践(七) 改造模块 connect2 解析 nodejs 发展很快,从 npm 上面的包托管数量就可以看出来.不过从另一方面来看,也是反映了 nodejs 的 ...

  8. asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发3-登录模块开发

    进行本文之前需要在数据库用户表里面增加一条用户数据,直接手动添加即可,未安全考虑密码一定要使用Md5加密后的,这里提供666666的Md5密文为(c831b04de153469d),本文完成登录模块的 ...

  9. Javascript模块化编程(一)模块的写法最佳实践

    Javascript模块化编程,已经成为一个迫切的需求.理想情况下,开发者只需要实现核心的业务逻辑,其他都可以加载别人已经写好的模块但是,Javascript不是一种模块化编程语言,它不支持类clas ...

随机推荐

  1. MacOS 10.12 Sierra 安全性与隐私没有任何来源选项解决方法

    MacOS 10.12 Sierra 安全性与隐私没有任何来源选项解决方法 来源: 时间:2016年09月21日 在升级了macOS Sierra (10.12)版本后在“安全性与隐私”中不再有“任何 ...

  2. 【转】Android动态破解微信本地数据库(EnMicroMsg.db)

    最近在公司接了一个任务,需要在几百台手机上安装一个app,目的是获取微信里面的通讯录,并且定时的把他发送到我们的服务器上.当时依次尝试的如下几个方案: 1.通过群控,将好友截图发送到服务端(pytho ...

  3. 【转】bios与CMOS有什么区别

    正确的解释应该是: BIOS是软件.是程序! CMOS是芯片.是硬件! 实际上我们是通过BIOS这个程序,去设置CMOS里的参数的. CMOS是一块芯片,集成在主板上,里面保存着重要的开机参数,而保存 ...

  4. 请根据英文单词的第一个字母判断星期几,如果第一个字母是一样的,则继续判断第二个字母。例如如果第一个字母是S,则继续判断第二个字母,如果第二个字母是a,则输出“星期六”

    请根据英文单词的第一个字母判断星期几,如果第一个字母是一样的,则继续判断第二个字母.例如如果第一个字母是S,则继续判断第二个字母,如果第二个字母是a,则输出“星期六”.星期的英文单词如下表所示. 星期 ...

  5. 操作循环的关键字switch,break,return的应用及区别

    break 使用break结束循环  break可以终止循环 和 switch语句的运行; break用于结束一个循环,即跳出循环体,执行循环体之后的代码: switch 使用continue提前结束 ...

  6. WindowsFormsHost下MouseWheel失效的解决办法

    原文:WindowsFormsHost下MouseWheel失效的解决办法 看了网上有些写的用钩子,但是,在Stack Overflow上找到一个简便的方式

  7. HTML+CSS之盒子模型

    一.元素分类 CSS中html的标签元素大体分为三种类型 1.块状元素 @特点: #每个块级元素都从新的一行开始,并且其后的元素也另起一行(一个块级元素独占一行) #元素的高度.宽度.行高以及顶和底边 ...

  8. Microsoft Tech Summit 2018 课程简述:利用 Windows 新特性开发出更好的手绘视频应用

    概述 Microsoft Tech Summit 2018 微软技术暨生态大会将于10月24日至27日在上海世博中心举行,这也会是国内举办的最后一届 Tech Summit,2019 年开始会以 Mi ...

  9. H5 id选择器和class选择器

    11-id选择器和class选择器 第一段文字 第二段文字 第三段文字 --> 第一段文字 第二段文字 第三段文字 <!DOCTYPE html> <html lang=&qu ...

  10. Generalized Power Method for Sparse Principal Component Analysis

    目录 重点 算法 这篇文章,看的晕晕的,但是被引用了400多次了,就简单地记一笔. 这个东西,因为\(\ell_1\)范数,所以会稀疏化,当然,和\(\gamma\)有关. 重点 我想重点写的地方是下 ...