AcupointTable.vue 59 KB

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