courses.data.ts 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. import { BasicColumn } from '/@/components/Table';
  2. import { FormSchema } from '/@/components/Table';
  3. import { rules } from '/@/utils/helper/validator';
  4. import { render } from '/@/utils/common/renderUtils';
  5. import { getWeekMonthQuarterYear } from '/@/utils';
  6. import { getInsureList, getSprotProject } from '/@/api/common/api';
  7. import { defHttp } from '/@/utils/http/axios';
  8. import { getCoachList } from './courses.api';
  9. import { useUserStore } from '/@/store/modules/user';
  10. import ZtCustomTable from '/@/components/ZtCustomTable/index.vue';
  11. import { h } from 'vue';
  12. import { Business } from '../gymnasiumBag/gymnasiumBag.api';
  13. import { storeToRefs } from 'pinia';
  14. const { userInfo } = storeToRefs(useUserStore());
  15. //列表数据
  16. export const columns: BasicColumn[] = [
  17. {
  18. title: '课程名称',
  19. align: 'center',
  20. dataIndex: 'name',
  21. },
  22. {
  23. title: '课程封面',
  24. align: 'center',
  25. dataIndex: 'cover',
  26. slots: {
  27. customRender: 'img',
  28. },
  29. },
  30. {
  31. title: '课时节数及时间',
  32. align: 'center',
  33. dataIndex: 'totalNum',
  34. slots: { customRender: 'totalNum' },
  35. },
  36. {
  37. title: '上课地点',
  38. align: 'center',
  39. dataIndex: 'address',
  40. },
  41. {
  42. title: '销售价/原价(元)',
  43. align: 'center',
  44. dataIndex: 'categoryId',
  45. slots: { customRender: 'price' },
  46. },
  47. {
  48. title: '上下架状态',
  49. align: 'center',
  50. dataIndex: 'rackingStatus',
  51. slots: { customRender: 'priceType' },
  52. },
  53. {
  54. title: '课程类型',
  55. align: 'center',
  56. dataIndex: 'categoryIds',
  57. },
  58. ];
  59. //查询数据
  60. export const searchFormSchema: FormSchema[] = [
  61. {
  62. field: 'name',
  63. label: '课程名称',
  64. component: 'Input',
  65. colProps: { span: 6 },
  66. },
  67. {
  68. field: '上下架状态',
  69. label: '上下架状态',
  70. component: 'Select',
  71. colProps: { span: 6 },
  72. componentProps: {
  73. options: [
  74. { label: '上架', value: 0 },
  75. { label: '下架', value: 1 },
  76. ],
  77. },
  78. },
  79. {
  80. field: 'coursesStatus',
  81. label: '课程进展',
  82. component: 'Select',
  83. colProps: { span: 6 },
  84. componentProps: {
  85. options: [
  86. { label: '全部', value: '' },
  87. // 全部、未开始、正常上课中、休息中、补课中、已结束
  88. { label: '未开始', value: 0 },
  89. { label: '正常上课中', value: 1 },
  90. { label: '休息中', value: 2 },
  91. { label: '补课中', value: 3 },
  92. { label: '已结束', value: 4 },
  93. ],
  94. },
  95. },
  96. {
  97. field: 'categoryId',
  98. label: '课程类型',
  99. component: 'ApiSelect',
  100. colProps: { span: 6 },
  101. componentProps: {
  102. api: () => defHttp.get({ url: '/app/appCategory/list' }),
  103. labelField: 'name',
  104. valueField: 'id',
  105. resultField: 'records',
  106. },
  107. },
  108. ];
  109. //表单数据
  110. export const formSchema: FormSchema[] = [
  111. {
  112. label: 'title1',
  113. field: 'orgCode',
  114. colSlot: 'title1',
  115. component: 'Input',
  116. },
  117. {
  118. label: '课程类型',
  119. field: 'categoryId',
  120. component: 'ApiSelect',
  121. required: true,
  122. componentProps: {
  123. api: getSprotProject,
  124. labelField: 'name',
  125. valueField: 'id',
  126. mode: 'tags',
  127. resultField: 'records',
  128. },
  129. },
  130. {
  131. label: '课程名称',
  132. required: true,
  133. field: 'name',
  134. component: 'Input',
  135. },
  136. {
  137. label: '课程封面',
  138. field: 'cover',
  139. component: 'JImageUpload',
  140. componentProps: {
  141. tipText: '支持单张上传;宽高比为5:4,且宽高均大于480px,大小5M以内。',
  142. },
  143. required: true,
  144. },
  145. {
  146. label: '上课地点',
  147. field: 'addressSiteId',
  148. component: 'ApiSelect',
  149. required: true,
  150. componentProps: {
  151. api: Business,
  152. labelField: 'name',
  153. valueField: 'tenantId',
  154. params: {
  155. orgCode: 'A01',
  156. type: 0,
  157. },
  158. },
  159. },
  160. {
  161. label: '教练',
  162. field: 'userId',
  163. component: 'ApiSelect',
  164. required: true,
  165. componentProps: {
  166. api: getCoachList,
  167. labelField: 'name',
  168. valueField: 'userId',
  169. params: { orgCode: useUserStore().userInfo?.orgCode },
  170. },
  171. },
  172. {
  173. label: 'title2',
  174. field: 'title2',
  175. component: 'Input',
  176. colSlot: 'title2',
  177. },
  178. {
  179. label: '原价',
  180. field: 'originalPrice',
  181. component: 'InputNumber',
  182. },
  183. {
  184. label: '销售价',
  185. field: 'sellingPrice',
  186. component: 'InputNumber',
  187. required: true,
  188. },
  189. {
  190. label: '限购',
  191. field: 'limitNum',
  192. required: true,
  193. component: 'InputNumber',
  194. componentProps: {
  195. addonBefore: '每人限制购买',
  196. addonAfter: '张',
  197. },
  198. },
  199. {
  200. label: '正常课表',
  201. field: 'priceRulesList',
  202. component: 'InputNumber',
  203. slot: 'ZtCustomTable1',
  204. required: true,
  205. },
  206. {
  207. label: 'title3',
  208. field: 'sellingPrice',
  209. component: 'InputNumber',
  210. colSlot: 'title3',
  211. },
  212. {
  213. label: '视频',
  214. field: 'video',
  215. component: 'JUpload',
  216. slot: 'VideoUpload',
  217. componentProps: {
  218. fileType: 'video',
  219. bizPath: 'video',
  220. },
  221. },
  222. {
  223. label: '图片',
  224. field: 'backgroundImage',
  225. component: 'JImageUpload',
  226. componentProps: {
  227. tipText: '支持单张上传;宽高比为5:4,且宽高均大于480px,大小5M以内。',
  228. },
  229. required: true,
  230. },
  231. {
  232. label: '使用须知',
  233. field: 'reminder',
  234. component: 'InputTextArea',
  235. required: true,
  236. },
  237. {
  238. label: '配套保险',
  239. field: 'insureIds',
  240. component: 'ApiSelect',
  241. required: true,
  242. componentProps: {
  243. api: getInsureList,
  244. resultField: 'data',
  245. labelField: 'name',
  246. valueField: 'id',
  247. mode: 'multiple',
  248. },
  249. },
  250. {
  251. label: '图文详情',
  252. field: 'details',
  253. component: 'JEditor',
  254. required: true,
  255. },
  256. {
  257. label: '上架状态',
  258. field: 'rackingStatus',
  259. component: 'Switch',
  260. required: true,
  261. componentProps: {
  262. //非选中时的内容
  263. unCheckedChildren: '下架',
  264. //非选中时的值
  265. unCheckedValue: 1,
  266. //选中时的内容
  267. checkedChildren: '上架',
  268. //选中时的值
  269. checkedValue: 0,
  270. },
  271. defaultValue: 0,
  272. },
  273. // TODO 主键隐藏字段,目前写死为ID
  274. {
  275. label: '',
  276. field: 'id',
  277. component: 'Input',
  278. show: false,
  279. },
  280. ];
  281. /**
  282. * 流程表单调用这个方法获取formSchema
  283. * @param param
  284. */
  285. export function getBpmFormSchema(_formData): FormSchema[] {
  286. // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
  287. return formSchema;
  288. }
  289. export const publishcoursesColums: BasicColumn[] = [
  290. {
  291. title: '时间段',
  292. dataIndex: 'time',
  293. editComponent: 'RangePicker',
  294. editRule: true,
  295. editComponentProps: {
  296. showTime: true,
  297. size: 'middle',
  298. placeholder: ['开始时间', '结束时间'],
  299. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  300. },
  301. width: 450,
  302. editRow: true,
  303. editable: true,
  304. },
  305. {
  306. title: '课时名称',
  307. dataIndex: 'name',
  308. editComponent: 'Input',
  309. editRule: true,
  310. editRow: true,
  311. editable: true,
  312. width: 500,
  313. editComponentProps: {
  314. size: 'middle',
  315. },
  316. },
  317. {
  318. key: 'op',
  319. dataIndex: 'operation',
  320. title: 'operation',
  321. fixed: 'right',
  322. ellipsis: true,
  323. width: 80,
  324. },
  325. ];
  326. export const coursesForm: FormSchema[] = [
  327. {
  328. label: '课程名称',
  329. field: 'name',
  330. component: 'Input',
  331. componentProps: {
  332. disabled: true,
  333. },
  334. required: true,
  335. },
  336. {
  337. label: '补课课表',
  338. field: 'dtoList',
  339. component: 'Input',
  340. required: true,
  341. render({ model, field }) {
  342. return h(ZtCustomTable, {
  343. tableColumn: [
  344. {
  345. dataIndex: 'time',
  346. title: '时间',
  347. editComponent: 'RangePicker',
  348. editRule: true,
  349. editComponentProps: {
  350. placeholder: ['开始时间', '结束时间'],
  351. size: 'middle',
  352. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  353. showTime: true,
  354. },
  355. width: 350,
  356. editRow: true,
  357. editable: true,
  358. },
  359. {
  360. dataIndex: 'name',
  361. title: '名称',
  362. editComponent: 'Input',
  363. editRule: true,
  364. editComponentProps: {
  365. size: 'middle',
  366. },
  367. width: 350,
  368. editRow: true,
  369. editable: true,
  370. },
  371. {
  372. dataIndex: 'operation',
  373. title: 'operation',
  374. fixed: 'right',
  375. },
  376. ],
  377. value: model[field],
  378. showIndex: true,
  379. showAction: true,
  380. });
  381. },
  382. defaultValue: [],
  383. },
  384. {
  385. label: '课程名称',
  386. field: 'id',
  387. component: 'Input',
  388. show: false,
  389. },
  390. ];