diff --git a/addons/command/.addonrc b/addons/command/.addonrc deleted file mode 100644 index 426decf..0000000 --- a/addons/command/.addonrc +++ /dev/null @@ -1 +0,0 @@ -{"files":["application\/admin\/validate\/Command.php","application\/admin\/controller\/Command.php","application\/admin\/lang\/zh-cn\/command.php","application\/admin\/model\/Command.php","application\/admin\/view\/command\/index.html","application\/admin\/view\/command\/add.html","application\/admin\/view\/command\/detail.html","public\/assets\/js\/backend\/command.js"],"license":"regular","licenseto":"98870","licensekey":"z9dMrLGQoCK7qN0T mJHxiy1bfG0ZfYKrR3mi7w==","domains":["0.1"],"licensecodes":[],"validations":["cbeddc9996d1ba6c230fc0319ab4d521"],"menus":["command","command\/index","command\/add","command\/detail","command\/command","command\/execute","command\/del","command\/multi"]} \ No newline at end of file diff --git a/addons/command/Command.php b/addons/command/Command.php deleted file mode 100755 index 1bbb1e2..0000000 --- a/addons/command/Command.php +++ /dev/null @@ -1,70 +0,0 @@ - 'command', - 'title' => '在线命令管理', - 'icon' => 'fa fa-terminal', - 'sublist' => [ - ['name' => 'command/index', 'title' => '查看'], - ['name' => 'command/add', 'title' => '添加'], - ['name' => 'command/detail', 'title' => '详情'], - ['name' => 'command/command', 'title' => '生成并执行命令'], - ['name' => 'command/execute', 'title' => '再次执行命令'], - ['name' => 'command/del', 'title' => '删除'], - ['name' => 'command/multi', 'title' => '批量更新'], - ] - ] - ]; - Menu::create($menu); - return true; - } - - /** - * 插件卸载方法 - * @return bool - */ - public function uninstall() - { - Menu::delete('command'); - return true; - } - - /** - * 插件启用方法 - * @return bool - */ - public function enable() - { - Menu::enable('command'); - return true; - } - - /** - * 插件禁用方法 - * @return bool - */ - public function disable() - { - Menu::disable('command'); - return true; - } - -} diff --git a/addons/command/config.php b/addons/command/config.php deleted file mode 100755 index b625128..0000000 --- a/addons/command/config.php +++ /dev/null @@ -1,4 +0,0 @@ -error("当前插件暂无前台页面"); - } - -} diff --git a/addons/command/info.ini b/addons/command/info.ini deleted file mode 100644 index 65cf366..0000000 --- a/addons/command/info.ini +++ /dev/null @@ -1,10 +0,0 @@ -name = command -title = 在线命令 -intro = 可在线执行一键生成CRUD、一键生成菜单等相关命令 -author = FastAdmin -website = https://www.fastadmin.net -version = 1.1.2 -state = 1 -url = http://127.0.0.1:8088/addons/command -license = regular -licenseto = 98870 diff --git a/addons/command/install.sql b/addons/command/install.sql deleted file mode 100755 index c584dbc..0000000 --- a/addons/command/install.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE IF NOT EXISTS `__PREFIX__command` ( - `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', - `type` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '类型', - `params` varchar(1500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '参数', - `command` varchar(1500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '命令', - `content` text COMMENT '返回结果', - `executetime` bigint(16) UNSIGNED DEFAULT NULL COMMENT '执行时间', - `createtime` bigint(16) UNSIGNED DEFAULT NULL COMMENT '创建时间', - `updatetime` bigint(16) UNSIGNED DEFAULT NULL COMMENT '更新时间', - `status` enum('successed','failured') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'failured' COMMENT '状态', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '在线命令表'; diff --git a/addons/command/library/Output.php b/addons/command/library/Output.php deleted file mode 100755 index aba7982..0000000 --- a/addons/command/library/Output.php +++ /dev/null @@ -1,28 +0,0 @@ -message[] = $message; - } - - public function getMessage() - { - return $this->message; - } - -} diff --git a/application/admin/controller/Command.php b/application/admin/controller/Command.php deleted file mode 100644 index 9c4cf45..0000000 --- a/application/admin/controller/Command.php +++ /dev/null @@ -1,248 +0,0 @@ -model = new \app\admin\model\Command; - $this->view->assign("statusList", $this->model->getStatusList()); - } - - /** - * 添加 - */ - public function add() - { - - $tableList = []; - $list = \think\Db::query("SHOW TABLES"); - foreach ($list as $key => $row) { - $tableList[reset($row)] = reset($row); - } - - $this->view->assign("tableList", $tableList); - return $this->view->fetch(); - } - - /** - * 获取字段列表 - * @internal - */ - public function get_field_list() - { - $dbname = Config::get('database.database'); - $prefix = Config::get('database.prefix'); - $table = $this->request->request('table'); - //从数据库中获取表字段信息 - $sql = "SELECT * FROM `information_schema`.`columns` " - . "WHERE TABLE_SCHEMA = ? AND table_name = ? " - . "ORDER BY ORDINAL_POSITION"; - //加载主表的列 - $columnList = Db::query($sql, [$dbname, $table]); - $fieldlist = []; - foreach ($columnList as $index => $item) { - $fieldlist[] = $item['COLUMN_NAME']; - } - $this->success("", null, ['fieldlist' => $fieldlist]); - } - - /** - * 获取控制器列表 - * @internal - */ - public function get_controller_list() - { - //搜索关键词,客户端输入以空格分开,这里接收为数组 - $word = (array)$this->request->request("q_word/a"); - $word = implode('', $word); - - $adminPath = dirname(__DIR__) . DS; - $controllerDir = $adminPath . 'controller' . DS; - $files = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($controllerDir), \RecursiveIteratorIterator::LEAVES_ONLY - ); - $list = []; - foreach ($files as $name => $file) { - if (!$file->isDir()) { - $filePath = $file->getRealPath(); - $name = str_replace($controllerDir, '', $filePath); - $name = str_replace(DS, "/", $name); - if (!preg_match("/(.*)\.php\$/", $name)) { - continue; - } - if (!$word || stripos($name, $word) !== false) { - $list[] = ['id' => $name, 'name' => $name]; - } - } - } - $pageNumber = $this->request->request("pageNumber"); - $pageSize = $this->request->request("pageSize"); - return json(['list' => array_slice($list, ($pageNumber - 1) * $pageSize, $pageSize), 'total' => count($list)]); - } - - /** - * 详情 - */ - public function detail($ids) - { - $row = $this->model->get($ids); - if (!$row) { - $this->error(__('No Results were found')); - } - $this->view->assign("row", $row); - return $this->view->fetch(); - } - - /** - * 执行 - */ - public function execute($ids) - { - $row = $this->model->get($ids); - if (!$row) { - $this->error(__('No Results were found')); - } - $result = $this->doexecute($row['type'], json_decode($row['params'], true)); - $this->success("", null, ['result' => $result]); - } - - /** - * 生成命令 - */ - public function command($action = '') - { - $commandtype = $this->request->request("commandtype"); - $params = $this->request->request(); - $allowfields = [ - 'crud' => 'table,controller,model,fields,force,local,delete,menu', - 'menu' => 'controller,delete,force', - 'min' => 'module,resource,optimize', - 'api' => 'url,module,output,template,force,title,author,class,language,addon', - ]; - $argv = []; - $allowfields = isset($allowfields[$commandtype]) ? explode(',', $allowfields[$commandtype]) : []; - $allowfields = array_filter(array_intersect_key($params, array_flip($allowfields))); - if (isset($params['local']) && !$params['local']) { - $allowfields['local'] = $params['local']; - } else { - unset($allowfields['local']); - } - foreach ($allowfields as $key => $param) { - $argv[] = "--{$key}=" . (is_array($param) ? implode(',', $param) : $param); - } - if ($commandtype == 'crud') { - $extend = 'setcheckboxsuffix,enumradiosuffix,imagefield,filefield,intdatesuffix,switchsuffix,citysuffix,selectpagesuffix,selectpagessuffix,ignorefields,sortfield,editorsuffix,headingfilterfield,tagsuffix,jsonsuffix,fixedcolumns'; - $extendArr = explode(',', $extend); - foreach ($params as $index => $item) { - if (in_array($index, $extendArr)) { - foreach (explode(',', $item) as $key => $value) { - if ($value) { - $argv[] = "--{$index}={$value}"; - } - } - } - } - $isrelation = (int)$this->request->request('isrelation'); - if ($isrelation && isset($params['relation'])) { - foreach ($params['relation'] as $index => $relation) { - foreach ($relation as $key => $value) { - $argv[] = "--{$key}=" . (is_array($value) ? implode(',', $value) : $value); - } - } - } - } else { - if ($commandtype == 'menu') { - if (isset($params['allcontroller']) && $params['allcontroller']) { - $argv[] = "--controller=all-controller"; - } else { - foreach (explode(',', $params['controllerfile']) as $index => $param) { - if ($param) { - $argv[] = "--controller=" . substr($param, 0, -4); - } - } - } - } else { - if ($commandtype == 'min') { - - } else { - if ($commandtype == 'api') { - - } else { - - } - } - } - } - if ($action == 'execute') { - if (stripos(implode(' ', $argv), '--controller=all-controller') !== false) { - $this->error("只允许在命令行执行该命令,执行前请做好菜单规则备份!!!"); - } - if (config('app_debug')) { - $result = $this->doexecute($commandtype, $argv); - $this->success("", null, ['result' => $result]); - } else { - $this->error("只允许在开发环境下执行命令"); - } - } else { - $this->success("", null, ['command' => "php think {$commandtype} " . implode(' ', $argv)]); - } - - return; - } - - protected function doexecute($commandtype, $argv) - { - if (!config('app_debug')) { - $this->error("只允许在开发环境下执行命令"); - } - if (preg_match("/([;\|&]+)/", implode(' ', $argv))) { - $this->error("不支持的命令参数"); - } - $commandName = "\\app\\admin\\command\\" . ucfirst($commandtype); - $input = new Input($argv); - $output = new \addons\command\library\Output(); - $command = new $commandName($commandtype); - $data = [ - 'type' => $commandtype, - 'params' => json_encode($argv), - 'command' => "php think {$commandtype} " . implode(' ', $argv), - 'executetime' => time(), - ]; - $this->model->save($data); - try { - $command->run($input, $output); - $result = implode("\n", $output->getMessage()); - $this->model->status = 'successed'; - } catch (Exception $e) { - $result = implode("\n", $output->getMessage()) . "\n"; - $result .= $e->getMessage(); - $this->model->status = 'failured'; - } - $result = trim($result); - $this->model->content = $result; - $this->model->save(); - return $result; - } - -} diff --git a/application/admin/controller/orders/Income.php b/application/admin/controller/orders/Income.php new file mode 100644 index 0000000..e47c3fc --- /dev/null +++ b/application/admin/controller/orders/Income.php @@ -0,0 +1,38 @@ +model = new \app\admin\model\OrderIncome; + $this->view->assign("itemTypeList", $this->model->getItemTypeList()); + $this->view->assign("incomeTypeList", $this->model->getIncomeTypeList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/lang/en/orders/income.php b/application/admin/lang/en/orders/income.php new file mode 100644 index 0000000..c3ceab9 --- /dev/null +++ b/application/admin/lang/en/orders/income.php @@ -0,0 +1,21 @@ + 'ID', + 'Order_id' => '订单ID', + 'Order_no' => '订单号', + 'Tel' => '客户手机', + 'Item_type' => '收款事项', + 'Item_type 1' => '定金', + 'Item_type 2' => '尾款', + 'Item_type 3' => '全款', + 'Item_type 4' => '其它', + 'Amount' => '收款金额', + 'Income_type' => '收款方式', + 'Income_type 1' => '平台收款', + 'Income_type 2' => '线下收款', + 'Admin_id' => '创建人ID', + 'Admin_user' => '创建人', + 'Payment_time' => '收款时间', + 'Create_time' => '创建时间' +]; diff --git a/application/admin/lang/zh-cn/command.php b/application/admin/lang/zh-cn/command.php deleted file mode 100644 index b010250..0000000 --- a/application/admin/lang/zh-cn/command.php +++ /dev/null @@ -1,16 +0,0 @@ - 'ID', - 'Type' => '类型', - 'Params' => '参数', - 'Command' => '命令', - 'Content' => '返回结果', - 'Executetime' => '执行时间', - 'Createtime' => '创建时间', - 'Updatetime' => '更新时间', - 'Execute again' => '再次执行', - 'Successed' => '成功', - 'Failured' => '失败', - 'Status' => '状态' -]; diff --git a/application/admin/lang/zh-cn/orders/income.php b/application/admin/lang/zh-cn/orders/income.php new file mode 100644 index 0000000..c3ceab9 --- /dev/null +++ b/application/admin/lang/zh-cn/orders/income.php @@ -0,0 +1,21 @@ + 'ID', + 'Order_id' => '订单ID', + 'Order_no' => '订单号', + 'Tel' => '客户手机', + 'Item_type' => '收款事项', + 'Item_type 1' => '定金', + 'Item_type 2' => '尾款', + 'Item_type 3' => '全款', + 'Item_type 4' => '其它', + 'Amount' => '收款金额', + 'Income_type' => '收款方式', + 'Income_type 1' => '平台收款', + 'Income_type 2' => '线下收款', + 'Admin_id' => '创建人ID', + 'Admin_user' => '创建人', + 'Payment_time' => '收款时间', + 'Create_time' => '创建时间' +]; diff --git a/application/admin/model/Command.php b/application/admin/model/Command.php deleted file mode 100644 index adede4d..0000000 --- a/application/admin/model/Command.php +++ /dev/null @@ -1,59 +0,0 @@ - __('Successed'), 'failured' => __('Failured')]; - } - - - public function getExecutetimeTextAttr($value, $data) - { - $value = $value ? $value : $data['executetime']; - return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; - } - - public function getTypeTextAttr($value, $data) - { - $value = $value ? $value : $data['type']; - $list = ['crud' => '一键生成CRUD', 'menu' => '一键生成菜单', 'min' => '一键压缩打包', 'api' => '一键生成文档']; - return $list[$value] ?? ''; - } - - public function getStatusTextAttr($value, $data) - { - $value = $value ? $value : $data['status']; - $list = $this->getStatusList(); - return $list[$value] ?? ''; - } - - protected function setExecutetimeAttr($value) - { - return $value && !is_numeric($value) ? strtotime($value) : $value; - } - - -} diff --git a/application/admin/model/OrderIncome.php b/application/admin/model/OrderIncome.php new file mode 100644 index 0000000..7e0b919 --- /dev/null +++ b/application/admin/model/OrderIncome.php @@ -0,0 +1,65 @@ + __('Item_type 1'), '2' => __('Item_type 2'), '3' => __('Item_type 3'), '4' => __('Item_type 4')]; + } + + public function getIncomeTypeList() + { + return ['1' => __('Income_type 1'), '2' => __('Income_type 2')]; + } + + + public function getItemTypeTextAttr($value, $data) + { + $value = $value ?: ($data['item_type'] ?? ''); + $list = $this->getItemTypeList(); + return $list[$value] ?? ''; + } + + + public function getIncomeTypeTextAttr($value, $data) + { + $value = $value ?: ($data['income_type'] ?? ''); + $list = $this->getIncomeTypeList(); + return $list[$value] ?? ''; + } + + + + +} diff --git a/application/admin/validate/Command.php b/application/admin/validate/OrderIncome.php similarity index 88% rename from application/admin/validate/Command.php rename to application/admin/validate/OrderIncome.php index 9da8fa6..0cc57df 100644 --- a/application/admin/validate/Command.php +++ b/application/admin/validate/OrderIncome.php @@ -4,7 +4,7 @@ namespace app\admin\validate; use think\Validate; -class Command extends Validate +class OrderIncome extends Validate { /** * 验证规则 @@ -23,5 +23,5 @@ class Command extends Validate 'add' => [], 'edit' => [], ]; - + } diff --git a/application/admin/view/command/add.html b/application/admin/view/command/add.html deleted file mode 100644 index 9374529..0000000 --- a/application/admin/view/command/add.html +++ /dev/null @@ -1,420 +0,0 @@ - -
-
- -
-
-
-
-
-
-
- -
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
- 主表设置 -
-
- - {:build_select('table',$tableList,null,['class'=>'form-control selectpicker', 'data-live-search'=>'true']);} -
-
- - -
-
- - -
-
- - -
- -
- -
- -
- 关联表设置 - - -
- -
-
- 字段识别设置 (与之匹配的字段都将生成相应组件) -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
- -
- -
- 生成命令行 - -
- -
- 返回结果 - -
- -
- - -
- -
-
-
-
- -
-
-
-
- -
- 基础设置 -
-
- - -
-
- - -
-
- - -
-
-
- -
- 生成命令行 - -
- -
- 返回结果 - -
- -
- - -
- -
-
-
-
-
-
-
-
- -
-
-
- - -
-
-
-
- 文档设置 -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- -
- 生成命令行 - -
- -
- 返回结果 - -
- -
- - -
- -
-
-
-
-
-
-
- diff --git a/application/admin/view/command/detail.html b/application/admin/view/command/detail.html deleted file mode 100644 index 71ae036..0000000 --- a/application/admin/view/command/detail.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{:__('Title')}{:__('Content')}
{:__('Type')}{$row.type}({$row.type_text})
{:__('Params')}{$row.params|htmlentities}
{:__('Command')}{$row.command|htmlentities}
{:__('Content')} - -
{:__('Executetime')}{$row.executetime|datetime}
{:__('Status')}{$row.status_text}
- \ No newline at end of file diff --git a/application/admin/view/command/index.html b/application/admin/view/command/index.html deleted file mode 100644 index 3b4f823..0000000 --- a/application/admin/view/command/index.html +++ /dev/null @@ -1,25 +0,0 @@ -
- {:build_heading()} - -
-
-
- -
- -
-
-
diff --git a/application/admin/view/orders/income/add.html b/application/admin/view/orders/income/add.html new file mode 100644 index 0000000..c5c6dc0 --- /dev/null +++ b/application/admin/view/orders/income/add.html @@ -0,0 +1,75 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/orders/income/edit.html b/application/admin/view/orders/income/edit.html new file mode 100644 index 0000000..539c0de --- /dev/null +++ b/application/admin/view/orders/income/edit.html @@ -0,0 +1,75 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/orders/income/index.html b/application/admin/view/orders/income/index.html new file mode 100644 index 0000000..ae96a17 --- /dev/null +++ b/application/admin/view/orders/income/index.html @@ -0,0 +1,29 @@ +
+ {:build_heading()} + +
+
+
+
+
+ + + + +
+ +
+
+
+ +
+
+
diff --git a/public/assets/js/backend/command.js b/public/assets/js/backend/command.js deleted file mode 100644 index 3df5515..0000000 --- a/public/assets/js/backend/command.js +++ /dev/null @@ -1,234 +0,0 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) { - - var Controller = { - index: function () { - // 初始化表格参数配置 - Table.api.init({ - extend: { - index_url: 'command/index', - add_url: 'command/add', - edit_url: '', - del_url: 'command/del', - multi_url: 'command/multi', - table: 'command', - } - }); - - var table = $("#table"); - - // 初始化表格 - table.bootstrapTable({ - url: $.fn.bootstrapTable.defaults.extend.index_url, - pk: 'id', - sortName: 'id', - columns: [ - [ - {checkbox: true}, - {field: 'id', title: __('Id')}, - {field: 'type', title: __('Type'), formatter: Table.api.formatter.search}, - {field: 'type_text', title: __('Type')}, - { - field: 'command', title: __('Command'), renderDefault: false, formatter: function (value, row, index) { - return ''; - } - }, - { - field: 'executetime', - title: __('Executetime'), - operate: 'RANGE', - addclass: 'datetimerange', - formatter: Table.api.formatter.datetime - }, - { - field: 'createtime', - title: __('Createtime'), - operate: 'RANGE', - addclass: 'datetimerange', - formatter: Table.api.formatter.datetime - }, - { - field: 'updatetime', - title: __('Updatetime'), - operate: 'RANGE', - addclass: 'datetimerange', - formatter: Table.api.formatter.datetime - }, - { - field: 'status', - title: __('Status'), - table: table, - custom: {"successed": 'success', "failured": 'danger'}, - searchList: {"successed": __('Successed'), "failured": __('Failured')}, - formatter: Table.api.formatter.status - }, - { - field: 'operate', - title: __('Operate'), - buttons: [ - { - name: 'execute', - title: __('Execute again'), - text: __('Execute again'), - url: 'command/execute', - icon: 'fa fa-repeat', - classname: 'btn btn-success btn-xs btn-execute btn-ajax', - success: function (data) { - Layer.alert("", { - title: __("执行结果"), - shadeClose: true - }); - table.bootstrapTable('refresh'); - return false; - } - }, - { - name: 'execute', - title: __('Detail'), - text: __('Detail'), - url: 'command/detail', - icon: 'fa fa-list', - classname: 'btn btn-info btn-xs btn-execute btn-dialog' - } - ], - table: table, - events: Table.api.events.operate, - formatter: Table.api.formatter.operate - } - ] - ] - }); - - // 为表格绑定事件 - Table.api.bindevent(table); - }, - add: function () { - require(['bootstrap-select', 'bootstrap-select-lang']); - var mainfields = []; - var relationfields = {}; - var maintable = []; - var relationtable = []; - var relationmode = ["belongsto", "hasone"]; - - var renderselect = function (select, data) { - var html = []; - for (var i = 0; i < data.length; i++) { - html.push(""); - } - $(select).html(html.join("")); - select.trigger("change"); - if (select.data("selectpicker")) { - select.selectpicker('refresh'); - } - return select; - }; - - $("select[name=table] option").each(function () { - maintable.push($(this).val()); - }); - $(document).on('change', "input[name='isrelation']", function () { - $("#relation-zone").toggleClass("hide", !$(this).prop("checked")); - }); - $(document).on('change', "select[name='table']", function () { - var that = this; - Fast.api.ajax({ - url: "command/get_field_list", - data: {table: $(that).val()}, - }, function (data, ret) { - mainfields = data.fieldlist; - $("#relation-zone .relation-item").remove(); - renderselect($("#fields"), mainfields); - return false; - }); - return false; - }); - $(document).on('click', "a.btn-newrelation", function () { - var that = this; - var index = parseInt($(that).data("index")) + 1; - var content = Template("relationtpl", {index: index}); - content = $(content.replace(/\[index\]/, index)); - $(this).data("index", index); - $(content).insertBefore($(that).closest(".row")); - $('select', content).selectpicker(); - var exists = [$("select[name='table']").val()]; - $("select.relationtable").each(function () { - exists.push($(this).val()); - }); - relationtable = []; - $.each(maintable, function (i, j) { - if ($.inArray(j, exists) < 0) { - relationtable.push(j); - } - }); - renderselect($("select.relationtable", content), relationtable); - $("select.relationtable", content).trigger("change"); - }); - $(document).on('click', "a.btn-removerelation", function () { - $(this).closest(".row").remove(); - }); - $(document).on('change', "#relation-zone select.relationmode", function () { - var table = $("select.relationtable", $(this).closest(".row")).val(); - var that = this; - Fast.api.ajax({ - url: "command/get_field_list", - data: {table: table}, - }, function (data, ret) { - renderselect($(that).closest(".row").find("select.relationprimarykey"), $(that).val() == 'belongsto' ? data.fieldlist : mainfields); - renderselect($(that).closest(".row").find("select.relationforeignkey"), $(that).val() == 'hasone' ? data.fieldlist : mainfields); - return false; - }); - }); - $(document).on('change', "#relation-zone select.relationtable", function () { - var that = this; - Fast.api.ajax({ - url: "command/get_field_list", - data: {table: $(that).val()}, - }, function (data, ret) { - renderselect($(that).closest(".row").find("select.relationmode"), relationmode); - renderselect($(that).closest(".row").find("select.relationfields"), mainfields) - renderselect($(that).closest(".row").find("select.relationforeignkey"), data.fieldlist) - renderselect($(that).closest(".row").find("select.relationfields"), data.fieldlist) - return false; - }); - }); - $(document).on('click', ".btn-command", function () { - var form = $(this).closest("form"); - var textarea = $("textarea[rel=command]", form); - textarea.val(''); - Fast.api.ajax({ - url: "command/command/action/command", - data: form.serialize(), - }, function (data, ret) { - textarea.val(data.command); - return false; - }); - }); - $(document).on('click', ".btn-execute", function () { - var form = $(this).closest("form"); - var textarea = $("textarea[rel=result]", form); - textarea.val(''); - Fast.api.ajax({ - url: "command/command/action/execute", - data: form.serialize(), - }, function (data, ret) { - textarea.val(data.result); - window.parent.$(".toolbar .btn-refresh").trigger('click'); - top.window.Fast.api.refreshmenu(); - return false; - }, function () { - window.parent.$(".toolbar .btn-refresh").trigger('click'); - }); - }); - $("select[name='table']").trigger("change"); - Controller.api.bindevent(); - }, - edit: function () { - Controller.api.bindevent(); - }, - api: { - bindevent: function () { - Form.api.bindevent($("form[role=form]")); - } - } - }; - return Controller; -}); diff --git a/public/assets/js/backend/orders/income.js b/public/assets/js/backend/orders/income.js new file mode 100644 index 0000000..57f9075 --- /dev/null +++ b/public/assets/js/backend/orders/income.js @@ -0,0 +1,64 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'orders/income/index' + location.search, + add_url: 'orders/income/add', + edit_url: 'orders/income/edit', + del_url: 'orders/income/del', + multi_url: 'orders/income/multi', + import_url: 'orders/income/import', + table: 'order_income', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + fixedColumns: true, + fixedRightNumber: 1, + commonSearch:true, + search:false, + columns: [ + [ + // {checkbox: true}, + {field: 'id', title: __('Id'),operate: false}, + // {field: 'order_id', title: __('Order_id')}, + {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, + {field: 'tel', title: __('Tel'), operate: 'LIKE'}, + {field: 'item_type', title: __('Item_type'), searchList: {"1":__('Item_type 1'),"2":__('Item_type 2'),"3":__('Item_type 3'),"4":__('Item_type 4')}, formatter: Table.api.formatter.normal}, + {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, + {field: 'income_type', title: __('Income_type'), searchList: {"1":__('Income_type 1'),"2":__('Income_type 2')}, formatter: Table.api.formatter.normal}, + // {field: 'admin_id', title: __('Admin_id')}, + {field: 'admin_user', title: __('Admin_user'), operate: 'LIKE'}, + {field: 'payment_time', title: __('Payment_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +});