info.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <?php
  2. $audit = Dever::config('base')->audit;
  3. $status = Dever::config('base')->status;
  4. $id = Dever::input('where_id');
  5. $unit = function()
  6. {
  7. $array = array();
  8. $data = Dever::load('product/unit-state');
  9. if($data)
  10. {
  11. $array += $data;
  12. }
  13. return $array;
  14. };
  15. $config = array
  16. (
  17. # 表名
  18. 'name' => 'info',
  19. # 显示给用户看的名称
  20. 'lang' => '商品设置',
  21. 'order' => 200,
  22. 'auto' => 10000000,
  23. 'set' => array
  24. (
  25. 'status' => $status,
  26. 'audit' => $audit,
  27. ),
  28. 'end' => array
  29. (
  30. //'insert' => 'product/lib/manage.infoUpdate',
  31. //'update' => 'product/lib/manage.infoUpdate',
  32. ),
  33. # 同步更新另外一个或多个表的数据,将数据同步到关联表中
  34. 'sync' => array
  35. (
  36. 'product/info_category' => array
  37. (
  38. # 更新另外一个表的字段 => 本表的字段
  39. 'where' => array('info_id', 'id'),
  40. # 要更新的数据
  41. 'update' => array('category_id' => 'category'),
  42. # 同步更新的类型,delete为先删再插入,update为直接更新
  43. 'type' => 'delete',
  44. )
  45. ),
  46. # 数据结构 不同的字段放这里
  47. 'struct' => array
  48. (
  49. 'id' => array
  50. (
  51. 'type' => 'int-11',
  52. 'name' => 'ID',
  53. 'default' => '',
  54. 'desc' => '',
  55. 'match' => 'is_numeric',
  56. 'list' => true,
  57. ),
  58. 'name' => array
  59. (
  60. 'type' => 'varchar-800',
  61. 'name' => '商品标题',
  62. 'default' => '',
  63. 'desc' => '商品标题',
  64. 'match' => 'is_string',
  65. 'update' => 'textarea',
  66. 'search' => 'fulltext',
  67. 'list' => true,
  68. //'edit' => true,
  69. ),
  70. 'unit' => array
  71. (
  72. 'type' => 'int-11',
  73. 'name' => '商品单位',
  74. 'default' => '',
  75. 'desc' => '商品单位',
  76. 'match' => 'is_numeric',
  77. 'search' => 'select',
  78. 'lang' => '请选择',
  79. 'update' => 'select',
  80. 'option' => $unit,
  81. 'option_add' => array('[添加新单位]', 'product/unit.add'),
  82. ),
  83. 'category' => array
  84. (
  85. 'type' => 'varchar-500',
  86. 'name' => '属性分类',
  87. 'default' => '',
  88. 'desc' => '分类',
  89. 'match' => 'is_string',
  90. 'search' => 'linkage',
  91. //'update' => $id ? false : 'linkage',
  92. 'update' => 'linkage',
  93. 'option' => Dever::url('category.get', 'product'),
  94. //'update' => 'radio',
  95. //'option' => Dever::db('product/category')->select(),
  96. 'list' => 'Dever::load("product/category.string", "{category}")',
  97. 'load' => 'product-info_attr',
  98. 'tab' => 1,
  99. ),
  100. 'product-info_attr'=> array
  101. (
  102. 'name' => '属性设置',
  103. 'default' => '',
  104. 'desc' => '请先选择属性分类',
  105. 'match' => 'option',
  106. # 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
  107. 'sync' => array('id', 'info_id'),
  108. # 根据category字段的值,获取product/attr.search接口的内容
  109. 'update' => 'load',
  110. 'update_load' => array('product/attr.getManageByCate', 'category'),
  111. 'tab' => 1,
  112. ),
  113. # 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧
  114. 'top_category_id' => array
  115. (
  116. 'type' => 'int-11',
  117. 'name' => '顶级分类ID-顶级分类,用于分类查询',
  118. 'default' => '-1',
  119. 'desc' => '顶级分类ID',
  120. 'match' => 'is_numeric',
  121. ),
  122. 'second_category_id' => array
  123. (
  124. 'type' => 'int-11',
  125. 'name' => '二级分类ID-二级分类,用于分类查询',
  126. 'default' => '-1',
  127. 'desc' => '二级分类ID',
  128. 'match' => 'is_numeric',
  129. ),
  130. 'category_id' => array
  131. (
  132. 'type' => 'int-11',
  133. 'name' => '子分类ID-最后一个级别的分类,用于分类查询',
  134. 'default' => '-1',
  135. 'desc' => '子分类ID',
  136. 'match' => 'is_numeric',
  137. ),
  138. 'pic' => array
  139. (
  140. 'type' => 'text-255',
  141. 'name' => '商品主图-图片尺寸500*500px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
  142. 'default' => '',
  143. 'desc' => '多张图片',
  144. 'match' => 'option',
  145. 'update' => 'images',
  146. 'key' => '1',
  147. 'place' => '500*500',
  148. ),
  149. 'audit' => array
  150. (
  151. 'type' => 'tinyint-1',
  152. 'name' => '审核',
  153. 'default' => '1',
  154. 'desc' => '审核',
  155. 'match' => 'is_numeric',
  156. //'update' => 'select',
  157. 'option' => $audit,
  158. //'search' => 'select',
  159. //'list' => true,
  160. 'edit' => true,
  161. ),
  162. 'status' => array
  163. (
  164. 'type' => 'tinyint-1',
  165. 'name' => '状态',
  166. 'default' => '2',
  167. 'desc' => '状态',
  168. 'match' => 'is_numeric',
  169. //'update' => 'select',
  170. 'option' => $status,
  171. 'search' => 'select',
  172. 'list' => true,
  173. 'edit' => true,
  174. ),
  175. 'reorder' => array
  176. (
  177. 'type' => 'int-11',
  178. 'name' => '排序-数值越大越靠前,相当于置顶',
  179. 'default' => '1',
  180. 'desc' => '请输入排序',
  181. 'match' => 'option',
  182. //'update' => 'text',
  183. 'search' => 'order',
  184. 'list' => true,
  185. 'order' => 'desc',
  186. 'edit' => true,
  187. ),
  188. 'content' => array
  189. (
  190. 'type' => 'text-800',
  191. 'name' => '商品介绍',
  192. 'default' => '',
  193. 'desc' => '商品介绍',
  194. 'match' => 'is_string',
  195. 'update' => 'editor',
  196. 'key' => '1',
  197. ),
  198. 'state' => array
  199. (
  200. 'type' => 'tinyint-1',
  201. 'name' => '数据状态',
  202. 'default' => '1',
  203. 'desc' => '请选择状态',
  204. 'match' => 'is_numeric',
  205. ),
  206. 'udate' => array
  207. (
  208. 'type' => 'int-11',
  209. 'name' => '更新时间',
  210. 'match' => array('is_numeric', time()),
  211. 'desc' => '',
  212. ),
  213. 'cdate' => array
  214. (
  215. 'type' => 'int-11',
  216. 'name' => '发布时间',
  217. 'match' => array('is_numeric', time()),
  218. 'desc' => '',
  219. # 只有insert时才生效
  220. 'insert' => true,
  221. 'search' => 'date',
  222. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  223. ),
  224. ),
  225. # 索引
  226. 'index' => array
  227. (
  228. 1 => array
  229. (
  230. 'search' => 'category,top_category_id,second_category_id,category_id',
  231. ),
  232. # 版本号 更改版本号会更新当前表的索引
  233. 'version' => 1,
  234. ),
  235. # 管理功能
  236. 'manage' => array
  237. (
  238. 'tab' => array('基本设置', '属性设置', '规格设置'),
  239. // 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
  240. 'res' => array
  241. (
  242. //'css' => 'demo',
  243. ),
  244. //'insert' => false,
  245. //'delete' => false,
  246. //'mul' => true,
  247. # 自定义快捷新增和编辑
  248. 'button' => array
  249. (
  250. //'类别管理' => array('list', 'cate&project=demand&search_option_key=cate&search_option_tablename=类别&oper_parent=info&oper_project=demand'),
  251. ),
  252. # 列表里的按钮
  253. /*
  254. 'list_button' => array
  255. (
  256. 'add' => array('属性', '"info_attr
  257. &project=goods
  258. &search_option_info_id={id}
  259. &search_option_category={category}
  260. &oper_parent=info&oper_project=goods
  261. &oper_save_jump=info
  262. &where_id={id}"'),
  263. 'list' => array('规格', '"info_sku
  264. &project=goods
  265. &search_option_info_id={id}
  266. &oper_parent=info&oper_project=goods
  267. &oper_save_jump=info&page_type=1"'),
  268. ),*/
  269. ),
  270. # request 请求接口定义
  271. 'request' => array
  272. (
  273. # 后台搜索用到
  274. 'search' => array
  275. (
  276. # 匹配的正则或函数 选填项
  277. 'option' => array
  278. (
  279. 'ids' => array('yes-id', 'in'),
  280. 'name' => array('yes', 'like'),
  281. 'id' => 'yes',
  282. 'state' => 1,
  283. ),
  284. 'type' => 'all',
  285. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  286. 'limit' => '0,1000',
  287. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  288. ),
  289. # 列表
  290. 'getAll' => array
  291. (
  292. # 匹配的正则或函数 选填项
  293. 'option' => array
  294. (
  295. 'audit' => 2,
  296. 'category' => array('yes', 'like'),
  297. 'top_category_id' => 'yes',
  298. 'second_category_id' => 'yes',
  299. 'category_id' => 'yes',
  300. //'status' => 1,
  301. 'state' => 1,
  302. ),
  303. 'type' => 'all',
  304. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  305. 'limit' => '0,10',
  306. //'page' => array(10, 'list'),
  307. 'col' => '*',
  308. ),
  309. # 分页
  310. 'getPageAll' => array
  311. (
  312. # 匹配的正则或函数 选填项
  313. 'option' => array
  314. (
  315. 'shop_id' => 'yes',
  316. 'brand_id' => 'yes',
  317. 'name' => array('yes', 'like'),
  318. 'audit' => 2,
  319. 'category' => array('yes', 'like'),
  320. 'top_category_id' => 'yes',
  321. 'second_category_id' => 'yes',
  322. 'category_id' => 'yes',
  323. //'status' => 1,
  324. 'state' => 1,
  325. ),
  326. 'type' => 'all',
  327. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  328. 'page' => array(10, 'list'),
  329. 'col' => '*',
  330. ),
  331. # 更新售出量
  332. 'updateSell' => array
  333. (
  334. 'type' => 'update',
  335. 'where' => array
  336. (
  337. 'id' => 'yes',
  338. ),
  339. 'set' => array
  340. (
  341. 'sell_num' => array('yes', '+='),
  342. ),
  343. ),
  344. 'getOne' => array
  345. (
  346. # 匹配的正则或函数 选填项
  347. 'option' => array
  348. (
  349. 'id' => 'yes',
  350. ),
  351. 'type' => 'one',
  352. 'col' => 'id,name,category,pic,content',
  353. ),
  354. ),
  355. );
  356. return $config;