tools.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. import {
  2. processStatus,
  3. liquidationStatus,
  4. approvedState,
  5. newOrderStatus,
  6. invoiceStatus,
  7. post,
  8. patternOrganization,
  9. station,
  10. conditionOrganization,
  11. addressList,
  12. categoryState,
  13. gameState,
  14. } from './dataDic';
  15. // 流程状态
  16. const getProcessStatus =(e) => {
  17. if (e || e === 0) {
  18. let theType = "";
  19. processStatus.forEach((item) => {
  20. if (item.value === e.toString()) {
  21. theType = item.key;
  22. }
  23. });
  24. return theType;
  25. }
  26. return '';
  27. }
  28. // 结算状态
  29. const getLiquidationStatus = (e) => {
  30. if (e || e === 0) {
  31. let theType = "";
  32. liquidationStatus.forEach((item) => {
  33. if (item.value === e.toString()) {
  34. theType = item.key;
  35. }
  36. });
  37. return theType;
  38. }
  39. return '';
  40. }
  41. // 特批状态
  42. const getApprovedState = (e) => {
  43. if (e || e === 0) {
  44. let theType = "";
  45. approvedState.forEach((item) => {
  46. if (item.value === e.toString()) {
  47. theType = item.key;
  48. }
  49. });
  50. return theType;
  51. }
  52. return '';
  53. }
  54. // 订单状态
  55. const getNewOrderStatus = (e) => {
  56. if (e || e === 0) {
  57. let theType = "";
  58. newOrderStatus.forEach((item) => {
  59. if (item.value === e.toString()) {
  60. theType = item.key;
  61. }
  62. });
  63. return theType;
  64. }
  65. return '';
  66. }
  67. // 开票状态
  68. const getInvoiceStatus = (e, record) => {
  69. if (record && record.approval === 1) {
  70. return "特批待审核";
  71. }else{
  72. if (e || e === 0) {
  73. let theType = "";
  74. invoiceStatus.forEach((item) => {
  75. if (item.value === e.toString()) {
  76. theType = item.key;
  77. }
  78. });
  79. return theType;
  80. }
  81. }
  82. }
  83. // 职务
  84. const getPost = (e) => {
  85. if (e) {
  86. let theType = "";
  87. post.map((item) => {
  88. if (item.value === e) {
  89. theType = item.key;
  90. }
  91. });
  92. return theType;
  93. }
  94. }
  95. // 岗位
  96. const getStation = (e) => {
  97. if (e) {
  98. let theType = "";
  99. station.map((item) => {
  100. if (item.value === e) {
  101. theType = item.key;
  102. }
  103. });
  104. return theType;
  105. }
  106. }
  107. // 组织类型
  108. const getPattern = (e) => {
  109. if (e) {
  110. let theType = "";
  111. patternOrganization.map((item) => {
  112. if (item.value === e) {
  113. theType = item.key;
  114. }
  115. });
  116. return theType;
  117. }
  118. }
  119. // 组织状态
  120. const getCondition = (e) => {
  121. if (e) {
  122. let theType = "";
  123. conditionOrganization.map((item) => {
  124. if (item.value === e) {
  125. theType = item.label;
  126. }
  127. });
  128. return theType;
  129. }
  130. }
  131. // 品类状态
  132. const getCategoryState = (e) => {
  133. if (e) {
  134. let theType = "";
  135. categoryState.map((item) => {
  136. if (item.value === e) {
  137. theType = item.key;
  138. }
  139. });
  140. return theType;
  141. }
  142. }
  143. // 处理图片地址
  144. const splitUrl = (string, i, url) => {
  145. let theList = [];
  146. let theArr = [];
  147. if (string && string.length) {
  148. theArr = string.split(i);
  149. theArr.map((item, i) => {
  150. let name = item.substring(item.lastIndexOf("_") + 1);
  151. theList.push({
  152. uid: -i - 1,
  153. name: name,
  154. url: url + item,
  155. response: {
  156. data: item,
  157. },
  158. });
  159. });
  160. }
  161. return {fileList:theList};
  162. }
  163. // 品类状态
  164. const getGameState = (index) => {
  165. let e = index ? index.toString() : "";
  166. if (e) {
  167. let theType = "";
  168. gameState.map((item) => {
  169. if (item.value === e) {
  170. theType = item.key;
  171. }
  172. });
  173. return theType;
  174. }
  175. }
  176. const citySelect = () => {
  177. let option = [];
  178. addressList.map((item, i) => {
  179. if (item.cityList.length) {
  180. let cityArr = [];
  181. item.cityList.map((city, n) => {
  182. cityArr.push({
  183. value: city.id,
  184. label: city.name
  185. });
  186. });
  187. option.push({
  188. value: item.id,
  189. label: item.name,
  190. });
  191. } else {
  192. option.push({
  193. value: item.id,
  194. label: item.name
  195. });
  196. };
  197. });
  198. return option;
  199. }
  200. // 地区选择 省市区
  201. const getAddressSelect = (arr = addressList) => {
  202. arr.map((v) =>{
  203. v.label = v.name;
  204. v.value = v.id;
  205. if(v.cityList){
  206. v.children = v.cityList;
  207. getAddressSelect(v.children);
  208. }
  209. if(v.areaList){
  210. v.children = v.areaList;
  211. getAddressSelect(v.children);
  212. }
  213. })
  214. return arr.filter(v=>v.id)
  215. }
  216. // 省份转换
  217. const getprovince = (e) => {
  218. let nub = parseInt(e);
  219. let theType = "";
  220. if (nub <= 34) {
  221. addressList.map((item) => {
  222. if (item.id === nub) {
  223. theType = item.name;
  224. }
  225. });
  226. }
  227. if (nub > 34 && nub < 380) {
  228. addressList.map((item) => {
  229. item.cityList && item.cityList.map((city) => {
  230. if (city.id === nub) {
  231. theType = city.name;
  232. }
  233. });
  234. });
  235. }
  236. if (nub >= 380) {
  237. addressList.map((item) => {
  238. item.cityList && item.cityList.map((city) => {
  239. city.areaList && city.areaList.map((areas) => {
  240. if (areas.id === nub) {
  241. theType = areas.name;
  242. }
  243. });
  244. });
  245. });
  246. }
  247. return theType;
  248. }
  249. export {
  250. getProcessStatus,
  251. getLiquidationStatus,
  252. getApprovedState,
  253. getNewOrderStatus,
  254. getInvoiceStatus,
  255. getPost,
  256. getPattern,
  257. getStation,
  258. splitUrl,
  259. getCondition,
  260. citySelect,
  261. getCategoryState,
  262. getGameState,
  263. getprovince,
  264. getAddressSelect,
  265. };