AcupointTable.vue 73 KB

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