data.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. import { FormProps, BasicColumn } from '/@/components/Table';
  2. import { FormSchema } from '/@/components/Form/index';
  3. import { adapt } from '/@/utils/adapt';
  4. import { h } from 'vue';
  5. import CustomInput from './customCom/CustomInput.vue';
  6. import moment from 'moment';
  7. import { Tag } from 'ant-design-vue';
  8. const adaptWidth = adapt();
  9. export const columns: BasicColumn[] = [
  10. {
  11. title: 'ID',
  12. dataIndex: 'id',
  13. editComponentProps: {
  14. prefix: '$',
  15. },
  16. width: 100,
  17. sorter: true,
  18. },
  19. {
  20. title: '姓名(名称)',
  21. dataIndex: 'name',
  22. width: 100,
  23. sorter: true,
  24. },
  25. {
  26. title: '会员身份',
  27. dataIndex: 'type',
  28. width: 130,
  29. customRender: ({ record }) => {
  30. const type = record.type;
  31. const enable = type === 2;
  32. const color = enable ? 'green' : 'red';
  33. const text = enable ? '个人' : '单位';
  34. return h(Tag, { color: color }, () => text);
  35. },
  36. sorter: true,
  37. },
  38. {
  39. title: '职务',
  40. dataIndex: 'duty',
  41. width: 130,
  42. customRender({ record }) {
  43. const options = ['会长', '副会长', '秘书长', '副秘书长', '理事', '会员'];
  44. return options[record.duty];
  45. },
  46. sorter: true,
  47. },
  48. {
  49. title: '入会时间',
  50. dataIndex: 'jointime',
  51. width: 150,
  52. customRender({ record }) {
  53. return moment(record.jointime).format('YYYY-MM-DD');
  54. },
  55. sorter: true,
  56. },
  57. {
  58. title: '当年会费',
  59. dataIndex: 'nowdues',
  60. width: 200,
  61. customRender({ record }) {
  62. if (record.nowdues === '未缴纳') {
  63. return h('span', { style: { color: 'red' } }, record.nowdues);
  64. }
  65. return h('span', {}, record.nowdues);
  66. },
  67. sorter: true,
  68. },
  69. {
  70. title: '去年会费',
  71. dataIndex: 'lastdues',
  72. width: 150,
  73. customRender({ record }) {
  74. if (record.lastdues === '未缴纳') {
  75. return h('span', { style: { color: 'red' } }, record.lastdues);
  76. }
  77. return h('span', {}, record.lastdues);
  78. },
  79. sorter: true,
  80. },
  81. {
  82. title: '当年参会率',
  83. dataIndex: 'nowmeeting',
  84. width: 130,
  85. sorter: true,
  86. },
  87. {
  88. title: '去年参会率',
  89. dataIndex: 'lastmeeting',
  90. width: 130,
  91. sorter: true,
  92. },
  93. ];
  94. export function getFormConfig(): Partial<FormProps> {
  95. return {
  96. labelWidth: 100,
  97. schemas: [
  98. {
  99. field: `id`,
  100. label: `ID`,
  101. component: 'Input',
  102. componentProps: {
  103. placeholder: 'ID',
  104. },
  105. colProps: {
  106. xl: 12,
  107. xxl: 8,
  108. },
  109. },
  110. {
  111. field: `name`,
  112. label: `姓名(名称)`,
  113. component: 'Input',
  114. componentProps: {
  115. placeholder: '姓名(名称)',
  116. },
  117. colProps: {
  118. xl: 12,
  119. xxl: 8,
  120. },
  121. },
  122. {
  123. field: `type`,
  124. label: `会员身份`,
  125. component: 'Select',
  126. componentProps: {
  127. placeholder: '会员身份',
  128. options: [
  129. { label: '个人', value: '2' },
  130. { label: '单位', value: '1' },
  131. ],
  132. },
  133. colProps: {
  134. xl: 12,
  135. xxl: 8,
  136. },
  137. },
  138. {
  139. field: `jointime`,
  140. label: `入会时间`,
  141. component: 'DatePicker',
  142. componentProps: {
  143. placeholder: '入会时间',
  144. },
  145. colProps: {
  146. xl: 12,
  147. xxl: 8,
  148. },
  149. },
  150. {
  151. field: `nowdues`,
  152. label: `当年会费`,
  153. component: 'Input',
  154. componentProps: {
  155. placeholder: '当年会费',
  156. },
  157. colProps: {
  158. xl: 12,
  159. xxl: 8,
  160. },
  161. },
  162. {
  163. field: `lastdues`,
  164. label: `去年会费`,
  165. component: 'Input',
  166. componentProps: {
  167. placeholder: '去年会费',
  168. },
  169. colProps: {
  170. xl: 12,
  171. xxl: 8,
  172. },
  173. },
  174. {
  175. field: `nowmeeting`,
  176. label: `当年参会率`,
  177. component: 'Input',
  178. componentProps: {
  179. placeholder: '当年参会率',
  180. },
  181. colProps: {
  182. xl: 12,
  183. xxl: 8,
  184. },
  185. },
  186. {
  187. field: `lastmeeting`,
  188. label: `去年参会率`,
  189. component: 'Input',
  190. componentProps: {
  191. placeholder: '去年参会率',
  192. },
  193. colProps: {
  194. xl: 12,
  195. xxl: 8,
  196. },
  197. },
  198. ],
  199. };
  200. }
  201. // =================popup================================
  202. export const schemas: FormSchema[] = [
  203. {
  204. field: 'type',
  205. label: '会员身份',
  206. component: 'RadioButtonGroup',
  207. labelWidth: adaptWidth.labelWidth,
  208. colProps: {
  209. span: adaptWidth.elContainer,
  210. },
  211. componentProps: (value) => {
  212. console.log(`value ---- type`, value);
  213. return {
  214. // disabled: true,
  215. options: [
  216. { label: '个人', value: '2' },
  217. { label: '单位', value: '1' },
  218. ],
  219. };
  220. },
  221. defaultValue: '2',
  222. },
  223. {
  224. field: 'duty',
  225. component: 'Select',
  226. label: '职务',
  227. labelWidth: adaptWidth.labelWidth,
  228. colProps: {
  229. span: adaptWidth.elContainer,
  230. },
  231. componentProps: {
  232. placeholder: '职务',
  233. options: [
  234. {
  235. label: '会长',
  236. value: 0,
  237. },
  238. {
  239. label: '副会长',
  240. value: 1,
  241. },
  242. {
  243. label: '秘书长',
  244. value: 2,
  245. },
  246. {
  247. label: '副秘书长',
  248. value: 3,
  249. },
  250. {
  251. label: '理事',
  252. value: 4,
  253. },
  254. {
  255. label: '会员',
  256. value: 5,
  257. },
  258. ],
  259. },
  260. required: true,
  261. },
  262. {
  263. field: 'jointime',
  264. component: 'DatePicker',
  265. label: '入会时间',
  266. labelWidth: adaptWidth.labelWidth,
  267. colProps: {
  268. span: adaptWidth.elContainer,
  269. },
  270. componentProps: {
  271. placeholder: '入会时间',
  272. },
  273. required: true,
  274. },
  275. {
  276. field: 'name',
  277. component: 'Input',
  278. label: '姓名(名称)',
  279. labelWidth: adaptWidth.labelWidth,
  280. colProps: {
  281. span: adaptWidth.elContainer,
  282. },
  283. render: ({ model, field }) => {
  284. return h(CustomInput, {
  285. value: model.name,
  286. type: model.type,
  287. placeholder: '添加个人',
  288. onChange(value) {
  289. model[field] = value;
  290. model['username'] = value.name;
  291. },
  292. });
  293. },
  294. required: true,
  295. },
  296. {
  297. field: 'username',
  298. component: 'Input',
  299. label: '用户名',
  300. labelWidth: adaptWidth.labelWidth,
  301. colProps: {
  302. span: adaptWidth.elContainer,
  303. },
  304. componentProps: {
  305. placeholder: '用户名',
  306. },
  307. required: true,
  308. },
  309. {
  310. field: 'password',
  311. component: 'InputPassword',
  312. label: '密码',
  313. labelWidth: adaptWidth.labelWidth,
  314. defaultValue: '123456',
  315. colProps: {
  316. span: adaptWidth.elContainer,
  317. },
  318. componentProps: {
  319. placeholder: '密码(初始密码123456)',
  320. },
  321. required: true,
  322. },
  323. ];