accompanied.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <div class="accompanied-container">
  3. <div class="col">
  4. <div class="header">兼证</div>
  5. <div :class="['col-item', active[0] == index ? 'active' : '']" v-for="(item, index) in listData"
  6. :key="index" @click="handleList(index)">
  7. {{ item.name }}
  8. </div>
  9. </div>
  10. <div class="col">
  11. <div class="header">治法</div>
  12. <div :class="['col-item', active[1] == index ? 'active' : '']" v-for="(item, index) in therapyList"
  13. :key="index" @click="handleTherapy(index)">
  14. {{ item.name }}
  15. </div>
  16. </div>
  17. <div class="col">
  18. <div class="header">药品</div>
  19. <div :class="['col-item']" v-for="(item, index) in medList" :key="index">
  20. <el-checkbox :value="item.checked" @change="ypChange(index)">{{ item.ypmc }}</el-checkbox>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import {
  27. accompaniedData
  28. } from "@/utils/data.js";
  29. import {
  30. changeAndJoin,
  31. } from "@/api/knowledge.js";
  32. import {CC_Dosage2Basis} from '@/utils/medicine';
  33. accompaniedData.forEach(item => {
  34. item.child.forEach(item1 => {
  35. item1.child.forEach(item2 => {
  36. item2.checked = false
  37. })
  38. })
  39. });
  40. export default {
  41. data() {
  42. return {
  43. active: [0, 0, 0],
  44. listData: accompaniedData, // 兼证 列表
  45. therapyList: [], // 治法列表
  46. medList: [], // 药品列表
  47. };
  48. },
  49. watch: {
  50. },
  51. created() {
  52. this.$nextTick(() => {
  53. this.therapyList = accompaniedData[this.active[0]].child;
  54. this.medList = this.therapyList[this.active[1]].child;
  55. });
  56. },
  57. methods: {
  58. // 兼症点击
  59. handleList(index) {
  60. this.active = [index, 0, 0]
  61. this.therapyList = accompaniedData[this.active[0]].child;
  62. this.medList = this.therapyList[this.active[1]].child;
  63. },
  64. // 治法点击
  65. handleTherapy(index) {
  66. let active_0 = this.active[0]
  67. this.active = [active_0, index, 0]
  68. this.medList = this.therapyList[this.active[1]].child;
  69. },
  70. // 药品改变
  71. ypChange(index) {
  72. let active_0 = this.active[0]
  73. let active_1 = this.active[1]
  74. let item = this.medList[index]
  75. let parent = this.$parent.$parent
  76. let parentTable = parent.recipe_tabs[parent.recipe_tabs_c].totalTableD
  77. let isRepate = false
  78. // 判断是否重复添加药品
  79. parentTable.forEach(parentItem => {
  80. if (parentItem.medid == item.pid) {
  81. isRepate = true
  82. }
  83. })
  84. if (isRepate) {
  85. this.medList[index].checked = false
  86. this.therapyList[active_1].child = this.medList
  87. this.$message.warning("请勿重复添加药品");
  88. return
  89. }
  90. this.medList[index].checked = !this.medList[index].checked
  91. this.therapyList[active_1].child = this.medList
  92. if (item.checked) { // 添加药品
  93. let scope = parentTable[parentTable.length - 1]
  94. let obj = {
  95. row: {
  96. id: scope.id + 1
  97. }
  98. }
  99. // parent.clickPid = item.pid
  100. // parent.addDis1(obj, 1)
  101. parent.chooseDis1({
  102. row: scope
  103. }, 0, item, 'accompanied')
  104. // this.changeAndJoin(item)
  105. } else {
  106. let id = item.pid
  107. let scope = null
  108. parentTable.forEach(parentItem => {
  109. if (id == parentItem.medid) {
  110. scope = parentItem
  111. parent.deleteDis1({
  112. row: scope
  113. })
  114. }
  115. })
  116. }
  117. },
  118. // 名家验案和 方剂转方/合方
  119. async changeAndJoin(item) {
  120. // type == 1 转方 type ==2 合方
  121. let parent = this.$parent.$parent
  122. let drugs = [item];
  123. // 新方式处理药房
  124. let pharmacyName = "";
  125. // let type1 = 0
  126. let type1 = parent.recipe_tabs[parent.recipe_tabs_c].radio;
  127. parent.pharmacyList.forEach(item => {
  128. if (item.pid == parent.recipe_tabs[parent.recipe_tabs_c].pharmacyID) {
  129. pharmacyName = item.pharmacyName;
  130. }
  131. });
  132. let ids = [];
  133. drugs.forEach(item => {
  134. item.oldDose = CC_Dosage2Basis(item);
  135. let idDose = item.pid + "&" + (item.oldDose || 0);
  136. ids.push(idDose);
  137. });
  138. const loading = this.$loading({
  139. lock: true,
  140. text: "正在处理药品数据,请稍等",
  141. spinner: "el-icon-loading",
  142. background: "rgba(0, 0, 0, 0.7)"
  143. });
  144. let res = await changeAndJoin({
  145. pharmacyid: parent.recipe_tabs[parent.recipe_tabs_c].pharmacyID,
  146. type: type1, // parent.recipe_tabs[parent.recipe_tabs_c].radio,
  147. drugIds: ids
  148. }).catch(err => {
  149. loading.close();
  150. });
  151. // 中药处方
  152. if (res.ResultCode == 0) {
  153. let noDrugs = []; // 查找不到的药品
  154. let hasDrugs = []; // 查找的到的药品
  155. res.Data.forEach((item, index) => {
  156. drugs.forEach((item1, index1) => {
  157. if (item == item1.pid) {
  158. // debugger
  159. item1.color = "red";
  160. let obj = {
  161. drugList: [],
  162. page: 1,
  163. loadMore: true,
  164. usageList: [],
  165. seqn: item1.seqn || '',
  166. ypmc: item1.matname || item1.ypmc,
  167. gg: "",
  168. dw: item1.dw,
  169. lsjg: item1.price ? item1.price : 0,
  170. price: item1.price ? item1.price : 0,
  171. kc: 0,
  172. cdmc: "无",
  173. pid: item1.pid,
  174. color: "red",
  175. dose: item1.dose || 0,
  176. useage: item1.useage || '',
  177. showSearch: false,
  178. matid: item1.pid,
  179. key: "",
  180. search_i: index
  181. };
  182. obj.oldDose = item1.oldDose;
  183. noDrugs.push(obj);
  184. // noDrugs.push(item1.matname)
  185. }
  186. if (item instanceof Object && item.oldYpid == item1.matid) {
  187. item.ggnum = +item.ggnum || 1;
  188. item.xbzxs = +item.xbzxs || '34'.includes(item.zylx) ? item.ggnum : 1;
  189. hasDrugs.push(item);
  190. }
  191. });
  192. });
  193. hasDrugs = hasDrugs.concat(noDrugs);
  194. if (hasDrugs.length > 0) {
  195. parent.recipe_tabs[
  196. parent.recipe_tabs_c
  197. ].totalTableD = parent.recipe_tabs[
  198. parent.recipe_tabs_c
  199. ].totalTableD.filter(item => {
  200. return item.name;
  201. });
  202. // console.log(hasDrugs, "has");
  203. // 赋值给表格
  204. hasDrugs.forEach((item, index) => {
  205. let obj1 = {
  206. color: item.color ? item.color : "#000",
  207. drugList: [],
  208. page: 1,
  209. loadMore: true,
  210. usageList: [],
  211. id: item.seqn,
  212. name: item.ypmc,
  213. spec: item.gg, // 规格
  214. dose: item.dose, // 剂量
  215. unit: item.dw, // 单位
  216. // usage: item.usagestr, // 用法
  217. usage: item.useage,
  218. // price: item.lsjg,
  219. price: item.price ? item.price : 0,
  220. total: item.price * item.dose,
  221. inventory: item.kc, // 库存
  222. key: "",
  223. search_i: index,
  224. medid: item.pid, // 药品id
  225. originname: item.cdmc, // 产地名称
  226. showSearch: false
  227. };
  228. obj1.ggnum = +item.ggnum || 1;
  229. obj1.xbzxs = +item.xbzxs || '34'.includes(item.zylx) ? obj1.ggnum : 1;
  230. parent.recipe_tabs[parent.recipe_tabs_c].totalTableD.push(obj1);
  231. parent.getSelectType("中药药品用法", index);
  232. });
  233. parent.recipe_tabs[parent.recipe_tabs_c].totalTableD.push({
  234. drugList: [],
  235. page: 1,
  236. loadMore: true,
  237. usageList: [],
  238. showSearch: false,
  239. search_i: 0,
  240. id: 1,
  241. key: ""
  242. });
  243. parent.recipe_tabs[
  244. parent.recipe_tabs_c
  245. ].totalTableD = this.removeRepeat(
  246. parent.recipe_tabs[parent.recipe_tabs_c].totalTableD,
  247. "medid"
  248. );
  249. parent.recipe_tabs[parent.recipe_tabs_c].totalTableD.filter(
  250. (item3, index3) => {
  251. return (item3.id = index3 + 1);
  252. }
  253. );
  254. parent.recipe_tabs[
  255. parent.recipe_tabs_c
  256. ].tableData = parent.recipe_tabs[
  257. parent.recipe_tabs_c
  258. ].totalTableD.filter(item2 => {
  259. if (item2.medid) {
  260. // if (item2.color != '#000') {
  261. // this.getRationalMedForPlat(item2.medid)
  262. // } else {
  263. // this.getRationalMed(item2.medid)
  264. // }
  265. if (item2.medid.indexOf("-") != -1) {
  266. this.$parent.$parent.$parent.getRationalMed(item2.medid);
  267. } else {
  268. this.$parent.$parent.$parent.getRationalMedForPlat(item2.medid);
  269. }
  270. }
  271. return Number(item2.id) % 2 != 0;
  272. });
  273. parent.recipe_tabs[
  274. parent.recipe_tabs_c
  275. ].tableData1 = parent.recipe_tabs[
  276. parent.recipe_tabs_c
  277. ].totalTableD.filter(item2 => {
  278. return Number(item2.id) % 2 == 0;
  279. });
  280. }
  281. this.$forceUpdate()
  282. loading.close();
  283. }
  284. },
  285. // 去重
  286. removeRepeat(arr, key) {
  287. let obj = {};
  288. arr = arr.reduce((pre, next) => {
  289. obj[next[key]] ? "" : (obj[next[key]] = true && pre.push(next));
  290. return pre;
  291. }, []);
  292. return arr;
  293. },
  294. }
  295. };
  296. </script>
  297. <style scoped lang="scss">
  298. .accompanied-container {
  299. width: 100%;
  300. display: flex;
  301. align-items: flex-start;
  302. justify-content: flex-start;
  303. max-height: 200px;
  304. overflow: auto;
  305. }
  306. .col {
  307. flex: 1;
  308. border: 1px solid #dcdfe6;
  309. border-bottom: 0;
  310. .header {
  311. background: #f3fffb;
  312. height: 20px;
  313. font-size: 12px;
  314. text-align: center;
  315. display: flex;
  316. align-items: center;
  317. justify-content: center;
  318. border-bottom: 1px solid #dcdfe6;
  319. }
  320. .col-item {
  321. height: 20px;
  322. font-size: 12px;
  323. text-align: center;
  324. display: flex;
  325. align-items: center;
  326. justify-content: center;
  327. padding: 0 4px;
  328. border-bottom: 1px solid #dcdfe6;
  329. cursor: pointer;
  330. }
  331. .active {
  332. background: #e6fff6;
  333. }
  334. }
  335. .col:nth-child(2),
  336. .col:nth-child(3) {
  337. // border-left: 0;
  338. .header {}
  339. }
  340. .col:nth-child(3) {
  341. .col-item {
  342. justify-content: flex-start;
  343. }
  344. }
  345. ::v-deep .el-checkbox__label {
  346. font-size: 12px;
  347. line-height: 20px;
  348. padding-left: 5px;
  349. }
  350. </style>