getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); }); } public function getIstreeList() { return ['0' => __('Istree 0'), '1' => __('Istree 1')]; } public function getEnabledList() { return ['1' => __('Enabled 1'), '0' => __('Enabled 0')]; } public function getIstreeTextAttr($value, $data) { $value = $value ? $value : $data['istree']; $list = $this->getIstreeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getEnabledTextAttr($value, $data) { $value = $value ? $value : $data['enabled']; $list = $this->getEnabledList(); return isset($list[$value]) ? $list[$value] : ''; } public function getDatadic($code = '') { $sqlresult = \think\Db::view('stock_datadict a','code') ->view('stock_datadictitem b','name,value','a.id=b.datadict_id') ->where('a.code',$code) ->order('b.weigh ASC') ->select(); $result = []; foreach ($sqlresult as $k => $v) { $result[$v['value']] = $v['name']; } return $result; } }