AcupointTable.vue 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036
  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="calcPrice"
  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="calcPrice"
  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. merTypeMap: {
  714. 1: "十二经脉",
  715. 2: "奇经八脉",
  716. 3: "经外奇穴",
  717. 4: "阿是穴",
  718. },
  719. };
  720. },
  721. computed: {
  722. isLocked() {
  723. return this.innerIsEditable === "0";
  724. },
  725. activeDetailTypes() {
  726. const validTypes = ["穴位", "经络", "耳穴", "部位", "其他详情"];
  727. return validTypes.filter((t) => this.innerDetailTypes.includes(t));
  728. },
  729. currentPricingUnit() {
  730. const p = this.prescriptions[this.activeIndex];
  731. return p?.pricingUnit || "";
  732. },
  733. },
  734. watch: {
  735. detailTables: {
  736. handler() {
  737. this.calcPrice();
  738. },
  739. deep: true,
  740. },
  741. },
  742. created() {
  743. this._prevDetailTypes = [...this.innerDetailTypes];
  744. this.getAcupointList();
  745. this.getMeridianList();
  746. this.getEarAcupointList();
  747. this.loadClassifyOptions();
  748. },
  749. methods: {
  750. // ========== 分类数据加载 ==========
  751. async loadClassifyOptions() {
  752. try {
  753. const res = await fetch(`${window.BASE_URL}data/classify.json`);
  754. const data = await res.json();
  755. this.classifyOptions = data.classify || [];
  756. } catch (e) {
  757. console.error("加载分类数据失败", e);
  758. }
  759. },
  760. // ========== Tab 切换 ==========
  761. saveCurrentTabData() {
  762. if (!this.prescriptions.length) return;
  763. this.$set(this.prescriptionDataMap, this.activeIndex, {
  764. detailTables: JSON.parse(JSON.stringify(this.detailTables)),
  765. innerIsEditable: this.innerIsEditable,
  766. innerDetailTypes: [...this.innerDetailTypes],
  767. detailRequired: this.detailRequired,
  768. operationGuide: this.operationGuide,
  769. singleCount: this.singleCount,
  770. treatCount: this.treatCount,
  771. frequency: this.frequency,
  772. frequencyUnit: this.frequencyUnit,
  773. singlePrice: this.singlePrice,
  774. coursePrice: this.coursePrice,
  775. totalPrice: this.totalPrice,
  776. currentUnitPrice: this.currentUnitPrice,
  777. });
  778. },
  779. loadTabData(index) {
  780. const data = this.prescriptionDataMap[index];
  781. if (data) {
  782. this.detailTables = JSON.parse(JSON.stringify(data.detailTables));
  783. this.innerIsEditable = data.innerIsEditable;
  784. this.innerDetailTypes = [...data.innerDetailTypes];
  785. this._prevDetailTypes = [...data.innerDetailTypes];
  786. this.detailRequired = data.detailRequired;
  787. this.operationGuide = data.operationGuide;
  788. this.singleCount = data.singleCount;
  789. this.treatCount = data.treatCount;
  790. this.frequency = data.frequency;
  791. this.frequencyUnit = data.frequencyUnit;
  792. this.singlePrice = data.singlePrice;
  793. this.coursePrice = data.coursePrice;
  794. this.totalPrice = data.totalPrice;
  795. this.currentUnitPrice = data.currentUnitPrice || 0;
  796. } else {
  797. const def = createPrescriptionData();
  798. this.detailTables = def.detailTables;
  799. this.innerIsEditable = def.innerIsEditable;
  800. this.innerDetailTypes = def.innerDetailTypes;
  801. this._prevDetailTypes = [...def.innerDetailTypes];
  802. this.detailRequired = def.detailRequired;
  803. this.operationGuide = def.operationGuide;
  804. this.singleCount = def.singleCount;
  805. this.treatCount = def.treatCount;
  806. this.frequency = def.frequency;
  807. this.frequencyUnit = def.frequencyUnit;
  808. this.singlePrice = def.singlePrice;
  809. this.coursePrice = def.coursePrice;
  810. this.totalPrice = def.totalPrice;
  811. this.currentUnitPrice = def.currentUnitPrice || 0;
  812. }
  813. },
  814. switchTab(index) {
  815. if (this.activeIndex === index) return;
  816. this.saveCurrentTabData();
  817. this.activeIndex = index;
  818. this.loadTabData(index);
  819. },
  820. // ========== 新增处方弹窗 ==========
  821. async openAddDialog() {
  822. this.addForm = {
  823. category: "",
  824. itemId: "",
  825. itemName: "",
  826. detailRequired: false,
  827. };
  828. this.itemOptions = [];
  829. this.showAddDialog = true;
  830. await this.fetchItemOptions();
  831. },
  832. async fetchItemOptions(query) {
  833. this.itemLoading = true;
  834. try {
  835. const params = {
  836. pageNum: 1,
  837. pageSize: 999,
  838. };
  839. if (this.addForm.category) {
  840. params.classify = this.addForm.category;
  841. }
  842. if (query) {
  843. params.py = query;
  844. }
  845. const res = await getMappedNondrugItemList(params);
  846. if (res.ResultCode == 0) {
  847. const list = res?.Data?.Items || [];
  848. this.itemOptions = list.map((item) => ({
  849. id: item.pid,
  850. name: item.itemName,
  851. detailRequired: item.detailIsnull === "1",
  852. detailDefault: item.detailDefault || "",
  853. detailCumulative: item.detailCumulative || "",
  854. classify: item.classify || "",
  855. price: item.price || 0,
  856. pricingUnit: item.pricingUnit || "",
  857. singleNumber: item.singleNumber || "",
  858. countCoefficient: item.countCoefficient || 1,
  859. minTreatmentDuration: item.minTreatmentDuration || 0,
  860. }));
  861. }
  862. } catch (e) {
  863. console.error("获取项目列表失败", e);
  864. } finally {
  865. this.itemLoading = false;
  866. }
  867. },
  868. onCategoryChange() {
  869. this.addForm.itemId = "";
  870. this.addForm.itemName = "";
  871. this.fetchItemOptions();
  872. },
  873. async searchItem(query) {
  874. await this.fetchItemOptions(query);
  875. },
  876. onItemSelected(id) {
  877. const item = this.itemOptions.find((i) => i.id === id);
  878. if (item) {
  879. this.addForm.itemName = item.name;
  880. }
  881. },
  882. async confirmAdd() {
  883. if (!this.addForm.itemId) {
  884. this.$message.warning("请选择项目名称");
  885. return;
  886. }
  887. // 检查项目是否已存在,不允许重复添加
  888. const isDuplicate = this.prescriptions.some(
  889. (p) => p.itemId === this.addForm.itemId
  890. );
  891. if (isDuplicate) {
  892. this.$message.warning("该项目已添加,不能重复添加");
  893. return;
  894. }
  895. // 调用详情接口获取项目完整信息
  896. let detailData = {};
  897. try {
  898. const res = await getNondrugItemDetail(this.addForm.itemId);
  899. if (res.ResultCode == 0) {
  900. detailData = res.Data || {};
  901. }
  902. } catch (e) {
  903. console.error("获取项目详情失败", e);
  904. }
  905. const categoryLabel =
  906. this.classifyOptions.find((c) => c.value === this.addForm.category)
  907. ?.label || "";
  908. // 解析详情默认值 → 详情类型名称
  909. const detailDefault = detailData.detailDefault || "";
  910. const detailTypeValues = detailDefault
  911. ? String(detailDefault).split(",")
  912. : [];
  913. const detailTypes = detailTypeValues
  914. .map((v) => DETAIL_DEFAULT_MAP[v.trim()])
  915. .filter(Boolean);
  916. // 详情是否必填
  917. const detailRequired = detailData.detailIsnull === "1";
  918. // 单次数量
  919. const singleNumber = detailData.singleNumber || "0";
  920. const singleCount = singleNumber === "0" ? 1 : 0;
  921. // 价格
  922. const price = detailData.price || 0;
  923. // 保存旧 tab 数据
  924. if (this.prescriptions.length > 0) {
  925. this.saveCurrentTabData();
  926. }
  927. // 从 itemOptions 中获取选中项的 classify
  928. const selectedItem = this.itemOptions.find(
  929. (i) => i.id === this.addForm.itemId,
  930. );
  931. const newIndex = this.prescriptions.length;
  932. this.prescriptions.push({
  933. category: this.addForm.category,
  934. categoryLabel,
  935. itemId: this.addForm.itemId,
  936. itemName: this.addForm.itemName,
  937. price,
  938. pricingUnit: detailData.pricingUnit || "",
  939. singleNumber,
  940. countCoefficient: detailData.countCoefficient || 1,
  941. minTreatmentDuration: detailData.minTreatmentDuration || 0,
  942. detailCumulative: detailData.detailCumulative || "",
  943. classify: selectedItem?.classify || "",
  944. ygtid: detailData.appId || "",
  945. departmentId: detailData.deptId || "",
  946. stitutionsId: detailData.institutionCode || "",
  947. stitutionsName: detailData.institutionName || "",
  948. });
  949. // 新 tab 的默认数据,根据详情设置
  950. this.prescriptionDataMap[newIndex] = createPrescriptionData({
  951. detailRequired,
  952. detailTypes,
  953. singleCount,
  954. unitPrice: price,
  955. });
  956. // 切到新 tab
  957. this.activeIndex = newIndex;
  958. this.loadTabData(newIndex);
  959. this.showAddDialog = false;
  960. this.$emit("prescriptions-change", this.prescriptions);
  961. },
  962. removePrescription(index) {
  963. this.$confirm("确认删除该处方?", "提示", {
  964. confirmButtonText: "确定",
  965. cancelButtonText: "取消",
  966. type: "warning",
  967. })
  968. .then(() => {
  969. this.prescriptions.splice(index, 1);
  970. const oldMap = this.prescriptionDataMap;
  971. this.prescriptionDataMap = {};
  972. this.prescriptions.forEach((_, i) => {
  973. if (i < index) {
  974. this.prescriptionDataMap[i] = oldMap[i];
  975. } else {
  976. this.prescriptionDataMap[i] = oldMap[i + 1];
  977. }
  978. });
  979. if (this.prescriptions.length === 0) {
  980. this.activeIndex = 0;
  981. this.detailTables = {
  982. 穴位: [createEmptyRow(1)],
  983. 经络: [],
  984. 耳穴: [],
  985. 部位: [],
  986. 其他详情: [],
  987. };
  988. } else {
  989. this.activeIndex = Math.min(index, this.prescriptions.length - 1);
  990. this.loadTabData(this.activeIndex);
  991. }
  992. this.$emit("prescriptions-change", this.prescriptions);
  993. })
  994. .catch(() => {});
  995. },
  996. clearAll() {
  997. if (!this.prescriptions.length) {
  998. // 没有处方 tab 时,仅重置表格和统计
  999. this.detailTables = {
  1000. 穴位: [createEmptyRow(1)],
  1001. 经络: [],
  1002. 耳穴: [],
  1003. 部位: [],
  1004. 其他详情: [],
  1005. };
  1006. this.operationGuide = "";
  1007. this.singleCount = 0;
  1008. this.treatCount = 1;
  1009. this.frequency = undefined;
  1010. this.frequencyUnit = undefined;
  1011. this.singlePrice = "0.00";
  1012. this.coursePrice = "0.00";
  1013. this.totalPrice = "0.00";
  1014. this.currentUnitPrice = 0;
  1015. this.innerIsEditable = "1";
  1016. this.innerDetailTypes = ["穴位"];
  1017. this._prevDetailTypes = ["穴位"];
  1018. this.detailRequired = false;
  1019. this.emitStatistics();
  1020. return;
  1021. }
  1022. // 只清空当前选中 tab 的内容,保留处方 tab 本身
  1023. const p = this.prescriptions[this.activeIndex];
  1024. const unitPrice = p?.price || 0;
  1025. this.prescriptionDataMap[this.activeIndex] = createPrescriptionData({
  1026. detailRequired: false,
  1027. detailTypes: [],
  1028. singleCount: 0,
  1029. unitPrice,
  1030. });
  1031. this.loadTabData(this.activeIndex);
  1032. this.calcPrice();
  1033. this.$emit("prescriptions-change", this.prescriptions);
  1034. },
  1035. // ========== 工具栏 change ==========
  1036. onEditableChange(val) {
  1037. this.$emit("update:isEditable", val);
  1038. },
  1039. onDetailTypesChange(val) {
  1040. // 无详情 与其他选项不能同时选中
  1041. const NO_DETAIL = "无详情";
  1042. const lastSelected = val.length > this._prevDetailTypes?.length
  1043. ? val.find((v) => !this._prevDetailTypes.includes(v))
  1044. : null;
  1045. if (lastSelected === NO_DETAIL) {
  1046. // 选中了"无详情",取消其他所有选项
  1047. val = [NO_DETAIL];
  1048. } else if (lastSelected && lastSelected !== NO_DETAIL && val.includes(NO_DETAIL)) {
  1049. // 选中了其他选项,取消"无详情"
  1050. val = val.filter((v) => v !== NO_DETAIL);
  1051. }
  1052. this.innerDetailTypes = val;
  1053. this._prevDetailTypes = [...val];
  1054. val.forEach((type) => {
  1055. const table = this.detailTables[type];
  1056. const isEmpty = !table || table.length === 0;
  1057. if (type === "无详情") {
  1058. if (isEmpty) {
  1059. this.$set(this.detailTables, type, [{ description: "" }]);
  1060. }
  1061. } else {
  1062. if (isEmpty) {
  1063. this.$set(this.detailTables, type, [createEmptyRow(1)]);
  1064. }
  1065. }
  1066. });
  1067. this.$emit("update:detailTypes", val);
  1068. },
  1069. // ========== 配穴表格(按详情类型) ==========
  1070. getDetailTable(type) {
  1071. if (!this.detailTables[type]) {
  1072. this.$set(this.detailTables, type, [createEmptyRow(1)]);
  1073. }
  1074. return this.detailTables[type];
  1075. },
  1076. getLeftList(type) {
  1077. return this.getDetailTable(type).filter((item) => item.id % 2 !== 0);
  1078. },
  1079. getRightList(type) {
  1080. return this.getDetailTable(type).filter((item) => item.id % 2 === 0);
  1081. },
  1082. async getAcupointList(keyword = "", serchtype = "") {
  1083. try {
  1084. const res = await getXueweiList({
  1085. pageid: 1,
  1086. pagesize: 999,
  1087. serchtype: serchtype,
  1088. keyword: keyword,
  1089. });
  1090. if (res.code === 0) {
  1091. this.acupointList = res.data.acupoints || [];
  1092. }
  1093. } catch (e) {
  1094. console.error("获取穴位列表失败", e);
  1095. }
  1096. },
  1097. async getMeridianList(keyword = "") {
  1098. try {
  1099. const res = await collateralChannels({
  1100. mertype: "1",
  1101. pageid: 1,
  1102. pagesize: 999,
  1103. keyword: keyword,
  1104. });
  1105. if (res.code == 0) {
  1106. this.meridianList = (res.data.meridians || []).map((item) => ({
  1107. acuid: item.merid,
  1108. acuname: item.mername,
  1109. }));
  1110. }
  1111. } catch (e) {
  1112. console.error("获取经络列表失败", e);
  1113. }
  1114. },
  1115. async getEarAcupointList(keyword = "") {
  1116. try {
  1117. const params = { page: 1, limit: 999 };
  1118. if (keyword) params.keyWord = keyword;
  1119. const res = await getAcuMeridianList(params);
  1120. if (res.code == 0) {
  1121. const list = res.data?.records || [];
  1122. this.earAcupointList = (Array.isArray(list) ? list : []).map(
  1123. (item) => ({
  1124. acuid: item.id,
  1125. acuname: item.name,
  1126. }),
  1127. );
  1128. }
  1129. } catch (e) {
  1130. console.error("获取耳穴列表失败", e);
  1131. }
  1132. },
  1133. getSearchOptions(type) {
  1134. switch (type) {
  1135. case "经络":
  1136. return this.meridianList;
  1137. case "耳穴":
  1138. return this.earAcupointList;
  1139. default:
  1140. return this.acupointList;
  1141. }
  1142. },
  1143. getFilterMethod(type) {
  1144. return (query) => {
  1145. this.searchByType(query, type);
  1146. };
  1147. },
  1148. searchByType(query, type) {
  1149. const pinyin = /^[A-Za-z]+$/g;
  1150. const serchtype = pinyin.test(query) ? "1" : "";
  1151. switch (type) {
  1152. case "经络":
  1153. this.getMeridianList(query);
  1154. break;
  1155. case "耳穴":
  1156. this.getEarAcupointList(query);
  1157. break;
  1158. default:
  1159. this.getAcupointList(query, serchtype);
  1160. }
  1161. },
  1162. onItemChange(acuid, scope, detailType) {
  1163. const row = scope.row;
  1164. const table = this.getDetailTable(detailType);
  1165. const exists = table.find(
  1166. (item) => item.acuid === acuid && item.id !== row.id,
  1167. );
  1168. if (exists) {
  1169. this.$message.error("不可重复选择");
  1170. row.acuid = "";
  1171. row.name = "";
  1172. row.acuname = "";
  1173. return;
  1174. }
  1175. const optionsList = this.getSearchOptions(detailType);
  1176. const selected = optionsList.find((item) => item.acuid === acuid);
  1177. if (selected) {
  1178. row.acuid = selected.acuid;
  1179. row.acuname = selected.acuname;
  1180. row.name = selected.acuname;
  1181. if (
  1182. detailType === "穴位" &&
  1183. selected.num != null &&
  1184. selected.num !== ""
  1185. ) {
  1186. row.count = Number(selected.num) || 1;
  1187. }
  1188. }
  1189. this.addDetailRow(scope, detailType);
  1190. },
  1191. onDetailInput(scope, detailType) {
  1192. // 其他详情输入文字后自动新增一行
  1193. if (scope.row.name) {
  1194. this.addDetailRow(scope, detailType);
  1195. }
  1196. },
  1197. addDetailRow(scope, detailType) {
  1198. const table = this.getDetailTable(detailType);
  1199. if (scope) {
  1200. const index = scope.row.id - 1;
  1201. if (index === table.length - 1) {
  1202. table.push(createEmptyRow(1));
  1203. } else {
  1204. const rest = table.splice(scope.row.id);
  1205. table.push(createEmptyRow(1));
  1206. this.$set(this.detailTables, detailType, table.concat(rest));
  1207. }
  1208. } else {
  1209. table.push(createEmptyRow(1));
  1210. }
  1211. this.reIndexDetail(detailType);
  1212. this.searchByType("", detailType);
  1213. },
  1214. isDeleteDisabled(row, detailType) {
  1215. if (!this.isLocked) return false;
  1216. if (detailType !== "穴位") return true;
  1217. return row.mainType === "1";
  1218. },
  1219. deleteDetailRow(scope, detailType) {
  1220. if (this.isDeleteDisabled(scope.row, detailType)) return;
  1221. const table = this.getDetailTable(detailType);
  1222. const index = scope.row.id - 1;
  1223. if (index === 0 && table.length === 1) return;
  1224. table.splice(index, 1);
  1225. this.reIndexDetail(detailType);
  1226. },
  1227. async find(scope, detailType) {
  1228. const row = scope.row;
  1229. if (!row.acuid) return;
  1230. try {
  1231. let res;
  1232. if (detailType === "经络") {
  1233. res = await getMerD({ merid: row.acuid });
  1234. } else if (detailType === "耳穴") {
  1235. res = await getAcuMeridianDetail(row.acuid);
  1236. } else {
  1237. res = await getAcupointD({ acuid: row.acuid });
  1238. }
  1239. if (res.code === 0 || res.ResultCode === 0) {
  1240. this.detailData = res.data || res.Data || {};
  1241. this.detailType = detailType;
  1242. this.showDetailDialog = true;
  1243. }
  1244. } catch (e) {
  1245. console.error("获取详情失败", e);
  1246. }
  1247. },
  1248. copyDetailRow(scope, detailType) {
  1249. const table = this.getDetailTable(detailType);
  1250. const copy = { ...scope.row, id: 1 };
  1251. const index = scope.row.id;
  1252. table.splice(index, 0, copy);
  1253. this.reIndexDetail(detailType);
  1254. },
  1255. reIndexDetail(detailType) {
  1256. const table = this.getDetailTable(detailType);
  1257. table.forEach((item, index) => {
  1258. item.id = index + 1;
  1259. });
  1260. },
  1261. // ========== 底部统计 ==========
  1262. calcPrice() {
  1263. const price = this.currentUnitPrice || this.unitPrice || 0;
  1264. const totalFromDetails = this.calcTotalCount();
  1265. if (totalFromDetails > 0) {
  1266. this.singleCount = totalFromDetails;
  1267. }
  1268. this.singlePrice = (this.singleCount * price).toFixed(2);
  1269. this.coursePrice = (
  1270. this.treatCount * parseFloat(this.singlePrice)
  1271. ).toFixed(2);
  1272. this.saveCurrentTabData();
  1273. let total = 0;
  1274. Object.values(this.prescriptionDataMap).forEach((d) => {
  1275. total += parseFloat(d.coursePrice) || 0;
  1276. });
  1277. this.totalPrice = total.toFixed(2);
  1278. this.emitStatistics();
  1279. },
  1280. calcTotalCount() {
  1281. let total = 0;
  1282. const validTypes = ["穴位", "经络", "耳穴", "部位", "其他详情"];
  1283. validTypes.forEach((type) => {
  1284. const table = this.detailTables[type];
  1285. if (table) {
  1286. table.forEach((row) => {
  1287. if (row.acuid || row.name) {
  1288. total += row.count || 0;
  1289. }
  1290. });
  1291. }
  1292. });
  1293. return total;
  1294. },
  1295. emitStatistics() {
  1296. this.$emit("update:statistics", {
  1297. operationGuide: this.operationGuide,
  1298. singleCount: this.singleCount,
  1299. treatCount: this.treatCount,
  1300. frequency: this.frequency,
  1301. frequencyUnit: this.frequencyUnit,
  1302. singlePrice: this.singlePrice,
  1303. coursePrice: this.coursePrice,
  1304. totalPrice: this.totalPrice,
  1305. });
  1306. },
  1307. validate() {
  1308. if (!this.prescriptions.length) {
  1309. this.$message.warning("请先新增处方");
  1310. return false;
  1311. }
  1312. if (this.detailRequired && this.innerDetailTypes.length === 0) {
  1313. this.$message.warning("请至少勾选一个详情类型");
  1314. return false;
  1315. }
  1316. if (!this.operationGuide.trim()) {
  1317. this.$message.warning("请输入操作指南");
  1318. return false;
  1319. }
  1320. if (!this.singleCount || this.singleCount <= 0) {
  1321. this.$message.warning("请输入单次数量");
  1322. return false;
  1323. }
  1324. return true;
  1325. },
  1326. handleSave() {
  1327. if (!this.validate()) return;
  1328. this.saveLoading = true;
  1329. const treatmentList = this.buildTreatmentList();
  1330. const firstP = this.prescriptions[0] || {};
  1331. const institutionInfo = {
  1332. ygtid: firstP.ygtid || "",
  1333. departmentId: firstP.departmentId || "",
  1334. stitutionsId: firstP.stitutionsId || "",
  1335. stitutionsName: firstP.stitutionsName || "",
  1336. };
  1337. this.$emit("save", treatmentList, institutionInfo);
  1338. },
  1339. saveDone() {
  1340. this.saveLoading = false;
  1341. },
  1342. buildTreatmentList() {
  1343. this.saveCurrentTabData();
  1344. const DETAIL_TYPE_MAP = {
  1345. 穴位: "1",
  1346. 经络: "2",
  1347. 耳穴: "3",
  1348. 部位: "4",
  1349. 其他详情: "5",
  1350. };
  1351. const TYPE_TO_FIELD = {
  1352. 穴位: "detailPoint",
  1353. 经络: "detailMeridian",
  1354. 耳穴: "detailEarPoint",
  1355. 部位: "detailBodyPart",
  1356. 其他详情: "detailOther",
  1357. };
  1358. return this.prescriptions.map((p, index) => {
  1359. const d = this.prescriptionDataMap[index] || createPrescriptionData();
  1360. const detailPoint = [];
  1361. const detailMeridian = [];
  1362. const detailEarPoint = [];
  1363. const detailBodyPart = [];
  1364. const detailOther = [];
  1365. const detailNone = [];
  1366. const detailArrays = {
  1367. 穴位: detailPoint,
  1368. 经络: detailMeridian,
  1369. 耳穴: detailEarPoint,
  1370. 部位: detailBodyPart,
  1371. 其他详情: detailOther,
  1372. };
  1373. Object.keys(detailArrays).forEach((type) => {
  1374. const table = d.detailTables[type] || [];
  1375. table.forEach((row) => {
  1376. if (row.acuid || row.name) {
  1377. detailArrays[type].push({
  1378. acupoint: type === "穴位" ? row.mainType || "0" : "0",
  1379. name: row.acuname || row.name || "",
  1380. num: row.count || 1,
  1381. pointCode: "",
  1382. pointId: row.acuid || "",
  1383. remark: row.remark || "",
  1384. seqn: String(row.id || ""),
  1385. type: DETAIL_TYPE_MAP[type] || "1",
  1386. });
  1387. }
  1388. });
  1389. });
  1390. return {
  1391. treatItemId: p.itemId,
  1392. treatItemName: p.itemName,
  1393. treatClass: p.classify || "",
  1394. isUpdate: d.innerIsEditable || "1",
  1395. singleQty: d.singleCount || 0,
  1396. singleAmount: parseFloat(d.singlePrice) || 0,
  1397. treatNum: d.treatCount || 0,
  1398. courseAmount: parseFloat(d.coursePrice) || 0,
  1399. frequency:
  1400. d.frequency && d.frequencyUnit
  1401. ? `${d.frequency}天${d.frequencyUnit}次`
  1402. : "",
  1403. useExplain: d.operationGuide || "",
  1404. pointMatchGuide: "",
  1405. seqn: index + 1,
  1406. ownerType: "1",
  1407. detailPoint,
  1408. detailMeridian,
  1409. detailEarPoint,
  1410. detailBodyPart,
  1411. detailOther,
  1412. detailNone: d.innerDetailTypes.includes("无详情")
  1413. ? { description: "" }
  1414. : null,
  1415. };
  1416. });
  1417. },
  1418. // 编辑时 回填组件数据
  1419. loadFromServerData(treatmentList) {
  1420. if (!Array.isArray(treatmentList) || !treatmentList.length) return;
  1421. const TYPE_VALUE_MAP = {
  1422. "1": "穴位",
  1423. "2": "经络",
  1424. "3": "耳穴",
  1425. "4": "部位",
  1426. "5": "其他详情",
  1427. "6": "无详情",
  1428. };
  1429. this.prescriptions = [];
  1430. this.prescriptionDataMap = {};
  1431. treatmentList.forEach((item, index) => {
  1432. const unitPrice = Number(item.price) || 0;
  1433. const pricingUnit = item.basisStitutionsnondrug?.pricingUnit || "";
  1434. this.prescriptions.push({
  1435. category: "",
  1436. categoryLabel: "",
  1437. itemId: item.treatItemId || "",
  1438. itemName: item.treatItemName || "",
  1439. price: unitPrice,
  1440. pricingUnit: pricingUnit,
  1441. singleNumber: "",
  1442. countCoefficient: 1,
  1443. minTreatmentDuration: 0,
  1444. detailCumulative: "",
  1445. });
  1446. const allDetails = [].concat(
  1447. item.detailPoint || [],
  1448. item.detailMeridian || [],
  1449. item.detailEarPoint || [],
  1450. item.detailBodyPart || [],
  1451. item.detailOther || [],
  1452. );
  1453. // 按 type 分组到 detailTables
  1454. const detailTables = {
  1455. 穴位: [],
  1456. 经络: [],
  1457. 耳穴: [],
  1458. 部位: [],
  1459. 其他详情: [],
  1460. 无详情: [],
  1461. };
  1462. const activeTypes = new Set();
  1463. if (
  1464. item.detailNone !== null &&
  1465. item.detailNone !== undefined &&
  1466. typeof item.detailNone === "object" &&
  1467. !Array.isArray(item.detailNone)
  1468. ) {
  1469. activeTypes.add("无详情");
  1470. }
  1471. allDetails.forEach((d) => {
  1472. const typeName = TYPE_VALUE_MAP[d.type] || "";
  1473. if (typeName && detailTables[typeName]) {
  1474. activeTypes.add(typeName);
  1475. detailTables[typeName].push({
  1476. id: detailTables[typeName].length + 1,
  1477. acuid: d.pointId || "",
  1478. acuname: d.name || "",
  1479. name: d.name || "",
  1480. count: d.num || 1,
  1481. remark: d.remark || "",
  1482. mainType: d.acupoint || "1",
  1483. });
  1484. }
  1485. });
  1486. ["穴位", "经络", "耳穴", "部位", "其他详情"].forEach((type) => {
  1487. if (detailTables[type].length === 0) {
  1488. detailTables[type] = [createEmptyRow(1)];
  1489. }
  1490. });
  1491. if (!detailTables["无详情"]) {
  1492. detailTables["无详情"] = [];
  1493. }
  1494. let parsedFreqDays = undefined;
  1495. let parsedFreqTimes = undefined;
  1496. if (item.frequency) {
  1497. const match = String(item.frequency).match(/(\d+)天(\d+)次/);
  1498. if (match) {
  1499. parsedFreqDays = parseInt(match[1], 10);
  1500. parsedFreqTimes = parseInt(match[2], 10);
  1501. }
  1502. }
  1503. // 构造 tab 数据
  1504. this.prescriptionDataMap[index] = {
  1505. detailTables,
  1506. innerIsEditable: item.isUpdate || "1",
  1507. innerDetailTypes: activeTypes.size > 0 ? [...activeTypes] : ["穴位"],
  1508. detailRequired: item.basisStitutionsnondrug?.detailIsnull === "1",
  1509. operationGuide: item.useExplain || "",
  1510. singleCount: item.singleQty || 0,
  1511. treatCount: item.treatNum || 1,
  1512. frequency: parsedFreqDays,
  1513. frequencyUnit: parsedFreqTimes,
  1514. singlePrice: String(item.singleAmount || "0.00"),
  1515. coursePrice: (
  1516. (item.treatNum || 1) * (item.singleAmount || 0)
  1517. ).toFixed(2),
  1518. totalPrice: "0.00",
  1519. currentUnitPrice: unitPrice,
  1520. };
  1521. });
  1522. this.activeIndex = 0;
  1523. this.loadTabData(0);
  1524. // 疗程金额
  1525. let total = 0;
  1526. Object.values(this.prescriptionDataMap).forEach((d) => {
  1527. total += parseFloat(d.coursePrice) || 0;
  1528. });
  1529. this.totalPrice = total.toFixed(2);
  1530. this.$emit("prescriptions-change", this.prescriptions);
  1531. },
  1532. getData() {
  1533. if (!this.validate()) return null;
  1534. this.saveCurrentTabData();
  1535. return {
  1536. prescriptions: this.prescriptions.map((p, i) => {
  1537. const d = this.prescriptionDataMap[i] || createPrescriptionData();
  1538. return {
  1539. ...p,
  1540. isEditable: d.innerIsEditable,
  1541. detailTypes: d.innerDetailTypes,
  1542. detailRequired: d.detailRequired,
  1543. detailTables: d.detailTables,
  1544. acupoints: (d.detailTables["穴位"] || []).filter(
  1545. (item) => item.acuid,
  1546. ),
  1547. statistics: {
  1548. operationGuide: d.operationGuide,
  1549. singleCount: d.singleCount,
  1550. treatCount: d.treatCount,
  1551. frequency: d.frequency,
  1552. frequencyUnit: d.frequencyUnit,
  1553. singlePrice: d.singlePrice,
  1554. coursePrice: d.coursePrice,
  1555. totalPrice: d.totalPrice,
  1556. },
  1557. };
  1558. }),
  1559. };
  1560. },
  1561. },
  1562. };
  1563. </script>
  1564. <style lang="scss" scoped>
  1565. .recipe-acupoint-wrapper {
  1566. .top-btns {
  1567. display: flex;
  1568. justify-content: flex-end;
  1569. margin-bottom: 6px;
  1570. flex-shrink: 0;
  1571. }
  1572. }
  1573. // 处方 tab 列表
  1574. .prescription-tabs {
  1575. display: flex;
  1576. margin-bottom: 10px;
  1577. flex-shrink: 0;
  1578. .tab-item {
  1579. position: relative;
  1580. display: flex;
  1581. align-items: center;
  1582. padding: 8px 20px;
  1583. font-size: 14px;
  1584. color: #666;
  1585. background: #f5f7fa;
  1586. border-radius: 4px;
  1587. cursor: pointer;
  1588. margin-right: 6px;
  1589. transition: all 0.25s;
  1590. &:hover {
  1591. color: #5386f6;
  1592. background: #e8eefb;
  1593. }
  1594. &.active {
  1595. background: #5386f6;
  1596. color: #fff;
  1597. &:hover {
  1598. background: #4078f0;
  1599. }
  1600. .tab-close {
  1601. color: rgba(255, 255, 255, 0.7);
  1602. &:hover {
  1603. color: #fff;
  1604. background: rgba(255, 255, 255, 0.2);
  1605. }
  1606. }
  1607. }
  1608. .tab-name {
  1609. max-width: 120px;
  1610. overflow: hidden;
  1611. text-overflow: ellipsis;
  1612. white-space: nowrap;
  1613. }
  1614. .tab-close {
  1615. margin-left: 8px;
  1616. width: 16px;
  1617. height: 16px;
  1618. line-height: 16px;
  1619. text-align: center;
  1620. border-radius: 50%;
  1621. font-size: 14px;
  1622. color: #999;
  1623. transition: all 0.2s;
  1624. &:hover {
  1625. background: rgba(0, 0, 0, 0.1);
  1626. color: #ff6245;
  1627. }
  1628. }
  1629. }
  1630. }
  1631. .recipe-acupoint {
  1632. border: 2px solid #dedede;
  1633. padding: 7px 0 0;
  1634. display: flex;
  1635. flex-direction: column;
  1636. // 工具栏
  1637. .table-toolbar {
  1638. margin-bottom: 10px;
  1639. padding: 0 5px;
  1640. flex-shrink: 0;
  1641. .toolbar-item {
  1642. margin-right: 30px;
  1643. margin-bottom: 5px;
  1644. span {
  1645. font-size: 14px;
  1646. color: #333;
  1647. white-space: nowrap;
  1648. }
  1649. }
  1650. }
  1651. // 滚动容器
  1652. .table-container {
  1653. padding: 0 5px;
  1654. flex: 1;
  1655. min-height: 0;
  1656. overflow: auto;
  1657. }
  1658. .no-data-tip {
  1659. flex: 1;
  1660. display: flex;
  1661. align-items: center;
  1662. justify-content: center;
  1663. color: #999;
  1664. font-size: 14px;
  1665. padding: 40px 0;
  1666. }
  1667. // 详情表格区域
  1668. .detail-table-section {
  1669. margin-bottom: 10px;
  1670. .detail-section-label {
  1671. display: inline-block;
  1672. padding: 2px 12px;
  1673. border: 1px solid #ff6245;
  1674. border-radius: 4px;
  1675. color: #ff6245;
  1676. font-size: 13px;
  1677. margin-bottom: 6px;
  1678. }
  1679. }
  1680. // 配穴表格
  1681. .table-show {
  1682. width: 100%;
  1683. overflow: auto;
  1684. display: flex;
  1685. align-items: flex-start;
  1686. justify-content: space-between;
  1687. .table-left {
  1688. flex: 0 0 49.9%;
  1689. overflow-y: auto;
  1690. border: 1px solid #dedede;
  1691. box-sizing: border-box;
  1692. }
  1693. }
  1694. // 底部统计
  1695. .table-bottom {
  1696. flex-shrink: 0;
  1697. padding: 0 5px;
  1698. margin-top: 5px;
  1699. .table-b-header {
  1700. .header-about {
  1701. .item {
  1702. margin-right: 20px;
  1703. margin-bottom: 10px;
  1704. span {
  1705. font-size: 14px;
  1706. color: #333;
  1707. white-space: nowrap;
  1708. }
  1709. }
  1710. }
  1711. }
  1712. }
  1713. .stat-row {
  1714. .stat-field {
  1715. margin-right: 50px;
  1716. margin-bottom: 5px;
  1717. span {
  1718. font-size: 14px;
  1719. color: #333;
  1720. white-space: nowrap;
  1721. }
  1722. .stat-unit {
  1723. margin: 0 4px;
  1724. }
  1725. }
  1726. }
  1727. .operate {
  1728. width: 100%;
  1729. height: 100%;
  1730. display: flex;
  1731. align-items: center;
  1732. justify-content: space-around;
  1733. img {
  1734. width: 16px;
  1735. }
  1736. }
  1737. }
  1738. .recipe-acupoint ::v-deep .el-table .cell {
  1739. text-align: center;
  1740. }
  1741. .recipe-acupoint ::v-deep .el-select {
  1742. width: 100%;
  1743. }
  1744. .recipe-acupoint ::v-deep .el-table td {
  1745. padding: 2px 0;
  1746. }
  1747. .recipe-acupoint ::v-deep .el-table th {
  1748. padding: 2px 0;
  1749. }
  1750. .recipe-acupoint .table-show .table-left::v-deep .el-table__empty-block {
  1751. min-height: 33px !important;
  1752. height: 33px !important;
  1753. }
  1754. // 底部金额
  1755. .table-b-bottom {
  1756. flex-shrink: 0;
  1757. padding: 10px;
  1758. border-top: 2px solid #dedede;
  1759. margin-top: 5px;
  1760. .t-b-l-item {
  1761. font-size: 14px;
  1762. color: #333;
  1763. margin-right: 20px;
  1764. span {
  1765. color: #ff6245;
  1766. }
  1767. }
  1768. }
  1769. // 详情弹窗样式(scoped 内)
  1770. .drug-body {
  1771. padding: 10px;
  1772. .drug-item {
  1773. display: flex;
  1774. align-items: flex-start;
  1775. margin-bottom: 12px;
  1776. > span {
  1777. min-width: 80px;
  1778. font-size: 14px;
  1779. color: #333;
  1780. text-align: right;
  1781. margin-right: 10px;
  1782. flex-shrink: 0;
  1783. }
  1784. > div {
  1785. flex: 1;
  1786. font-size: 14px;
  1787. color: #666;
  1788. word-break: break-all;
  1789. line-height: 1.6;
  1790. }
  1791. .detail-img {
  1792. img {
  1793. max-width: 100%;
  1794. max-height: 300px;
  1795. }
  1796. }
  1797. }
  1798. }
  1799. </style>
  1800. <style lang="scss">
  1801. .add-prescription-dialog {
  1802. margin: 0 auto;
  1803. .el-dialog__header {
  1804. padding: 0;
  1805. }
  1806. .el-dialog__body {
  1807. padding: 18px;
  1808. }
  1809. .add-dialog-header {
  1810. display: flex;
  1811. align-items: center;
  1812. justify-content: center;
  1813. height: 34px;
  1814. background: #5386f6;
  1815. position: relative;
  1816. span {
  1817. font-size: 16px;
  1818. font-family: PingFang SC;
  1819. font-weight: 400;
  1820. color: #fff;
  1821. }
  1822. .close-btn {
  1823. transform: rotate(45deg);
  1824. color: #fff;
  1825. position: absolute;
  1826. top: -13px;
  1827. right: 20px;
  1828. font-size: 44px;
  1829. cursor: pointer;
  1830. }
  1831. }
  1832. .add-dialog-body {
  1833. min-height: 350px;
  1834. .add-form-row {
  1835. display: flex;
  1836. align-items: center;
  1837. margin-bottom: 16px;
  1838. .label {
  1839. font-size: 14px;
  1840. color: #333;
  1841. white-space: nowrap;
  1842. min-width: 100px;
  1843. text-align: right;
  1844. }
  1845. }
  1846. }
  1847. .add-dialog-btns {
  1848. display: flex;
  1849. justify-content: center;
  1850. margin-top: 20px;
  1851. .confirm-btn {
  1852. width: 108px;
  1853. height: 40px;
  1854. line-height: 40px;
  1855. text-align: center;
  1856. background: #5386f6;
  1857. color: #fff;
  1858. border-radius: 3px;
  1859. font-size: 18px;
  1860. cursor: pointer;
  1861. }
  1862. }
  1863. }
  1864. .detail-dialog {
  1865. margin: 0 auto;
  1866. .el-dialog__header {
  1867. padding: 0;
  1868. background: #5386f6;
  1869. text-align: center;
  1870. height: 40px;
  1871. line-height: 40px;
  1872. }
  1873. .el-dialog__title {
  1874. font-size: 16px;
  1875. color: #fff;
  1876. }
  1877. .el-dialog__headerbtn {
  1878. top: 8px;
  1879. right: 10px;
  1880. font-size: 22px;
  1881. .el-dialog__close {
  1882. color: #fff;
  1883. font-size: 22px;
  1884. }
  1885. }
  1886. .el-dialog__body {
  1887. padding: 18px;
  1888. max-height: 75vh;
  1889. overflow-y: auto;
  1890. }
  1891. .drug-body {
  1892. padding: 10px;
  1893. .drug-item {
  1894. display: flex;
  1895. align-items: flex-start;
  1896. margin-bottom: 12px;
  1897. > span {
  1898. min-width: 80px;
  1899. font-size: 14px;
  1900. color: #333;
  1901. text-align: right;
  1902. margin-right: 10px;
  1903. flex-shrink: 0;
  1904. }
  1905. > div {
  1906. flex: 1;
  1907. font-size: 14px;
  1908. color: #666;
  1909. word-break: break-all;
  1910. line-height: 1.6;
  1911. }
  1912. .detail-img {
  1913. img {
  1914. max-width: 100%;
  1915. max-height: 300px;
  1916. }
  1917. }
  1918. }
  1919. }
  1920. }
  1921. </style>