diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php index 087241b36..8399bff66 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php @@ -360,7 +360,7 @@ class SystemCrud extends AuthController if (config('filesystem.password') != $pwd) { return app('json')->fail('文件管理密码错误'); } - + if (empty($filepath) || !$id) { return app('json')->fail(410087); } diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index bd421af0f..8b6f47515 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -172,10 +172,10 @@ class SystemCrudServices extends BaseServices // 'value' => 'dateTimeRange', // 'label' => '日期时间区间选择', // ], - [ - 'value' => 'checkbox', - 'label' => '多选框', - ], +// [ +// 'value' => 'checkbox', +// 'label' => '多选框', +// ], [ 'value' => 'radio', 'label' => '单选框', @@ -811,6 +811,10 @@ class SystemCrudServices extends BaseServices if (in_array($fieldType, ['text', 'longtext', 'tinytext'])) { unset($option['limit']); } + //判断字段类型 + if ($fieldType == 'boolean' && isset($option['default']) && $option['default'] === '') { + unset($option['default']); + } $table->addColumn($item['field'], $this->changeTabelRule($item['field_type']), $option); } } diff --git a/crmeb/crmeb/services/AccessTokenServeService.php b/crmeb/crmeb/services/AccessTokenServeService.php index 489e5d2f1..92bb48cb2 100644 --- a/crmeb/crmeb/services/AccessTokenServeService.php +++ b/crmeb/crmeb/services/AccessTokenServeService.php @@ -146,15 +146,14 @@ class AccessTokenServeService extends HttpService * @param bool $isHeader * @return array|mixed */ - public function httpRequest(string $url, array $data = [], string $method = 'POST', bool $isHeader = true) + public function httpRequest(string $url, array $data = [], string $method = 'POST', bool $isHeader = true, array $header = []) { - $header = []; if ($isHeader) { $this->getToken(); if (!$this->accessToken) { throw new ApiException(410086); } - $header = ['Authorization:Bearer-' . $this->accessToken]; + $header = array_merge($header, ['Authorization:Bearer-' . $this->accessToken]); } $res = $this->request($this->get($url), $method, $data, $header); diff --git a/crmeb/crmeb/services/crud/Make.php b/crmeb/crmeb/services/crud/Make.php index 2156caa26..9d9ff3812 100644 --- a/crmeb/crmeb/services/crud/Make.php +++ b/crmeb/crmeb/services/crud/Make.php @@ -81,6 +81,12 @@ abstract class Make */ protected $value = []; + /** + * 数据库获取器后缀 + * @var string + */ + protected $attrPrefix = '_label'; + /** * 后台前端模板根路径 * @var string diff --git a/crmeb/crmeb/services/crud/Model.php b/crmeb/crmeb/services/crud/Model.php index 5795dd7cb..6ca3bc4f7 100644 --- a/crmeb/crmeb/services/crud/Model.php +++ b/crmeb/crmeb/services/crud/Model.php @@ -14,6 +14,8 @@ namespace crmeb\services\crud; +use think\helper\Str; + /** * Class Model * @author 等风来 @@ -57,9 +59,73 @@ class Model extends Make $this->value['content-php'] = $this->tab() . "use SoftDelete;\n"; } $this->value['modelName'] = $options['modelName'] ?? $name; + $field = $options['fromField'] ?? []; + + $attrFnContent = []; + foreach ($field as $item) { + if (in_array($item['type'], ['radio', 'select']) && !empty($item['option'])) { + $attrFnContent[] = $this->getAttrFnContent($item['field'], $item['name'], $item['option']); + } + } + if ($attrFnContent) { + $this->value['attr-php'] = "\n" . implode("\n", $attrFnContent); + } + return parent::handle($name, $options); } + /** + * + * @param string $key + * @param array $options + * @return array|false|string|string[] + * @author 等风来 + * @email 136327134@qq.com + * @date 2023/5/11 + */ + protected function getAttrFnContent(string $key, string $comment, array $options) + { + $attrFnStub = file_get_contents($this->getStub('attr')); + $var = ['{%field%}', '{%date%}', '{%name%}', '{%content-php%}']; + $value = [ + Str::studly($key . $this->attrPrefix), + date('Y-m-d'), + $comment, + $this->getSwithAndSelectPhpContent($options) + ]; + + return str_replace($var, $value, $attrFnStub); + } + + /** + * 获取开关和下拉框获取器内容 + * @param array $options + * @return string + * @author 等风来 + * @email 136327134@qq.com + * @date 2023/5/11 + */ + protected function getSwithAndSelectPhpContent(array $options) + { + if (!$options) { + return ''; + } + $case = []; + foreach ($options as $option) { + $case[] = $this->tab(3) . "case " . $option['value'] . ":\n" . $this->tab(4) . "\$attr = '$option[label]';\n" . $this->tab(4) . "break;"; + } + $caseContent = implode("\n", $case); + $tab2 = $this->tab(2); + $content = << $routePath . 'crudModel.stub', + 'attr' => $routePath . 'getattr.stub', + ]; + + return $type ? $stubs[$type] : $stubs['model']; } } diff --git a/crmeb/crmeb/services/crud/Service.php b/crmeb/crmeb/services/crud/Service.php index 88d91c0ee..b7c602541 100644 --- a/crmeb/crmeb/services/crud/Service.php +++ b/crmeb/crmeb/services/crud/Service.php @@ -59,12 +59,20 @@ class Service extends Make $contentAction .= $stub . "\n"; } - //生成form表单 - if (in_array('save', $action) || in_array('update', $action)) { - $var = ['{%key%}', '{%date%}', '{%route%}', '{%form-php%}', '{%modelName%}']; + if ($field) { + //生成form表单 + $var = ['{%key%}', '{%date%}', '{%route%}', '{%form-php%}', '{%modelName%}', '{%field%}']; $value = [$options['key'] ?? 'id', $this->value['date'], Str::snake($options['route'] ?? $name)]; $from = []; + $select = []; foreach ($field as $item) { + //处理查询字段 + if (in_array($item['type'], ['radio', 'select', 'checkbox'])) { + $select[] = $item['field'] . ' as ' . $item['field'] . $this->attrPrefix; + } else { + $select[] = $item['field']; + } + //处理表单信息 switch ($item['type']) { case 'frameImageOne': $from[] = $this->tab(2) . $this->getframeImageOnePhpContent($item['field'], $item['name']) . ';'; @@ -95,7 +103,10 @@ class Service extends Make $value[] = ''; } $value[] = $options['modelName'] ?? $options['menus'] ?? $name; - + if (!empty($options['key'])) { + array_push($select, $options['key']); + } + $value[] = implode(',', $select); if ($value && $var) { $contentAction = str_replace($var, $value, $contentAction); } diff --git a/crmeb/crmeb/services/crud/ViewPages.php b/crmeb/crmeb/services/crud/ViewPages.php index 56f089a66..8193da491 100644 --- a/crmeb/crmeb/services/crud/ViewPages.php +++ b/crmeb/crmeb/services/crud/ViewPages.php @@ -75,6 +75,7 @@ class ViewPages extends Make $contentVue = []; foreach ($field as $key => $item) { $keyName = 'key'; + $fieldValue = $item['field']; if (isset($item['type'])) { switch ($item['type']) { case 'frameImageOne': @@ -88,9 +89,11 @@ class ViewPages extends Make $contentVue[] = str_replace(['{%field%}'], [$item['field']], $templateContent); break; } + if (in_array($item['type'], ['radio', 'select', 'checkbox'])) { + $fieldValue = $fieldValue . $this->attrPrefix; + } } - - $columnStr[] = ($key == 0 ? $this->tab(2) : '') . "{\n" . $this->tab(3) . "title:\"{$item['name']}\"," . $this->tab(2) . "\n" . $this->tab(3) . "$keyName:\"{$item['field']}\"\n" . $this->tab(2) . "}\n"; + $columnStr[] = ($key == 0 ? $this->tab(2) : '') . "{\n" . $this->tab(3) . "title:\"{$item['name']}\"," . $this->tab(2) . "\n" . $this->tab(3) . "$keyName:\"{$fieldValue}\"\n" . $this->tab(2) . "}\n"; } $this->value['auth'] = Str::snake($name); $this->value['componentName'] = $this->value['auth']; diff --git a/crmeb/crmeb/services/crud/stubs/controller/delete.stub b/crmeb/crmeb/services/crud/stubs/controller/delete.stub index 293b74fbb..cbe7de7a4 100644 --- a/crmeb/crmeb/services/crud/stubs/controller/delete.stub +++ b/crmeb/crmeb/services/crud/stubs/controller/delete.stub @@ -10,7 +10,7 @@ return app('json')->fail(100100); } - if ($this->service->destroy($id)) { + if ($this->service->destroy((int)$id)) { return app('json')->success(100002); } else { return app('json')->success(100008); diff --git a/crmeb/crmeb/services/crud/stubs/controller/edit.stub b/crmeb/crmeb/services/crud/stubs/controller/edit.stub index 6e01c891f..fbb378b70 100644 --- a/crmeb/crmeb/services/crud/stubs/controller/edit.stub +++ b/crmeb/crmeb/services/crud/stubs/controller/edit.stub @@ -6,5 +6,5 @@ */ public function edit($id) { - return app('json')->success($this->service->getCrudForm($id)); + return app('json')->success($this->service->getCrudForm((int)$id)); } diff --git a/crmeb/crmeb/services/crud/stubs/model/crudModel.stub b/crmeb/crmeb/services/crud/stubs/model/crudModel.stub index 29eaf0230..738ee2aa5 100644 --- a/crmeb/crmeb/services/crud/stubs/model/crudModel.stub +++ b/crmeb/crmeb/services/crud/stubs/model/crudModel.stub @@ -41,5 +41,5 @@ class {%nameCamel%} extends BaseModel * @var string */ protected $pk = '{%key%}'; - +{%attr-php%} } diff --git a/crmeb/crmeb/services/crud/stubs/model/getattr.stub b/crmeb/crmeb/services/crud/stubs/model/getattr.stub index c445665cb..96e3568f6 100644 --- a/crmeb/crmeb/services/crud/stubs/model/getattr.stub +++ b/crmeb/crmeb/services/crud/stubs/model/getattr.stub @@ -1,3 +1,9 @@ + /** + * {%name%}获取器 + * @date {%date%} + * @param string $value + * @return string + */ public function get{%field%}Attr($value) { {%content-php%} diff --git a/crmeb/crmeb/services/crud/stubs/service/crudListIndex.stub b/crmeb/crmeb/services/crud/stubs/service/crudListIndex.stub index 4761b01d2..ea7de17ca 100644 --- a/crmeb/crmeb/services/crud/stubs/service/crudListIndex.stub +++ b/crmeb/crmeb/services/crud/stubs/service/crudListIndex.stub @@ -7,7 +7,7 @@ public function getCrudListIndex(array $where = []) { [$page, $limit] = $this->getPageValue(); - $model = $this->dao->selectModel($where, '*', 0, 0, '{%key%} desc'); + $model = $this->dao->selectModel($where, '{%field%}', 0, 0, '{%key%} desc'); return ['count' => $model->count(), 'list' => $model->page($page ?: 1, $limit ?: 10)->select()->toArray()]; } diff --git a/crmeb/crmeb/services/express/storage/Express.php b/crmeb/crmeb/services/express/storage/Express.php index 85393992f..a0132b904 100644 --- a/crmeb/crmeb/services/express/storage/Express.php +++ b/crmeb/crmeb/services/express/storage/Express.php @@ -168,7 +168,7 @@ class Express extends BaseExpress if (!$data['siid']) { $param['print_type'] = 'IMAGE'; } - return $this->accessToken->httpRequest(self::EXPRESS_DUMP, $param, 'POST'); + return $this->accessToken->httpRequest(self::EXPRESS_DUMP, $param, 'POST', true, ['version:v1.1']); } } diff --git a/crmeb/public/install/crmeb.sql b/crmeb/public/install/crmeb.sql index 99060f3ce..72c6fdf7d 100755 --- a/crmeb/public/install/crmeb.sql +++ b/crmeb/public/install/crmeb.sql @@ -28453,6 +28453,9 @@ CREATE TABLE IF NOT EXISTS `eb_store_order` ( `delivery_code` varchar(50) NOT NULL DEFAULT '' COMMENT '快递公司编码', `delivery_type` varchar(32) NOT NULL DEFAULT '' COMMENT '发货类型', `delivery_id` varchar(64) NOT NULL DEFAULT '' COMMENT '快递单号/手机号', + `kuaidi_label` varchar(255) NOT NULL DEFAULT '' COMMENT '快递单号图片', + `kuaidi_task_id` varchar(64) NOT NULL DEFAULT '' COMMENT '快递单任务id', + `kuaidi_order_id` varchar(64) NOT NULL DEFAULT '' COMMENT '快递单订单号', `fictitious_content` varchar(500) NOT NULL DEFAULT '' COMMENT '虚拟发货内容', `delivery_uid` int(11) NOT NULL DEFAULT '0' COMMENT '配送员id', `gain_integral` decimal(8,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '消费赚取积分', diff --git a/template/admin/package-lock.json b/template/admin/package-lock.json index 1af86ccc8..5f651f4a2 100644 --- a/template/admin/package-lock.json +++ b/template/admin/package-lock.json @@ -19377,6 +19377,11 @@ } } }, + "print-js": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/print-js/-/print-js-1.6.0.tgz", + "integrity": "sha512-BfnOIzSKbqGRtO4o0rnj/K3681BSd2QUrsIZy/+WdCIugjIswjmx3lDEZpXB2ruGf9d4b3YNINri81+J0FsBWg==" + }, "printj": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", diff --git a/template/admin/package.json b/template/admin/package.json index 6bf1853e9..db7647fa3 100644 --- a/template/admin/package.json +++ b/template/admin/package.json @@ -43,6 +43,7 @@ "monaco-editor": "^0.28.1", "monaco-editor-webpack-plugin": "^4.2.0", "oss": "0.0.1", + "print-js": "^1.6.0", "qiniu-js": "^2.5.5", "qrcodejs2": "0.0.2", "qs": "^6.6.0", diff --git a/template/admin/src/layout/navBars/breadcrumb/user.vue b/template/admin/src/layout/navBars/breadcrumb/user.vue index 860298c87..18ab06964 100644 --- a/template/admin/src/layout/navBars/breadcrumb/user.vue +++ b/template/admin/src/layout/navBars/breadcrumb/user.vue @@ -194,8 +194,8 @@ export default { done(); this.$Message.success('您已成功退出'); this.$store.commit('clearAll'); - localStorage.clear(); - sessionStorage.clear(); + // localStorage.clear(); + // sessionStorage.clear(); removeCookies('token'); removeCookies('expires_time'); removeCookies('uuid'); diff --git a/template/admin/src/pages/order/orderList/components/tableList.vue b/template/admin/src/pages/order/orderList/components/tableList.vue index b8068ad56..0bdd191e4 100644 --- a/template/admin/src/pages/order/orderList/components/tableList.vue +++ b/template/admin/src/pages/order/orderList/components/tableList.vue @@ -147,6 +147,7 @@ 已收货 删除订单 + 快递面单打印 @@ -190,6 +191,7 @@