AcupointTable.vue 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083
  1. <template>
  2. <div class="recipe-acupoint-wrapper">
  3. <div class="top-btns">
  4. <el-button size="mini" type="primary" @click="openAddDialog()"
  5. >新增</el-button
  6. >
  7. <el-button size="mini" type="warning" @click="clearAll()">清空</el-button>
  8. </div>
  9. <!-- 处方 tab 切换 -->
  10. <div class="prescription-tabs" v-if="prescriptions.length">
  11. <div
  12. class="tab-item"
  13. :class="{ active: activeIndex === index }"
  14. v-for="(item, index) in prescriptions"
  15. :key="index"
  16. @click="switchTab(index)"
  17. >
  18. <span class="tab-name">{{ item.itemName }}</span>
  19. <span class="tab-close" @click.stop="removePrescription(index)">×</span>
  20. </div>
  21. </div>
  22. <!--新增适宜技术处方弹窗 -->
  23. <el-dialog
  24. :visible.sync="showAddDialog"
  25. width="800px"
  26. top="10vh"
  27. :show-close="false"
  28. :close-on-click-modal="false"
  29. append-to-body
  30. custom-class="add-prescription-dialog"
  31. >
  32. <div slot="title" class="add-dialog-header">
  33. <span>新增适宜技术处方</span>
  34. <div class="close-btn" @click="showAddDialog = false">+</div>
  35. </div>
  36. <div class="add-dialog-body">
  37. <div class="add-form-row">
  38. <span class="label">分类:</span>
  39. <el-select
  40. size="mini"
  41. v-model="addForm.category"
  42. placeholder="请选择"
  43. clearable
  44. style="flex: 1"
  45. @change="onCategoryChange"
  46. >
  47. <el-option
  48. v-for="item in classifyOptions"
  49. :key="item.value"
  50. :label="item.label"
  51. :value="item.value"
  52. ></el-option>
  53. </el-select>
  54. <span class="label"
  55. ><span style="color: red">*</span> 项目名称:</span
  56. >
  57. <el-select
  58. ref="itemSelect"
  59. size="mini"
  60. v-model="addForm.itemId"
  61. filterable
  62. :filter-method="searchItem"
  63. :loading="itemLoading"
  64. loading-text="搜索中..."
  65. no-data-text="暂无数据"
  66. placeholder="请搜索选择"
  67. style="flex: 1"
  68. @change="onItemSelected"
  69. @visible-change="onItemSelectVisibleChange"
  70. >
  71. <el-option
  72. v-for="item in itemOptions"
  73. :key="item.id"
  74. :label="item.name"
  75. :value="item.id"
  76. ></el-option>
  77. </el-select>
  78. </div>
  79. </div>
  80. <div class="add-dialog-btns">
  81. <div class="confirm-btn" @click="confirmAdd()">确定</div>
  82. </div>
  83. </el-dialog>
  84. <div class="recipe-acupoint">
  85. <div
  86. class="table-toolbar flex-vertical-center-l flex-wrap"
  87. v-if="prescriptions.length"
  88. >
  89. <div class="toolbar-item flex-vertical-center-l" v-if="showEditable">
  90. <span><span style="color: red">*</span> 是否可修改:</span>
  91. <el-select
  92. size="mini"
  93. v-model="innerIsEditable"
  94. placeholder="请选择"
  95. style="width: 80px"
  96. @change="onEditableChange"
  97. >
  98. <el-option label="是" value="1"></el-option>
  99. <el-option label="否" value="0"></el-option>
  100. </el-select>
  101. </div>
  102. <div class="toolbar-item flex-vertical-center-l">
  103. <span
  104. ><span v-if="detailRequired" style="color: red">*</span>
  105. 详情:</span
  106. >
  107. <el-checkbox-group
  108. v-model="innerDetailTypes"
  109. size="mini"
  110. @change="onDetailTypesChange"
  111. >
  112. <el-checkbox label="穴位">穴位</el-checkbox>
  113. <el-checkbox label="经络">经络</el-checkbox>
  114. <el-checkbox label="耳穴">耳穴</el-checkbox>
  115. <el-checkbox label="部位">部位</el-checkbox>
  116. <el-checkbox label="其他详情">其他详情</el-checkbox>
  117. <el-checkbox label="无详情">无详情</el-checkbox>
  118. </el-checkbox-group>
  119. </div>
  120. </div>
  121. <div class="table-container" v-if="prescriptions.length">
  122. <!-- 表格 -->
  123. <div
  124. v-for="detailType in activeDetailTypes"
  125. :key="detailType"
  126. class="detail-table-section"
  127. >
  128. <div class="detail-section-label" v-if="prescriptions.length">
  129. {{ detailType }}
  130. </div>
  131. <div class="table-show flex-vertical-between">
  132. <!-- 左侧表格 -->
  133. <div class="table-left">
  134. <el-table
  135. :data="getLeftList(detailType)"
  136. border
  137. size="mini"
  138. style="width: 100%"
  139. >
  140. <el-table-column
  141. prop="id"
  142. label="序号"
  143. width="50"
  144. align="center"
  145. ></el-table-column>
  146. <el-table-column :label="detailType" min-width="100">
  147. <template slot-scope="scope">
  148. <el-select
  149. v-if="detailType !== '其他详情' && detailType !== '部位'"
  150. size="mini"
  151. :value="scope.row.name"
  152. remote
  153. filterable
  154. :filter-method="getFilterMethod(detailType)"
  155. placeholder="请选择"
  156. @change="onItemChange($event, scope, detailType)"
  157. @focus="searchByType('', detailType)"
  158. >
  159. <el-option
  160. v-for="(item, idx) in getSearchOptions(detailType)"
  161. :key="idx"
  162. :label="item.acuname"
  163. :value="item.acuid"
  164. ></el-option>
  165. </el-select>
  166. <el-input
  167. v-else
  168. size="mini"
  169. v-model="scope.row.name"
  170. placeholder="请输入"
  171. @change="onDetailInput(scope, detailType)"
  172. ></el-input>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="数量" width="80" align="center">
  176. <template slot-scope="scope">
  177. <el-input-number
  178. size="mini"
  179. v-model="scope.row.count"
  180. :min="1"
  181. :controls="false"
  182. style="width: 100%"
  183. ></el-input-number>
  184. </template>
  185. </el-table-column>
  186. <el-table-column label="备注" min-width="80">
  187. <template slot-scope="scope">
  188. <el-input
  189. size="mini"
  190. v-model="scope.row.remark"
  191. placeholder="请输入"
  192. ></el-input>
  193. </template>
  194. </el-table-column>
  195. <el-table-column
  196. label="主配穴"
  197. width="100"
  198. align="center"
  199. v-if="detailType === '穴位'"
  200. >
  201. <template slot-scope="scope">
  202. <el-select
  203. size="mini"
  204. v-model="scope.row.mainType"
  205. style="width: 100%"
  206. >
  207. <el-option label="主穴" value="1"></el-option>
  208. <el-option label="配穴" value="2"></el-option>
  209. </el-select>
  210. </template>
  211. </el-table-column>
  212. <el-table-column label="操作" width="100" fixed="right">
  213. <template slot-scope="scope" v-if="scope.row.name">
  214. <div class="operate">
  215. <img
  216. src="~@/assets/add.png"
  217. alt
  218. @click="addDetailRow(scope, detailType)"
  219. />
  220. <img
  221. src="~@/assets/delete1.png"
  222. alt
  223. @click="deleteDetailRow(scope, detailType)"
  224. />
  225. <img
  226. v-if="
  227. detailType !== '其他详情' && detailType !== '部位'
  228. "
  229. src="~@/assets/find.png"
  230. alt
  231. @click="find(scope, detailType)"
  232. />
  233. </div>
  234. </template>
  235. </el-table-column>
  236. </el-table>
  237. </div>
  238. <!-- 右侧表格 -->
  239. <div class="table-left">
  240. <el-table
  241. :data="getRightList(detailType)"
  242. border
  243. size="mini"
  244. style="width: 100%"
  245. >
  246. <el-table-column
  247. prop="id"
  248. label="序号"
  249. width="50"
  250. align="center"
  251. ></el-table-column>
  252. <el-table-column :label="detailType" min-width="100">
  253. <template slot-scope="scope">
  254. <el-select
  255. v-if="detailType !== '其他详情' && detailType !== '部位'"
  256. size="mini"
  257. :value="scope.row.name"
  258. remote
  259. filterable
  260. :filter-method="getFilterMethod(detailType)"
  261. placeholder="请选择"
  262. @change="onItemChange($event, scope, detailType)"
  263. @focus="searchByType('', detailType)"
  264. >
  265. <el-option
  266. v-for="(item, idx) in getSearchOptions(detailType)"
  267. :key="idx"
  268. :label="item.acuname"
  269. :value="item.acuid"
  270. ></el-option>
  271. </el-select>
  272. <el-input
  273. v-else
  274. size="mini"
  275. v-model="scope.row.name"
  276. placeholder="请输入"
  277. @change="onDetailInput(scope, detailType)"
  278. ></el-input>
  279. </template>
  280. </el-table-column>
  281. <el-table-column label="数量" width="80" align="center">
  282. <template slot-scope="scope">
  283. <el-input-number
  284. size="mini"
  285. v-model="scope.row.count"
  286. :min="1"
  287. :controls="false"
  288. style="width: 100%"
  289. ></el-input-number>
  290. </template>
  291. </el-table-column>
  292. <el-table-column label="备注" min-width="80">
  293. <template slot-scope="scope">
  294. <el-input
  295. size="mini"
  296. v-model="scope.row.remark"
  297. placeholder="请输入"
  298. ></el-input>
  299. </template>
  300. </el-table-column>
  301. <el-table-column
  302. label="主配穴"
  303. width="100"
  304. align="center"
  305. v-if="detailType === '穴位'"
  306. >
  307. <template slot-scope="scope">
  308. <el-select
  309. size="mini"
  310. v-model="scope.row.mainType"
  311. style="width: 100%"
  312. >
  313. <el-option label="主穴" value="1"></el-option>
  314. <el-option label="配穴" value="2"></el-option>
  315. </el-select>
  316. </template>
  317. </el-table-column>
  318. <el-table-column label="操作" width="100" fixed="right">
  319. <template slot-scope="scope" v-if="scope.row.name">
  320. <div class="operate">
  321. <img
  322. src="~@/assets/add.png"
  323. alt
  324. @click="addDetailRow(scope, detailType)"
  325. />
  326. <img
  327. src="~@/assets/delete1.png"
  328. alt
  329. @click="deleteDetailRow(scope, detailType)"
  330. />
  331. <img
  332. v-if="
  333. detailType !== '其他详情' && detailType !== '部位'
  334. "
  335. src="~@/assets/find.png"
  336. alt
  337. @click="find(scope, detailType)"
  338. />
  339. </div>
  340. </template>
  341. </el-table-column>
  342. </el-table>
  343. </div>
  344. </div>
  345. </div>
  346. </div>
  347. <div class="no-data-tip" v-else>
  348. <span>暂无项目,请先点击"新增"添加项目</span>
  349. </div>
  350. <!-- 底部统计 -->
  351. <div class="table-bottom" v-if="prescriptions.length">
  352. <div class="table-b-header">
  353. <div class="header-about">
  354. <div
  355. class="item flex-vertical-center-l"
  356. style="align-items: flex-start;"
  357. >
  358. <span> 配穴指南:</span>
  359. <div style="flex: 1;">
  360. <el-input
  361. size="mini"
  362. placeholder="请输入"
  363. v-model="pointMatchGuide"
  364. type="textarea"
  365. auto-size="{ minRows: 1, maxRows: 4 }"
  366. @input="emitStatistics"
  367. ></el-input>
  368. </div>
  369. </div>
  370. <div
  371. class="item flex-vertical-center-l"
  372. style="align-items: flex-start;"
  373. >
  374. <span><span style="color: red">*</span> 操作指南:</span>
  375. <div style="flex: 1;">
  376. <el-input
  377. size="mini"
  378. placeholder="请输入"
  379. v-model="operationGuide"
  380. type="textarea"
  381. auto-size="{ minRows: 1, maxRows: 4 }"
  382. @input="emitStatistics"
  383. ></el-input>
  384. </div>
  385. </div>
  386. </div>
  387. <div class="header-about">
  388. <div class="stat-row flex-vertical-center-l flex-wrap">
  389. <div class="stat-field flex-vertical-center-l">
  390. <span><span style="color: red">*</span> 单次:</span>
  391. <el-input-number
  392. size="mini"
  393. v-model="singleCount"
  394. :min="1"
  395. :controls="false"
  396. style="width: 60px"
  397. @change="onSingleCountChange"
  398. placeholder="请输入"
  399. ></el-input-number>
  400. <span class="stat-unit">{{ currentPricingUnit }}</span>
  401. </div>
  402. <div class="stat-field flex-vertical-center-l">
  403. <span>治疗次数:</span>
  404. <el-input-number
  405. size="mini"
  406. v-model="treatCount"
  407. :min="0"
  408. :controls="false"
  409. style="width: 60px"
  410. @change="updatePrice"
  411. ></el-input-number>
  412. </div>
  413. <div class="stat-field flex-vertical-center-l">
  414. <span>频次:</span>
  415. <el-input-number
  416. size="mini"
  417. v-model="frequency"
  418. :min="0"
  419. :controls="false"
  420. style="width: 60px"
  421. @change="emitStatistics"
  422. placeholder="请输入"
  423. ></el-input-number>
  424. <span class="stat-unit">天</span>
  425. <el-input-number
  426. size="mini"
  427. v-model="frequencyUnit"
  428. :min="0"
  429. :controls="false"
  430. style="width: 60px"
  431. @change="emitStatistics"
  432. placeholder="请输入"
  433. ></el-input-number>
  434. <span class="stat-unit">次</span>
  435. </div>
  436. </div>
  437. </div>
  438. </div>
  439. </div>
  440. <!-- 底部金额 -->
  441. <div class="table-b-bottom flex-vertical-between">
  442. <div class="t-b-b-left flex-vertical-center-l flex-wrap">
  443. <div class="t-b-l-item">
  444. 单次金额:<span>{{ singlePrice || "0.00" }}元</span>
  445. </div>
  446. <div class="t-b-l-item">
  447. 疗程金额:<span>{{ coursePrice || "0.00" }}元</span>
  448. </div>
  449. <div class="t-b-l-item">
  450. 协定方总金额:<span>{{ totalPrice || "0.00" }}元</span>
  451. </div>
  452. </div>
  453. <div class="t-b-b-right flex-vertical-center-r">
  454. <el-button
  455. type="primary"
  456. size="mini"
  457. :loading="saveLoading"
  458. @click="handleSave"
  459. >保存</el-button
  460. >
  461. </div>
  462. </div>
  463. </div>
  464. <!-- 查看详情弹窗 -->
  465. <el-dialog
  466. :visible.sync="showDetailDialog"
  467. width="50%"
  468. top="5vh"
  469. :title="detailType + '详情'"
  470. append-to-body
  471. custom-class="detail-dialog"
  472. >
  473. <div class="drug-body">
  474. <!-- 穴位详情 -->
  475. <template v-if="detailType === '穴位'">
  476. <div class="drug-item">
  477. <span>穴位名称:</span>
  478. <div>{{ detailData.acuname }}</div>
  479. </div>
  480. <div class="drug-item">
  481. <span>定位:</span>
  482. <div>{{ detailData.acuposotion }}</div>
  483. </div>
  484. <div class="drug-item">
  485. <span>解剖:</span>
  486. <div>{{ detailData.acudiscection }}</div>
  487. </div>
  488. <div class="drug-item">
  489. <span>主治:</span>
  490. <div>{{ detailData.acumaintreat }}</div>
  491. </div>
  492. <div class="drug-item">
  493. <span>操作:</span>
  494. <div>{{ detailData.acuoperation }}</div>
  495. </div>
  496. <div class="drug-item">
  497. <span>针刺:</span>
  498. <div>{{ detailData.acuneedling }}</div>
  499. </div>
  500. <div class="drug-item" v-if="detailData.acuimg">
  501. <span>图示:</span>
  502. <div class="detail-img"><img :src="detailData.acuimg" /></div>
  503. </div>
  504. </template>
  505. <!-- 经络详情 -->
  506. <template v-else-if="detailType === '经络'">
  507. <div class="drug-item">
  508. <span>经络名称:</span>
  509. <div>{{ detailData.mername }}</div>
  510. </div>
  511. <div class="drug-item">
  512. <span>类型:</span>
  513. <div>{{ merTypeMap[detailData.mertype] || "-" }}</div>
  514. </div>
  515. <div class="drug-item" v-if="detailData.mermaindisease">
  516. <span>主要病候:</span>
  517. <div v-html="detailData.mermaindisease"></div>
  518. </div>
  519. <div class="drug-item" v-if="detailData.mermaintreat">
  520. <span>主治概要:</span>
  521. <div v-html="detailData.mermaintreat"></div>
  522. </div>
  523. <div class="drug-item" v-if="detailData.merimg">
  524. <span>图片:</span>
  525. <div class="detail-img"><img :src="detailData.merimg" /></div>
  526. </div>
  527. </template>
  528. <!-- 耳穴详情 -->
  529. <template v-else-if="detailType === '耳穴'">
  530. <div class="drug-item">
  531. <span>名称:</span>
  532. <div>{{ detailData.name }}</div>
  533. </div>
  534. <div class="drug-item" v-if="detailData.area">
  535. <span>定位:</span>
  536. <div>{{ detailData.area }}</div>
  537. </div>
  538. <div class="drug-item" v-if="detailData.effect">
  539. <span>功能:</span>
  540. <div>{{ detailData.effect }}</div>
  541. </div>
  542. <div class="drug-item" v-if="detailData.mainTreat">
  543. <span>主治:</span>
  544. <div>{{ detailData.mainTreat }}</div>
  545. </div>
  546. <div class="drug-item" v-if="detailData.photo">
  547. <span>图片:</span>
  548. <div class="detail-img"><img :src="detailData.photo" /></div>
  549. </div>
  550. </template>
  551. </div>
  552. </el-dialog>
  553. </div>
  554. </template>
  555. <script>
  556. import {
  557. getXueweiList,
  558. collateralChannels,
  559. getAcupointD,
  560. getMerD,
  561. getAcuMeridianList,
  562. getAcuMeridianDetail,
  563. } from "@/api/knowledge.js";
  564. import {
  565. getMappedNondrugItemList,
  566. getNondrugItemDetail,
  567. } from "@/api/technology.js";
  568. import popup from "@/components/Propup.vue";
  569. // 详情默认值 value → label 映射
  570. const DETAIL_DEFAULT_MAP = {
  571. "1": "穴位",
  572. "2": "部位",
  573. "3": "耳穴",
  574. "4": "经络",
  575. "5": "其他详情",
  576. "6": "无详情",
  577. };
  578. function createEmptyRow(id) {
  579. return {
  580. id,
  581. acuid: "",
  582. acuname: "",
  583. name: "",
  584. count: 1,
  585. remark: "",
  586. mainType: "1",
  587. };
  588. }
  589. function createPrescriptionData(options = {}) {
  590. const {
  591. detailRequired = false,
  592. detailTypes = [],
  593. singleCount = 0,
  594. unitPrice = 0,
  595. } = options;
  596. const singlePrice = (singleCount * unitPrice).toFixed(2);
  597. const allTypes = ["穴位", "经络", "耳穴", "部位", "其他详情", "无详情"];
  598. const detailTables = {};
  599. allTypes.forEach((type) => {
  600. if (type === "无详情") {
  601. detailTables[type] = detailTypes.includes(type)
  602. ? [{ description: "" }]
  603. : [];
  604. } else {
  605. detailTables[type] = detailTypes.includes(type)
  606. ? [createEmptyRow(1)]
  607. : [];
  608. }
  609. });
  610. return {
  611. detailTables,
  612. innerIsEditable: "1",
  613. innerDetailTypes: detailTypes.length > 0 ? detailTypes : [],
  614. detailRequired: !!detailRequired,
  615. operationGuide: "",
  616. pointMatchGuide: "",
  617. singleCount,
  618. treatCount: 1,
  619. frequency: undefined,
  620. frequencyUnit: undefined,
  621. singlePrice,
  622. coursePrice: "0.00",
  623. totalPrice: "0.00",
  624. currentUnitPrice: unitPrice,
  625. _manualSingleCount: false,
  626. };
  627. }
  628. export default {
  629. name: "AcupointTable",
  630. components: { popup },
  631. props: {
  632. value: {
  633. type: Array,
  634. default: () => [],
  635. },
  636. isEditable: {
  637. type: String,
  638. default: "1",
  639. },
  640. showEditable: {
  641. type: Boolean,
  642. default: true,
  643. },
  644. detailTypes: {
  645. type: Array,
  646. default: () => ["穴位"],
  647. },
  648. statistics: {
  649. type: Object,
  650. default: () => ({}),
  651. },
  652. showGuide: {
  653. type: Boolean,
  654. default: false,
  655. },
  656. unitPrice: {
  657. type: Number,
  658. default: 0,
  659. },
  660. },
  661. data() {
  662. return {
  663. // 配穴相关
  664. acupointList: [],
  665. meridianList: [],
  666. earAcupointList: [],
  667. detailTables: {
  668. 穴位: [createEmptyRow(1)],
  669. 经络: [],
  670. 耳穴: [],
  671. 部位: [],
  672. 其他详情: [],
  673. 无详情: [],
  674. },
  675. innerIsEditable: this.isEditable,
  676. innerDetailTypes: ["穴位"],
  677. detailRequired: false,
  678. // 统计相关
  679. currentUnitPrice: 0,
  680. operationGuide: "",
  681. pointMatchGuide: "",
  682. singleCount: 0,
  683. treatCount: 1,
  684. frequency: undefined,
  685. frequencyUnit: undefined,
  686. singlePrice: "0.00",
  687. coursePrice: "0.00",
  688. totalPrice: "0.00",
  689. _manualSingleCount: false,
  690. // 处方 tab
  691. activeIndex: 0,
  692. prescriptionDataMap: {},
  693. // 新增处方弹窗
  694. showAddDialog: false,
  695. classifyOptions: [],
  696. itemOptions: [],
  697. itemLoading: false,
  698. addForm: {
  699. category: "",
  700. itemId: "",
  701. itemName: "",
  702. detailRequired: false,
  703. },
  704. prescriptions: [],
  705. // 详情弹窗
  706. showDetailDialog: false,
  707. detailData: {},
  708. detailType: "",
  709. saveLoading: false,
  710. _isLoadingTab: false,
  711. merTypeMap: {
  712. 1: "十二经脉",
  713. 2: "奇经八脉",
  714. 3: "经外奇穴",
  715. 4: "阿是穴",
  716. },
  717. };
  718. },
  719. computed: {
  720. isLocked() {
  721. return this.innerIsEditable === "0";
  722. },
  723. activeDetailTypes() {
  724. const validTypes = ["穴位", "经络", "耳穴", "部位", "其他详情"];
  725. return validTypes.filter((t) => this.innerDetailTypes.includes(t));
  726. },
  727. currentPricingUnit() {
  728. const p = this.prescriptions[this.activeIndex];
  729. return p?.pricingUnit || "";
  730. },
  731. currentSingleNumber() {
  732. const p = this.prescriptions[this.activeIndex];
  733. return p?.singleNumber || "0";
  734. },
  735. // 当前处方的计数系数
  736. currentCountCoefficient() {
  737. const p = this.prescriptions[this.activeIndex];
  738. return Number(p?.countCoefficient) || 1;
  739. },
  740. currentDetailCumulativeTypes() {
  741. const p = this.prescriptions[this.activeIndex];
  742. const val = p?.detailCumulative || "";
  743. if (!val) return [];
  744. const CUMULATIVE_MAP = {
  745. "1": "穴位",
  746. "2": "部位",
  747. "3": "耳穴",
  748. "4": "经络",
  749. "5": "其他详情",
  750. };
  751. return String(val)
  752. .split(/[,、]/)
  753. .filter(Boolean)
  754. .map((v) => CUMULATIVE_MAP[v.trim()])
  755. .filter(Boolean);
  756. },
  757. },
  758. watch: {
  759. detailTables: {
  760. handler() {
  761. this.updatePrice();
  762. },
  763. deep: true,
  764. },
  765. },
  766. created() {
  767. this._prevDetailTypes = [...this.innerDetailTypes];
  768. this.getAcupointList();
  769. this.getMeridianList();
  770. this.getEarAcupointList();
  771. this.loadClassifyOptions();
  772. },
  773. methods: {
  774. async loadClassifyOptions() {
  775. try {
  776. const res = await fetch(`${window.BASE_URL}data/classify.json`);
  777. const data = await res.json();
  778. this.classifyOptions = data.classify || [];
  779. } catch (e) {
  780. console.error("加载分类数据失败", e);
  781. }
  782. },
  783. saveCurrentTabData() {
  784. if (!this.prescriptions.length) return;
  785. this.$set(this.prescriptionDataMap, this.activeIndex, {
  786. detailTables: JSON.parse(JSON.stringify(this.detailTables)),
  787. innerIsEditable: this.innerIsEditable,
  788. innerDetailTypes: [...this.innerDetailTypes],
  789. detailRequired: this.detailRequired,
  790. operationGuide: this.operationGuide,
  791. pointMatchGuide: this.pointMatchGuide,
  792. singleCount: this.singleCount,
  793. treatCount: this.treatCount,
  794. frequency: this.frequency,
  795. frequencyUnit: this.frequencyUnit,
  796. singlePrice: this.singlePrice,
  797. coursePrice: this.coursePrice,
  798. totalPrice: this.totalPrice,
  799. currentUnitPrice: this.currentUnitPrice,
  800. _manualSingleCount: this._manualSingleCount,
  801. });
  802. },
  803. loadTabData(index) {
  804. this._isLoadingTab = true;
  805. const data = this.prescriptionDataMap[index];
  806. if (data) {
  807. this.detailTables = JSON.parse(JSON.stringify(data.detailTables));
  808. this.innerIsEditable = data.innerIsEditable;
  809. this.innerDetailTypes = [...data.innerDetailTypes];
  810. this._prevDetailTypes = [...data.innerDetailTypes];
  811. this.detailRequired = data.detailRequired;
  812. this.operationGuide = data.operationGuide;
  813. this.pointMatchGuide = data.pointMatchGuide || "";
  814. this.singleCount = data.singleCount;
  815. this.treatCount = data.treatCount;
  816. this.frequency = data.frequency;
  817. this.frequencyUnit = data.frequencyUnit;
  818. this.singlePrice = data.singlePrice;
  819. this.coursePrice = data.coursePrice;
  820. this.totalPrice = data.totalPrice;
  821. this.currentUnitPrice = data.currentUnitPrice || 0;
  822. this._manualSingleCount = data._manualSingleCount || false;
  823. } else {
  824. const def = createPrescriptionData();
  825. this.detailTables = def.detailTables;
  826. this.innerIsEditable = def.innerIsEditable;
  827. this.innerDetailTypes = def.innerDetailTypes;
  828. this._prevDetailTypes = [...def.innerDetailTypes];
  829. this.detailRequired = def.detailRequired;
  830. this.operationGuide = def.operationGuide;
  831. this.pointMatchGuide = def.pointMatchGuide;
  832. this.singleCount = def.singleCount;
  833. this.treatCount = def.treatCount;
  834. this.frequency = def.frequency;
  835. this.frequencyUnit = def.frequencyUnit;
  836. this.singlePrice = def.singlePrice;
  837. this.coursePrice = def.coursePrice;
  838. this.totalPrice = def.totalPrice;
  839. this.currentUnitPrice = def.currentUnitPrice || 0;
  840. this._manualSingleCount = def._manualSingleCount || false;
  841. }
  842. this.$nextTick(() => {
  843. this._isLoadingTab = false;
  844. // 加载完毕后,如果是自动计算模式,触发一次初始计算
  845. if (this.currentSingleNumber !== "0") {
  846. this.updatePrice();
  847. }
  848. });
  849. },
  850. switchTab(index) {
  851. if (this.activeIndex === index) return;
  852. this.saveCurrentTabData();
  853. this.activeIndex = index;
  854. this.loadTabData(index);
  855. },
  856. async openAddDialog() {
  857. this.addForm = {
  858. category: "",
  859. itemId: "",
  860. itemName: "",
  861. detailRequired: false,
  862. };
  863. this.itemOptions = [];
  864. this.showAddDialog = true;
  865. await this.fetchItemOptions();
  866. },
  867. async fetchItemOptions(query) {
  868. this.itemLoading = true;
  869. try {
  870. const params = {
  871. pageNum: 1,
  872. pageSize: 999,
  873. };
  874. if (this.addForm.category) {
  875. params.classify = this.addForm.category;
  876. }
  877. if (query) {
  878. if (/^[A-Za-z]+$/.test(query)) {
  879. params.py = query;
  880. } else {
  881. params.itemName = query;
  882. }
  883. }
  884. const res = await getMappedNondrugItemList(params);
  885. if (res.ResultCode == 0) {
  886. const list = res?.Data?.Items || [];
  887. this.itemOptions = list.map((item) => ({
  888. id: item.pid,
  889. name: item.itemName,
  890. detailRequired: item.detailIsnull === "1",
  891. detailDefault: item.detailDefault || "",
  892. detailCumulative: item.detailCumulative || "",
  893. classify: item.classify || "",
  894. price: item.price || 0,
  895. pricingUnit: item.pricingUnit || "",
  896. singleNumber: item.singleNumber || "",
  897. countCoefficient: item.countCoefficient || 1,
  898. minTreatmentDuration: item.minTreatmentDuration || 0,
  899. }));
  900. }
  901. } catch (e) {
  902. console.error("获取项目列表失败", e);
  903. } finally {
  904. this.itemLoading = false;
  905. }
  906. },
  907. onCategoryChange() {
  908. this.addForm.itemId = "";
  909. this.addForm.itemName = "";
  910. this.fetchItemOptions();
  911. },
  912. onItemSelectVisibleChange(visible) {
  913. if (visible) {
  914. this.fetchItemOptions();
  915. }
  916. },
  917. async searchItem(query) {
  918. await this.fetchItemOptions(query);
  919. },
  920. onItemSelected(id) {
  921. const item = this.itemOptions.find((i) => i.id === id);
  922. if (item) {
  923. this.addForm.itemName = item.name;
  924. }
  925. },
  926. async confirmAdd() {
  927. if (!this.addForm.itemId) {
  928. this.$message.warning("请选择项目名称");
  929. return;
  930. }
  931. // 检查项目是否已存在,不允许重复添加
  932. const isDuplicate = this.prescriptions.some(
  933. (p) => p.itemId === this.addForm.itemId,
  934. );
  935. if (isDuplicate) {
  936. this.$message.warning("该项目已添加,不能重复添加");
  937. return;
  938. }
  939. // 调用详情接口获取项目完整信息
  940. let detailData = {};
  941. try {
  942. const res = await getNondrugItemDetail(this.addForm.itemId);
  943. if (res.ResultCode == 0) {
  944. detailData = res.Data || {};
  945. }
  946. } catch (e) {
  947. console.error("获取项目详情失败", e);
  948. }
  949. const categoryLabel =
  950. this.classifyOptions.find((c) => c.value === this.addForm.category)
  951. ?.label || "";
  952. const detailDefault = detailData.detailDefault || "";
  953. const detailTypeValues = detailDefault
  954. ? String(detailDefault).split(",")
  955. : [];
  956. const detailTypes = detailTypeValues
  957. .map((v) => DETAIL_DEFAULT_MAP[v.trim()])
  958. .filter(Boolean);
  959. // 详情是否必填
  960. const detailRequired = detailData.detailIsnull === "1";
  961. // 单次数量
  962. const singleNumber = detailData.singleNumber || "0";
  963. const singleCount = singleNumber === "0" ? 1 : 0;
  964. // 价格
  965. const price = detailData.price || 0;
  966. // 保存旧 tab 数据
  967. if (this.prescriptions.length > 0) {
  968. this.saveCurrentTabData();
  969. }
  970. // 从 itemOptions 中获取选中项的 classify
  971. const selectedItem = this.itemOptions.find(
  972. (i) => i.id === this.addForm.itemId,
  973. );
  974. const newIndex = this.prescriptions.length;
  975. this.prescriptions.push({
  976. category: this.addForm.category,
  977. categoryLabel,
  978. itemId: this.addForm.itemId,
  979. itemName: this.addForm.itemName,
  980. price,
  981. pricingUnit: detailData.pricingUnit || "",
  982. singleNumber,
  983. countCoefficient: detailData.countCoefficient || 1,
  984. minTreatmentDuration: detailData.minTreatmentDuration || 0,
  985. detailCumulative: detailData.detailCumulative || "",
  986. classify: selectedItem?.classify || "",
  987. ygtid: detailData.appId || "",
  988. departmentId: detailData.deptId || "",
  989. stitutionsId: detailData.institutionCode || "",
  990. stitutionsName: detailData.institutionName || "",
  991. });
  992. this.prescriptionDataMap[newIndex] = createPrescriptionData({
  993. detailRequired,
  994. detailTypes,
  995. singleCount,
  996. unitPrice: price,
  997. });
  998. this.activeIndex = newIndex;
  999. this.loadTabData(newIndex);
  1000. this.showAddDialog = false;
  1001. this.$emit("prescriptions-change", this.prescriptions);
  1002. },
  1003. removePrescription(index) {
  1004. this.$confirm("确认删除该处方?", "提示", {
  1005. confirmButtonText: "确定",
  1006. cancelButtonText: "取消",
  1007. type: "warning",
  1008. })
  1009. .then(() => {
  1010. this.prescriptions.splice(index, 1);
  1011. const oldMap = this.prescriptionDataMap;
  1012. this.prescriptionDataMap = {};
  1013. this.prescriptions.forEach((_, i) => {
  1014. if (i < index) {
  1015. this.prescriptionDataMap[i] = oldMap[i];
  1016. } else {
  1017. this.prescriptionDataMap[i] = oldMap[i + 1];
  1018. }
  1019. });
  1020. if (this.prescriptions.length === 0) {
  1021. this.activeIndex = 0;
  1022. this.detailTables = {
  1023. 穴位: [createEmptyRow(1)],
  1024. 经络: [],
  1025. 耳穴: [],
  1026. 部位: [],
  1027. 其他详情: [],
  1028. };
  1029. } else {
  1030. this.activeIndex = Math.min(index, this.prescriptions.length - 1);
  1031. this.loadTabData(this.activeIndex);
  1032. }
  1033. this.$emit("prescriptions-change", this.prescriptions);
  1034. })
  1035. .catch(() => {});
  1036. },
  1037. clearAll() {
  1038. if (!this.prescriptions.length) {
  1039. this.detailTables = {
  1040. 穴位: [createEmptyRow(1)],
  1041. 经络: [],
  1042. 耳穴: [],
  1043. 部位: [],
  1044. 其他详情: [],
  1045. };
  1046. this.operationGuide = "";
  1047. this.singleCount = 0;
  1048. this.treatCount = 1;
  1049. this.frequency = undefined;
  1050. this.frequencyUnit = undefined;
  1051. this.singlePrice = "0.00";
  1052. this.coursePrice = "0.00";
  1053. this.totalPrice = "0.00";
  1054. this.currentUnitPrice = 0;
  1055. this.innerIsEditable = "1";
  1056. this.innerDetailTypes = ["穴位"];
  1057. this._prevDetailTypes = ["穴位"];
  1058. this.detailRequired = false;
  1059. this.emitStatistics();
  1060. return;
  1061. }
  1062. const p = this.prescriptions[this.activeIndex];
  1063. const unitPrice = p?.price || 0;
  1064. this.prescriptionDataMap[this.activeIndex] = createPrescriptionData({
  1065. detailRequired: false,
  1066. detailTypes: [],
  1067. singleCount: 0,
  1068. unitPrice,
  1069. });
  1070. this.loadTabData(this.activeIndex);
  1071. this.updatePrice();
  1072. this.$emit("prescriptions-change", this.prescriptions);
  1073. },
  1074. onEditableChange(val) {
  1075. this.$emit("update:isEditable", val);
  1076. },
  1077. onDetailTypesChange(val) {
  1078. const NO_DETAIL = "无详情";
  1079. const lastSelected =
  1080. val.length > this._prevDetailTypes?.length
  1081. ? val.find((v) => !this._prevDetailTypes.includes(v))
  1082. : null;
  1083. if (lastSelected === NO_DETAIL) {
  1084. val = [NO_DETAIL];
  1085. } else if (
  1086. lastSelected &&
  1087. lastSelected !== NO_DETAIL &&
  1088. val.includes(NO_DETAIL)
  1089. ) {
  1090. val = val.filter((v) => v !== NO_DETAIL);
  1091. }
  1092. this.innerDetailTypes = val;
  1093. this._prevDetailTypes = [...val];
  1094. val.forEach((type) => {
  1095. const table = this.detailTables[type];
  1096. const isEmpty = !table || table.length === 0;
  1097. if (type === "无详情") {
  1098. if (isEmpty) {
  1099. this.$set(this.detailTables, type, [{ description: "" }]);
  1100. }
  1101. } else {
  1102. if (isEmpty) {
  1103. this.$set(this.detailTables, type, [createEmptyRow(1)]);
  1104. }
  1105. }
  1106. });
  1107. this.$emit("update:detailTypes", val);
  1108. },
  1109. getDetailTable(type) {
  1110. if (!this.detailTables[type]) {
  1111. this.$set(this.detailTables, type, [createEmptyRow(1)]);
  1112. }
  1113. return this.detailTables[type];
  1114. },
  1115. getLeftList(type) {
  1116. return this.getDetailTable(type).filter((item) => item.id % 2 !== 0);
  1117. },
  1118. getRightList(type) {
  1119. return this.getDetailTable(type).filter((item) => item.id % 2 === 0);
  1120. },
  1121. async getAcupointList(keyword = "", serchtype = "") {
  1122. try {
  1123. const res = await getXueweiList({
  1124. pageid: 1,
  1125. pagesize: 999,
  1126. serchtype: serchtype,
  1127. keyword: keyword,
  1128. });
  1129. if (res.code === 0) {
  1130. this.acupointList = res.data.acupoints || [];
  1131. }
  1132. } catch (e) {
  1133. console.error("获取穴位列表失败", e);
  1134. }
  1135. },
  1136. async getMeridianList(keyword = "", serchtype = "") {
  1137. try {
  1138. const res = await collateralChannels({
  1139. mertype: "1",
  1140. pageid: 1,
  1141. pagesize: 999,
  1142. keyword: keyword,
  1143. serchtype: serchtype,
  1144. });
  1145. if (res.code == 0) {
  1146. this.meridianList = (res.data.meridians || []).map((item) => ({
  1147. acuid: item.merid,
  1148. acuname: item.mername,
  1149. }));
  1150. }
  1151. } catch (e) {
  1152. console.error("获取经络列表失败", e);
  1153. }
  1154. },
  1155. async getEarAcupointList(keyword = "", serchtype = "") {
  1156. try {
  1157. const params = { page: 1, limit: 999, serchtype };
  1158. if (keyword) params.keyWord = keyword;
  1159. const res = await getAcuMeridianList(params);
  1160. if (res.code == 0) {
  1161. const list = res.data?.records || [];
  1162. this.earAcupointList = (Array.isArray(list) ? list : []).map(
  1163. (item) => ({
  1164. acuid: item.id,
  1165. acuname: item.name,
  1166. }),
  1167. );
  1168. }
  1169. } catch (e) {
  1170. console.error("获取耳穴列表失败", e);
  1171. }
  1172. },
  1173. getSearchOptions(type) {
  1174. switch (type) {
  1175. case "经络":
  1176. return this.meridianList;
  1177. case "耳穴":
  1178. return this.earAcupointList;
  1179. default:
  1180. return this.acupointList;
  1181. }
  1182. },
  1183. getFilterMethod(type) {
  1184. return (query) => {
  1185. this.searchByType(query, type);
  1186. };
  1187. },
  1188. searchByType(query, type) {
  1189. const pinyin = /^[A-Za-z]+$/g;
  1190. const serchtype = pinyin.test(query) ? "1" : "";
  1191. switch (type) {
  1192. case "经络":
  1193. this.getMeridianList(query, serchtype);
  1194. break;
  1195. case "耳穴":
  1196. this.getEarAcupointList(query, serchtype);
  1197. break;
  1198. default:
  1199. this.getAcupointList(query, serchtype);
  1200. }
  1201. },
  1202. onItemChange(acuid, scope, detailType) {
  1203. const row = scope.row;
  1204. const table = this.getDetailTable(detailType);
  1205. const exists = table.find(
  1206. (item) => item.acuid === acuid && item.id !== row.id,
  1207. );
  1208. if (exists) {
  1209. this.$message.error("不可重复选择");
  1210. row.acuid = "";
  1211. row.name = "";
  1212. row.acuname = "";
  1213. return;
  1214. }
  1215. const optionsList = this.getSearchOptions(detailType);
  1216. const selected = optionsList.find((item) => item.acuid === acuid);
  1217. if (selected) {
  1218. row.acuid = selected.acuid;
  1219. row.acuname = selected.acuname;
  1220. row.name = selected.acuname;
  1221. if (
  1222. detailType === "穴位" &&
  1223. selected.num != null &&
  1224. selected.num !== ""
  1225. ) {
  1226. row.count = Number(selected.num) || 1;
  1227. }
  1228. }
  1229. this.addDetailRow(scope, detailType);
  1230. },
  1231. onDetailInput(scope, detailType) {
  1232. // 其他详情输入文字后自动新增一行
  1233. if (scope.row.name) {
  1234. this.addDetailRow(scope, detailType);
  1235. }
  1236. },
  1237. addDetailRow(scope, detailType) {
  1238. const table = this.getDetailTable(detailType);
  1239. if (scope) {
  1240. const index = scope.row.id - 1;
  1241. if (index === table.length - 1) {
  1242. table.push(createEmptyRow(1));
  1243. } else {
  1244. const rest = table.splice(scope.row.id);
  1245. table.push(createEmptyRow(1));
  1246. this.$set(this.detailTables, detailType, table.concat(rest));
  1247. }
  1248. } else {
  1249. table.push(createEmptyRow(1));
  1250. }
  1251. this.reIndexDetail(detailType);
  1252. this.searchByType("", detailType);
  1253. },
  1254. isDeleteDisabled(row, detailType) {
  1255. return false;
  1256. },
  1257. deleteDetailRow(scope, detailType) {
  1258. if (this.isDeleteDisabled(scope.row, detailType)) return;
  1259. const table = this.getDetailTable(detailType);
  1260. const index = scope.row.id - 1;
  1261. if (index === 0 && table.length === 1) return;
  1262. table.splice(index, 1);
  1263. this.reIndexDetail(detailType);
  1264. },
  1265. async find(scope, detailType) {
  1266. const row = scope.row;
  1267. if (!row.acuid) return;
  1268. try {
  1269. let res;
  1270. if (detailType === "经络") {
  1271. res = await getMerD({ merid: row.acuid });
  1272. } else if (detailType === "耳穴") {
  1273. res = await getAcuMeridianDetail(row.acuid);
  1274. } else {
  1275. res = await getAcupointD({ acuid: row.acuid });
  1276. }
  1277. if (res.code === 0 || res.ResultCode === 0) {
  1278. this.detailData = res.data || res.Data || {};
  1279. this.detailType = detailType;
  1280. this.showDetailDialog = true;
  1281. }
  1282. } catch (e) {
  1283. console.error("获取详情失败", e);
  1284. }
  1285. },
  1286. copyDetailRow(scope, detailType) {
  1287. const table = this.getDetailTable(detailType);
  1288. const copy = { ...scope.row, id: 1 };
  1289. const index = scope.row.id;
  1290. table.splice(index, 0, copy);
  1291. this.reIndexDetail(detailType);
  1292. },
  1293. reIndexDetail(detailType) {
  1294. const table = this.getDetailTable(detailType);
  1295. table.forEach((item, index) => {
  1296. item.id = index + 1;
  1297. });
  1298. },
  1299. onSingleCountChange(val) {
  1300. if (val !== undefined && val !== null) {
  1301. this._manualSingleCount = true;
  1302. }
  1303. this.updatePrice();
  1304. },
  1305. updatePrice() {
  1306. if (this.currentSingleNumber !== "0" && !this._isLoadingTab && !this._manualSingleCount) {
  1307. this.singleCount = this.calcTotalCount();
  1308. }
  1309. const price = this.currentUnitPrice || this.unitPrice || 0;
  1310. this.singlePrice = (this.singleCount * price).toFixed(2);
  1311. this.coursePrice = (
  1312. this.treatCount * parseFloat(this.singlePrice)
  1313. ).toFixed(2);
  1314. this.saveCurrentTabData();
  1315. let total = 0;
  1316. Object.values(this.prescriptionDataMap).forEach((d) => {
  1317. total += parseFloat(d.coursePrice) || 0;
  1318. });
  1319. this.totalPrice = total.toFixed(2);
  1320. this.emitStatistics();
  1321. },
  1322. calcTotalCount() {
  1323. let total = 0;
  1324. const types = this.activeDetailTypes;
  1325. types.forEach((type) => {
  1326. const table = this.detailTables[type];
  1327. if (table) {
  1328. table.forEach((row) => {
  1329. if (row.acuid || row.name) {
  1330. total += row.count || 0;
  1331. }
  1332. });
  1333. }
  1334. });
  1335. const coefficient = this.currentCountCoefficient;
  1336. const result = coefficient > 0 ? total / coefficient : total;
  1337. return Math.ceil(result);
  1338. },
  1339. emitStatistics() {
  1340. this.$emit("update:statistics", {
  1341. operationGuide: this.operationGuide,
  1342. singleCount: this.singleCount,
  1343. treatCount: this.treatCount,
  1344. frequency: this.frequency,
  1345. frequencyUnit: this.frequencyUnit,
  1346. singlePrice: this.singlePrice,
  1347. coursePrice: this.coursePrice,
  1348. totalPrice: this.totalPrice,
  1349. });
  1350. },
  1351. validate() {
  1352. if (!this.prescriptions.length) {
  1353. this.$message.warning("请先新增处方");
  1354. return false;
  1355. }
  1356. if (this.detailRequired && this.innerDetailTypes.length === 0) {
  1357. this.$message.warning("请至少勾选一个详情类型");
  1358. return false;
  1359. }
  1360. if (!this.operationGuide.trim()) {
  1361. this.$message.warning("请输入操作指南");
  1362. return false;
  1363. }
  1364. if (!this.singleCount || this.singleCount <= 0) {
  1365. this.$message.warning("请输入单次数量");
  1366. return false;
  1367. }
  1368. return true;
  1369. },
  1370. handleSave() {
  1371. if (!this.validate()) return;
  1372. this.saveLoading = true;
  1373. const treatmentList = this.buildTreatmentList();
  1374. const firstP = this.prescriptions[0] || {};
  1375. const institutionInfo = {
  1376. ygtid: firstP.ygtid || "",
  1377. departmentId: firstP.departmentId || "",
  1378. stitutionsId: firstP.stitutionsId || "",
  1379. stitutionsName: firstP.stitutionsName || "",
  1380. };
  1381. this.$emit("save", treatmentList, institutionInfo);
  1382. },
  1383. saveDone() {
  1384. this.saveLoading = false;
  1385. },
  1386. buildTreatmentList() {
  1387. this.saveCurrentTabData();
  1388. const DETAIL_TYPE_MAP = {
  1389. 穴位: "1",
  1390. 经络: "2",
  1391. 耳穴: "3",
  1392. 部位: "4",
  1393. 其他详情: "5",
  1394. };
  1395. const TYPE_TO_FIELD = {
  1396. 穴位: "detailPoint",
  1397. 经络: "detailMeridian",
  1398. 耳穴: "detailEarPoint",
  1399. 部位: "detailBodyPart",
  1400. 其他详情: "detailOther",
  1401. };
  1402. return this.prescriptions.map((p, index) => {
  1403. const d = this.prescriptionDataMap[index] || createPrescriptionData();
  1404. const detailPoint = [];
  1405. const detailMeridian = [];
  1406. const detailEarPoint = [];
  1407. const detailBodyPart = [];
  1408. const detailOther = [];
  1409. const detailNone = [];
  1410. const detailArrays = {
  1411. 穴位: detailPoint,
  1412. 经络: detailMeridian,
  1413. 耳穴: detailEarPoint,
  1414. 部位: detailBodyPart,
  1415. 其他详情: detailOther,
  1416. };
  1417. Object.keys(detailArrays).forEach((type) => {
  1418. const table = d.detailTables[type] || [];
  1419. table.forEach((row) => {
  1420. if (row.acuid || row.name) {
  1421. detailArrays[type].push({
  1422. acupoint: type === "穴位" ? row.mainType || "0" : "0",
  1423. name: row.acuname || row.name || "",
  1424. num: row.count || 1,
  1425. pointCode: "",
  1426. pointId: row.acuid || "",
  1427. remark: row.remark || "",
  1428. seqn: String(row.id || ""),
  1429. type: DETAIL_TYPE_MAP[type] || "1",
  1430. });
  1431. }
  1432. });
  1433. });
  1434. return {
  1435. treatItemId: p.itemId,
  1436. treatItemName: p.itemName,
  1437. treatClass: p.classify || "",
  1438. isUpdate: d.innerIsEditable || "1",
  1439. singleQty: d.singleCount || 0,
  1440. singleAmount: parseFloat(d.singlePrice) || 0,
  1441. treatNum: d.treatCount || 0,
  1442. courseAmount: parseFloat(d.coursePrice) || 0,
  1443. frequency:
  1444. d.frequency && d.frequencyUnit
  1445. ? `${d.frequency}天${d.frequencyUnit}次`
  1446. : "",
  1447. useExplain: d.operationGuide || "",
  1448. pointMatchGuide: d.pointMatchGuide || "",
  1449. seqn: index + 1,
  1450. ownerType: "1",
  1451. detailPoint,
  1452. detailMeridian,
  1453. detailEarPoint,
  1454. detailBodyPart,
  1455. detailOther,
  1456. detailNone: d.innerDetailTypes.includes("无详情")
  1457. ? { description: "" }
  1458. : null,
  1459. };
  1460. });
  1461. },
  1462. loadFromServerData(treatmentList) {
  1463. if (!Array.isArray(treatmentList) || !treatmentList.length) return;
  1464. const TYPE_VALUE_MAP = {
  1465. "1": "穴位",
  1466. "2": "经络",
  1467. "3": "耳穴",
  1468. "4": "部位",
  1469. "5": "其他详情",
  1470. "6": "无详情",
  1471. };
  1472. this.prescriptions = [];
  1473. this.prescriptionDataMap = {};
  1474. treatmentList.forEach((item, index) => {
  1475. const unitPrice = Number(item.basisStitutionsnondrug.price) || 0;
  1476. const pricingUnit = item.basisStitutionsnondrug?.pricingUnit || "";
  1477. this.prescriptions.push({
  1478. category: "",
  1479. categoryLabel: "",
  1480. itemId: item.treatItemId || "",
  1481. itemName: item.treatItemName || "",
  1482. price: unitPrice,
  1483. pricingUnit: pricingUnit,
  1484. singleNumber: item.basisStitutionsnondrug?.singleNumber || "0",
  1485. countCoefficient: item.basisStitutionsnondrug?.countCoefficient || 1,
  1486. minTreatmentDuration:
  1487. item.basisStitutionsnondrug?.minTreatmentDuration || 0,
  1488. detailCumulative: item.basisStitutionsnondrug?.detailCumulative || "",
  1489. });
  1490. const allDetails = [].concat(
  1491. item.detailPoint || [],
  1492. item.detailMeridian || [],
  1493. item.detailEarPoint || [],
  1494. item.detailBodyPart || [],
  1495. item.detailOther || [],
  1496. );
  1497. // 按 type 分组到 detailTables
  1498. const detailTables = {
  1499. 穴位: [],
  1500. 经络: [],
  1501. 耳穴: [],
  1502. 部位: [],
  1503. 其他详情: [],
  1504. 无详情: [],
  1505. };
  1506. const activeTypes = new Set();
  1507. if (
  1508. item.detailNone !== null &&
  1509. item.detailNone !== undefined &&
  1510. typeof item.detailNone === "object" &&
  1511. !Array.isArray(item.detailNone)
  1512. ) {
  1513. activeTypes.add("无详情");
  1514. }
  1515. allDetails.forEach((d) => {
  1516. const typeName = TYPE_VALUE_MAP[d.type] || "";
  1517. if (typeName && detailTables[typeName]) {
  1518. activeTypes.add(typeName);
  1519. detailTables[typeName].push({
  1520. id: detailTables[typeName].length + 1,
  1521. acuid: d.pointId || "",
  1522. acuname: d.name || "",
  1523. name: d.name || "",
  1524. count: d.num || 1,
  1525. remark: d.remark || "",
  1526. mainType: d.acupoint || "1",
  1527. });
  1528. }
  1529. });
  1530. ["穴位", "经络", "耳穴", "部位", "其他详情"].forEach((type) => {
  1531. if (detailTables[type].length === 0) {
  1532. detailTables[type] = [createEmptyRow(1)];
  1533. }
  1534. });
  1535. if (!detailTables["无详情"]) {
  1536. detailTables["无详情"] = [];
  1537. }
  1538. let parsedFreqDays = undefined;
  1539. let parsedFreqTimes = undefined;
  1540. if (item.frequency) {
  1541. const match = String(item.frequency).match(/(\d+)天(\d+)次/);
  1542. if (match) {
  1543. parsedFreqDays = parseInt(match[1], 10);
  1544. parsedFreqTimes = parseInt(match[2], 10);
  1545. }
  1546. }
  1547. // 构造 tab 数据
  1548. const singleNumber = item.basisStitutionsnondrug?.singleNumber || "0";
  1549. this.prescriptionDataMap[index] = {
  1550. detailTables,
  1551. innerIsEditable: item.isUpdate || "1",
  1552. innerDetailTypes: activeTypes.size > 0 ? [...activeTypes] : ["穴位"],
  1553. detailRequired: item.basisStitutionsnondrug?.detailIsnull === "1",
  1554. operationGuide: item.useExplain || "",
  1555. pointMatchGuide: item.pointMatchGuide || "",
  1556. singleCount: item.singleQty || 0,
  1557. treatCount: item.treatNum || 1,
  1558. frequency: parsedFreqDays,
  1559. frequencyUnit: parsedFreqTimes,
  1560. singlePrice: String(item.singleAmount || "0.00"),
  1561. coursePrice: (
  1562. (item.treatNum || 1) * (item.singleAmount || 0)
  1563. ).toFixed(2),
  1564. totalPrice: "0.00",
  1565. currentUnitPrice: unitPrice,
  1566. _manualSingleCount: singleNumber !== "0",
  1567. };
  1568. });
  1569. this.activeIndex = 0;
  1570. this.loadTabData(0);
  1571. let total = 0;
  1572. Object.values(this.prescriptionDataMap).forEach((d) => {
  1573. total += parseFloat(d.coursePrice) || 0;
  1574. });
  1575. this.totalPrice = total.toFixed(2);
  1576. this.$emit("prescriptions-change", this.prescriptions);
  1577. },
  1578. getData() {
  1579. if (!this.validate()) return null;
  1580. this.saveCurrentTabData();
  1581. return {
  1582. prescriptions: this.prescriptions.map((p, i) => {
  1583. const d = this.prescriptionDataMap[i] || createPrescriptionData();
  1584. return {
  1585. ...p,
  1586. isEditable: d.innerIsEditable,
  1587. detailTypes: d.innerDetailTypes,
  1588. detailRequired: d.detailRequired,
  1589. detailTables: d.detailTables,
  1590. acupoints: (d.detailTables["穴位"] || []).filter(
  1591. (item) => item.acuid,
  1592. ),
  1593. statistics: {
  1594. operationGuide: d.operationGuide,
  1595. singleCount: d.singleCount,
  1596. treatCount: d.treatCount,
  1597. frequency: d.frequency,
  1598. frequencyUnit: d.frequencyUnit,
  1599. singlePrice: d.singlePrice,
  1600. coursePrice: d.coursePrice,
  1601. totalPrice: d.totalPrice,
  1602. },
  1603. };
  1604. }),
  1605. };
  1606. },
  1607. },
  1608. };
  1609. </script>
  1610. <style lang="scss" scoped>
  1611. .recipe-acupoint-wrapper {
  1612. .top-btns {
  1613. display: flex;
  1614. justify-content: flex-end;
  1615. margin-bottom: 6px;
  1616. flex-shrink: 0;
  1617. }
  1618. }
  1619. // 处方 tab 列表
  1620. .prescription-tabs {
  1621. display: flex;
  1622. margin-bottom: 10px;
  1623. flex-shrink: 0;
  1624. .tab-item {
  1625. position: relative;
  1626. display: flex;
  1627. align-items: center;
  1628. padding: 8px 20px;
  1629. font-size: 14px;
  1630. color: #666;
  1631. background: #f5f7fa;
  1632. border-radius: 4px;
  1633. cursor: pointer;
  1634. margin-right: 6px;
  1635. transition: all 0.25s;
  1636. &:hover {
  1637. color: #5386f6;
  1638. background: #e8eefb;
  1639. }
  1640. &.active {
  1641. background: #5386f6;
  1642. color: #fff;
  1643. &:hover {
  1644. background: #4078f0;
  1645. }
  1646. .tab-close {
  1647. color: rgba(255, 255, 255, 0.7);
  1648. &:hover {
  1649. color: #fff;
  1650. background: rgba(255, 255, 255, 0.2);
  1651. }
  1652. }
  1653. }
  1654. .tab-name {
  1655. max-width: 120px;
  1656. overflow: hidden;
  1657. text-overflow: ellipsis;
  1658. white-space: nowrap;
  1659. }
  1660. .tab-close {
  1661. margin-left: 8px;
  1662. width: 16px;
  1663. height: 16px;
  1664. line-height: 16px;
  1665. text-align: center;
  1666. border-radius: 50%;
  1667. font-size: 14px;
  1668. color: #999;
  1669. transition: all 0.2s;
  1670. &:hover {
  1671. background: rgba(0, 0, 0, 0.1);
  1672. color: #ff6245;
  1673. }
  1674. }
  1675. }
  1676. }
  1677. .recipe-acupoint {
  1678. border: 2px solid #dedede;
  1679. padding: 7px 0 0;
  1680. display: flex;
  1681. flex-direction: column;
  1682. // 工具栏
  1683. .table-toolbar {
  1684. margin-bottom: 10px;
  1685. padding: 0 5px;
  1686. flex-shrink: 0;
  1687. .toolbar-item {
  1688. margin-right: 30px;
  1689. margin-bottom: 5px;
  1690. span {
  1691. font-size: 14px;
  1692. color: #333;
  1693. white-space: nowrap;
  1694. }
  1695. }
  1696. }
  1697. // 滚动容器
  1698. .table-container {
  1699. padding: 0 5px;
  1700. flex: 1;
  1701. min-height: 0;
  1702. overflow: auto;
  1703. }
  1704. .no-data-tip {
  1705. flex: 1;
  1706. display: flex;
  1707. align-items: center;
  1708. justify-content: center;
  1709. color: #999;
  1710. font-size: 14px;
  1711. padding: 40px 0;
  1712. }
  1713. // 详情表格区域
  1714. .detail-table-section {
  1715. margin-bottom: 10px;
  1716. .detail-section-label {
  1717. display: inline-block;
  1718. padding: 2px 12px;
  1719. border: 1px solid #ff6245;
  1720. border-radius: 4px;
  1721. color: #ff6245;
  1722. font-size: 13px;
  1723. margin-bottom: 6px;
  1724. }
  1725. }
  1726. // 配穴表格
  1727. .table-show {
  1728. width: 100%;
  1729. overflow: auto;
  1730. display: flex;
  1731. align-items: flex-start;
  1732. justify-content: space-between;
  1733. .table-left {
  1734. flex: 0 0 49.9%;
  1735. overflow-y: auto;
  1736. border: 1px solid #dedede;
  1737. box-sizing: border-box;
  1738. }
  1739. }
  1740. // 底部统计
  1741. .table-bottom {
  1742. flex-shrink: 0;
  1743. padding: 0 5px;
  1744. margin-top: 5px;
  1745. .table-b-header {
  1746. .header-about {
  1747. .item {
  1748. margin-right: 20px;
  1749. margin-bottom: 10px;
  1750. span {
  1751. font-size: 14px;
  1752. color: #333;
  1753. white-space: nowrap;
  1754. }
  1755. }
  1756. }
  1757. }
  1758. }
  1759. .stat-row {
  1760. .stat-field {
  1761. margin-right: 50px;
  1762. margin-bottom: 5px;
  1763. span {
  1764. font-size: 14px;
  1765. color: #333;
  1766. white-space: nowrap;
  1767. }
  1768. .stat-unit {
  1769. margin: 0 4px;
  1770. }
  1771. }
  1772. }
  1773. .operate {
  1774. width: 100%;
  1775. height: 100%;
  1776. display: flex;
  1777. align-items: center;
  1778. justify-content: space-around;
  1779. img {
  1780. width: 16px;
  1781. }
  1782. }
  1783. }
  1784. .recipe-acupoint ::v-deep .el-table .cell {
  1785. text-align: center;
  1786. }
  1787. .recipe-acupoint ::v-deep .el-select {
  1788. width: 100%;
  1789. }
  1790. .recipe-acupoint ::v-deep .el-table td {
  1791. padding: 2px 0;
  1792. }
  1793. .recipe-acupoint ::v-deep .el-table th {
  1794. padding: 2px 0;
  1795. }
  1796. .recipe-acupoint .table-show .table-left::v-deep .el-table__empty-block {
  1797. min-height: 33px !important;
  1798. height: 33px !important;
  1799. }
  1800. // 底部金额
  1801. .table-b-bottom {
  1802. flex-shrink: 0;
  1803. padding: 10px;
  1804. border-top: 2px solid #dedede;
  1805. margin-top: 5px;
  1806. .t-b-l-item {
  1807. font-size: 14px;
  1808. color: #333;
  1809. margin-right: 20px;
  1810. span {
  1811. color: #ff6245;
  1812. }
  1813. }
  1814. }
  1815. // 详情弹窗样式(scoped 内)
  1816. .drug-body {
  1817. padding: 10px;
  1818. .drug-item {
  1819. display: flex;
  1820. align-items: flex-start;
  1821. margin-bottom: 12px;
  1822. > span {
  1823. min-width: 80px;
  1824. font-size: 14px;
  1825. color: #333;
  1826. text-align: right;
  1827. margin-right: 10px;
  1828. flex-shrink: 0;
  1829. }
  1830. > div {
  1831. flex: 1;
  1832. font-size: 14px;
  1833. color: #666;
  1834. word-break: break-all;
  1835. line-height: 1.6;
  1836. }
  1837. .detail-img {
  1838. img {
  1839. max-width: 100%;
  1840. max-height: 300px;
  1841. }
  1842. }
  1843. }
  1844. }
  1845. </style>
  1846. <style lang="scss">
  1847. .add-prescription-dialog {
  1848. margin: 0 auto;
  1849. .el-dialog__header {
  1850. padding: 0;
  1851. }
  1852. .el-dialog__body {
  1853. padding: 18px;
  1854. }
  1855. .add-dialog-header {
  1856. display: flex;
  1857. align-items: center;
  1858. justify-content: center;
  1859. height: 34px;
  1860. background: #5386f6;
  1861. position: relative;
  1862. span {
  1863. font-size: 16px;
  1864. font-family: PingFang SC;
  1865. font-weight: 400;
  1866. color: #fff;
  1867. }
  1868. .close-btn {
  1869. transform: rotate(45deg);
  1870. color: #fff;
  1871. position: absolute;
  1872. top: -13px;
  1873. right: 20px;
  1874. font-size: 44px;
  1875. cursor: pointer;
  1876. }
  1877. }
  1878. .add-dialog-body {
  1879. min-height: 350px;
  1880. .add-form-row {
  1881. display: flex;
  1882. align-items: center;
  1883. margin-bottom: 16px;
  1884. .label {
  1885. font-size: 14px;
  1886. color: #333;
  1887. white-space: nowrap;
  1888. min-width: 100px;
  1889. text-align: right;
  1890. }
  1891. }
  1892. }
  1893. .add-dialog-btns {
  1894. display: flex;
  1895. justify-content: center;
  1896. margin-top: 20px;
  1897. .confirm-btn {
  1898. width: 108px;
  1899. height: 40px;
  1900. line-height: 40px;
  1901. text-align: center;
  1902. background: #5386f6;
  1903. color: #fff;
  1904. border-radius: 3px;
  1905. font-size: 18px;
  1906. cursor: pointer;
  1907. }
  1908. }
  1909. }
  1910. .detail-dialog {
  1911. margin: 0 auto;
  1912. .el-dialog__header {
  1913. padding: 0;
  1914. background: #5386f6;
  1915. text-align: center;
  1916. height: 40px;
  1917. line-height: 40px;
  1918. }
  1919. .el-dialog__title {
  1920. font-size: 16px;
  1921. color: #fff;
  1922. }
  1923. .el-dialog__headerbtn {
  1924. top: 8px;
  1925. right: 10px;
  1926. font-size: 22px;
  1927. .el-dialog__close {
  1928. color: #fff;
  1929. font-size: 22px;
  1930. }
  1931. }
  1932. .el-dialog__body {
  1933. padding: 18px;
  1934. max-height: 75vh;
  1935. overflow-y: auto;
  1936. }
  1937. .drug-body {
  1938. padding: 10px;
  1939. .drug-item {
  1940. display: flex;
  1941. align-items: flex-start;
  1942. margin-bottom: 12px;
  1943. > span {
  1944. min-width: 80px;
  1945. font-size: 14px;
  1946. color: #333;
  1947. text-align: right;
  1948. margin-right: 10px;
  1949. flex-shrink: 0;
  1950. }
  1951. > div {
  1952. flex: 1;
  1953. font-size: 14px;
  1954. color: #666;
  1955. word-break: break-all;
  1956. line-height: 1.6;
  1957. }
  1958. .detail-img {
  1959. img {
  1960. max-width: 100%;
  1961. max-height: 300px;
  1962. }
  1963. }
  1964. }
  1965. }
  1966. }
  1967. </style>