rules.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import { hasSpace, isAddr, isChinese, isEmoticon, isMobile, isnumber, isSpecialSymbol } from '@/utils/validate'
  2. export const addressRules = {
  3. receipt_quantity: [
  4. {
  5. required: true,
  6. trigger: 'blur',
  7. validator: (rule, value, callback) => {
  8. if (value === '') {
  9. callback(new Error('不能为空!'))
  10. } else {
  11. if (!isnumber(value)) {
  12. callback(new Error('仅支持整数!'))
  13. } else {
  14. callback()
  15. }
  16. }
  17. }
  18. }
  19. ],
  20. contactor: [
  21. {
  22. required: true,
  23. trigger: 'blur',
  24. validator: (rule, value, callback) => {
  25. if (value === '') {
  26. callback(new Error('联系人不能为空!'))
  27. } else {
  28. if (value.length < 2 || value.length > 10) {
  29. callback(new Error('联系人规则为2~10位汉字!'))
  30. } else {
  31. if (!isChinese(value)) {
  32. callback(new Error('联系人规则为2~10位汉字!'))
  33. } else if (isEmoticon(value)) {
  34. callback(new Error('联系人规则为2~10位汉字!'))
  35. } else {
  36. callback()
  37. }
  38. }
  39. }
  40. }
  41. }
  42. ],
  43. mobile: [
  44. {
  45. required: true,
  46. validator: (rule, value, callback) => {
  47. if (value === '') {
  48. callback(new Error('手机号不能为空!'))
  49. } else {
  50. if (!isMobile(value)) {
  51. callback(new Error('手机号格式不正确!'))
  52. } else {
  53. callback()
  54. }
  55. }
  56. },
  57. trigger: 'blur'
  58. }
  59. ],
  60. // addr_code: [
  61. // {
  62. // type: 'array',
  63. // required: false,
  64. // message: '收货省市区不能为空',
  65. // trigger: 'change'
  66. // }
  67. // ],
  68. addr: [
  69. {
  70. required: true,
  71. trigger: 'blur',
  72. validator: (rule, value, callback) => {
  73. if (value === '') {
  74. callback(new Error('详细地址不能为空!'))
  75. } else {
  76. if (hasSpace(value)) {
  77. callback(new Error('系统不允许输入转义字符,请检查后重新输入!'))
  78. } else if (isSpecialSymbol(value)) {
  79. callback(new Error('不能使用英文特殊字符!'))
  80. } else if (isAddr(value)) {
  81. callback()
  82. } else {
  83. callback(new Error('详细地址填写不规范!'))
  84. }
  85. }
  86. }
  87. }
  88. ]
  89. }
  90. export const createRules = {
  91. customerCode: {
  92. required: true,
  93. message: '业务公司不能为空',
  94. trigger: 'blur'
  95. },
  96. companyName: {
  97. required: true,
  98. message: '客户名称不能为空',
  99. trigger: 'blur'
  100. },
  101. num: {
  102. required: true,
  103. message: '销售数量不能为空',
  104. trigger: 'blur'
  105. },
  106. is_determine_price: {
  107. required: true,
  108. message: '销售价不能为空',
  109. trigger: 'blur'
  110. },
  111. price: {
  112. required: true,
  113. message: '采购价不能为空',
  114. trigger: 'blur'
  115. },
  116. service_proportion: {
  117. required: true,
  118. message: '服务费比例不能为空',
  119. trigger: 'blur'
  120. },
  121. expect_service: {
  122. required: true,
  123. message: '期望服务费不能为空',
  124. trigger: 'blur'
  125. },
  126. brand_id: {
  127. required: true,
  128. message: '请选择品牌',
  129. trigger: 'blur'
  130. },
  131. preservation_day: {
  132. required: true,
  133. message: '有效期不能为空',
  134. trigger: 'blur'
  135. },
  136. delivery_day: {
  137. required: true,
  138. message: '物流时间不能为空',
  139. trigger: 'blur'
  140. },
  141. make_day: {
  142. required: true,
  143. message: '生产工期不能为空',
  144. trigger: 'blur'
  145. },
  146. tax: {
  147. required: true,
  148. message: '税点不能为空',
  149. trigger: 'blur'
  150. },
  151. unit_id: {
  152. required: true,
  153. message: '请选择单位',
  154. trigger: 'blur'
  155. },
  156. cat_id: {
  157. required: true,
  158. message: '请选择分类',
  159. trigger: 'blur'
  160. },
  161. spec_list: {
  162. required: true,
  163. message: '请选择规格',
  164. trigger: 'blur'
  165. },
  166. good_name: {
  167. required: true,
  168. message: '商品名称不能为空',
  169. trigger: 'blur'
  170. },
  171. delivery_place: {
  172. required: true,
  173. message: '发货地不能为空',
  174. trigger: 'blur'
  175. },
  176. origin_place: {
  177. required: true,
  178. message: '产地不能为空',
  179. trigger: 'blur'
  180. },
  181. weight: {
  182. required: true,
  183. message: '总重量不能为空',
  184. trigger: 'blur'
  185. },
  186. supply_area: {
  187. required: true,
  188. message: '请选择供货区域',
  189. trigger: 'blur'
  190. },
  191. pay_way: {
  192. required: true,
  193. message: '请选择支付方式',
  194. trigger: 'blur'
  195. },
  196. config: {
  197. required: true,
  198. message: '配置要求不能为空',
  199. trigger: 'blur'
  200. },
  201. other_config: {
  202. required: true,
  203. message: '其他配置要求不能为空',
  204. trigger: 'blur'
  205. },
  206. remark: {
  207. required: true,
  208. message: '采购备注不能为空',
  209. trigger: 'blur'
  210. },
  211. cost_desc: {
  212. required: true,
  213. message: '工艺说明不能为空',
  214. trigger: 'blur'
  215. },
  216. good_img: {
  217. required: true,
  218. message: '请上传商品图片',
  219. trigger: 'blur'
  220. },
  221. supplierNo: {
  222. required: true,
  223. message: '供应商不能为空',
  224. trigger: 'blur'
  225. }
  226. }