getChainDetail.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. export default function getChainDetail ({ row, cache }) {
  2. return new Promise(resolve => {
  3. const patchNum = {
  4. nodeType: 'item',
  5. required: true,
  6. label: '批次号',
  7. nodeList: [
  8. {
  9. nodeType: 'input',
  10. keyword: 'patch_num',
  11. hub: 'chain-detail',
  12. props: {
  13. placeholder: '请输入',
  14. clearable: true,
  15. },
  16. },
  17. ],
  18. }
  19. const produceDate = {
  20. nodeType: 'item',
  21. required: true,
  22. label: '产蛋时间',
  23. nodeList: [
  24. {
  25. nodeType: 'datePicker',
  26. keyword: 'produce_date',
  27. hub: 'chain-detail',
  28. props: {
  29. placeholder: '请输入',
  30. clearable: true,
  31. },
  32. },
  33. ],
  34. }
  35. const variety = {
  36. nodeType: 'item',
  37. required: true,
  38. label: '鸡种',
  39. nodeList: [
  40. {
  41. nodeType: 'input',
  42. keyword: 'variety',
  43. hub: 'chain-detail',
  44. props: {
  45. placeholder: '请输入',
  46. clearable: true,
  47. },
  48. },
  49. ],
  50. }
  51. const varietyImg = {
  52. nodeType: 'item',
  53. required: true,
  54. label: '鸡种图片',
  55. nodeList: [
  56. {
  57. nodeType: 'ossUploader',
  58. keyword: 'variety_img',
  59. hub: 'chain-detail',
  60. props: {},
  61. },
  62. ],
  63. }
  64. const age = {
  65. nodeType: 'item',
  66. required: true,
  67. label: '年龄',
  68. tip: '例如: 25周;12月',
  69. nodeList: [
  70. {
  71. nodeType: 'input',
  72. keyword: 'age',
  73. hub: 'chain-detail',
  74. props: {
  75. placeholder: '请输入',
  76. clearable: true,
  77. },
  78. },
  79. ],
  80. }
  81. const food = {
  82. nodeType: 'item',
  83. required: true,
  84. label: '口粮',
  85. nodeList: [
  86. {
  87. nodeType: 'input',
  88. keyword: 'food',
  89. hub: 'chain-detail',
  90. props: {
  91. placeholder: '请输入',
  92. clearable: true,
  93. },
  94. },
  95. ],
  96. }
  97. const foodImg = {
  98. nodeType: 'item',
  99. required: true,
  100. label: '口粮图片',
  101. nodeList: [
  102. {
  103. nodeType: 'ossUploader',
  104. keyword: 'food_img',
  105. hub: 'chain-detail',
  106. props: {},
  107. },
  108. ],
  109. }
  110. const water = {
  111. nodeType: 'item',
  112. required: true,
  113. label: '水源',
  114. nodeList: [
  115. {
  116. nodeType: 'input',
  117. keyword: 'water',
  118. hub: 'chain-detail',
  119. props: {
  120. placeholder: '请输入',
  121. clearable: true,
  122. },
  123. },
  124. ],
  125. }
  126. const waterImg = {
  127. nodeType: 'item',
  128. required: true,
  129. label: '水源图片',
  130. nodeList: [
  131. {
  132. nodeType: 'ossUploader',
  133. keyword: 'water_img',
  134. hub: 'chain-detail',
  135. props: {},
  136. },
  137. ],
  138. }
  139. const farm = {
  140. nodeType: 'item',
  141. required: true,
  142. label: '农场图片',
  143. nodeList: [
  144. {
  145. nodeType: 'ossUploader',
  146. keyword: 'farm',
  147. hub: 'chain-detail',
  148. props: {
  149. maxCount: 10,
  150. },
  151. },
  152. ],
  153. }
  154. const report = {
  155. nodeType: 'item',
  156. required: true,
  157. label: '质检内容',
  158. size: 'flow',
  159. nodeList: [
  160. {
  161. nodeType: 'editor',
  162. keyword: 'report',
  163. hub: 'chain-detail',
  164. props: {},
  165. },
  166. ],
  167. }
  168. const componentData = [
  169. {
  170. nodeType: 'block',
  171. nodeList: [
  172. patchNum,
  173. produceDate,
  174. variety,
  175. varietyImg,
  176. age,
  177. food,
  178. foodImg,
  179. water,
  180. waterImg,
  181. farm,
  182. report,
  183. ],
  184. },
  185. ]
  186. const value = {
  187. patch_num: '',
  188. produce_date: '',
  189. variety: '',
  190. variety_img: '',
  191. age: '',
  192. food: '',
  193. food_img: '',
  194. water: '',
  195. water_img: '',
  196. farm: [],
  197. report: '',
  198. }
  199. const data = row || cache
  200. if (data) {
  201. Object.keys(value).forEach(i => {
  202. value[i] = data[i]
  203. })
  204. }
  205. const response = {
  206. componentData,
  207. value,
  208. option: {},
  209. error: {},
  210. preview: !!row,
  211. }
  212. resolve(response)
  213. })
  214. }