prescriptionTable.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div class="prescriptionTable">
  3. <el-table v-if="activeType == 1" :data="prescription.advices" border style="width: 99%;" :row-style="{ color: '#303133' }"
  4. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}" highlight-current-row>
  5. <el-table-column align="center" type="index" width="40" label="序号"></el-table-column>
  6. <el-table-column align="center" prop="drug_name" label="名称">
  7. <template slot-scope="scope"><span :title="scope.row.drug_name">{{ scope.row.drug_name }}</span></template>
  8. </el-table-column>
  9. <el-table-column align="center" prop="single_dose" width="90" label="单次用量">
  10. <template slot-scope="scope">
  11. <div style="display:flex;align-items:center;">
  12. <el-input v-model="scope.row.single_dose" @input="getSingleDose(scope)" style="width:65%;"></el-input>
  13. <div>{{scope.row.single_dose_unit}}</div>
  14. </div>
  15. </template>
  16. </el-table-column>
  17. <el-table-column align="center" prop="delivery_way" width="100" label="用法">
  18. <template slot-scope="scope">
  19. <el-select v-model="scope.row.delivery_way" placeholder="请选择">
  20. <el-option
  21. v-for="(item,index) in drugways"
  22. :key="index"
  23. :label="item.name"
  24. :value="item.name">
  25. </el-option>
  26. </el-select>
  27. </template>
  28. </el-table-column>
  29. <el-table-column align="center" prop="execution_frequency" width="100" label="频率">
  30. <template slot-scope="scope">
  31. <el-select v-model="scope.row.execution_frequency" placehold er="请选择">
  32. <el-option
  33. v-for="item,index in efs"
  34. :key="index"
  35. :label="item.name"
  36. :value="item.name">
  37. </el-option>
  38. </el-select>
  39. </template>
  40. </el-table-column>
  41. <el-table-column align="center" prop="day" width="50" label="天数">
  42. <template slot-scope="scope">
  43. <el-input v-model="scope.row.day" @input="getDay(scope)" placeholder=""></el-input>
  44. <div>{{'天'}}</div>
  45. </template>
  46. </el-table-column>
  47. <el-table-column align="center" prop="prescribing_number" width="80" label="总量">
  48. <template slot-scope="scope">
  49. <div style="display:flex;align-items:center;">
  50. <el-input v-model="scope.row.prescribing_number" style="width:60%" placeholder=""></el-input>
  51. <div> {{scope.row.prescribing_number_unit}}</div>
  52. </div>
  53. </template>
  54. </el-table-column>
  55. <el-table-column align="center" prop="retail_price" width="60" label="单价">
  56. <template slot-scope="scope">
  57. <el-input v-model="scope.row.retail_price" placeholder="" readonly></el-input>
  58. <div>{{'元'}}</div>
  59. </template>
  60. </el-table-column>
  61. <el-table-column align="center" prop="remark" width="50" label="备注">
  62. <template slot-scope="scope">
  63. <el-input v-model="scope.row.remark" :title="scope.row.remark" placeholder=""></el-input>
  64. </template>
  65. </el-table-column>
  66. <el-table-column align="center" width="40" prop="name" label="操作">
  67. <template slot-scope="scope">
  68. <i class="el-icon-delete" @click="deleteDrug(scope.$index, scope.row)"></i>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <el-table v-if="activeType == 2" :data="prescription.project" border style="width: 99%;" :row-style="{ color: '#303133' }"
  73. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}" highlight-current-row>
  74. <el-table-column align="center" type="index" width="40" label="序号"></el-table-column>
  75. <el-table-column align="center" prop="project_name" label="名称">
  76. <template slot-scope="scope"><span :title="scope.row.project_name">{{ scope.row.project_name }}</span></template>
  77. </el-table-column>
  78. <el-table-column align="center" prop="statistical_classification" width="100" label="组">
  79. <template slot-scope="scope">{{getGroup(scope.row.statistical_classification)}}</template>
  80. </el-table-column>
  81. <el-table-column align="center" prop="single_dose" width="80" label="单次用量">
  82. <template slot-scope="scope">
  83. <el-input v-model="scope.row.single_dose" @input="getProjectSingleDose(scope)" placeholder=""></el-input>
  84. <div>{{scope.row.unit}}</div>
  85. </template>
  86. </el-table-column>
  87. <el-table-column align="center" prop="delivery_way" width="80" label="用法">
  88. <template slot-scope="scope">
  89. <el-autocomplete
  90. style="width:100%;"
  91. class="inline-input"
  92. v-model="scope.row.delivery_way"
  93. :fetch-suggestions="querySearch2"
  94. placeholder="请输入内容"
  95. ></el-autocomplete>
  96. </template>
  97. </el-table-column>
  98. <el-table-column align="center" prop="execution_frequency" width="80" label="频率">
  99. <template slot-scope="scope">
  100. <el-input v-model="scope.row.execution_frequency" placeholder=""></el-input>
  101. </template>
  102. </el-table-column>
  103. <el-table-column align="center" prop="number_days" width="50" label="天数">
  104. <template slot-scope="scope">
  105. <el-input v-model="scope.row.number_days" @input="getProjectDay(scope)" placeholder=""></el-input>
  106. <div>{{'天'}}</div>
  107. </template>
  108. </el-table-column>
  109. <el-table-column align="center" prop="total" width="70" label="总量">
  110. <template slot-scope="scope">
  111. <div style="display:flex;align-items:center;">
  112. <el-input v-model="scope.row.total" style="width:60%" placeholder=""></el-input>
  113. <div>{{scope.row.unit}}</div>
  114. </div>
  115. </template>
  116. </el-table-column>
  117. <el-table-column align="center" prop="name" width="50" label="单价">
  118. <template slot-scope="scope">
  119. <el-input v-model="scope.row.price" placeholder="" readonly></el-input>
  120. <div>{{'元'}}</div>
  121. </template>
  122. </el-table-column>
  123. <el-table-column align="center" prop="name" width="50" label="备注">
  124. <template slot-scope="scope">
  125. <el-input v-model="scope.row.remark" :title="scope.row.remark"></el-input>
  126. </template>
  127. </el-table-column>
  128. <el-table-column align="center" width="40" prop="name" label="操作">
  129. <template slot-scope="scope">
  130. <i class="el-icon-delete" @click="deleteProject(scope.row,scope.$index)"></i>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. <div class="additionalBox">
  135. <div class="additionalOne" v-for="(item,index) in prescription.addition" :key="index">
  136. <span :title="item.item_name">{{item.item_name}}</span>
  137. <el-input v-model="item.price" placeholder="" style="width:50px;"></el-input>
  138. <el-input v-model="item.count" placeholder="" style="width:50px;"></el-input>
  139. <i class="el-icon-delete deleteIcon" @click="delAddition(index,item)"></i>
  140. </div>
  141. </div>
  142. </div>
  143. </template>
  144. <script>
  145. import { getDictionaryDataConfig} from "@/utils/data";
  146. import { getInitData,delHisAdvice,delHisProject,delHisAddition } from '@/api/his/his'
  147. export default {
  148. props: {
  149. preDrugs: Array,
  150. activeType: Number,
  151. addtions_charge:Array,
  152. prescription:{
  153. type:Object,
  154. default: function () {
  155. return {
  156. name:"",
  157. advices:[],
  158. project:[],
  159. drugways:[],
  160. efs:[],
  161. };
  162. }
  163. },
  164. },
  165. data() {
  166. return {
  167. advices:[],
  168. tableData: [],
  169. newoptions: [{
  170. value: '1',
  171. label: '1'
  172. }, {
  173. value: '2',
  174. label: '2'
  175. }, {
  176. value: '3',
  177. label: '3'
  178. }, {
  179. value: '4',
  180. label: '4'
  181. }, {
  182. value: '5',
  183. label: '5'
  184. }],
  185. value: '1',
  186. input: 1,
  187. }
  188. },
  189. methods:{
  190. createFilter(queryString) {
  191. return (restaurant) => {
  192. return (restaurant.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
  193. }
  194. },
  195. querySearch2(queryString, cb) {
  196. var restaurants = this.getDictionaryDataConfig("system","project_use")
  197. restaurants.map(item => {
  198. item.value = item.name
  199. })
  200. var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants
  201. // 调用 callback 返回建议列表的数据
  202. cb(results)
  203. },
  204. delAddition(index, addition){
  205. if(this.prescription.order_status == 2){
  206. this.$message.error('该处方已经结算,无法删除')
  207. return
  208. }
  209. this.$confirm("附加费删除后不可恢复,是否确认删除", "删除", {
  210. confirmButtonText: "确 定",
  211. cancelButtonText: "取 消",
  212. type: "warning"
  213. }).then(() => {
  214. this.$nextTick(function(){
  215. if(addition.id == 0){
  216. this.prescription.addition.splice(index, 1)
  217. }else{
  218. let params = {
  219. 'id': addition.id,
  220. }
  221. delHisAddition(params).then(response => {
  222. if (response.data.state == 0) {
  223. this.$message.error(response.data.msg)
  224. return false
  225. } else {
  226. var temp2 = this.deepClone(this.prescription.addition)
  227. temp2.splice(index, 1)
  228. this.prescription.addition = temp2
  229. this.$message.success(response.data.data.msg)
  230. }
  231. })
  232. }
  233. });
  234. })
  235. .catch(() => {});
  236. },
  237. getInitData(){
  238. getInitData().then(response => {
  239. if (response.data.state == 0) {
  240. this.$message.error(response.data.msg)
  241. return false
  242. } else {
  243. this.drugways = response.data.data.drugways
  244. this.efs = response.data.data.efs
  245. }
  246. })
  247. },deleteDrug:function(index, row){
  248. if(this.prescription.order_status == 2){
  249. this.$message.error('该处方已经结算,无法删除')
  250. return
  251. }
  252. this.$confirm("药品删除后不可恢复,是否确认删除", "删除", {
  253. confirmButtonText: "确 定",
  254. cancelButtonText: "取 消",
  255. type: "warning"
  256. }).then(() => {
  257. this.$nextTick(function(){
  258. if(row.advice_id == 0){
  259. this.prescription.advices.splice(index, 1)
  260. }else{
  261. let params = {
  262. 'id': row.advice_id,
  263. }
  264. delHisAdvice(params).then(response => {
  265. if (response.data.state == 0) {
  266. this.$message.error(response.data.msg)
  267. return false
  268. } else {
  269. var temp2 = this.deepClone(this.prescription.advices)
  270. temp2.splice(index, 1)
  271. this.prescription.advices = temp2
  272. this.$message.success(response.data.data.msg)
  273. }
  274. })
  275. }
  276. });
  277. })
  278. .catch(() => {});
  279. },deepClone(source) {
  280. if (!source && typeof source !== 'object') {
  281. throw new Error('error arguments', 'shallowClone')
  282. }
  283. const targetObj = source.constructor === Array ? [] : {}
  284. Object.keys(source).forEach((keys) => {
  285. if (source[keys] && typeof source[keys] === 'object') {
  286. targetObj[keys] = this.deepClone(source[keys])
  287. } else {
  288. targetObj[keys] = source[keys]
  289. }
  290. })
  291. return targetObj
  292. },
  293. setNewData:function(data){
  294. this.prescription = data
  295. // this.prescription.advices = data.advices
  296. },
  297. getDictionaryDataConfig(module, filed_name) {
  298. return getDictionaryDataConfig(module, filed_name)
  299. },
  300. getGroup(id){
  301. var name = ""
  302. var statistics_category = getDictionaryDataConfig('system','statistics_category')
  303. console.log("2235",statistics_category)
  304. for(let i=0;i<statistics_category.length;i++){
  305. if(id == statistics_category[i].id){
  306. name = statistics_category[i].name
  307. }
  308. }
  309. return name
  310. },
  311. deleteProject(row,i){
  312. if(this.prescription.order_status == 2){
  313. this.$message.error('该处方已经结算,无法删除')
  314. return
  315. }
  316. this.$confirm("项目删除后不可恢复,是否确认删除", "删除", {
  317. confirmButtonText: "确 定",
  318. cancelButtonText: "取 消",
  319. type: "warning"
  320. }).then(() => {
  321. if(row.id == 0){
  322. this.prescription.project.splice(i, 1)
  323. }else{
  324. let params = {
  325. 'id': row.id,
  326. }
  327. delHisProject(params).then(response => {
  328. if (response.data.state == 0) {
  329. this.$message.error(response.data.msg)
  330. return false
  331. } else {
  332. for (let i = 0; i < this.prescription.project.length; i++){
  333. if(this.prescription.project[i].id == row.id){
  334. this.prescription.project.splice(i, 1)
  335. }
  336. }
  337. this.$message.success(response.data.data.msg)
  338. }
  339. })
  340. }
  341. })
  342. .catch(() => {});
  343. },
  344. getSingleDose(scope){
  345. this.prescription.advices[scope.$index].prescribing_number = scope.row.single_dose * scope.row.day
  346. },
  347. getDay(scope){
  348. this.prescription.advices[scope.$index].prescribing_number = scope.row.single_dose * scope.row.day
  349. },
  350. getProjectSingleDose(scope){
  351. this.prescription.project[scope.$index].total = scope.row.single_dose * scope.row.number_days
  352. },
  353. getProjectDay(scope){
  354. this.prescription.project[scope.$index].total = scope.row.single_dose * scope.row.number_days
  355. }
  356. },mounted(){
  357. this.getInitData()
  358. },
  359. watch:{
  360. // "prescription.advices":{
  361. // handler(newVal,oldVal){
  362. // newVal.map(item => {
  363. // item.prescribing_number = item.single_dose * item.day
  364. // if(item.single_dose != oldVal[index].single_dose || item.number_days != oldVal[index].number_days){
  365. // item.total = item.single_dose * item.number_days
  366. // }
  367. // })
  368. // },
  369. // deep:true
  370. // },
  371. // "prescription.project":{
  372. // handler(newVal,oldVal){
  373. // newVal.map((item,index) => {
  374. // if(item.single_dose != oldVal[index].single_dose || item.number_days != oldVal[index].number_days){
  375. // item.total = item.single_dose * item.number_days
  376. // }
  377. // })
  378. // },
  379. // deep:true
  380. // }
  381. }
  382. }
  383. </script>
  384. <style lang="scss">
  385. .prescriptionTable {
  386. .el-input__inner{
  387. padding: 0 5px;
  388. }
  389. .additionalBox{
  390. margin-top: 20px;
  391. display: flex;
  392. flex-wrap: wrap;
  393. .additionalOne{
  394. margin-right:20px;
  395. margin-bottom:10px;
  396. display: flex;
  397. align-items: center;
  398. >span{
  399. white-space: nowrap;
  400. overflow: hidden;
  401. text-overflow: ellipsis;
  402. width:80px;
  403. display: inline-block;
  404. font-size: 14px;
  405. }
  406. }
  407. .deleteIcon{
  408. color:red;
  409. margin-left:5px;
  410. }
  411. }
  412. .el-table th .cell, .el-table td .cell {
  413. padding: 0 2px;
  414. white-space: pre-line;
  415. }
  416. .el-icon-delete {
  417. color: red;
  418. }
  419. }
  420. </style>