AddItems.vue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468
  1. <script lang="ts" setup>
  2. import { ref, watch, reactive, onMounted, h, computed } from 'vue';
  3. import { message } from 'ant-design-vue';
  4. import { PlusOutlined } from '@ant-design/icons-vue'; // 确保导入
  5. import { notification } from 'ant-design-vue';
  6. import VxeUI from 'vxe-table';
  7. import { useRequest } from 'alova/client';
  8. import { getDictionaryMethod, cpMedicinesMethod } from '@/request/api/dictionary.api';
  9. import { branchMethod } from '@/request/api/system.api';
  10. import { systemCpEditMethod, getAllSupplierMethod, getConditioningSchemeDetailMethod } from '@/request/api/care.api';
  11. import { UploadIFile } from '@/request/api/follow.api';
  12. import type { SystemItemModel } from '@/model/care.model';
  13. import RemoteSelect from '@/libs/v-select-page/RemoteSelect.vue';
  14. import SearchableSelect from '@/components/SearchableSelect.vue';
  15. import type { UploadFile } from 'ant-design-vue/es/upload/interface';
  16. import type { FormInstance } from 'ant-design-vue';
  17. import Derivation from '@/service/Derivation.vue';
  18. type SystemModel = Partial<SystemItemModel>;
  19. const props = defineProps<{ data: SystemModel; institutionId: string | number }>();
  20. const formRef = ref<FormInstance>();
  21. const typeOptionsLoading = ref<boolean>(false);
  22. const typeOptions = ref<{ label: string; value: string }[]>([]);
  23. const supplierOptions = ref<{ label: string; value: string }[]>([]);
  24. const isRequired = ref<boolean>(true);
  25. const unitOptions = [
  26. { label: '袋', value: '袋' },
  27. { label: '包', value: '包' },
  28. { label: '贴', value: '贴' },
  29. { label: '次', value: '次' },
  30. ];
  31. const herbList = ref<any[]>([]);
  32. // 获取所有的机构
  33. const branch = ref<any[]>([]);
  34. const { loading: branchLoading } = useRequest(branchMethod).onSuccess(({ data }) => {
  35. const to = (data?: any[]): any[] => {
  36. return Array.isArray(data)
  37. ? data.map((item) => {
  38. return {
  39. ...item,
  40. value: item.id,
  41. key: item.id.toString(),
  42. children: to(item.children),
  43. };
  44. })
  45. : [];
  46. };
  47. branch.value = to(data);
  48. });
  49. const form = reactive<SystemItemModel>({
  50. institutionName: '',
  51. conditioningProgramType: '',
  52. conditioningProgramSupplierId: '',
  53. institutionId: '',
  54. cpDynamicPricingRule: [
  55. { min: '', max: '', priceType: '', price: '' },
  56. { min: '', max: '', priceType: '', price: '' },
  57. ],
  58. pricingType: '0',
  59. cpFixedPricingRule: {
  60. unitPrice: '',
  61. pricingUnit: '',
  62. convertDose: '',
  63. convertUnit: '',
  64. },
  65. cpPatientMatchRule: {
  66. sex: '', // 性别
  67. age: '', // 年龄
  68. diagnoseDiseaseNames: [], // 疾病
  69. diagnoseSyndromeNames: [], // 证型
  70. constitutionGroupNames: [], // 体质
  71. willillStateNames: [], // 欲病状态
  72. tabooCrowds: [], // 禁忌
  73. },
  74. cpMedicines: [{ name: '', dosage: '', id: '' }],
  75. isOffline: null,
  76. isDelivery: null,
  77. effect: '', // 功效
  78. photo: '', // 商品图片
  79. itemImgFirst: '', // 操作图片
  80. itemVideoFirst: '', // 操作视频
  81. attrFirst: '', // 特色
  82. attrSeventh: '', //使用注意
  83. attrSixth: '', // 疗程说明
  84. attrFifth: '', // 操作方法
  85. attrFourth: '', // 用法
  86. attrThird: '', // 制法
  87. status: '0', // 状态
  88. isForWrap: null, // 是否服务包项目
  89. isForInfer: null, // 是否调理方案项目
  90. });
  91. const checkedList = ref<string[]>(['1']); // 默认选中第一个
  92. const onlineArr = ref<string[]>([]);
  93. const deliverArr = ref<string[]>([]);
  94. const rules = {
  95. name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
  96. conditioningProgramType: [{ required: true, message: '请选择方案类型', trigger: 'change' }],
  97. institutionId: [{ required: true, message: '请选择机构名称', trigger: 'change' }],
  98. };
  99. const isShowOnline = ref<boolean>(false);
  100. const isShowDelivery = ref<boolean>(false);
  101. const supplierArr = ref<any[]>([]);
  102. // 弹层容器:避免模板中直接引用 document 导致类型检查报错
  103. const getBodyContainer = () => document.body as HTMLElement;
  104. // 获取所有的供应商
  105. async function getSupplier(params: any) {
  106. supplierOptions.value = [];
  107. const res = await getAllSupplierMethod(params);
  108. if (res && res.length > 0) {
  109. supplierArr.value = res;
  110. supplierOptions.value = res.map((item: any) => ({
  111. label: item.name,
  112. value: item.id,
  113. }));
  114. getisOffline(params.conditioningProgramSupplierId, params.isOffline, params.isDelivery, params.conditioningProgramTypes);
  115. }
  116. }
  117. function getisOffline(e: any, newOffline: any, newDelivery: any, newType: any) {
  118. let filterSupplierArr = supplierArr.value.filter((item: any) => item.id === e);
  119. if (filterSupplierArr.length > 0) {
  120. isShowOnline.value = filterSupplierArr.every((items: any) => {
  121. if (newType.length > 0) {
  122. if (items.offlineCPTypes?.includes(newType[0]) && items.onlineCPTypes?.includes(newType[0])) {
  123. return true;
  124. } else {
  125. if (items.offlineCPTypes?.includes(newType[0])) {
  126. form.isOffline = 'Y';
  127. return false;
  128. } else if (items.onlineCPTypes?.includes(newType[0])) {
  129. form.isOffline = 'N';
  130. // 线上项目 显示配送选项
  131. isShowDelivery.value = true;
  132. return false;
  133. } else {
  134. form.isOffline = null;
  135. return false;
  136. }
  137. }
  138. } else {
  139. return false;
  140. }
  141. });
  142. if (isShowOnline.value) {
  143. if (newOffline) {
  144. onlineArr.value = [newOffline];
  145. if (onlineArr.value.length > 1) {
  146. onlineArr.value = [onlineArr.value[onlineArr.value.length - 1]];
  147. } else if (onlineArr.value.length === 0) {
  148. onlineArr.value = [];
  149. }
  150. // newOffline ==Y 线下项目 不需要配送
  151. if (newOffline === 'Y') {
  152. form.isDelivery = null;
  153. isShowDelivery.value = false;
  154. } else {
  155. isShowDelivery.value = true;
  156. }
  157. } else {
  158. isShowDelivery.value = false;
  159. }
  160. if (newDelivery) {
  161. deliverArr.value = [newDelivery];
  162. if (deliverArr.value.length > 1) {
  163. deliverArr.value = [deliverArr.value[deliverArr.value.length - 1]];
  164. } else if (deliverArr.value.length === 0) {
  165. deliverArr.value = [];
  166. }
  167. }
  168. } else {
  169. // 线上项目 显示配送选项
  170. if (newOffline === 'N') {
  171. isShowDelivery.value = true;
  172. deliverArr.value = [newDelivery];
  173. if (deliverArr.value.length > 1) {
  174. deliverArr.value = [deliverArr.value[deliverArr.value.length - 1]];
  175. } else if (deliverArr.value.length === 0) {
  176. deliverArr.value = [];
  177. }
  178. }
  179. }
  180. } else {
  181. isShowOnline.value = false;
  182. isShowDelivery.value = false;
  183. onlineArr.value = [];
  184. deliverArr.value = [];
  185. }
  186. }
  187. watch(
  188. [() => form.conditioningProgramType, () => form.institutionId, () => form.conditioningProgramSupplierId, () => form.isOffline, () => form.isDelivery],
  189. ([newType, newInstitutionId, newSupplierId, newOffline, newDelivery]) => {
  190. getSupplier({
  191. conditioningProgramTypes: newType ? [newType] : form.conditioningProgramType ? [form.conditioningProgramType] : [],
  192. collaborateDeptId: newInstitutionId ? newInstitutionId : form.institutionId ? form.institutionId : '',
  193. conditioningProgramSupplierId: newSupplierId ? newSupplierId : form.conditioningProgramSupplierId ? form.conditioningProgramSupplierId : '',
  194. isOffline: newOffline,
  195. isDelivery: newDelivery,
  196. });
  197. },
  198. { immediate: true }
  199. );
  200. function addHerb() {
  201. if (!form.cpMedicines) {
  202. form.cpMedicines = [];
  203. }
  204. form.cpMedicines.push({ name: '', dosage: '', id: '' });
  205. }
  206. function removeHerb(idx: number) {
  207. if (form.cpMedicines) {
  208. form.cpMedicines.splice(idx, 1);
  209. }
  210. }
  211. // 新增:处理自定义药材输入
  212. function handleCustomHerb(value: string, idx: number) {
  213. if (form.cpMedicines && form.cpMedicines[idx]) {
  214. form.cpMedicines[idx].name = value;
  215. form.cpMedicines[idx].id = value; // 自定义选项使用输入值作为ID
  216. }
  217. }
  218. function cancel() {
  219. VxeUI.modal.close(`add-items-modal`);
  220. }
  221. function doSubmit() {
  222. // 自定义验证:检查项目应用是否已选择
  223. if (!checkedList.value || checkedList.value.length === 0) {
  224. notification.error({
  225. message: '请选择项目应用',
  226. });
  227. return;
  228. }
  229. form.isForWrap = checkedList.value.includes('1') ? 'Y' : null;
  230. form.isForInfer = checkedList.value.includes('2') ? 'Y' : null;
  231. // 服务包项目相关必填
  232. if ((form.addType === 'itemsList' && checkedList.value.includes('1')) || form.addType === 'system') {
  233. // 计价规则
  234. if (!form.pricingType) {
  235. notification.error({
  236. message: '请选择计价规则',
  237. });
  238. return;
  239. }
  240. // console.log(form.pricingType, 'form.pricingType==>', form);
  241. // 计价规则相关字段校验
  242. if (form.pricingType === '0') {
  243. console.log(form.cpFixedPricingRule, 'form.cpFixedPricingRule');
  244. const { unitPrice, pricingUnit, convertDose, convertUnit } = form.cpFixedPricingRule || {};
  245. const allFilled = (unitPrice !== '' && unitPrice !== null && unitPrice !== undefined) && pricingUnit && (convertDose !== '' && convertDose !== null && convertDose !== undefined) && convertUnit;
  246. if (!allFilled) {
  247. notification.error({
  248. message: '请将单价、计价单位、相当于、使用单位全部填写',
  249. });
  250. return;
  251. }
  252. form.cpDynamicPricingRule = undefined;
  253. } else if (form.pricingType === '1') {
  254. const rule1 = form.cpDynamicPricingRule[0] || {};
  255. const rule2 = form.cpDynamicPricingRule[1] || {};
  256. const allFilled1 = rule1.min && typeof rule1.priceType !== 'undefined' && rule1.price;
  257. const allFilled2 = rule2.max && typeof rule2.priceType !== 'undefined' && rule2.price;
  258. rule1.max = 0;
  259. rule2.min = 0;
  260. if (!(allFilled1 && allFilled2)) {
  261. notification.error({
  262. message: '请将按穴位/经络/部位的所有计价字段全部填写',
  263. });
  264. return;
  265. }
  266. // 按穴位模式:清空一口价数据
  267. form.cpFixedPricingRule = undefined;
  268. }
  269. // 供应商
  270. if (form.addType === 'itemsList' && checkedList.value.includes('1')) {
  271. if (!form.conditioningProgramSupplierId) {
  272. message.error('请选择供应商');
  273. return;
  274. }
  275. } else if (form.addType === 'system') {
  276. form.isOffline = 'N';
  277. form.isDelivery = 'N';
  278. }
  279. // 线下项目
  280. if (isShowOnline.value && !form.isOffline) {
  281. message.error('请选择是否为线下项目');
  282. return;
  283. }
  284. // 配送
  285. if (isShowDelivery.value && (!deliverArr.value || deliverArr.value.length === 0)) {
  286. message.error('请选择配送方式');
  287. return;
  288. }
  289. } else if (form.addType === 'itemsList') {
  290. // 计价规则非必填时,做全填/全空校验
  291. if (form.pricingType === '0') {
  292. const { unitPrice, pricingUnit, convertDose, convertUnit } = form.cpFixedPricingRule || {};
  293. const allFilled = (unitPrice !== '' && unitPrice !== null && unitPrice !== undefined) && pricingUnit && (convertDose !== '' && convertDose !== null && convertDose !== undefined) && convertUnit;
  294. const allEmpty = !unitPrice && !pricingUnit && !convertDose && !convertUnit;
  295. if (!(allFilled || allEmpty)) {
  296. message.error('单价、计价单位、相当于、使用单位要么全部填写,要么全部为空');
  297. return;
  298. }
  299. // 一口价模式:清空按穴位数据
  300. if (allFilled) {
  301. form.cpDynamicPricingRule = undefined;
  302. }
  303. } else if (form.pricingType === '1') {
  304. const rule1 = form.cpDynamicPricingRule[0] || {};
  305. const rule2 = form.cpDynamicPricingRule[1] || {};
  306. const allFilled1 = rule1.min && typeof rule1.priceType !== 'undefined' && rule1.price;
  307. const allEmpty1 = !rule1.min && (typeof rule1.priceType === 'undefined' || rule1.priceType === '' || rule1.priceType === null) && !rule1.price;
  308. const allFilled2 = rule2.max && typeof rule2.priceType !== 'undefined' && rule2.price;
  309. const allEmpty2 = !rule2.max && (typeof rule2.priceType === 'undefined' || rule2.priceType === '' || rule2.priceType === null) && !rule2.price;
  310. if (!((allFilled1 && allFilled2) || (allEmpty1 && allEmpty2))) {
  311. message.error('按穴位/经络/部位的所有计价字段要么全部填写,要么全部为空');
  312. return;
  313. }
  314. // 按穴位模式:清空一口价数据
  315. if (allFilled1 && allFilled2) {
  316. form.cpFixedPricingRule = undefined;
  317. }
  318. }
  319. }
  320. // 调理方案项目相关必填
  321. if (form.addType === 'itemsList' && checkedList.value.includes('2')) {
  322. if (!hasDerivationLogic.value) {
  323. message.error('请设置推导逻辑');
  324. return;
  325. }
  326. }
  327. // 购买链接与跳转类型联动校验:有购买链接则必须选择跳转类型
  328. if (form.addType === 'itemsList') {
  329. const hasBuyUrl = !!(form.buyUrl && String(form.buyUrl).trim());
  330. if (hasBuyUrl && !form.jumpType) {
  331. message.error('有“购买链接”时必须选择“跳转类型”');
  332. return;
  333. }
  334. }
  335. formRef.value?.validate().then(() => {
  336. form.photo = fileList.value[0]?.response?.url || fileList.value[0]?.url || '';
  337. form.itemImgFirst = optionsList.value[0]?.response?.url || optionsList.value[0]?.url || '';
  338. // 合并推导逻辑数据到表单数据中
  339. if (hasDerivationLogic.value && derivationData.value.cpPatientMatchRule) {
  340. form.cpPatientMatchRule = { ...derivationData.value.cpPatientMatchRule };
  341. }
  342. if (props.data.isType === 'itemsList') {
  343. delete form.id;
  344. }
  345. submit(form);
  346. });
  347. // .catch((error: any) => {
  348. // notification.error({
  349. // message: error.message || '必填内容请填写完整',
  350. // });
  351. // });
  352. }
  353. // 获取方案类型
  354. async function getConditioningProgramType() {
  355. typeOptionsLoading.value = true;
  356. try {
  357. const res = await getDictionaryMethod('condition_type');
  358. if (res?.length > 0) {
  359. typeOptions.value = res; // 直接使用返回的数据
  360. }
  361. } catch (error: any) {
  362. notification.error({
  363. message: error.message,
  364. });
  365. } finally {
  366. typeOptionsLoading.value = false;
  367. }
  368. }
  369. // 处理下拉框点击事件
  370. function handleSelectClick() {
  371. // 如果选项为空且不在加载中,尝试重新获取数据
  372. if (typeOptions.value.length === 0 && !typeOptionsLoading.value) {
  373. getConditioningProgramType();
  374. }
  375. }
  376. // 搜索过滤函数
  377. function filterOption(input: string, option: any) {
  378. const searchText = input.toLowerCase();
  379. const optionText = option.label?.toLowerCase() || '';
  380. return optionText.includes(searchText);
  381. }
  382. onMounted(async () => {
  383. const deptId = localStorage.getItem('deptId');
  384. if (props.data.addType === 'system' && deptId) {
  385. form.institutionId = deptId;
  386. }
  387. if (props.data.addType === 'system') {
  388. isRequired.value = false;
  389. }
  390. form.addType = props.data.addType;
  391. if (props.data.id || props.data.sourceId) {
  392. const res: any = await getConditioningSchemeDetailMethod(props.data);
  393. const checked: string[] = [];
  394. if (res.isForWrap === 'Y') checked.push('1');
  395. if (res.isForInfer === 'Y') checked.push('2');
  396. checkedList.value = checked.length > 0 ? checked : ['1', '2'];
  397. Object.assign(form, res);
  398. form.cpMedicines = (res.cpMedicines ?? []).map((item: any) => ({
  399. name: item.name || item.herbName || item.medicineName || '',
  400. dosage: item.dosage,
  401. id: item.id,
  402. }));
  403. // 处理推导逻辑数据回填
  404. if (res.cpPatientMatchRule) {
  405. derivationData.value = { cpPatientMatchRule: res.cpPatientMatchRule };
  406. hasDerivationLogic.value = true;
  407. }
  408. fileList.value = res.photo
  409. ? [
  410. {
  411. uid: '-1',
  412. name: 'image.png',
  413. status: 'done',
  414. url: res.photo,
  415. thumbUrl: res.photo,
  416. },
  417. ]
  418. : [];
  419. optionsList.value = res.itemImgFirst
  420. ? [
  421. {
  422. uid: '-1',
  423. name: 'image.png',
  424. status: 'done',
  425. url: res.itemImgFirst,
  426. thumbUrl: res.itemImgFirst,
  427. },
  428. ]
  429. : [];
  430. // 处理视频数据
  431. if (res.itemVideoFirst) {
  432. videoFileList.value = [
  433. {
  434. uid: '-1',
  435. name: '操作视频',
  436. status: 'done',
  437. url: res.itemVideoFirst,
  438. response: { url: res.itemVideoFirst },
  439. },
  440. ];
  441. }
  442. if (props.data.isType === 'itemsList' && props.data.sourceId) {
  443. form.sourceId = form.id;
  444. // form.institutionId = '';
  445. form.institutionId = props.data.institutionId;
  446. form.institutionName = props.data.institutionName;
  447. }
  448. }
  449. // 获取方案类型
  450. getConditioningProgramType();
  451. });
  452. const emits = defineEmits<{
  453. submit: [data?: SystemItemModel];
  454. addSubmit: [data?: SystemItemModel];
  455. }>();
  456. const { loading: submitting, send: submit } = useRequest(systemCpEditMethod, {
  457. immediate: false,
  458. }).onSuccess(({ data }) => {
  459. emits('submit');
  460. });
  461. const visible = ref<boolean>(false);
  462. const setVisible = (value: boolean): void => {
  463. visible.value = value;
  464. };
  465. const previewImg = ref<string>('');
  466. const uploadProps = reactive({ showRemoveIcon: true });
  467. // 商品图片
  468. const fileList = ref<UploadFile[]>([]);
  469. // 操作图片
  470. const optionsList = ref<UploadFile[]>([]);
  471. // 安全挂载弹层,避免 document 不可用或被父层遮挡
  472. function getSafePopupContainer(triggerNode?: HTMLElement) {
  473. try {
  474. // @ts-ignore
  475. if (typeof document !== 'undefined' && document?.body) return document.body;
  476. } catch (e) {}
  477. return (triggerNode?.parentNode as HTMLElement) || undefined;
  478. }
  479. // 统一用 change 处理(避免 @select 改值导致面板被打断)
  480. function onInstitutionChange(val: string | number | undefined) {
  481. form.institutionId = val as any;
  482. }
  483. // 预览图片
  484. const handlePreview = async (file: UploadFile) => {
  485. previewImg.value = file.response?.url ?? file.thumbUrl;
  486. visible.value = true;
  487. };
  488. function customUpload(e: any) {
  489. UploadIFile(e.file)
  490. .then((res) => {
  491. // 调用实例的成功方法通知组件该文件上传成功
  492. e.onSuccess(res, e);
  493. })
  494. .catch((err) => {
  495. // 调用实例的失败方法通知组件该文件上传失败
  496. e.onError(err);
  497. });
  498. }
  499. // 视频上传相关
  500. const accept = 'video/mp4,video/avi,video/mov,video/webm';
  501. const maxSize = 100 * 1024 * 1024; // 100MB
  502. const videoUrl = ref('');
  503. const uploading = ref(false);
  504. const progress = ref(0);
  505. const videoFileList = ref<UploadFile[]>([]);
  506. // 供应商校验规则:仅在“项目应用 勾选 服务包”且“新增项目(itemsList)”时必填
  507. const supplierRules = computed(() => {
  508. const need = checkedList.value.includes('1') && form.addType === 'itemsList';
  509. return need ? [{ required: true, message: '请选择供应商', trigger: ['change', 'blur'] }] : [];
  510. });
  511. // 上传前校验
  512. function beforeVideoUpload(file: File) {
  513. const isValidType = accept.split(',').includes(file.type);
  514. if (!isValidType) {
  515. message.error('仅支持mp4、avi、mov、webm格式视频');
  516. return false;
  517. }
  518. const isValidSize = file.size <= maxSize;
  519. if (!isValidSize) {
  520. message.error('视频大小不能超过100MB');
  521. return false;
  522. }
  523. return true;
  524. }
  525. // 视频预览
  526. function handleVideoPreview(file: UploadFile) {
  527. const videoUrl = file.response?.url || file.url || form.itemVideoFirst;
  528. if (videoUrl) {
  529. VxeUI.modal.open({
  530. title: '视频预览',
  531. width: 800,
  532. height: 600,
  533. escClosable: true,
  534. destroyOnClose: true,
  535. slots: {
  536. default() {
  537. return h(
  538. 'div',
  539. {
  540. style: {
  541. display: 'flex',
  542. justifyContent: 'center',
  543. alignItems: 'center',
  544. height: '100%',
  545. },
  546. },
  547. [
  548. h('video', {
  549. src: videoUrl,
  550. controls: true,
  551. style: {
  552. maxWidth: '100%',
  553. maxHeight: '100%',
  554. borderRadius: '8px',
  555. },
  556. }),
  557. ]
  558. );
  559. },
  560. },
  561. });
  562. }
  563. }
  564. // 删除视频
  565. function removeVideo() {
  566. form.itemVideoFirst = '';
  567. videoFileList.value = [];
  568. message.success('视频已删除');
  569. }
  570. // 自定义上传
  571. function customVideoRequest(e: any) {
  572. const { file, onSuccess, onError, onProgress } = e;
  573. // 验证文件
  574. if (!beforeVideoUpload(file)) {
  575. onError(new Error('文件验证失败'));
  576. return;
  577. }
  578. uploading.value = true;
  579. progress.value = 0;
  580. // 模拟上传进度
  581. const progressInterval = setInterval(() => {
  582. if (progress.value < 90) {
  583. progress.value += Math.random() * 10;
  584. onProgress({ percent: progress.value });
  585. }
  586. }, 200);
  587. // 上传文件
  588. UploadIFile(file)
  589. .then((res: any) => {
  590. clearInterval(progressInterval);
  591. progress.value = 100;
  592. onProgress({ percent: 100 });
  593. // 设置视频URL
  594. form.itemVideoFirst = res?.url || res?.data?.url;
  595. // 更新文件列表
  596. videoFileList.value = [
  597. {
  598. uid: file.uid,
  599. name: file.name,
  600. status: 'done',
  601. url: form.itemVideoFirst,
  602. response: res,
  603. },
  604. ];
  605. onSuccess(res, e);
  606. uploading.value = false;
  607. message.success('视频上传成功');
  608. })
  609. .catch((err) => {
  610. clearInterval(progressInterval);
  611. uploading.value = false;
  612. progress.value = 0;
  613. onError(err);
  614. message.error('视频上传失败,请重试');
  615. });
  616. }
  617. // 视频上传状态变化
  618. function handleVideoChange(info: any) {
  619. const { file, fileList } = info;
  620. if (file.status === 'uploading') {
  621. uploading.value = true;
  622. } else if (file.status === 'done') {
  623. uploading.value = false;
  624. videoFileList.value = fileList;
  625. } else if (file.status === 'error') {
  626. uploading.value = false;
  627. message.error('视频上传失败');
  628. }
  629. }
  630. watch(
  631. () => form.pricingType,
  632. (val) => {
  633. if (val === '0') {
  634. // 一口价模式:确保 cpFixedPricingRule 存在
  635. if (!form.cpFixedPricingRule) {
  636. form.cpFixedPricingRule = {
  637. unitPrice: '',
  638. pricingUnit: '',
  639. convertDose: '',
  640. convertUnit: '',
  641. };
  642. }
  643. } else if (val === '1') {
  644. // 按穴位模式:确保 cpDynamicPricingRule 存在
  645. if (!form.cpDynamicPricingRule) {
  646. form.cpDynamicPricingRule = [
  647. { min: '', max: '', priceType: '', price: '' },
  648. { min: '', max: '', priceType: '', price: '' },
  649. ];
  650. }
  651. }
  652. }
  653. );
  654. function bindchange(e: any) {
  655. form.conditioningProgramSupplierId = '';
  656. form.isOffline = null;
  657. }
  658. function onlineChange(value: any) {
  659. form.isOffline = value[value.length - 1];
  660. deliverArr.value = [];
  661. form.isDelivery = null;
  662. }
  663. function deliveryChange(value: any) {
  664. form.isDelivery = value[value.length - 1];
  665. }
  666. function getConditioningProgramSupplier(value: any) {
  667. onlineArr.value = [];
  668. deliverArr.value = [];
  669. form.isOffline = null;
  670. form.isDelivery = null;
  671. isShowDelivery.value = false;
  672. }
  673. function handleSelect(value: any, node: any) {
  674. form.institutionId = value;
  675. if (node && node.label) {
  676. form.institutionName = node.label;
  677. } else if (node && node.title) {
  678. form.institutionName = node.title;
  679. }
  680. }
  681. // 项目应用数据
  682. const plainOptions = [
  683. { id: '1', name: '服务包项目' },
  684. { id: '2', name: '调理方案项目' },
  685. ];
  686. // 推导逻辑
  687. const hasDerivationLogic = ref(false); // 添加推导逻辑状态跟踪
  688. const derivationData = ref<any>({});
  689. // 判断推导逻辑内容是否为空
  690. const isDerivationEmpty = computed(() => {
  691. const rule = derivationData.value.cpPatientMatchRule;
  692. if (!rule) return true;
  693. // 检查所有字段都为空或未填写
  694. const fields = ['sex', 'age', 'diagnoseDiseaseNames', 'diagnoseSyndromeNames', 'constitutionGroupNames', 'willillStateNames', 'tabooCrowds'];
  695. return fields.every((key) => {
  696. const val = rule[key];
  697. if (Array.isArray(val)) return val.length === 0;
  698. return !val;
  699. });
  700. });
  701. function handleDerivation() {
  702. VxeUI.modal.open({
  703. title: `推导逻辑`,
  704. height: 750,
  705. width: 750,
  706. escClosable: true,
  707. destroyOnClose: true,
  708. id: `derivation-modal`,
  709. remember: true,
  710. storage: true,
  711. slots: {
  712. default() {
  713. return h(Derivation, {
  714. data: {
  715. ...props.data,
  716. // 传递当前的推导逻辑数据
  717. cpPatientMatchRule: derivationData.value.cpPatientMatchRule || form.cpPatientMatchRule,
  718. checkedList: checkedList.value,
  719. },
  720. onSubmit: (data: any) => {
  721. derivationData.value = data;
  722. hasDerivationLogic.value = true; // 设置推导逻辑已编辑
  723. },
  724. });
  725. },
  726. },
  727. });
  728. }
  729. const jumpTypeOptions = [
  730. { label: '小程序', value: '1' },
  731. { label: 'H5', value: '2' },
  732. ];
  733. </script>
  734. <template>
  735. <div class="form-container">
  736. <a-form ref="formRef" :model="form" :rules="rules" layout="horizontal">
  737. <a-form-item label="项目名称:" name="name" required>
  738. <a-input v-model:value="form.name" placeholder="请输入" />
  739. </a-form-item>
  740. <a-form-item label="方案类型:" name="conditioningProgramType" required style="width: 100%">
  741. <vxe-select v-model="form.conditioningProgramType" :options="typeOptions" placeholder="请选择" clearable filterable transfer @change="bindchange" style="width: 100%" />
  742. </a-form-item>
  743. <a-form-item label="项目应用:" required v-if="form.addType === 'itemsList'">
  744. <a-checkbox-group v-model:value="checkedList">
  745. <a-checkbox v-for="option in plainOptions" :key="option.id" :value="option.id">
  746. {{ option.name }}
  747. </a-checkbox>
  748. </a-checkbox-group>
  749. </a-form-item>
  750. <a-form-item label="计价规则:" name="pricingType" :required="checkedList.includes('1')">
  751. <a-radio-group v-model:value="form.pricingType">
  752. <a-radio value="0">一口价</a-radio>
  753. <a-radio value="1">按穴位/经络/部位</a-radio>
  754. </a-radio-group>
  755. </a-form-item>
  756. <div class="price-row" v-if="form.pricingType === '0' && form.cpFixedPricingRule">
  757. <span class="label">单价:</span>
  758. <a-input v-model:value="form.cpFixedPricingRule.unitPrice" placeholder="请输入" style="width: 100px" />
  759. <span style="margin: 0 8px">元</span>
  760. <span class="label" style="margin-left: 32px">计价单位:</span>
  761. <a-input v-model:value="form.cpFixedPricingRule.pricingUnit" placeholder="请输入" style="width: 100px" />
  762. <span style="margin-left: 32px">相当于</span>
  763. <a-input v-model:value="form.cpFixedPricingRule.convertDose" placeholder="请输入" style="width: 100px; margin-left: 8px" />
  764. <vxe-select v-model="form.cpFixedPricingRule.convertUnit" :options="unitOptions" placeholder="请选择" clearable transfer style="width: 100px; margin-left: 8px" />
  765. <span style="color: #aaa; margin-left: 8px">(使用单位)</span>
  766. </div>
  767. <div v-if="form.pricingType === '1'" class="per-rule">
  768. <div class="price-row">
  769. <span>计价1:</span>
  770. <span class="flex items-center"
  771. >当"穴位/经络/部位" ≤
  772. <a-input
  773. placeholder="请输入"
  774. class="w-20 ml-2 mr-2"
  775. v-model:value="form.cpDynamicPricingRule[0].min"
  776. @change="() => (form.cpDynamicPricingRule[1].max = form.cpDynamicPricingRule[0].min)"
  777. />个时,</span
  778. >
  779. <vxe-select
  780. v-model="form.cpDynamicPricingRule[0].priceType"
  781. :options="[
  782. { label: '单价', value: 0, priceType: 0 },
  783. { label: '一口价', value: 1, priceType: 1 },
  784. ]"
  785. placeholder="请选择"
  786. clearable
  787. transfer
  788. style="width: 100px; margin: 0 4px"
  789. />
  790. <span>=</span>
  791. <a-input v-model:value="form.cpDynamicPricingRule[0].price" style="width: 80px; margin: 0 4px" placeholder="请输入" />
  792. <span>元</span>
  793. </div>
  794. <div class="price-row">
  795. <span>计价2:</span>
  796. <span class="flex items-center"
  797. >当"穴位/经络/部位" &gt; <a-input placeholder="请输入" class="w-20 ml-2 mr-2" v-model:value="form.cpDynamicPricingRule[1].max" disabled />个时,</span
  798. >
  799. <vxe-select
  800. v-model="form.cpDynamicPricingRule[1].priceType"
  801. :options="[
  802. { label: '单价', value: 0, priceType: 0 },
  803. { label: '一口价', value: 1, priceType: 1 },
  804. ]"
  805. placeholder="请选择"
  806. clearable
  807. transfer
  808. style="width: 100px; margin: 0 4px"
  809. />
  810. <span>=</span>
  811. <a-input v-model:value="form.cpDynamicPricingRule[1].price" style="width: 80px; margin: 0 4px" placeholder="请输入" />
  812. <span>元</span>
  813. </div>
  814. </div>
  815. <a-form-item label="组成:">
  816. <div class="herb-list">
  817. <template v-for="(herb, idx) in form.cpMedicines" :key="herb.id">
  818. <div class="herb-item">
  819. <button class="herb-remove" v-if="form?.cpMedicines?.length > 1" @click="removeHerb(idx)" type="button">×</button>
  820. <!-- <RemoteSelect :load="cpMedicinesMethod" key-prop="name" v-model:value="herb.name" /> -->
  821. <SearchableSelect
  822. v-model="herb.name"
  823. :options="herbList"
  824. placeholder="请选择"
  825. value-key="name"
  826. label-key="name"
  827. key-key="id"
  828. :fetch-options="cpMedicinesMethod"
  829. style="width: 150px"
  830. :allow-custom-input="true"
  831. />
  832. <a-input v-model:value="herb.dosage" class="herb-dosage" placeholder="剂量" />
  833. <span>g</span>
  834. </div>
  835. </template>
  836. <button style="margin-left: 8px" @click="addHerb" type="button">+</button>
  837. </div>
  838. </a-form-item>
  839. <a-form-item label="特色:" v-if="form.addType === 'itemsList'">
  840. <textarea
  841. v-model="form.attrFirst"
  842. placeholder="请输入"
  843. rows="3"
  844. style="width: 100%; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px; resize: vertical; font-family: inherit"
  845. />
  846. </a-form-item>
  847. <a-form-item label="功效:">
  848. <a-input v-model:value="form.effect" placeholder="请输入" />
  849. </a-form-item>
  850. <a-form-item label="制法:" v-if="form.addType === 'itemsList'">
  851. <a-input v-model:value="form.attrThird" placeholder="请输入" />
  852. </a-form-item>
  853. <a-form-item label="用法:" v-if="form.addType === 'itemsList'">
  854. <a-input v-model:value="form.attrFourth" placeholder="请输入" />
  855. </a-form-item>
  856. <a-form-item label="操作方法:" v-if="form.addType === 'itemsList'">
  857. <textarea
  858. v-model="form.attrFifth"
  859. placeholder="请输入"
  860. rows="3"
  861. style="width: 100%; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px; resize: vertical; font-family: inherit"
  862. />
  863. </a-form-item>
  864. <div class="image-row">
  865. <a-form-item label="操作图片:" class="image-form-item" v-if="form.addType === 'itemsList'">
  866. <a-upload :showUploadList="uploadProps" v-model:file-list="optionsList" list-type="picture-card" @preview="handlePreview" :maxCount="1" :customRequest="customUpload">
  867. <div v-if="optionsList.length < 1">
  868. <PlusOutlined />
  869. <div style="margin-top: 8px">上传</div>
  870. </div>
  871. </a-upload>
  872. </a-form-item>
  873. <a-form-item label="商品图片:" class="image-form-item">
  874. <a-upload :showUploadList="uploadProps" v-model:file-list="fileList" list-type="picture-card" @preview="handlePreview" :maxCount="1" :customRequest="customUpload">
  875. <div v-if="fileList.length < 1">
  876. <PlusOutlined />
  877. <div style="margin-top: 8px">上传</div>
  878. </div>
  879. </a-upload>
  880. </a-form-item>
  881. </div>
  882. <a-form-item label="操作视频:" class="image-form-item" v-if="form.addType === 'itemsList'">
  883. <div class="video-upload-wrapper">
  884. <div class="video-upload-container">
  885. <a-upload
  886. :showUploadList="false"
  887. :custom-request="customVideoRequest"
  888. :max-count="1"
  889. :multiple="false"
  890. :before-upload="beforeVideoUpload"
  891. @change="handleVideoChange"
  892. :file-list="videoFileList"
  893. accept="video/mp4,video/avi,video/mov,video/webm"
  894. >
  895. <div v-if="!form.itemVideoFirst && !uploading" class="video-upload-btn">
  896. <PlusOutlined />
  897. <div style="margin-top: 8px">上传视频</div>
  898. <div class="video-upload-tip">mp4/avi/mov/webm<br />最大100MB</div>
  899. </div>
  900. <!-- 上传中状态 -->
  901. <div v-else-if="uploading" class="video-uploading">
  902. <div class="upload-progress">
  903. <a-progress :percent="progress" :show-info="false" size="small" stroke-color="#1890ff" />
  904. <div class="upload-text">上传中... {{ Math.round(progress) }}%</div>
  905. </div>
  906. </div>
  907. <!-- 视频预览 -->
  908. <div v-else class="video-preview-container">
  909. <div class="video-thumbnail">
  910. <video :src="form.itemVideoFirst" preload="metadata" class="video-preview" />
  911. <div class="video-overlay">
  912. <a-button
  913. type="primary"
  914. size="small"
  915. @click.stop="
  916. handleVideoPreview({
  917. uid: 'video-preview',
  918. name: '操作视频',
  919. url: form.itemVideoFirst,
  920. })
  921. "
  922. >
  923. 预览
  924. </a-button>
  925. <a-button danger size="small" @click.stop="removeVideo"> 删除 </a-button>
  926. </div>
  927. </div>
  928. <!-- <div class="video-info">
  929. <div class="video-name">操作视频</div>
  930. <div class="video-size">已上传</div>
  931. </div> -->
  932. </div>
  933. </a-upload>
  934. </div>
  935. </div>
  936. </a-form-item>
  937. <a-form-item label="疗程说明:" v-if="form.addType === 'itemsList'">
  938. <textarea
  939. v-model="form.attrSixth"
  940. placeholder="请输入"
  941. rows="3"
  942. style="width: 100%; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px; resize: vertical; font-family: inherit"
  943. />
  944. </a-form-item>
  945. <a-form-item label="使用注意:" v-if="form.addType === 'itemsList'">
  946. <textarea
  947. v-model="form.attrSeventh"
  948. placeholder="请输入"
  949. rows="3"
  950. style="width: 100%; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px; resize: vertical; font-family: inherit"
  951. />
  952. </a-form-item>
  953. <a-form-item label="推导逻辑:" v-if="form.addType === 'itemsList'" :required="checkedList.includes('2')">
  954. <button @click="handleDerivation" v-if="!hasDerivationLogic || isDerivationEmpty">编辑</button>
  955. <div v-else @click="handleDerivation" style="cursor: pointer">
  956. <div v-if="derivationData.cpPatientMatchRule" class="derivation-container">
  957. <div v-if="derivationData.cpPatientMatchRule.sex" class="derivation-item">
  958. <span class="derivation-label">性别限制:</span>
  959. <span class="derivation-content">{{ derivationData.cpPatientMatchRule.sex }}</span>
  960. </div>
  961. <div v-if="derivationData.cpPatientMatchRule.age" class="derivation-item">
  962. <span class="derivation-label">年龄限制:</span>
  963. <span class="derivation-content">{{ derivationData.cpPatientMatchRule.age }}</span>
  964. </div>
  965. <div v-if="derivationData.cpPatientMatchRule.diagnoseDiseaseNames && derivationData.cpPatientMatchRule.diagnoseDiseaseNames.length > 0" class="derivation-item">
  966. <span class="derivation-label">专病:</span>
  967. <span class="derivation-content">{{ derivationData.cpPatientMatchRule.diagnoseDiseaseNames.join('、') }}</span>
  968. </div>
  969. <div v-if="derivationData.cpPatientMatchRule.diagnoseSyndromeNames && derivationData.cpPatientMatchRule.diagnoseSyndromeNames.length > 0" class="derivation-item">
  970. <span class="derivation-label">证型:</span>
  971. <span class="derivation-content">{{ derivationData.cpPatientMatchRule.diagnoseSyndromeNames.join('、') }}</span>
  972. </div>
  973. <div v-if="derivationData.cpPatientMatchRule.constitutionGroupNames && derivationData.cpPatientMatchRule.constitutionGroupNames.length > 0" class="derivation-item">
  974. <span class="derivation-label">体质:</span>
  975. <span class="derivation-content">{{ derivationData.cpPatientMatchRule.constitutionGroupNames.join('、') }}</span>
  976. </div>
  977. <div v-if="derivationData.cpPatientMatchRule.willillStateNames && derivationData.cpPatientMatchRule.willillStateNames.length > 0" class="derivation-item">
  978. <span class="derivation-label">欲病状态:</span>
  979. <span class="derivation-content">{{ derivationData.cpPatientMatchRule.willillStateNames.join('、') }}</span>
  980. </div>
  981. <div v-if="derivationData.cpPatientMatchRule.tabooCrowds && derivationData.cpPatientMatchRule.tabooCrowds.length > 0" class="derivation-item">
  982. <span class="derivation-label">禁忌人群:</span>
  983. <span class="derivation-content">{{ derivationData.cpPatientMatchRule.tabooCrowds.join('、') }}</span>
  984. </div>
  985. </div>
  986. </div>
  987. </a-form-item>
  988. <!-- 购买链接 -->
  989. <a-form-item label="购买链接:" v-if="form.addType === 'itemsList'">
  990. <a-input v-model:value="form.buyUrl" placeholder="请输入" />
  991. </a-form-item>
  992. <!-- 跳转类型 -->
  993. <a-form-item label="跳转类型:" v-if="form.addType === 'itemsList'" style="width: 100%">
  994. <Vxe-select v-model="form.jumpType" :options="jumpTypeOptions" placeholder="请选择" clearable transfer style="width: 100%" />
  995. </a-form-item>
  996. <!-- 机构名称 -->
  997. <a-form-item label="机构名称:" v-if="form?.addType === 'itemsList'" required name="institutionId">
  998. <a-tree-select
  999. :disabled="form.addType === 'itemsList' && !!form.sourceId"
  1000. v-model:value="form.institutionId"
  1001. style="width: 100%"
  1002. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto', zIndex: 4000 }"
  1003. :dropdownMatchSelectWidth="false"
  1004. :getPopupContainer="getSafePopupContainer"
  1005. placeholder="请选择"
  1006. allow-clear
  1007. tree-default-expand-all
  1008. :tree-data="branch"
  1009. :loading="branchLoading"
  1010. @change="onInstitutionChange"
  1011. ></a-tree-select>
  1012. </a-form-item>
  1013. <a-form-item label="供应商:" name="conditioningProgramSupplierId" :rules="supplierRules" style="width: 100%">
  1014. <vxe-select
  1015. v-model="form.conditioningProgramSupplierId"
  1016. :options="supplierOptions"
  1017. placeholder="请选择"
  1018. clearable
  1019. filterable
  1020. transfer
  1021. @change="getConditioningProgramSupplier"
  1022. style="width: 100%"
  1023. />
  1024. </a-form-item>
  1025. <a-form-item label="线下项目:" name="isOffline" v-if="isShowOnline" :required="checkedList.includes('1')">
  1026. <a-checkbox-group v-model:value="onlineArr" @change="onlineChange">
  1027. <a-checkbox value="Y">是</a-checkbox>
  1028. <a-checkbox value="N">否</a-checkbox>
  1029. </a-checkbox-group>
  1030. </a-form-item>
  1031. <a-form-item label="配送:" name="isDelivery" v-if="isShowDelivery" :required="checkedList.includes('1')">
  1032. <a-checkbox-group v-model:value="deliverArr" @change="deliveryChange">
  1033. <a-checkbox value="Y">支持</a-checkbox>
  1034. <a-checkbox value="N">不支持</a-checkbox>
  1035. </a-checkbox-group>
  1036. </a-form-item>
  1037. <a-form-item label="启用状态:" name="status" v-if="form.addType === 'itemsList'" required>
  1038. <a-radio-group v-model:value="form.status">
  1039. <a-radio value="0">启用</a-radio>
  1040. <a-radio value="1">停用</a-radio>
  1041. </a-radio-group>
  1042. </a-form-item>
  1043. <a-image
  1044. :width="200"
  1045. :style="{ display: 'none' }"
  1046. :preview="{
  1047. visible,
  1048. onVisibleChange: setVisible,
  1049. }"
  1050. :src="previewImg"
  1051. />
  1052. <video :src="videoUrl" controls v-if="videoUrl" style="width: 100%; max-width: 500px; border-radius: 6px" preload="metadata" />
  1053. <div class="form-actions-center">
  1054. <a-button @click="cancel">取消</a-button>
  1055. <a-button type="primary" style="background: #faad14; border: none" @click="doSubmit">确定</a-button>
  1056. </div>
  1057. </a-form>
  1058. </div>
  1059. </template>
  1060. <style scoped>
  1061. .form-container {
  1062. width: 760px;
  1063. margin: 0 auto;
  1064. padding: 10px 0px 0 0;
  1065. }
  1066. .per-rule {
  1067. margin-bottom: 16px;
  1068. }
  1069. .price-row {
  1070. display: flex;
  1071. align-items: center;
  1072. margin-bottom: 10px;
  1073. }
  1074. .label {
  1075. font-weight: 500;
  1076. color: #222;
  1077. margin-right: 8px;
  1078. }
  1079. .herb-list {
  1080. display: flex;
  1081. align-items: center;
  1082. flex-wrap: wrap;
  1083. }
  1084. .herb-item {
  1085. position: relative;
  1086. display: flex;
  1087. align-items: center;
  1088. margin-right: 8px;
  1089. margin-bottom: 8px;
  1090. padding-left: 16px;
  1091. }
  1092. .herb-dosage {
  1093. width: 70px;
  1094. font-size: 14px;
  1095. margin-right: 10px;
  1096. }
  1097. .herb-remove {
  1098. position: absolute;
  1099. left: 0;
  1100. top: 0;
  1101. background: #fff;
  1102. border: none;
  1103. color: #ff4d4f;
  1104. font-size: 14px;
  1105. cursor: pointer;
  1106. line-height: 1;
  1107. width: 16px;
  1108. height: 16px;
  1109. padding: 0;
  1110. display: flex;
  1111. align-items: center;
  1112. justify-content: center;
  1113. }
  1114. .form-actions-center {
  1115. display: flex;
  1116. justify-content: center;
  1117. gap: 16px;
  1118. }
  1119. .slider-section {
  1120. margin-bottom: 16px;
  1121. }
  1122. .slider-labels {
  1123. display: flex;
  1124. justify-content: space-between;
  1125. width: 200px;
  1126. margin-left: 230px;
  1127. margin-bottom: 4px;
  1128. font-weight: 500;
  1129. color: #222;
  1130. }
  1131. .slider-row {
  1132. display: flex;
  1133. align-items: center;
  1134. }
  1135. .slider-desc {
  1136. color: #222;
  1137. white-space: nowrap;
  1138. display: flex;
  1139. flex-direction: column;
  1140. align-items: center;
  1141. justify-content: center;
  1142. }
  1143. .slider-value {
  1144. margin-left: 16px;
  1145. color: #faad14;
  1146. font-weight: bold;
  1147. }
  1148. .upload-btn {
  1149. display: flex;
  1150. flex-direction: column;
  1151. align-items: center;
  1152. justify-content: center;
  1153. min-height: 100px;
  1154. border: 1px dashed #d9d9d9;
  1155. border-radius: 6px;
  1156. background: #fafafa;
  1157. cursor: pointer;
  1158. transition: border-color 0.3s;
  1159. width: 100px;
  1160. }
  1161. .upload-btn:hover {
  1162. border-color: #1890ff;
  1163. background: #f0f7ff;
  1164. }
  1165. .upload-btn .anticon {
  1166. font-size: 16px;
  1167. color: #1890ff;
  1168. }
  1169. .upload-btn .upload-text {
  1170. margin-top: 8px;
  1171. color: #666;
  1172. font-size: 15px;
  1173. }
  1174. .video-preview {
  1175. border-radius: 6px;
  1176. background: #000;
  1177. width: 120px !important;
  1178. height: 100px !important;
  1179. }
  1180. .video-preview video {
  1181. border-radius: 6px;
  1182. background: #000;
  1183. width: 120px;
  1184. height: 100px;
  1185. }
  1186. .video-preview .ant-btn-link {
  1187. padding: 0;
  1188. font-size: 14px;
  1189. color: #ff4d4f;
  1190. }
  1191. .image-row {
  1192. display: flex;
  1193. gap: 32px;
  1194. align-items: flex-start;
  1195. margin-bottom: 16px;
  1196. }
  1197. .image-form-item {
  1198. flex: 1;
  1199. margin-bottom: 0 !important;
  1200. }
  1201. .image-form-item .ant-upload-picture-card-wrapper {
  1202. display: flex;
  1203. flex-direction: column;
  1204. align-items: flex-start;
  1205. }
  1206. .derivation-item {
  1207. display: flex;
  1208. align-items: center;
  1209. min-width: 200px;
  1210. max-width: 300px;
  1211. padding: 6px 12px;
  1212. background: #f5f5f5;
  1213. border-radius: 4px;
  1214. border: 1px solid #e8e8e8;
  1215. }
  1216. .derivation-label {
  1217. font-weight: 500;
  1218. color: #222;
  1219. margin-right: 8px;
  1220. white-space: nowrap;
  1221. font-size: 13px;
  1222. }
  1223. .derivation-content {
  1224. color: #555;
  1225. font-size: 13px;
  1226. flex: 1;
  1227. word-break: break-all;
  1228. }
  1229. .derivation-container {
  1230. display: flex;
  1231. flex-wrap: wrap;
  1232. gap: 16px;
  1233. align-items: flex-start;
  1234. }
  1235. .video-upload-wrapper {
  1236. display: flex;
  1237. align-items: flex-start;
  1238. }
  1239. .video-upload-container {
  1240. position: relative;
  1241. width: 130px;
  1242. height: 130px;
  1243. display: flex;
  1244. align-items: center;
  1245. justify-content: center;
  1246. border: 2px dashed #d9d9d9;
  1247. border-radius: 8px;
  1248. background: #fafafa;
  1249. cursor: pointer;
  1250. transition: all 0.3s ease;
  1251. overflow: hidden;
  1252. margin-bottom: 20px;
  1253. }
  1254. .video-upload-container:hover {
  1255. border-color: #1890ff;
  1256. background: #f0f7ff;
  1257. transform: translateY(-1px);
  1258. box-shadow: 0 2px 8px rgba(24, 144, 255, 0.1);
  1259. }
  1260. .video-upload-btn {
  1261. display: flex;
  1262. flex-direction: column;
  1263. align-items: center;
  1264. justify-content: center;
  1265. padding: 16px 12px;
  1266. text-align: center;
  1267. }
  1268. .video-upload-btn .anticon {
  1269. font-size: 20px;
  1270. color: #1890ff;
  1271. margin-bottom: 6px;
  1272. }
  1273. .video-upload-tip {
  1274. font-size: 11px;
  1275. color: #999;
  1276. margin-top: 6px;
  1277. line-height: 1.3;
  1278. }
  1279. .video-uploading {
  1280. position: absolute;
  1281. top: 0;
  1282. left: 0;
  1283. width: 100%;
  1284. height: 100%;
  1285. background: rgba(255, 255, 255, 0.95);
  1286. display: flex;
  1287. flex-direction: column;
  1288. align-items: center;
  1289. justify-content: center;
  1290. z-index: 10;
  1291. backdrop-filter: blur(2px);
  1292. }
  1293. .upload-progress {
  1294. display: flex;
  1295. flex-direction: column;
  1296. align-items: center;
  1297. gap: 8px;
  1298. width: 90%;
  1299. max-width: 160px;
  1300. }
  1301. .upload-text {
  1302. font-size: 12px;
  1303. color: #1890ff;
  1304. font-weight: 500;
  1305. text-align: center;
  1306. }
  1307. .video-preview-container {
  1308. display: flex;
  1309. flex-direction: column;
  1310. align-items: center;
  1311. justify-content: center;
  1312. width: 100%;
  1313. height: 100%;
  1314. padding: 10px;
  1315. background: #fafafa;
  1316. border-radius: 8px;
  1317. }
  1318. .video-thumbnail {
  1319. position: relative;
  1320. width: 100%;
  1321. height: 100px;
  1322. border-radius: 6px;
  1323. overflow: hidden;
  1324. background: #000;
  1325. display: flex;
  1326. align-items: center;
  1327. justify-content: center;
  1328. margin-bottom: 8px;
  1329. }
  1330. .video-thumbnail .video-preview {
  1331. width: 100%;
  1332. height: 100%;
  1333. object-fit: cover;
  1334. }
  1335. .video-overlay {
  1336. position: absolute;
  1337. top: 0;
  1338. left: 0;
  1339. width: 100%;
  1340. height: 100%;
  1341. background: rgba(0, 0, 0, 0.7);
  1342. border-radius: 6px;
  1343. display: flex;
  1344. align-items: center;
  1345. justify-content: center;
  1346. gap: 8px;
  1347. opacity: 0;
  1348. transition: opacity 0.3s ease;
  1349. }
  1350. .video-preview-container:hover .video-overlay {
  1351. opacity: 1;
  1352. }
  1353. .video-overlay .ant-btn {
  1354. background: rgba(255, 255, 255, 0.95);
  1355. border: none;
  1356. color: #333;
  1357. font-size: 11px;
  1358. padding: 3px 8px;
  1359. border-radius: 4px;
  1360. transition: all 0.3s ease;
  1361. min-width: 40px;
  1362. height: 28px;
  1363. line-height: 1.2;
  1364. display: flex;
  1365. align-items: center;
  1366. justify-content: center;
  1367. white-space: nowrap;
  1368. }
  1369. .video-overlay .ant-btn:hover {
  1370. background: rgba(255, 255, 255, 1);
  1371. transform: scale(1.05);
  1372. }
  1373. .video-overlay .ant-btn-danger {
  1374. background: rgba(255, 77, 79, 0.95);
  1375. color: #fff;
  1376. }
  1377. .video-overlay .ant-btn-danger:hover {
  1378. background: rgba(255, 77, 79, 1);
  1379. }
  1380. .video-info {
  1381. text-align: center;
  1382. font-size: 11px;
  1383. color: #666;
  1384. }
  1385. .video-name {
  1386. font-weight: 500;
  1387. color: #333;
  1388. margin-bottom: 2px;
  1389. }
  1390. .video-size {
  1391. color: #999;
  1392. font-size: 10px;
  1393. }
  1394. </style>