AddItems.vue 47 KB

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