yvanui.grid.format.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. (function ($) {
  2. //========= ts 时间戳转换
  3. $.extend($.fn.fmatter, {
  4. ts: function (cellvalue, options, rowdata) {
  5. var date = new Date();
  6. date.setTime(cellvalue);
  7. var y = date.getFullYear();
  8. var m = date.getMonth() + 1;
  9. m = m < 10 ? ('0' + m) : m;
  10. var d = date.getDate();
  11. d = d < 10 ? ('0' + d) : d;
  12. var h = date.getHours();
  13. h = h < 10 ? ('0' + h) : h;
  14. var minute = date.getMinutes();
  15. var second = date.getSeconds();
  16. minute = minute < 10 ? ('0' + minute) : minute;
  17. second = second < 10 ? ('0' + second) : second;
  18. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
  19. }
  20. });
  21. $.extend($.fn.fmatter.ts, {
  22. unformat: function (cellvalue, options) {
  23. return (new Date(cellvalue)).valueOf();
  24. }
  25. });
  26. //========= enable 转换
  27. $.extend($.fn.fmatter, {
  28. enable: function (cellvalue, options, rowdata) {
  29. switch ($.trim(cellvalue)) {
  30. case '1':
  31. return '启用';
  32. case '0':
  33. return '禁用';
  34. case '-1':
  35. return '删除';
  36. }
  37. return cellvalue;
  38. }
  39. });
  40. $.extend($.fn.fmatter.enable, {
  41. unformat: function (cellvalue, options) {
  42. if (cellvalue === '启用') {
  43. return 1;
  44. } else if (cellvalue === '禁用') {
  45. return 0;
  46. } else if (cellvalue === '删除') {
  47. return -1;
  48. }
  49. return cellvalue;
  50. }
  51. });
  52. //========= c1转换
  53. $.extend($.fn.fmatter, {
  54. c1: function (cellvalue, options, rowdata) {
  55. if (cellvalue) {
  56. return '#' + cellvalue;
  57. }
  58. return '';
  59. }
  60. });
  61. $.extend($.fn.fmatter.c1, {
  62. unformat: function (cellvalue, options) {
  63. if (cellvalue) {
  64. return cellvalue.slice(1);
  65. }
  66. return cellvalue.slice(1);
  67. }
  68. });
  69. //========= beAction 转换
  70. $.extend($.fn.fmatter, {
  71. beAction: function (cellvalue, options, rowdata) {
  72. if (cellvalue === 'Y') {
  73. return '启用';
  74. } else if (cellvalue === 'N') {
  75. return '禁用';
  76. } else if (cellvalue === 'D') {
  77. return '删除';
  78. }
  79. return cellvalue;
  80. }
  81. });
  82. $.extend($.fn.fmatter.beAction, {
  83. unformat: function (cellvalue, options) {
  84. if (cellvalue === '启用') {
  85. return 'Y';
  86. } else if (cellvalue === '禁用') {
  87. return 'N';
  88. } else if (cellvalue === '删除') {
  89. return 'D';
  90. }
  91. return cellvalue;
  92. }
  93. });
  94. //========= c2转换
  95. $.extend($.fn.fmatter, {
  96. c2: function (cellvalue, options, rowdata) {
  97. if (cellvalue) {
  98. return '*' + cellvalue;
  99. }
  100. return '';
  101. }
  102. });
  103. $.extend($.fn.fmatter.c2, {
  104. unformat: function (cellvalue, options) {
  105. if (cellvalue) {
  106. return cellvalue.slice(1);
  107. }
  108. return '';
  109. }
  110. });
  111. //========= staffJob 转换
  112. $.extend($.fn.fmatter, {
  113. staffJob: function (cellvalue, options, rowdata) {
  114. switch ($.trim(cellvalue)) {
  115. case '1':
  116. return '拣货员';
  117. case '2':
  118. return '发货员';
  119. case '3':
  120. return '收货员';
  121. case '4':
  122. return '验货员';
  123. }
  124. return cellvalue;
  125. }
  126. });
  127. $.extend($.fn.fmatter.staffJob, {
  128. unformat: function (cellvalue, options) {
  129. if (cellvalue === '拣货员') {
  130. return 1;
  131. } else if (cellvalue === '发货员') {
  132. return 2;
  133. } else if (cellvalue === '收货员') {
  134. return 3;
  135. } else if (cellvalue === '验货员') {
  136. return 4;
  137. }
  138. return cellvalue;
  139. }
  140. });
  141. //========= whareaCategory 转换
  142. $.extend($.fn.fmatter, {
  143. whareaCategory: function (cellvalue, options, rowdata) {
  144. switch ($.trim(cellvalue)) {
  145. case '1':
  146. return '存储区';
  147. case '2':
  148. return '拣货区';
  149. case '3':
  150. return '播种区';
  151. case '4':
  152. return '复核理货区';
  153. case '5':
  154. return '集货发运区';
  155. case '6':
  156. return '组装加工区';
  157. case '7':
  158. return '月台区';
  159. case '8':
  160. return '停车场';
  161. case '9':
  162. return '退货区';
  163. }
  164. return cellvalue;
  165. }
  166. });
  167. $.extend($.fn.fmatter.whareaCategory, {
  168. unformat: function (cellvalue, options) {
  169. if (cellvalue === '存储区') {
  170. return 1;
  171. } else if (cellvalue === '拣货区') {
  172. return 2;
  173. } else if (cellvalue === '播种区') {
  174. return 3;
  175. } else if (cellvalue === '复核理货区') {
  176. return 4;
  177. } else if (cellvalue === '集货发运区') {
  178. return 5;
  179. } else if (cellvalue === '组装加工区') {
  180. return 6;
  181. } else if (cellvalue === '月台区') {
  182. return 7;
  183. } else if (cellvalue === '停车场') {
  184. return 8;
  185. } else if (cellvalue === '退货区') {
  186. return 9;
  187. }
  188. return cellvalue;
  189. }
  190. });
  191. //========= stockEnv 转换
  192. $.extend($.fn.fmatter, {
  193. stockEnv: function (cellvalue, options, rowdata) {
  194. switch ($.trim(cellvalue)) {
  195. case '1':
  196. return '冷藏';
  197. case '2':
  198. return '常温';
  199. case '3':
  200. return '阴凉';
  201. }
  202. return cellvalue;
  203. }
  204. });
  205. $.extend($.fn.fmatter.stockEnv, {
  206. unformat: function (cellvalue, options) {
  207. if (cellvalue === '冷藏') {
  208. return 1;
  209. } else if (cellvalue === '常温') {
  210. return 2;
  211. } else if (cellvalue === '阴凉') {
  212. return 3;
  213. }
  214. return cellvalue;
  215. }
  216. });
  217. //========= double转换
  218. $.extend($.fn.fmatter, {
  219. double: function (cellvalue, options, rowdata) {
  220. if (cellvalue != null) {
  221. return parseFloat(cellvalue).toFixed(2);
  222. }
  223. return '';
  224. }
  225. });
  226. //========= turnoverDemand 转换
  227. $.extend($.fn.fmatter, {
  228. turnoverDemand: function (cellvalue, options, rowdata) {
  229. switch ($.trim(cellvalue)) {
  230. case '1':
  231. return '快速周转';
  232. case '2':
  233. return '中速周转';
  234. case '3':
  235. return '慢速周转';
  236. }
  237. return cellvalue;
  238. }
  239. });
  240. $.extend($.fn.fmatter.turnoverDemand, {
  241. unformat: function (cellvalue, options) {
  242. if (cellvalue === '快速周转') {
  243. return 1;
  244. } else if (cellvalue === '中速周转') {
  245. return 2;
  246. } else if (cellvalue === '慢速周转') {
  247. return 3;
  248. }
  249. return cellvalue;
  250. }
  251. });
  252. //========= locatType 转换
  253. $.extend($.fn.fmatter, {
  254. locatType: function (cellvalue, options, rowdata) {
  255. switch ($.trim(cellvalue)) {
  256. case '1':
  257. return '地面平仓';
  258. case '2':
  259. return '重力式货架';
  260. case '3':
  261. return '货架';
  262. case '4':
  263. return '自动化货架';
  264. case '5':
  265. return '高层货架';
  266. }
  267. return cellvalue;
  268. }
  269. });
  270. $.extend($.fn.fmatter.locatType, {
  271. unformat: function (cellvalue, options) {
  272. if (cellvalue === '地面平仓') {
  273. return 1;
  274. } else if (cellvalue === '重力式货架') {
  275. return 2;
  276. } else if (cellvalue === '货架') {
  277. return 3;
  278. } else if (cellvalue === '自动化货架') {
  279. return 4;
  280. } else if (cellvalue === '高层货架') {
  281. return 5;
  282. }
  283. return cellvalue;
  284. }
  285. });
  286. //========= locatProcMode 转换
  287. $.extend($.fn.fmatter, {
  288. locatProcMode: function (cellvalue, options, rowdata) {
  289. switch ($.trim(cellvalue)) {
  290. case '1':
  291. return '仅限整箱';
  292. case '2':
  293. return '仅限托盘';
  294. case '3':
  295. return '其他';
  296. }
  297. return cellvalue;
  298. }
  299. });
  300. $.extend($.fn.fmatter.locatProcMode, {
  301. unformat: function (cellvalue, options) {
  302. if (cellvalue === '仅限整箱') {
  303. return 1;
  304. } else if (cellvalue === '仅限托盘') {
  305. return 2;
  306. } else if (cellvalue === '其他') {
  307. return 3;
  308. }
  309. return cellvalue;
  310. }
  311. });
  312. //========= locatAttr 转换
  313. $.extend($.fn.fmatter, {
  314. locatAttr: function (cellvalue, options, rowdata) {
  315. switch ($.trim(cellvalue)) {
  316. case '1':
  317. return '正常';
  318. case '2':
  319. return '封存';
  320. case '3':
  321. return '管控';
  322. case '4':
  323. return '禁入';
  324. }
  325. return cellvalue;
  326. }
  327. });
  328. $.extend($.fn.fmatter.locatAttr, {
  329. unformat: function (cellvalue, options) {
  330. if (cellvalue === '正常') {
  331. return 1;
  332. } else if (cellvalue === '封存') {
  333. return 2;
  334. } else if (cellvalue === '管控') {
  335. return 3;
  336. } else if (cellvalue === '禁入') {
  337. return 4;
  338. }
  339. return cellvalue;
  340. }
  341. });
  342. //========= 上架库位颜色 转换
  343. $.extend($.fn.fmatter, {
  344. fmtCodeColor: function (cellvalue, options, rowdata) {
  345. if (cellvalue != null && cellvalue != '')
  346. return '<span style="color:blue">' + cellvalue + '</span>';
  347. else
  348. return '';
  349. }
  350. });
  351. //========= 上架数量颜色 转换
  352. $.extend($.fn.fmatter, {
  353. fmtQtyColor: function (cellvalue, options, rowdata) {
  354. if (cellvalue != null && cellvalue != '')
  355. return '<span style="color:blue">' + parseFloat(cellvalue).toFixed(2) + '</span>';
  356. else
  357. return '';
  358. }
  359. });
  360. //========= 是否 转换
  361. $.extend($.fn.fmatter, {
  362. yesOrNo: function (cellvalue, options, rowdata) {
  363. switch ($.trim(cellvalue)) {
  364. case '1':
  365. return '是';
  366. case '0':
  367. return '否';
  368. }
  369. return cellvalue;
  370. }
  371. });
  372. $.extend($.fn.fmatter.yesOrNo, {
  373. unformat: function (cellvalue, options) {
  374. if (cellvalue === '是') {
  375. return 1;
  376. } else if (cellvalue === '否') {
  377. return 0;
  378. }
  379. return cellvalue;
  380. }
  381. });
  382. //========= 取消、未取消 转换
  383. $.extend($.fn.fmatter, {
  384. cancel: function (cellvalue, options, rowdata) {
  385. switch ($.trim(cellvalue)) {
  386. case '1':
  387. return '取消';
  388. case '0':
  389. return '未取消';
  390. }
  391. return cellvalue;
  392. }
  393. });
  394. $.extend($.fn.fmatter.cancel, {
  395. unformat: function (cellvalue, options) {
  396. if (cellvalue === '取消') {
  397. return 1;
  398. } else if (cellvalue === '未取消') {
  399. return 0;
  400. }
  401. return cellvalue;
  402. }
  403. });
  404. })(jQuery);