| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace app\admin\model\ps;
- use think\Model;
- class Field_dict extends Model
- {
-
-
- // 表名
- protected $name = 'ps_field_dict';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'status_text'
- ];
-
- protected static function init()
- {
- self::afterInsert(function ($row) {
- if (!$row['weigh']) {
- $pk = $row->getPk();
- $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
- }
- });
- }
-
- public function getStatusList()
- {
- return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
- }
- public function getGroupList()
- {
- return [
- 'product' => __('Product'),
- 'workorder' => __('Workorder'),
- 'process' => __('Process'),
- 'user' => __('User'),
- 'print' => __('Print'),
- ];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ?: ($data['status'] ?? '');
- $list = $this->getStatusList();
- return $list[$value] ?? '';
- }
- }
|